[arch-projects] [ABS] [PATCH 2/2] Refactor rubygem proto

Maxime Gauduin alucryd at gmail.com
Tue Oct 8 05:00:29 EDT 2013


The previous way of installing a gem left a lot of crust in the system.
This refactoring mimics the layout of ruby packages in [community]
which are packaged from source.

Signed-off-by: Maxime Gauduin <alucryd at gmail.com>
---
 prototypes/PKGBUILD-rubygem.proto | 42 ++++++++++++++++++++++++++++-----------
 1 file changed, 30 insertions(+), 12 deletions(-)

diff --git a/prototypes/PKGBUILD-rubygem.proto b/prototypes/PKGBUILD-rubygem.proto
index 84fbd70..303f6b2 100644
--- a/prototypes/PKGBUILD-rubygem.proto
+++ b/prototypes/PKGBUILD-rubygem.proto
@@ -7,28 +7,46 @@
 # information on Ruby Gem packaging.
 
 # Maintainer: Your Name <youremail at domain.com>
-_gemname=GEMNAME
-pkgname=ruby-$_gemname
+pkgname=ruby-GEM_NAME
 pkgver=VERSION
 pkgrel=1
 pkgdesc=""
-arch=(any)
+arch=()
 url=""
 license=('GPL')
 depends=(ruby) # Full dependency information is available in the yaml specification
-makedepends=(rubygems)
-source=(http://gems.rubyforge.org/gems/$_gemname-$pkgver.gem)
-noextract=($_gemname-$pkgver.gem)
+makedepends=()
+source=("https://rubygems.org/downloads/${pkgname#ruby-}-$pkgver.gem")
+noextract=("${pkgname#ruby-}-$pkgver.gem")
 md5sums=()
 
-package() {
+build() {
   cd "$srcdir"
-  # _gemdir is defined inside package() because if ruby[gems] is not installed on
-  # the system, makepkg will exit with an error when sourcing the PKGBUILD.
-  local _gemdir="$(ruby -rubygems -e'puts Gem.default_dir')"
 
-  gem install --no-user-install --ignore-dependencies -i "$pkgdir$_gemdir" -n "$pkgdir/usr/bin" \
-    "$_gemname-$pkgver.gem"
+  gem install --no-{document,user-install} --ignore-dependencies -i . ${pkgname#ruby-}-$pkgver.gem
+}
+
+package() {
+  cd "$srcdir"/gems/${pkgname#ruby-}-$pkgver
+
+  local _rubyver="$(ruby --version | sed 's/.* \(.*\)p.*/\1/')"
+
+  install -dm 755 "${pkgdir}"/usr/lib/ruby/{gems/$_rubyver,vendor_ruby}
+  mv lib "${pkgdir}"/usr/lib/ruby/vendor_ruby/$_rubyver
+
+# Executables
+  mv bin "${pkgdir}"/usr/
+
+# Native extensions
+  install -dm 755 "${pkgdir}"/usr/lib/ruby/vendor_ruby/$_rubyver/$CARCH-linux
+  pushd "${pkgdir}"/usr/lib/ruby/vendor_ruby/$_rubyver/${pkgname#ruby-}
+  for ext in *.{h,so}; do
+    mv $ext ../$CARCH-linux/$ext
+  done
+  popd
+
+# Gem compatibility
+  mv ../../specifications "${pkgdir}"/usr/lib/ruby/gems/$_rubyver/
 }
 
 # vim:set ts=2 sw=2 et:
-- 
1.8.4



More information about the arch-projects mailing list