From 96685ceb061ce05383b6cfa14c158fdf8c36822ab1f77d0de1f1894bca367d39 Mon Sep 17 00:00:00 2001 From: Stephan Kulow Date: Wed, 4 Jul 2012 05:08:42 +0000 Subject: [PATCH] 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 --- ruby.changes | 13 +++++++++++++ ruby.macros | 44 +++++++++++++++++++++++++++++++++++++++++++- ruby.spec | 6 ++++++ rubygems.attr | 4 ++++ rubygemsdeps.sh | 33 +++++++++++++++++++++++++++++++++ 5 files changed, 99 insertions(+), 1 deletion(-) create mode 100644 rubygems.attr create mode 100644 rubygemsdeps.sh diff --git a/ruby.changes b/ruby.changes index 40a9a1d..2c56dd0 100644 --- a/ruby.changes +++ b/ruby.changes @@ -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 diff --git a/ruby.macros b/ruby.macros index 5da96cb..164a7a4 100644 --- a/ruby.macros +++ b/ruby.macros @@ -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} + + diff --git a/ruby.spec b/ruby.spec index 372bafb..ef8fe09 100644 --- a/ruby.spec +++ b/ruby.spec @@ -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 diff --git a/rubygems.attr b/rubygems.attr new file mode 100644 index 0000000..bfb25fe --- /dev/null +++ b/rubygems.attr @@ -0,0 +1,4 @@ +%__rubygems_requires %{_rpmconfigdir}/rubygemsdeps.sh --requires +%__rubygems_provides %{_rpmconfigdir}/rubygemsdeps.sh --provides +%__rubygems_path ^%{_libdir}/ruby/gems/.*/specifications + diff --git a/rubygemsdeps.sh b/rubygemsdeps.sh new file mode 100644 index 0000000..90fd442 --- /dev/null +++ b/rubygemsdeps.sh @@ -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