%define ruby    /usr/bin/ruby
%define rdoc    /usr/bin/rdoc
%define gemdir  %{_localstatedir}/lib/gems/%(%{ruby} -r rbconfig -e 'print File.basename(Config::CONFIG["rubylibdir"])')

Summary: packaging system for Ruby application or library
Summary(ja): Rubyアプリケーションやライブラリのためのパッケージシステム
Name: rubygems
Version: 1.8.10
Release: 1%{?_dist_release}
License: Ruby or GPLv2
Group: Development/Tools
Source0: rubygems-%{version}.tgz
Patch1: rubygems-1.8.1-default-dir.patch
URL: http://www.rubygems.org/
BuildArch: noarch
BuildRoot: %{_tmppath}/%{name}-%{version}-root
BuildRequires: ruby ruby-devel rdoc
Requires: ruby ruby-devel rdoc
Requires(pre): shadow-utils

%description
RubyGems is the name of the project that developed the gem packaging
system and the gem command.
* Easy Installation and removal of RubyGems packages and their
  dependents.
* Management and control of local packages
* Package dependency management
* Query, search and list local and remote packages
* Multiple version support for installed packages
* Web-based interface to view the documentation for your installed
  gems
* Easy to use interface for building gem packages
* Simple server for distributing your own gem packages

%description -l ja

%prep

%setup -q

%patch1 -p1 -b .default-dir

%install
rm -rf ${RPM_BUILD_ROOT}

GEM_HOME=${RPM_BUILD_ROOT}%{gemdir} \
  %{ruby} -I%{rlibdir} setup.rb install \
  --destdir=${RPM_BUILD_ROOT}%{rlibdir} \
  --no-rdoc --no-ri \
  --prefix=/

# fix install path
mkdir -p %{buildroot}%{_bindir}
mv %{buildroot}%{rlibdir}/bin/gem %{buildroot}%{_bindir}/gem
rmdir %{buildroot}%{rlibdir}/bin
mv %{buildroot}%{rlibdir}/lib/* %{buildroot}%{rlibdir}/.

mkdir -p $RPM_BUILD_ROOT%{gemdir}/{cache,gems,specifications,doc}

%clean
rm -rf ${RPM_BUILD_ROOT}
rm -rf html

%pre
getent group rubygems >/dev/null || %{_sbindir}/groupadd rubygems

%files
%defattr(-, root, root)
%doc GPL.txt LICENSE.txt
%doc README* TODO
%{rbindir}/*
%{rlibdir}/*
%defattr(664,root,rubygems,775)
%{gemdir}

%changelog
* Mon Aug 29 2011 Daisuke SUZUKI <daisuke@linux.or.jp> 1.8.10-1
- update to 1.8.10

* Thu May 12 2011 Daisuke SUZUKI <daisuke@linux.or.jp> 1.8.1-1
- update to 1.8.2
- drop rdoc, ri

* Tue Mar 22 2011 Daisuke SUZUKI <daisuke@linux.or.jp> 1.6.2-1
- new upstream release
- s/BuildPreReq/BuildRequires
- add R(pre): shadow-utils
- update default dir patch (Patch1)
- use getent in %%pre script
- update License: tag

* Thu Sep 16 2010 IWAI, Masaharu <iwai@alib.jp> 1.3.7-1
- new upstream release
- update default dir patch (Patch1)

* Mon Dec 14 2009 Daisuke SUZUKI <daisuke@linux.or.jp> 1.3.5-1
- new upstream release

* Sat Mar  7 2009 IWAI, Masaharu <iwai@alib.jp> 1.3.1-1
- new upstream release
- apply new versioning policy
- spec in UTF-8
- update URL
- update default dir patch (Patch1)
- drop fix shebang patch (Patch2)
- drop postinst patch (Patch3)
- add install dir patch (Patch4)
- update %%install section
- create rubygems group for %%{gemdir}

* Mon Mar 19 2007 akira yamada <akira@vinelinux.org> 0.9.2-0vl1
- initial packaging.
