From 49e11e1ca59a3ee5a20b1e3568252193610aa59a Mon Sep 17 00:00:00 2001 From: maxice8 Date: Tue, 30 Oct 2018 19:52:59 -0300 Subject: [PATCH] build_style: Add gem build_style --- Manual.md | 5 +++ common/build-style/gem.sh | 60 +++++++++++++++++++++++++++ common/environment/build-style/gem.sh | 9 ++++ 3 files changed, 74 insertions(+) create mode 100644 common/build-style/gem.sh create mode 100644 common/environment/build-style/gem.sh diff --git a/Manual.md b/Manual.md index e93566ea263..96460a3267c 100644 --- a/Manual.md +++ b/Manual.md @@ -781,6 +781,11 @@ with the character `r` in the `version` variable. The `distfiles` location will automatically be set as well as the package made to depend on `R`. +- `gem` For packages that are installed using gems from [RubyGems](https://rubygems.org/). +The gem command can be overridden by `gem_cmd`. `noarch` is set unconditionally and `distfiles` +is set by the build style if the template does not do so. If your gem provides extensions which +must be compiled consider using the `gemspec` build style instead. + - `ruby-module` For packages that are ruby modules and are installable via `ruby install.rb`. Additional install arguments can be specified via `make_install_args`. diff --git a/common/build-style/gem.sh b/common/build-style/gem.sh new file mode 100644 index 00000000000..2cf5f8ab2ca --- /dev/null +++ b/common/build-style/gem.sh @@ -0,0 +1,60 @@ +# +# This helper is for templates using gem files from RubyGems. +# +do_install() { + : ${gem_cmd:=gem} + + local _GEMDIR _INSTDIR + + _GEMDIR=$($gem_cmd env gemdir) + _INSTDIR=${DESTDIR}/${_GEMDIR}/gems/${pkgname#ruby-}-${version} + + $gem_cmd install \ + --local \ + --install-dir ${DESTDIR}/${_GEMDIR} \ + --bindir ${DESTDIR}/usr/bin \ + --ignore-dependencies \ + --no-document \ + --verbose \ + ${XBPS_SRCDISTDIR}/${pkgname}-${version}/${pkgname#ruby-}-${version}.gem + + # Remove cache + rm -rf ${DESTDIR}/${_GEMDIR}/cache + + # Remove ext directory. they are only source code and configuration + # The actual extensions are guarded in an arch path + rm -rf ${_INSTDIR}/ext + + # Remove installed tests and benchmarks + rm -rf ${_INSTDIR}/{test,tests,autotest,benchmark,benchmarks,script,examples,demo} + + # Remove files shipped on the root of the gem, most of the time they are useless + find ${_INSTDIR} -maxdepth 1 -type f -delete + + # Remove unnecessary files + find ${DESTDIR}/${_GEMDIR}/extensions \( -name mkmf.log -o -name gem_make.out \) -delete + + # Place manpages in usr/share/man/man[0-9] + find ${_INSTDIR}/man -type f -name '*.[0-8n]' | while read -r m; do + vman ${m} + done + + rm -rf "${_INSTDIR}/man" + + # Place executables in /usr/bin + if [ -d "${_INSTDIR}/bin" ]; then + for f in "${_INSTDIR}"/bin/*; do + vbin "${f}" + done + fi + + rm -rf ${_INSTDIR}/bin + + # Place conf files in their places + find ${_INSTDIR}/etc -type f | while read -r c; do + vmkdir $(dirname ${c##*${_INSTDIR}}) + mv ${c} "${DESTDIR}/${c##*${_INSTDIR}}" + done + + rm -rf ${_INSTDIR}/etc +} diff --git a/common/environment/build-style/gem.sh b/common/environment/build-style/gem.sh new file mode 100644 index 00000000000..4d2c58d1f35 --- /dev/null +++ b/common/environment/build-style/gem.sh @@ -0,0 +1,9 @@ +lib32disabled=yes +hostmakedepends+=" ruby" +depends+=" ruby" +noarch=yes + +# default to rubygems +if [ -z "$distfiles" ]; then + distfiles="https://rubygems.org/downloads/${pkgname#ruby-}-${version}.gem" +fi