summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 7271d3fd5e21b21683d80cc34f757bcb1f625145 (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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# Maintainer:  Vitalii Kuzhdin <vitaliikuzhdin@gmail.com>
# Contributor: Hiroshi Hatake <cosmo0920.wp[at]gmail.com>

_name="rdtool"
pkgname="ruby-${_name}"
pkgver=0.6.38
pkgrel=1
pkgdesc="A formatter for RD"
arch=('any')
url="https://uwabami.github.io/software/rdtool"
_url="https://github.com/uwabami/${_name}"
license=('Ruby License' 'GPL-2.0-or-later')
makedepends=('ruby-rake' 'ruby-racc>=1.4.6')
checkdepends=('ruby-test-unit')
depends=('ruby' 'ruby-ostruct' 'ruby-image_size' 'ruby-forwardable'
         'ruby-optparse' 'ruby-cgi')
_pkgsrc="${_name}-${pkgver}"
source=("${_pkgsrc}.tar.gz::${_url}/archive/v${pkgver}.tar.gz")
sha256sums=('2d679e8ac0705136ebbcea771f0cd410490d164dc3bcbf9fd5493346df179ded')

prepare() {
  cd "${srcdir}/${_pkgsrc}"
  mv -f "HISTORY" "HISTORY.rd"

  sed -i --regexp-extended 's|~>|>=|g' "${_name}.gemspec"
  sed -i --regexp-extended 's|`git ls-files -- bin/\*`|`find ./bin -type f -print`|' "${_name}.gemspec"
  sed -i --regexp-extended 's|`git ls-files -- test/\*`|`find ./test -type f -print`|' "${_name}.gemspec"
  sed -i 's|GPL-2+|GPL-2.0+|g' "${_name}.gemspec"
  sed -i 's|HISTORY|HISTORY\.html|g' "${_name}.gemspec"
}

build() {
  local _gemdir="$(gem env gemdir)"

  cd "${srcdir}/${_pkgsrc}"
  rake doc

  gem build "${_name}.gemspec"
  gem install \
    --local \
    --verbose \
    --ignore-dependencies \
    --no-user-install \
    --install-dir "tmp_install/${_gemdir}" \
    --bindir "tmp_install/usr/bin" \
    "${_name}-${pkgver}.gem"

  # remove unrepreducible files
  rm --force --recursive --verbose \
    "tmp_install/${_gemdir}/cache/" \
    "tmp_install/${_gemdir}/gems/${_name}-${pkgver}/vendor/" \
    "tmp_install/${_gemdir}/doc/${_name}-${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() {
  local _gemdir="$(gem env gemdir)"

  cd "${srcdir}/${_pkgsrc}"
  GEM_HOME="tmp_install/${_gemdir}" rake test
}

package() {
  local _gemdir="$(gem env gemdir)"
  local _sourcedir="${_gemdir}/gems/${_pkgsrc}"
  local _docdir="${pkgdir}/usr/share/doc/${pkgname}"
  local _licensedir="${pkgdir}/usr/share/licenses/${pkgname}"

  cd "${srcdir}/${_pkgsrc}"
  cp --archive --verbose tmp_install/* "${pkgdir}"

  install -d "${_docdir}"
  install -d "${_licensedir}"

  ln -s "${_sourcedir}/README.html"    "${_docdir}/README.html"
  ln -s "${_sourcedir}/README.ja.html" "${_docdir}/README.ja.html"
  ln -s "${_sourcedir}/HISTORY.html"   "${_docdir}/HISTORY.html"

  ln -s "${_sourcedir}/LICENSE.txt" "${_licensedir}/LICENSE"
  ln -s "${_sourcedir}/COPYING.txt" "${_licensedir}/COPYING"
  ln -s "${_sourcedir}/LGPL-2.1"    "${_licensedir}/LGPL-2.1"
}