ruby-common/ruby.rpm-macros
Marcus Rueckert 0c812e5108 Accepting request 253103 from home:darix:ruby
- we dont always have /usr/bin/ruby, use perl for patching the
  version in the bin wrapper. also replaced the sed for patching
  the shebang line.
- fixed a bad bug in the shebang line. we had an additional "."
  there.

- install gemrc on all distros

- dont delete .a files. there are actually gems where we need them
  like rubygem-libv8 for rubygem-therubyracer

- fix the case where we dont symlink the binaries. 

- gem_cleanup macro was missed when updating for old ruby versions.

- switch from "ruby -rrubygems -e 
  'print Gem::Specification.new.base_dir'"
  to "gem env gemdir"
 

- gem_build_cleanup: also delete static library files

- ruby 1.8 support:
  - gem_packages.sh: change to /usr/src/packages when
    /home/abuild/rpmbuild doesn't exist.
  - gem_packages template:
    - require rbconfigpackagingsupport to fix the ruby_install_name
      dependent variables. we do that for all distros but catch the
      LoadError and continue.
    - and dont use not(), we need to use "!" instead.

OBS-URL: https://build.opensuse.org/request/show/253103
OBS-URL: https://build.opensuse.org/package/show/devel:languages:ruby/ruby-common?expand=0&rev=73
2014-09-29 13:29:35 +00:00

95 lines
4.2 KiB
Plaintext

%rb_binary /usr/bin/ruby
%rb_arch %(%{rb_binary} -e 'print RUBY_PLATFORM')
%rb_ver %(%{rb_binary} -r rbconfig -e 'print RbConfig::CONFIG["ruby_version"]')
#
## Base
# "rubylibprefix"=>"/usr/lib64/ruby",
%rb_dir %(%{rb_binary} -rrbconfig -e 'puts RbConfig::CONFIG["rubylibprefix"]' )
# "rubylibdir" =>"/usr/lib64/ruby/2.1.0",
%rb_libdir %(%{rb_binary} -rrbconfig -e 'puts RbConfig::CONFIG["rubylibdir"]' )
# "archdir" =>"/usr/lib64/ruby/2.1.0/x86_64-linux",
%rb_archdir %(%{rb_binary} -rrbconfig -e 'puts RbConfig::CONFIG["archdir"]' )
## Site
# "sitedir" =>"/usr/lib64/ruby/site_ruby",
%rb_sitedir %(%{rb_binary} -rrbconfig -e 'puts RbConfig::CONFIG["sitedir"]' )
# "sitelibdir" =>"/usr/lib64/ruby/site_ruby/2.1.0",
%rb_sitelibdir %(%{rb_binary} -rrbconfig -e 'puts RbConfig::CONFIG["sitelibdir"]' )
# "sitearchdir" =>"/usr/lib64/ruby/site_ruby/2.1.0/x86_64-linux",
%rb_sitearchdir %(%{rb_binary} -rrbconfig -e 'puts RbConfig::CONFIG["sitearchdir"]' )
## Vendor
# "vendordir" =>"/usr/lib64/ruby/vendor_ruby",
%rb_vendordir %(%{rb_binary} -rrbconfig -e 'puts RbConfig::CONFIG["vendordir"]' )
# "vendorlibdir" =>"/usr/lib64/ruby/vendor_ruby/2.1.0",
%rb_vendorlibdir %(%{rb_binary} -rrbconfig -e 'puts RbConfig::CONFIG["vendorlibdir"]' )
# "vendorarchdir" =>"/usr/lib64/ruby/vendor_ruby/2.1.0/x86_64-linux",
%rb_vendorarchdir %(%{rb_binary} -rrbconfig -e 'puts RbConfig::CONFIG["vendorarchdir"]' )
# backward compat
%rb_sitearch %{rb_sitearchdir}
%rb_sitelib %{rb_sitelibdir}
%rb_vendorlib %{rb_vendorlibdir}
%rb_vendorarch %{rb_vendorarchdir}
# %%gem_unpack macro unpacks a gem file into %%{_builddir}
#
# example:
# %prep
# %gem_unpack %{SOURCE0}
# %patch1 -p1
#
%gem_unpack(s:) \
source=%{-s:%{-s*}}%{!-s:%{SOURCE0}} \
%{?gem_binary}%{!?gem_binary:/usr/bin/gem} unpack --verbose $source \
cd %{mod_name}-%{version} \
chmod og-w -R . \
%{?gem_binary}%{!?gem_binary:/usr/bin/gem} specification --ruby $source > %{mod_name}-%{version}.gemspec \
%{nil}
# %%gem_build macro ...
#
%gem_build() \
GEMSPEC_SOURCE_DIR=`find . -maxdepth 2 -type f -name %{mod_name}-%{version}.gemspec | xargs dirname` \
cd $GEMSPEC_SOURCE_DIR && %{?gem_binary}%{!?gem_binary:/usr/bin/gem} build --verbose %{mod_name}-%{version}.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 /usr/lib/rpm/gem_install.sh --default-gem %{mod_name}-%{version}.gem --gem-name=%{mod_name} --gem-version=%{version} --build-root %{buildroot} %{?mod_version_suffix:--gem-suffix=%{mod_version_suffix}} %{?gem_binary:--gem-binary %{gem_binary}}
%gem_packages %{expand:%(/usr/lib/rpm/gem_packages.sh --default-gem %{mod_name}-%{version}.gem --gem-name=%{mod_name} --gem-version=%{version} --build-root %{buildroot})}
# we need to copy parts of the %fdupes macro as rpm can't expand parameters in macro "calls" ;(
%gem_cleanup() \
shopt -s nullglob \
for ruby in /usr/bin/ruby.* /usr/bin/ruby[0-9].[0-9] ; do \
rb_suffix="${ruby#/usr/bin/ruby}" \
gem_base="$(/usr/bin/gem$rb_suffix env gemdir)" \
/usr/lib/rpm/gem_build_cleanup.sh %{buildroot}${gem_base} \
fdupes -q -p -n -r %{buildroot}${gem_base} | \
while read _file; do \
if test -z "$_target" ; then \
_target="$_file"; \
else \
if test -z "$_file" ; then \
_target=""; \
continue ; \
fi ; \
ln -sf "${_target#%{buildroot}}" "$_file"; \
fi ; \
done \
done \
%{nil}
# this is used in older gems - but it's pointless with newer ruby/rpm versions
%rubygems_requires %{nil}
%gem_base %(%{rb_binary} -rrubygems -e 'print Gem::Specification.new.base_dir' )
%gem_extensions %(%{rb_binary} -rrubygems -e 'print Gem::Specification.new.extensions_dir' || echo %{_libdir}/ruby/gems/%{rb_ver}/gems )
%gem_doc_ext %(%{rb_binary} -r rubygems -e 'bs = Gem::Specification.new; rp = bs.extensions_dir.rpartition(bs.base_dir); print rp[1]+"/doc"+rp[2]' )
%gem_platform %(%{rb_binary} -r rubygems -r rbconfig -e 'print Gem::Platform.new(RbConfig::CONFIG["arch"]).to_s' )