summaryrefslogtreecommitdiff
path: root/libre/ruby/PKGBUILD
blob: f38c688669fc60e60f6463b38acb8be39f758277 (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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# Contributor (Arch): Thomas Dziedzic <gostrc@gmail.com>
# Contributor (Arch): Allan McRae <allan@archlinux.org>
# Contributor (Arch): John Proctor <jproctor@prium.net>
# Contributor (Arch): Jeramy Rutley <jrutley@gmail.com>

# Maintainer: Omar Vega Ramos <ovruni@gnu.org.pe>
# Contributor: Daniel Milewski <niitotantei@riseup.net>
# Contributor: André Silva <emulatorman@hyperbola.info>
# Contributor: Luke Shumaker <lukeshu@parabola.nu>
# Contributor: fauno <fauno@parabola.nu>

# Rationale for inclusion in [libre]: Problematic license of
# generator.c in bundled json extension.
#
# https://labs.parabola.nu/issues/674
# https://bugs.ruby-lang.org/issues/11844
# https://github.com/flori/json/issues/277

pkgname=(ruby ruby-docs)
pkgver=2.5.1
_jsonver=2.1.0
pkgrel=2.parabola1
_srcrel=1 # increment this to rebuild the sourceball without bumping pkgver
arch=(i686 x86_64 armv7h)
url='http://www.ruby-lang.org/en/'
license=(BSD2 custom)
makedepends=(gdbm openssl libffi doxygen graphviz libyaml ttf-dejavu tk)
options=(!emptydirs)
source=(https://repo.parabola.nu/other/ruby-libre/ruby-${pkgver}-libre${_srcrel}.tar.gz)
sha512sums=('0e312bb211abff335cb1a65f0e6645f0dfcaa9bf9790cae11ad200027719f73f17793d4b7b6462aaaec043a72ad60b54cc92b6c686027a7715a011bc73ee1852')

mkdepends=('ruby') # for 'gem build'
mksource=(https://cache.ruby-lang.org/pub/ruby/${pkgver:0:3}/ruby-${pkgver}.tar.xz
          ruby-${pkgver}-remove-json-ext.patch
          ruby-${pkgver}-add-json_pure.patch
          json-${_jsonver}.tar.gz::https://github.com/flori/json/archive/v${_jsonver}.tar.gz
          json-${_jsonver}-libre.patch)
mksha512sums=('31bacf58469953282cd5d8b51862dcf4b84dedb927c1871bc3fca32fc157fe49187631575a70838705fe246f4555647577a7ecc26894445a7d64de5503dc11b4'
              'dbfd2517e87571e25fea832f50535e76c07972e15f48050ad7b08b04993c566ae7b5e8b1dd0e3cd65eb6161290026eaa71ff4528e98a92e37983066b4929cfb1'
              '303172561a4ba54515fddfd9ea7e0c833e550b0ae5e9f331956f178f8c5e20aa0e3c4036251ddfd04312769ef7d71d83fde0afe64f6fa8e9052ca5a294c62927'
              '6019cc26a0919e4d39ae0bf737b51cd9a474c74a55d25f6931ac04d61826bb810d063190a80a29810e57d7457d1a247acd82fd78de2c4c01acb7d73ee9fde603'
              '582017bd0f98878c0ac6f4625854422662d83ae6274a34762082a720052023780dceb17694b1f4e18d9a0dcbb525990341176eac31040aa63099a8b3a8d52071')

mksource() {
  # Start with the vanilla version of json
  cd "$srcdir/json-${_jsonver}"
  # Modify it so that 'json' doesn't try to load (non-free!) 'json/ext'
  rm -rf -- json.gemspec ext lib/json/ext*
  patch -p1 -i ../json-${_jsonver}-libre.patch

  # Now modify the ruby sources to include the json_pure lib instead
  # of the json ext
  cd "$srcdir/ruby-${pkgver}"
  # remove the json ext
  rm -rv ext/json test/json
  patch -p1 -i ../ruby-${pkgver}-remove-json-ext.patch
  # and insert the json_pure lib
  cp -r  ../json-${_jsonver}/lib/*             -t lib/
  cp     ../json-${_jsonver}/json_pure.gemspec -t lib/json/
  cp -rT ../json-${_jsonver}/tests                test/json
  patch -p1 -i ../ruby-${pkgver}-add-json_pure.patch

  # Clean up the original json sources
  cd "$srcdir"
  rm -rf "json-${_jsonver}"
}

prepare() {
  cd ruby-${pkgver}
  # remove bundled gems, we are going to ship them as separate packages
  rm -rf gems/
}

build() {
  cd ruby-${pkgver}

  ./configure \
    --prefix=/usr \
    --sysconfdir=/etc \
    --localstatedir=/var \
    --sharedstatedir=/var/lib \
    --libexecdir=/usr/lib/ruby \
    --enable-shared \
    --disable-rpath \
    --with-dbm-type=gdbm_compat

  make
}

check() {
  cd ruby-${pkgver}

  make test
}

package_ruby() {
  pkgdesc='An object-oriented language for quick and easy programming'
  depends=(gdbm openssl libffi libyaml gmp zlib rubygems)
  optdepends=(
      'ruby-docs: Ruby documentation'
      'tk: for Ruby/TK'
  )

  cd ruby-${pkgver}

  make DESTDIR="${pkgdir}" install-nodoc

  install -D -m644 COPYING "${pkgdir}/usr/share/licenses/ruby/LICENSE"
  install -D -m644 BSDL "${pkgdir}/usr/share/licenses/ruby/BSDL"

  rubyver=${pkgver:0:3}.0

  # remove rubygems as it shipped in a separate package
  rm -r "${pkgdir}"/usr/lib/ruby/${rubyver}/{rubygems,rubygems.rb}
  rm "${pkgdir}"/usr/bin/gem

  # remove bundled rdoc gem
  # we are doing it here instead of prepare() because rdoc used doring Ruby build process
  rm -r "${pkgdir}"/usr/lib/ruby/${rubyver}/rdoc/
  rm "${pkgdir}"/usr/bin/{rdoc,ri}
  rm -r "${pkgdir}"/usr/lib/ruby/gems/${rubyver}/gems/*
  rm "${pkgdir}"/usr/lib/ruby/gems/${rubyver}/specifications/default/rdoc-*.gemspec
}

package_ruby-docs() {
  pkgdesc='Documentation files for ruby'

  cd ruby-${pkgver}

  make DESTDIR="${pkgdir}" install-doc install-capi

  install -D -m644 COPYING "${pkgdir}/usr/share/licenses/ruby-docs/LICENSE"
  install -D -m644 BSDL "${pkgdir}/usr/share/licenses/ruby-docs/BSDL"

  # sometimes it installs ruby/capi/doxygen_objdb_XXXXXXX.tmp;
  # otherwise /usr/share/doc is empty
  rm -rf "$pkgdir/usr/share/doc"
}