Accepting request 127027 from home:coolo:branches:openSUSE:Factory

- Provide the following new RPM macros:
  + %gem_unpack
  + %gem_build
  + %gem_install (retaining the old behavior)

- add automatic provides and requires for rubygems

OBS-URL: https://build.opensuse.org/request/show/127027
OBS-URL: https://build.opensuse.org/package/show/devel:languages:ruby/ruby?expand=0&rev=32
This commit is contained in:
Stephan Kulow 2012-07-04 05:08:42 +00:00 committed by Git OBS Bridge
parent 3546ed42e8
commit 96685ceb06
5 changed files with 99 additions and 1 deletions

View File

@ -1,3 +1,16 @@
-------------------------------------------------------------------
Tue Jul 3 08:02:01 UTC 2012 - saschpe@suse.de
- Provide the following new RPM macros:
+ %gem_unpack
+ %gem_build
+ %gem_install (retaining the old behavior)
-------------------------------------------------------------------
Mon Jul 2 14:06:43 UTC 2012 - coolo@suse.com
- add automatic provides and requires for rubygems
-------------------------------------------------------------------
Tue Jun 19 10:10:00 UTC 2012 - coolo@suse.com

View File

@ -1,8 +1,8 @@
%gem_install %{gem19_install}
%gem_cleanup /usr/bin/gem_build_cleanup %{buildroot}%{_libdir}/ruby/gems/%{rb_ver}
%rubygems_requires %{rubygems19_requires}
%rb_binary %{rb19_binary}
%gem_binary /usr/bin/gem
%rb_arch %{rb19_arch}
%rb_ver %{rb19_ver}
@ -26,3 +26,45 @@
%rb_vendorlib %rb19_vendorlibdir
%rb_vendorarch %rb19_vendorarchdir
# %%gem_unpack macro unpacks a gem file into %%{_builddir}
#
# example:
# %prep
# %gem_unpack %{SOURCE0}
# %patch1 -p1
#
%gem_unpack() \
if [ %# -eq 0 ]; then \
%{gem_binary} unpack --verbose %{SOURCE0} \
else \
%{gem_binary} unpack --verbose %1 \
fi \
cd %{mod_name}-%{version} \
%{nil}
# %%gem_build macro ...
#
%gem_build() \
GEMSPEC_SOURCE_DIR=`find . -maxdepth 2 -type f -name "*.gemspec" | xargs dirname` \
cd $GEMSPEC_SOURCE_DIR && %{gem_binary} build --verbose *.gemspec \
%{nil}
# %%gem_install macro ...
#
# When invoked with a single parameter, the macro retains the old macro behavior, i.e.
# building the upstream gem directly in $RPM_BUILD_ROOT without unpacking to %{_builddir} first.
#
%gem_install() \
if [ %# -eq 1 ]; then \
%{gem_binary} install --verbose --local --build-root=%{buildroot} \
else \
GEM_FILE=`find . -maxdepth 2 -type f -name "%{mod_name}-%{version}.gem"` \
%{gem_binary} install --verbose --local --bindir %{buildroot}%{_bindir} --install-dir %{buildroot}%{_libdir}/ruby/gems/%{rb_ver} $GEM_FILE \
fi \
%{nil}
%gem_cleanup() \
/usr/bin/gem_build_cleanup %{buildroot}%{_libdir}/ruby/gems/%{rb_ver}/ \
%{nil}

View File

@ -26,6 +26,8 @@ Source0: ruby.macros
Source1: gem_build_cleanup
Source2: gemrc
Source3: ruby.common-macros
Source4: rubygems.attr
Source5: rubygemsdeps.sh
Provides: /usr/bin/ruby
Url: http://www.ruby-lang.org/
Summary: An Interpreted Object-Oriented Scripting Language
@ -95,6 +97,8 @@ ln -s %_libdir/libruby1.9.so $RPM_BUILD_ROOT%_libdir/libruby.so
install -D -m 0644 %{S:0} $RPM_BUILD_ROOT/etc/rpm/macros.ruby
install -D -m 0644 %{S:3} $RPM_BUILD_ROOT/etc/rpm/macros.common-ruby
install -D -m 0644 %{S:2} $RPM_BUILD_ROOT/etc/gemrc
install -D -m 0644 %{S:4} $RPM_BUILD_ROOT/%{_rpmconfigdir}/fileattrs/rubygems.attr
install -D -m 0755 %{S:5} $RPM_BUILD_ROOT/%{_rpmconfigdir}/rubygemsdeps.sh
export NO_BRP_STALE_LINK_ERROR=yes
%files
@ -111,6 +115,8 @@ export NO_BRP_STALE_LINK_ERROR=yes
%defattr(-,root,root)
/etc/gemrc
/etc/rpm/macros.common-ruby
%{_rpmconfigdir}/fileattrs/rubygems.attr
%{_rpmconfigdir}/rubygemsdeps.sh
%_bindir/gem_build_cleanup
%changelog

4
rubygems.attr Normal file
View File

@ -0,0 +1,4 @@
%__rubygems_requires %{_rpmconfigdir}/rubygemsdeps.sh --requires
%__rubygems_provides %{_rpmconfigdir}/rubygemsdeps.sh --provides
%__rubygems_path ^%{_libdir}/ruby/gems/.*/specifications

33
rubygemsdeps.sh Normal file
View File

@ -0,0 +1,33 @@
#!/bin/bash
[ $# -ge 1 ] || {
cat > /dev/null
exit 0
}
case $1 in
-P|--provides)
shift
RPM_BUILD_ROOT="$1"
while read possible
do
case "$possible" in
*.gemspec)
possible=${possible##*/}
possible=${possible%.gemspec}
echo "$possible" | sed -e 's,^\(.*\)-,rubygem(\1) = ,'
;;
esac
done
;;
-R|--requires)
while read possible ; do
case "$possible" in
*.gemspec)
echo "$possible" | sed -ne 's,.*/gems/,ruby(abi) = ,; s,/.*,,p'
;;
esac
done
;;
esac
exit 0