aboutsummaryrefslogtreecommitdiffstats
path: root/main/busybox/APKBUILD
blob: 3b02edea03eed6515de3478a525e9ab92ef9cf7c (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
# Contributor: Łukasz Jendrysik <scadu@yandex.com>
# Contributor: Oliver Smith <ollieparanoid@bitmessage.ch>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=busybox
pkgver=1.29.3
pkgrel=0
pkgdesc="Size optimized toolbox of many common UNIX utilities"
url=http://busybox.net
arch="all"
license="GPL-2.0"
makedepends_build=""
makedepends_host="linux-headers libressl-dev"
makedepends="$makedepends_build $makedepends_host"
checkdepends="zip"
provides="/bin/sh"
install="$pkgname.post-install $pkgname.post-upgrade
	$pkgname-extras.post-install $pkgname-extras.pre-deinstall"
subpackages="$pkgname-static $pkgname-suid $pkgname-extras ssl_client"
options="suid !check"
triggers="busybox.trigger=/bin:/usr/bin:/sbin:/usr/sbin:/lib/modules/*"
source="http://busybox.net/downloads/$pkgname-$pkgver.tar.bz2
	0001-properly-fix-wget-https-support.patch
	0002-fsck-resolve-LABEL-.-UUID-.-spec-to-device.patch
	0003-ash-exec-busybox.static.patch
	0004-app-location-for-cpio-vi-and-lspci.patch
	0005-udhcpc-set-default-discover-retries-to-5.patch
	0006-ping-make-ping-work-without-root-privileges.patch
	0007-fbsplash-support-console-switching.patch
	0008-fbsplash-support-image-and-bar-alignment-and-positio.patch
	0009-depmod-support-generating-kmod-binary-index-files.patch
	0010-Add-flag-for-not-following-symlinks-when-recursing.patch
	0011-sysklogd-add-Z-option-to-adjust-message-timezones.patch
	0012-udhcpc-Don-t-background-if-n-is-given.patch
	0013-testsuite-fix-cpio-tests.patch
	0014-miscutils-microcom-Fixed-segfault.patch

	acpid.logrotate
	busyboxconfig
	busyboxconfig-extras
	bbsuid.c
	dad.if-up
	nologin.c
	ssl_client.c
	"

# secfixes:
#   1.27.2-r4:
#   - CVE-2017-16544
#   - CVE-2017-15873
#   - CVE-2017-15874

builddir="$srcdir"/$pkgname-$pkgver

_staticdir="$srcdir"/build-static
_dyndir="$srcdir"/build-dynamic
_dyndir_extras="$srcdir"/build-dynamic-extras
_config="$srcdir"/busyboxconfig
_config_extras="$srcdir"/busyboxconfig-extras

prepare() {
	default_prepare

	cd "$builddir"
	mkdir -p "$_staticdir" "$_dyndir" "$_dyndir_extras"
	cp "$srcdir"/nologin.c loginutils/
}

build() {
	# build bbsuid
	msg "Building bbsuid"
	${CC:-${CROSS_COMPILE}gcc} ${CPPFLAGS} ${CFLAGS} \
		${LDFLAGS} "$srcdir"/bbsuid.c -o "$_dyndir"/bbsuid

	msg "Building ssl_client"
	${CC:-${CROSS_COMPILE}gcc} ${CPPFLAGS} ${CFLAGS} $(pkg-config --cflags libtls) \
		"$srcdir"/ssl_client.c -o "$_dyndir"/ssl_client ${LDFLAGS} $(pkg-config --libs libtls)

	# build dynamic
	cd "$_dyndir"
	msg "Building dynamic busybox"
	cp "$_config" .config
	[ "$CLIBC" = musl ] && sed -i \
		-e "s/CONFIG_EXTRA_COMPAT=y/CONFIG_EXTRA_COMPAT=n/" \
		.config
	make -C "$builddir" O="$PWD" silentoldconfig
	make

	# build dynamic (extras)
	cd "$_dyndir_extras"
	msg "Building dynamic busybox-extras"
	cp "$_config_extras" .config
	[ "$CLIBC" = musl ] && sed -i \
		-e "s/CONFIG_EXTRA_COMPAT=y/CONFIG_EXTRA_COMPAT=n/" \
		.config
	make -C "$builddir" O="$PWD" silentoldconfig
	make

	# build static
	cd "$_staticdir"
	msg "Building static busybox"
	# enable internal ssl_client for static build
	sed -e "s/.*CONFIG_PIE.*/\# CONFIG_PIE is not set/" \
		-e "s/.*CONFIG_STATIC.*/CONFIG_STATIC=y/" \
		-e "s/.*CONFIG_SSL_CLIENT.*/CONFIG_SSL_CLIENT=y/" \
		"$_config" > .config
	# musl does not support GNU regex
	[ "$CLIBC" = musl ] && sed -i \
		-e "s/CONFIG_EXTRA_COMPAT=y/CONFIG_EXTRA_COMPAT=n/" \
		.config
	make -C "$builddir" O="$PWD" silentoldconfig
	make
	mv busybox busybox.static
}

check() {
	cd "$_dyndir"
	SKIP_KNOWN_BUGS=1 make -C "$builddir" O="$PWD" V=1 check

	cd "$_dyndir_extras"
	SKIP_KNOWN_BUGS=1 make -C "$builddir" O="$PWD" V=1 check
}

package() {
	cd "$_dyndir"
	mkdir -p "$pkgdir"/usr/sbin "$pkgdir"/usr/bin "$pkgdir"/tmp \
		"$pkgdir"/var/cache/misc "$pkgdir"/bin "$pkgdir"/sbin
	chmod 1777 "$pkgdir"/tmp
	install -m755 busybox "$pkgdir"/bin/busybox || return 1
	# we need /bin/sh to be able to execute post-install
	ln -s /bin/busybox "$pkgdir"/bin/sh

	#ifupdown needs those dirs to be present
	mkdir -p \
		"$pkgdir"/etc/network/if-down.d \
		"$pkgdir"/etc/network/if-post-down.d \
		"$pkgdir"/etc/network/if-post-up.d \
		"$pkgdir"/etc/network/if-pre-down.d \
		"$pkgdir"/etc/network/if-pre-up.d \
		"$pkgdir"/etc/network/if-up.d
	install -m775 "$srcdir"/dad.if-up "$pkgdir"/etc/network/if-up.d/dad

	install -Dm644 "$srcdir"/acpid.logrotate \
		"$pkgdir/etc/logrotate.d/acpid"

	mkdir -p "$pkgdir"/var/lib/udhcpd
	install -Dm644 "$builddir"/examples/udhcp/udhcpd.conf \
		"$pkgdir"/etc/udhcpd.conf
	cat >"$pkgdir"/etc/securetty <<EOF
console
tty1
tty2
tty3
tty4
tty5
tty6
tty7
tty8
tty9
tty10
tty11
EOF
}

extras() {
	pkgdesc="Additional binaries of Busybox"
	depends="${pkgname}"
	install -Dm755 "$_dyndir_extras"/busybox "$subpkgdir"/bin/busybox-extras
}

suid() {
	pkgdesc="suid binaries of Busybox"
	depends="${pkgname}"

	cd "$_dyndir"
	mkdir -p "$subpkgdir"/bin
	install -m4111 bbsuid "$subpkgdir"/bin/bbsuid
}

static() {
	pkgdesc="Statically linked Busybox"
	mkdir -p "$subpkgdir"/bin
	install -m755 "$_staticdir"/busybox.static \
		"$subpkgdir"/bin/busybox.static
}

ssl_client() {
	pkgdesc="EXternal ssl_client for busybox wget"
	local _sslver=$(pkg-config --modversion libssl)
	# automatically pull in if both busybox and libssl is installed
	install_if="$pkgname=$pkgver-r$pkgrel libressl${_sslver%.*}-libssl"
	mkdir -p "$subpkgdir"/usr/bin
	install -m755 "$_dyndir"/ssl_client \
		"$subpkgdir"/usr/bin/ssl_client
}

sha512sums="bf90e24b4564071e0ac2785e2ee4ec4ea0e229a1ff330bb38befe7a27c5a529e7b0657354ce731473814325a27a0c181ab922e0a0a89d5023ba08a6d80472297  busybox-1.29.3.tar.bz2
d09a5cca79b33a7ae05b2c52ba11028ef104aa8a2378c31ef1fa50c45d8e32c397906d4349d48fcbdf65f328b4875efde811704540bdc4c6981895921ef0e445  0001-properly-fix-wget-https-support.patch
d8694293edc8cd55cecafeb902f03c01af318e13966f399365cf792b840793891ac086bb67ef83e7a5a2e01b246497a6c6511cb6a856834f6672dee4bca76896  0002-fsck-resolve-LABEL-.-UUID-.-spec-to-device.patch
8c34dd5ce9a6e84279fa6494cbae0b254778976f341af1d0ccc2a3afb405fb22d374e9623ea83d1500da77c7463db2ed5218d2c9f49350a21114bd0bb17fd87d  0003-ash-exec-busybox.static.patch
e4be12a1453a306a58c4ea59cd8a0bf1f261514ae090ea962ac6f7609dc1e9dab0d4d8d351d7adf4f76bf52d37db9ad0102116635e437945c131f762d5750d19  0004-app-location-for-cpio-vi-and-lspci.patch
f96d66ce5a0295a2459a2c49c281b64e016de675ebd31a49af18cb06f3498fe27dfbc8667324b4391fdf8136aea8533dce643f1c740d10de811808985950bd15  0005-udhcpc-set-default-discover-retries-to-5.patch
136e35be699b6953e1b624c65bcc41fd096cf98fb00de4409855d0eda8b8a1ee830eb6eb1f0d0dd7d47ee940321e056b3765fd77747bf6a90a07d9cf84a9626c  0006-ping-make-ping-work-without-root-privileges.patch
7873b98c676a92faea61511d50c1efac1220354d20afd53de19e2c8f1472559cb333b9dd4e0d6432616d8c5f59885f1503c448c86a912e8031c9bfed628c2db1  0007-fbsplash-support-console-switching.patch
2c56906dac70dea6276e4c573707cb06c4c8b53defcd33b1e5a28f928e7dafe905a52ce40571de430e4af7e00a75ecc0f249d2fec02da5f3d9edd4e904919a35  0008-fbsplash-support-image-and-bar-alignment-and-positio.patch
907aef47c88f60e93bcd290eb43102721978ab6fc6eca52914172801ace7306ae8b11f38ed8b086452bbf46d75424740161e4f1e7840a485f0f78024455f902b  0009-depmod-support-generating-kmod-binary-index-files.patch
3b13ba6bd9b697e48864cb5376849c1ac95b30650e3e27605cc05edf4fdc1ecbb4c4503d4fe9012a581bcd660f6bb44d644575cf437d30423614cb83ee92c22c  0010-Add-flag-for-not-following-symlinks-when-recursing.patch
60863a5eca8b88189ee93822fb3f9d45dd5ff43022e64b8ec5394c129c0cfe9999075c3e9f187dff76aea280726e02e5329dd48e9eb21954b118aa454a5da331  0011-sysklogd-add-Z-option-to-adjust-message-timezones.patch
025ad19f4e0cd299f11eba4a0c852c166fc91787756838f9c755405dad924fd1fe3c08067b938e14f9d8c609881d2ce5915152810e855eaa5ca510a76650069e  0012-udhcpc-Don-t-background-if-n-is-given.patch
d8926f0e4ed7d2fe5af89ff2a944d781b45b109c9edf1ef2591e7bce2a8bbadd7c8ca814cb3c928ae09027d9603434fe70496f308d701f3d42260ebd1e9e9b29  0013-testsuite-fix-cpio-tests.patch
8cb91903f2be3620b5500a4e8f4190537c93601282510b82303c3b516141b36ab872aeff5a7f5ae00f270439abab862ceabda531bdf180643da165b2f3b35d9f  0014-miscutils-microcom-Fixed-segfault.patch
a9b1403c844c51934637215307dd9e2adb9458921047acff0d86dcf229b6e0027f4b2c6cdaa25a58407aad9d098fb5685d58eb5ff8d2aa3de4912cdea21fe54c  acpid.logrotate
8fc1b81f39cb73430ebc9bca8706a71ae82b51efd2fee8ac15b4abe9b0899239075a46234cb7eae58f906c7499d1f75d11b29bcb9ca8dada8b34822df0948e73  busyboxconfig
1dc5c94708fc4d4129015c0cdd64fbe0edd2794bb10422ac2686db8a4ef06182d306ec89560d0310190c1ed86b8422c13594d2cc2b9281c8895145d5a233cc0c  busyboxconfig-extras
0becc2186d6c32fb0c401cf7bc0e46268b38ce8892db33be1daf40273024c1c02d518283f44086a313a2ccef34230a1d945ec148cc173f26e6aa9d88a7426e54  bbsuid.c
a1127c8a384294135e11500fde7ead33b73d24b11c21911b08447a4c4ef71d7a9965d6466f60f2da64e3b877213b0a3e924a5add3c5333ee3ecde8c2a91c5e02  dad.if-up
061f7417c1cbf0424a5fab77e2f5912aa1593f39b33ea294af4c03518ca712d793a77ea82ff1f36e9cb98751d9faacb9d0240cdf0894efd8f26c13c28a692404  nologin.c
646ad9aefe3596d0170d92c8506ca1846e43b5b83cbef97ae565f15ffa7b14665a8c7061bc69c608c043f834c134c5d63f042509f8999031e89163508a868e46  ssl_client.c"