summaryrefslogtreecommitdiff
path: root/libre/ruby/PKGBUILD
blob: 8e7917dd85a65d5548a944dc881e681ade6b5fd2 (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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
# 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=3.0.1
_jsonver=2.5.1
pkgrel=1
pkgrel+=.parabola1
_srcrel=1 # increment this to rebuild the sourceball without bumping pkgver
arch=(x86_64)
arch+=(i686 armv7h)
url='https://www.ruby-lang.org/en/'
license=(BSD2 custom)
depends=(libxcrypt)
makedepends=(gdbm openssl libffi doxygen graphviz libyaml ttf-dejavu tk)
options=(!emptydirs)
source=(https://cache.ruby-lang.org/pub/ruby/${pkgver:0:3}/ruby-${pkgver}.tar.xz
        json-${_jsonver}.tar.gz::https://github.com/flori/json/archive/v${_jsonver}.tar.gz
        remove-json-ext.patch
        add-json_pure.patch
        json-libre.patch)
sha512sums=('97d2e883656060846b304368d9d836e2f3ef39859c36171c9398a0573818e4ed75bfd7460f901a9553f7f53518c505327a66e74f83704a881469f5ac61fe13d7'
            '4df7ec9b86692376e89c2019c2c1ab3ae9af28fb4742864acc6f985c0551fc10795742cc1124d6435e820617c00d4c5f4aa6c83b21d2fff43ed05cd9d0a89087'
            'e3cb4d17872d69d7bc2697b751e27c7f76edbf996f4e3007241cd8a60d2251056cf8dd858f249c0b28088da5b969c63bc5c0d52eef9c95e52e190234d3e46609'
            'c3933f1c6d7ddf669e0cfd8ffdd60abeb59a10bdfcab05a1c1b826ab65bed7019df85c15dd8af0b127a5728d5f6c322fcd724e0b9ecf0d9cdb5d28956050cc9a'
            'bb2cc232a0b096a3c40e219258aaa008183ed9a1f8b3bfd5f84680809f4b60e659f02e1db24480b30e6f11ad726b258da9dab17462621e8bfb8f9b6ed98dfbfd')

prepare() {
  cd "$srcdir/json-${_jsonver}"

  # Modify 'json' so that it doesn't try to load (non-free!) 'json/ext'
  msg "applying json-libre.patch"
  rm -rf -- json.gemspec ext lib/json/ext*
  patch -p1 -i ../json-libre.patch

  # Now remove the json ext from the ruby sources
  cd "$srcdir/ruby-${pkgver}"
  msg "applying remove-json-ext.patch"
  rm -r ext/json test/json
  patch -p1 -i ../remove-json-ext.patch

  # and insert the json_pure lib instead
  msg "applying add-json_pure.patch"
  cp -r  ../json-${_jsonver}/lib/*             -t lib/
  cp     ../json-${_jsonver}/json_pure.gemspec -t lib/json/
  cp -rT ../json-${_jsonver}/tests                test/json
  sed -i "s/File.read(\"VERSION\").chomp/\"${_jsonver}\"/g" lib/json/json_pure.gemspec
  patch -p1 -i ../add-json_pure.patch

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

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 ruby-irb)
  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 as a separate package
  rm -r "${pkgdir}"/usr/lib/ruby/${rubyver}/{rubygems,rubygems.rb}
  rm "${pkgdir}"/usr/bin/gem

  # remove bundler as it shipped as a separate package
  rm -r "${pkgdir}"/usr/lib/ruby/${rubyver}/{bundler,bundler.rb}
  rm "${pkgdir}"/usr/bin/{bundle,bundler}
  rm "${pkgdir}"/usr/lib/ruby/gems/${rubyver}/specifications/default/bundler-*.gemspec

  # remove bundled rdoc gem
  rm -r "${pkgdir}"/usr/lib/ruby/${rubyver}/{rdoc,rdoc.rb}
  rm "${pkgdir}"/usr/bin/{rdoc,ri}
  rm "${pkgdir}"/usr/lib/ruby/gems/${rubyver}/specifications/default/rdoc-*.gemspec
  rm "${pkgdir}"/usr/share/man/man1/ri.1

  # remove irb as it is a separate package now
  rm -r "${pkgdir}"/usr/lib/ruby/${rubyver}/{irb,irb.rb}
  rm "${pkgdir}"/usr/bin/irb
  rm "${pkgdir}"/usr/lib/ruby/gems/${rubyver}/specifications/default/irb-*.gemspec
  rm "${pkgdir}"/usr/share/man/man1/irb.1

  # remove other binaries that are shipped as separate packages
  rm "${pkgdir}"/usr/bin/{rake,rbs,typeprof,erb,racc}
  rm "${pkgdir}"/usr/share/man/man1/erb.1

  # remove all bundled gems to avoid conflicts with ruby-* Arch packages
  rm -r "${pkgdir}"/usr/lib/ruby/gems/${rubyver}/gems/*
  rm "${pkgdir}"/usr/lib/ruby/gems/${rubyver}/specifications/*.gemspec
  rm "${pkgdir}"/usr/lib/ruby/gems/${rubyver}/cache/*.gem
}

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"
}