aboutsummaryrefslogtreecommitdiffstats
path: root/main/ruby/APKBUILD
blob: 0ae8221ae5e7b27e5784fb1545668e5535892c7b (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
# Contributor: Carlo Landmeter <clandmeter@gmail.com>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=ruby
pkgver=2.0.0_p353
_pkgver=${pkgver/_/-}
pkgrel=2

_abi=2.0.0

pkgdesc="An object-oriented language for quick and easy programming"
url="http://www.ruby-lang.org/en/"
arch="all"
license="Ruby"
depends=""
makedepends="zlib-dev openssl-dev libiconv-dev gdbm-dev db-dev readline-dev
	libffi-dev coreutils yaml-dev autoconf"
subpackages="$pkgname-doc $pkgname-dev $pkgname-irb
	$pkgname-rdoc $pkgname-rake $pkgname-bigdecimal
	$pkgname-io-console:io_console $pkgname-minitest
	$pkgname-libs
	"
patches="
	ruby-io.patch
	readline-6.3.patch
	"
source="ftp://ftp.ruby-lang.org/pub/ruby/${pkgver%.*}/${pkgname}-${_pkgver}.tar.bz2
	$patches"
options="!fhs"
replaces="ruby-gems"

#
# maybe its a good idea to split dep libs to seperate pkg's.
#

_builddir="$srcdir/$pkgname-${_pkgver}"
_gemdir="/usr/lib/ruby/gems/$_abi"
_rubydir="/usr/lib/ruby/$_abi"
_arch=$CARCH
case $CARCH in
x86) _arch=i386;;
esac

prepare() {
	cd "$_builddir"
	update_config_sub || return 1
	for i in $patches; do
		msg $i
		patch -p1 -i "$srcdir"/$i || return 1
	done
	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"

	# turn off distcc/ccache
	# http://bugs.alpinelinux.org/issues/show/1
#	export CC=gcc

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

	case "$CLIBC" in
	uclibc | musl)
		# the configure script does not detect isnan/isinf as macros
		export ac_cv_func_isnan=yes
		export ac_cv_func_isinf=yes
		;;
	esac

	./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
	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
	install -Dm644 COPYING \
		"${pkgdir}/usr/share/licenses/${pkgname}"/COPYING || return 1
	# unbundle
	_rmgem json
}

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

_mvgem() {
	cd "$pkgdir"
	for i in ./$_rubydir/${1}.rb \
			./$_rubydir/${1} \
			./$_rubydir/${CHOST/-alpine-/-}/${1} \
			./$_gemdir/gems/${1}-* \
			./$_gemdir/specifications/default/${1}-* ; do
		[ -e "$pkgdir"/$i ] || continue
		_mv "$i"
	done
}

_rmgem() {
	cd "$pkgdir"
	for i in ./$_rubydir/${1}.rb \
			./$_rubydir/${1} \
			./$_rubydir/${CHOST/-alpine-/-}/${1} \
			./$_gemdir/gems/${1}-* \
			./$_gemdir/specifications/default/${1}-* ; do
		[ -e "$pkgdir"/$i ] && rm -r "$pkgdir/$i"
	done
	return 0
}

rake() {
	pkgdesc="Ruby based make-like utility"
	depends="ruby"
	arch="noarch"
	_mvgem rake || return 1
	_mv usr/bin/rake
}

irb() {
	pkgdesc="The Interactive Ruby"
	replaces="ruby"
	depends="ruby"
	arch="noarch"
	cd "$pkgdir"
	_mv usr/bin/irb \
		usr/lib/ruby/$_abi/irb*
}

rdoc() {
	pkgdesc="Ruby documentation tool"
	depends="ruby"
	arch="noarch"
	_mvgem rdoc || return 1
	_mv usr/bin/ri \
		usr/bin/rdoc
}

bigdecimal() {
	pkgdesc="Ruby arbitrary-precision floating point decimal arithmetic"
	depends="ruby"
	arch="noarch"
	_mvgem bigdecimal
}

io_console() {
	pkgdesc="Ruby simple console IO library"
	depends="ruby"
	_mvgem io-console
	_mv $_rubydir/io \
		$_rubydir/${CHOST/-alpine-/-}/io/console.so
}

minitest() {
	pkgdesc="Ruby suite of testing facilities"
	depends="ruby"
	arch="noarch"
	_mvgem minitest
}

libs() {
	pkgdesc="Libraries necessary to run Ruby"
	depends=""
	mkdir -p "$subpkgdir"/usr
	mv "$pkgdir"/usr/lib "$subpkgdir"/usr/
}

md5sums="20eb8f067d20f6b76b7e16cce2a85a55  ruby-2.0.0-p353.tar.bz2
7a4d86c7bf1ddad97f1cde52d849202f  ruby-io.patch
5f396d3d9825441a0d112c3a95885074  readline-6.3.patch"
sha256sums="3de4e4d9aff4682fa4f8ed2b70bd0d746fae17452fc3d3a8e8f505ead9105ad9  ruby-2.0.0-p353.tar.bz2
f8822c378f94ecce7214c370703db74723e2b3ce9efa956840036b1ffd8f32e1  ruby-io.patch
e61a58c5f59500f636b0e6a62434f68c772e8d6af29acdc54afbaf3c3f911f06  readline-6.3.patch"
sha512sums="52aa64c5991e61cc49c2062672554353bc88ab563da93a1d1591257153c2f6d8de02417a33d7a585eb0102f1079a993e46671fb6c97c62eac8615de567b575f2  ruby-2.0.0-p353.tar.bz2
af001e5540e65e3a042d193a56cb46c3983de1c77ca89869406816561021480741b856996d252a97913fb882cb739949f6dbb6754790e54258b58a9d861be1ba  ruby-io.patch
439f14cb2718b03502018df42d27def3761c7bb67be5104769527d8f0d2342a92fd4f326748f03ab6287a864daa7b2d13f5539cc577bb9315b8af6b9d45600ac  readline-6.3.patch"