summaryrefslogtreecommitdiff
path: root/libre/ruby2.3/PKGBUILD
blob: 19acd2deaaa9ac7690f455ca6b57d0d55c6dab0a (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
# Maintainer (Arch): Sven-Hendrik Haase <sh@lutzhaase.com>
# Contributor (Arch): Sergey Shatunov <me@prok.pw>
# Contributor (Arch): Jonne Haß <me@jhass.eu>
# 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: Luke Shumaker <lukeshu@parabola.nu>
# Contributor: Omar Vega Ramos <ovruni@gnu.org.pe>

# 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

_rubyver=2.3
pkgname=ruby2.3
pkgver=2.3.5
_jsonver=1.8.3
pkgdesc='An object-oriented language for quick and easy programming'
pkgrel=4.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=(BSD custom)
depends=(gdbm openssl-1.0 libffi libyaml gmp zlib)
optdepends=('tk: for Ruby/TK')
makedepends=(gdbm openssl-1.0 libffi doxygen graphviz libyaml ttf-dejavu tk)
options=(!emptydirs)
source=(https://repo.parabola.nu/other/ruby-libre/ruby-${pkgver}-libre${_srcrel}.tar.gz)
sha512sums=('73187c128092bf0c16d2c0955e6bcdcad943b4721b9c852a82324779219bd6480e672054c4a4831f89e4331844f1f181135e91692900da1b830e6e11f80dfd28')

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}-ruby-${pkgver}-backports.patch
          json-${_jsonver}-libre.patch)
mksha512sums=('c55e3b71241f505b6bbad78b3bd40235064faae3443ca14b77b6356556caed6a0d055dc2e2cd7ebdb5290ab908e06d2b7d68f72469af5017eda4b29664b0d889'
              'bd36519010a36d9368450de3bb6e46fd4b95682521877450f5875d0c0fc87119c52bd32cfdd7bcadf336d59e51665437a632d43d2f41934c808079ce6623a58c'
              'fcfde775beb157db7a9788c897b06c11191a5f1c34e94a1644ce9c9b32675dab9001b66f1b26fdb6082eb9e85ba38423ccc9917716c788bb9cd8fa54e723c757'
              '147ce1834a1a0f02596386969c6e95c14237cc4d5303be974b9293d349d61a074cf9cc99d2f6bc434aa6da8aac9ddc35cfdeb7b9f77b14c112f8be70ff0846f7'
              '05078d112741d80289acfe7221d98c244dad6c905b536c16886001ca78fef93523af0ba4d49f19cc8ebf0ac6a0e10278f53c07f055d8ae658a6bc57fcdc1c5ad'
              'aac35c74c16be38b4c7b2a5677189036bf90fbc00bcffdffe6a76ddaf6eb87d0ddb30ad239aefe4d7ff5c13ddd2b2fa18007e4d0a8f5e38b1153aed6e3d35c58')
mksource() {
  # Start with the vanilla version of json
  cd "$srcdir/json-${_jsonver}"
  # Apply changes made to it for the ruby distribution
  patch -p1 -i ../json-${_jsonver}-ruby-${pkgver}-backports.patch
  chmod 644 tests/test_json_*
  # 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}"
}

build() {
  cd ruby-${pkgver}

  CFLAGS+=' -O1' # GCC 7 produces a broken Ruby 2.3 with -O2
  CPPFLAGS+=' -U_FORTIFY_SOURCE' # _FORTIFY_SOURCE requires at least -O2

  export PKG_CONFIG_PATH=/usr/lib/openssl-1.0/pkgconfig
  PKG_CONFIG=/usr/bin/pkg-config ./configure \
    --prefix=/opt/ruby${_rubyver} \
    --program-suffix=-${_rubyver} \
    --sysconfdir=/etc \
    --localstatedir=/var \
    --sharedstatedir=/var/lib \
    --libexecdir=/usr/lib/ruby \
    --enable-shared \
    --disable-rpath \
    --with-dbm-type=gdbm_compat

  make ruby
}

check() {
  cd ruby-${pkgver}

  make test
}

package() {
  cd ruby-${pkgver}

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

  install -dm755 $pkgdir/usr/bin
  install -dm755 $pkgdir/usr/lib

  for i in erb irb rdoc ri ruby testrb rake gem; do
    ln -s /opt/$pkgname/bin/$i-${_rubyver} $pkgdir/usr/bin/$i-${_rubyver}
    ln -s /opt/$pkgname/bin/$i-${_rubyver} $pkgdir/opt/$pkgname/bin/$i
  done

  ln -s /opt/$pkgname/lib/libruby.so.${_rubyver} $pkgdir/usr/lib/libruby.so.${_rubyver}

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