summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 1366a441fd57e2781d5d205f3cf5561afa0e15f1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# Maintainer: Carl Smedstad <carsme@archlinux.org>

pkgname=ruby-flexmock
_pkgname=${pkgname#ruby-}
pkgver=3.0.1
pkgrel=1
pkgdesc="Flexible mocking for Ruby testing"
arch=(any)
url="https://github.com/doudou/flexmock"
license=(MIT)
depends=(ruby)
makedepends=(
  git
  rubygems
)
checkdepends=(
  ruby-bundler
  ruby-minitest
  ruby-rake
  ruby-simplecov
)
options=(!emptydirs)
source=("git+$url.git#tag=v$pkgver")
sha256sums=('eba38fa86a4d5948939922135ee1ebb5788f72ad81066f8a6ec7a3eda47021b0')

prepare() {
  cd "$_pkgname"
  # Update gemspec/Gemfile to allow newer version of the dependencies
  sed --in-place --regexp-extended 's|~>|>=|g' "$_pkgname.gemspec"
}

build() {
  cd "$_pkgname"

  local gemdir="$(gem env gemdir)"

  gem build "$_pkgname.gemspec"

  gem install \
    --local \
    --verbose \
    --ignore-dependencies \
    --no-user-install \
    --install-dir "tmp_install/$gemdir" \
    --bindir "tmp_install/usr/bin" \
    "$_pkgname-$pkgver.gem"

  # Remove unrepreducible files
  rm --force --recursive --verbose \
    "tmp_install/$gemdir/cache/" \
    "tmp_install/$gemdir/gems/$_pkgname-$pkgver/vendor/" \
    "tmp_install/$gemdir/doc/$_pkgname-$pkgver/ri/ext/"

  find "tmp_install/$gemdir/gems/" \
    -type f \
    \( \
    -iname "*.o" -o \
    -iname "*.c" -o \
    -iname "*.so" -o \
    -iname "*.time" -o \
    -iname "gem.build_complete" -o \
    -iname "Makefile" \
    \) \
    -delete

  find "tmp_install/$gemdir/extensions/" \
    -type f \
    \( \
    -iname "mkmf.log" -o \
    -iname "gem_make.out" \
    \) \
    -delete
}

check() {
  cd "$_pkgname"
  GEM_HOME="tmp_install/$(gem env gemdir)" rake test -v
}

package() {
  cd "$_pkgname"
  cp -a tmp_install/* "$pkgdir"
  install -vDm644 -t "$pkgdir/usr/share/doc/$pkgname" ./*.md
  install -vDm644 -t "$pkgdir/usr/share/licenses/$pkgname" LICENSE.txt
}