aboutsummaryrefslogtreecommitdiffstats
path: root/main/ruby/APKBUILD
blob: ff8d6657ad960c66074430435779792a4e4c0936 (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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
# Contributor: Carlo Landmeter <clandmeter@gmail.com>
# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=ruby
pkgver=2.4.1
_abiver="${pkgver%.*}.0"
pkgrel=2
pkgdesc="An object-oriented language for quick and easy programming"
url="http://www.ruby-lang.org/en/"
arch="all"
license="Ruby"
depends="ca-certificates"
depends_dev="gmp-dev"
makedepends="$depends_dev zlib-dev libressl-dev gdbm-dev db-dev readline-dev
	libffi-dev coreutils yaml-dev linux-headers autoconf"
subpackages="$pkgname-doc $pkgname-dev
	$pkgname-bigdecimal::noarch
	$pkgname-did_you_mean::noarch
	$pkgname-io-console:io_console
	$pkgname-irb::noarch
	$pkgname-json
	$pkgname-minitest::noarch
	$pkgname-net-telnet:net_telnet:noarch
	$pkgname-power_assert::noarch
	$pkgname-rake::noarch
	$pkgname-rdoc::noarch
	$pkgname-test-unit:test_unit:noarch
	$pkgname-xmlrpc::noarch
	$pkgname-libs
	"
source="ftp://ftp.ruby-lang.org/pub/ruby/${pkgver%.*}/$pkgname-$pkgver.tar.bz2"
options="!fhs"
replaces="ruby-gems"
builddir="$srcdir/$pkgname-$pkgver"

_gemdir="/usr/lib/ruby/gems/$_abiver"
_rubydir="/usr/lib/ruby/$_abiver"
_chost="${CHOST/-alpine-/-}"

case "$CARCH" in
	x86) _arch="i386";;
	*) _arch="$CARCH";;
esac

prepare() {
	default_prepare || return 1

	cd "$builddir"
	autoconf
}

build() {
	cd "$builddir"

	# -fomit-frame-pointer makes ruby segfault, see gentoo bug #150413
	# In many places aliasing rules are broken; play it safe
	# as it's risky with newer compilers to leave it as it is.
	export CFLAGS="$CFLAGS -fno-omit-frame-pointer -fno-strict-aliasing"
	export CPPFLAGS="$CPPFLAGS -fno-omit-frame-pointer -fno-strict-aliasing"

	# ruby saves path to install. we want use $PATH
	export INSTALL=install

	# the configure script does not detect isnan/isinf as macros
	export ac_cv_func_isnan=yes
	export ac_cv_func_isinf=yes

	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--infodir=/usr/share/info \
		--with-sitedir='/usr/local/lib/site_ruby' \
		--with-search-path="/usr/lib/site_ruby/\$(ruby_ver)/$_arch-linux" \
		--enable-pthread \
		--disable-rpath \
		--enable-shared \
		--with-mantype=man \
		|| return 1
	make || return 1
	make test || return 1
}

package() {
	cd "$builddir"

	make DESTDIR="$pkgdir" install || return 1

	install -m 644 -D COPYING \
		"$pkgdir"/usr/share/licenses/$pkgname/COPYING || return 1

	rm -R "$pkgdir"$_gemdir/cache/*

	# Remove bundled CA certificates.
	rm -R "$pkgdir"$_rubydir/rubygems/ssl_certs/*.pem || true

	if [ -d "$pkgdir"/usr/local ]; then
		local f=$(cd "$pkgdir" ; find usr/local -type f)
		if [ -n "$f" ]; then
			error "Found files in /usr/local:"
			echo "$f"
			return 1
		fi
	fi
}

bigdecimal() {
	pkgdesc="Ruby arbitrary-precision floating point decimal arithmetic"
	depends="$pkgname"

	_mvgem bigdecimal
}

did_you_mean() {
	pkgdesc="Did you mean? experience in Ruby"
	depends="$pkgname"

	_mvgem did_you_mean
}

io_console() {
	pkgdesc="Ruby simple console IO library"
	depends="$pkgname"

	_mvgem io-console
	_mv $_rubydir/io \
		$_rubydir/$_chost/io/console.so
}

irb() {
	pkgdesc="The Interactive Ruby"
	replaces="$pkgname"
	depends="$pkgname"

	cd "$pkgdir"
	_mv usr/bin/irb \
		usr/lib/ruby/$_abiver/irb*
}

json() {
	pkgdesc="JSON implementation as a Ruby extension in C"
	depends="$pkgname"

	_mvgem json
}

minitest() {
	pkgdesc="Ruby suite of testing facilities"
	depends="$pkgname"

	_mvgem minitest
}

net_telnet() {
	pkgdesc="Telnet client functionality for Ruby"
	depends="$pkgname"

	_mvgem net-telnet
}

power_assert() {
	pkgdesc="Power Assert for Ruby"
	depends="$pkgname"

	_mvgem power_assert
}

rake() {
	pkgdesc="Ruby based make-like utility"
	depends="$pkgname"

	_mvgem rake || return 1
	_mv usr/bin/rake
}

rdoc() {
	pkgdesc="Ruby documentation tool"
	depends="$pkgname $pkgname-json $pkgname-io-console"

	_mvgem rdoc || return 1
	_mv usr/bin/ri \
		usr/bin/rdoc
}

test_unit() {
	pkgdesc="An xUnit family unit testing framework for Ruby"
	depends="$pkgname $pkgname-power_assert"

	_mvgem test-unit
}

xmlrpc() {
	pkgdesc="XMLRPC library for Ruby"
	depends="$pkgname"

	_mvgem xmlrpc
}

libs() {
	pkgdesc="Libraries necessary to run Ruby"
	depends=""

	mkdir -p "$subpkgdir"/usr
	mv "$pkgdir"/usr/lib "$subpkgdir"/usr/
}

_mv() {
	local i; for i in "$@"; do
		mkdir -p "$subpkgdir"/${i%/*}
		mv "$pkgdir"/${i} "$subpkgdir"/${i%/*}/ || return 1
	done
}

_mvgem() {
	cd "$pkgdir"
	local path; for path in ./$_rubydir/${1}.rb \
			./$_rubydir/${1} \
			./$_rubydir/$_chost/${1} \
			./$_gemdir/gems/${1}-* \
			./$_gemdir/specifications/${1}-* \
			./$_gemdir/specifications/default/${1}-* ; do
		[ ! -e "$pkgdir/$path" ] || _mv "$path"
	done
}

sha512sums="1c80d4c30ecb51758a193b26b76802a06d214de7f15570f1e85b5fae4cec81bda7237f086b81f6f2b5767f2e93d347ad1fa3f49d7b5c2e084d5f57c419503f74  ruby-2.4.1.tar.bz2"