git » ruby-irb.git » main » tree

[main] / PKGBUILD

# Maintainer: Anatol Pomozov
# Maintainer: Andreas 'Segaja' Schleifer <segaja at archlinux dot org>

_gemname='irb'
pkgname="ruby-${_gemname}"
pkgver=1.6.2
pkgrel=1
pkgdesc='Interactive Ruby command-line tool for REPL (Read Eval Print Loop).'
arch=('any')
url="https://github.com/ruby/${_gemname}"
license=('RUBY' 'BSD-2')
depends=('ruby' 'ruby-reline')
makedepends=('ruby-rdoc' ruby-bundler)
checkdepends=('ruby-rake' ruby-debug)
options=('!emptydirs')
source=("${url}/archive/v${pkgver}/${pkgname}-${pkgver}.tar.gz")
sha512sums=('87fb5f30f32640dba32d7f8d9e4d3a255dbb36ab67b9947d0e88c29f5c65308040b62bf18d830012fdfcb1b7ed0feb42809a2eb7f8b4032c29f1ef46a6a4f164')

prepare() {
  cd "${_gemname}-${pkgver}"

  # update gemspec/Gemfile to allow newer version of the dependencies
  sed --in-place --regexp-extended 's|~>|>=|g' "${_gemname}.gemspec"
}

build() {
  cd "${_gemname}-${pkgver}"

  gem build "${_gemname}.gemspec"
}

#check() {
#  cd "${_gemname}-${pkgver}"

#  rake test
#  rake test_yamatanooroti
#}

package() {
  cd "${_gemname}-${pkgver}"

  local _gemdir="$(gem env gemdir)"
  local _platform="$(gem env platform | cut -d':' -f2)"
  local _extension_api_version="$(ruby -e 'puts Gem.extension_api_version')"

  gem install \
    --local \
    --verbose \
    --ignore-dependencies \
    --no-user-install \
    --install-dir "${pkgdir}/${_gemdir}" \
    --bindir "${pkgdir}/usr/bin" \
    "${_gemname}-${pkgver}.gem"

  install --verbose --directory --mode=0755 \
    "${pkgdir}/usr/lib/ruby/${_extension_api_version}/${_platform}" \
    "${pkgdir}${_gemdir}/specifications/default"

  mv --verbose "${pkgdir}${_gemdir}/specifications/${_gemname}-${pkgver}.gemspec" "${pkgdir}${_gemdir}/specifications/default/${_gemname}-${pkgver}.gemspec"
  mv --verbose "${pkgdir}${_gemdir}/gems/${_gemname}-${pkgver}/lib/${_gemname}.rb" "${pkgdir}/usr/lib/ruby/${_extension_api_version}/${_gemname}.rb"
  mv --verbose "${pkgdir}${_gemdir}/gems/${_gemname}-${pkgver}/lib/${_gemname}" "${pkgdir}/usr/lib/ruby/${_extension_api_version}/${_gemname}"

  # remove unrepreducible files
  rm --force --recursive --verbose \
    "${pkgdir}${_gemdir}/cache/" \
    "${pkgdir}${_gemdir}/build_info/" \
    "${pkgdir}${_gemdir}/extensions/" \
    "${pkgdir}${_gemdir}/gems/${_gemname}-${pkgver}/"{.git*,.document,bin,doc,man,*.*,Gemfile,Rakefile} \
    "${pkgdir}${_gemdir}/plugins/" \
    "${pkgdir}${_gemdir}/doc/${_gemname}-${pkgver}/ri/ext/"

  install --verbose -D --mode=0644 man/irb.1 --target-directory "${pkgdir}/usr/share/man/man1"
  install --verbose -D --mode=0644 LICENSE.txt --target-directory "${pkgdir}/usr/share/licenses/${pkgname}"
  install --verbose -D --mode=0644 *.md --target-directory "${pkgdir}/usr/share/doc/${pkgname}"
}