Skip to content

Commit

Permalink
main/busybox: add subpackage busybox-extras
Browse files Browse the repository at this point in the history
The following programs have been moved from busybox to the new
subpackage busybox-extras: ftpget, ftpput, telnet, tftp, ftpd, httpd
New programs in busybox-extras: tftpd, telnetd

When busybox-extras gets installed, busybox gets properly
uninstalled. Reversing this operation is also possible, as described
in busybox-extras.post-install.
  • Loading branch information
Oliver Smith committed May 5, 2017
1 parent 90f4bdf commit 4dfcdd0
Show file tree
Hide file tree
Showing 7 changed files with 1,223 additions and 57 deletions.
76 changes: 52 additions & 24 deletions main/busybox/APKBUILD
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
# Contributor: Łukasz Jendrysik <scadu@yandex.com>
# Contributor: Oliver Smith <ollieparanoid@bitmessage.ch>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=busybox
pkgver=1.26.2
pkgrel=2
pkgrel=3
pkgdesc="Size optimized toolbox of many common UNIX utilities"
url=http://busybox.net
arch="all"
license="GPL2"
makedepends_build=""
makedepends_host="linux-headers"
makedepends="$makedepends_build $makedepends_host"
install="$pkgname.post-install $pkgname.post-upgrade"
subpackages="$pkgname-static $pkgname-suid"
install="$pkgname.post-install $pkgname-extras.post-install $pkgname.post-upgrade"
subpackages="$pkgname-extras $pkgname-static $pkgname-suid"
options="suid"
triggers="busybox.trigger=/bin:/usr/bin:/sbin:/usr/sbin:/lib/modules/*"
_triggerpaths="/bin:/usr/bin:/sbin:/usr/sbin:/lib/modules/*"
triggers="busybox.trigger=$_triggerpaths busybox-extras.trigger=$_triggerpaths"
source="http://busybox.net/downloads/$pkgname-$pkgver.tar.bz2
0001-ash-exec-busybox.static.patch
0002-app-location-for-vi-and-lspci.patch
Expand All @@ -34,6 +36,7 @@ source="http://busybox.net/downloads/$pkgname-$pkgver.tar.bz2
acpid.logrotate
busyboxconfig
busyboxconfig-extras
bbsuid.c
dad.if-up
nologin.c
Expand All @@ -42,10 +45,12 @@ source="http://busybox.net/downloads/$pkgname-$pkgver.tar.bz2
_sdir="$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() {
mkdir -p "$_staticdir" "$_dyndir"
mkdir -p "$_staticdir" "$_dyndir" "$_dyndir_extras"
#patches
cd "$_sdir"
for i in $source; do
Expand Down Expand Up @@ -74,6 +79,16 @@ build() {
make -C "$_sdir" O="$PWD" silentoldconfig || return 1
make || return 1

# 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 "$_sdir" O="$PWD" silentoldconfig || return 1
make || return 1

# build static
cd "$_staticdir"
msg "Building static busybox"
Expand All @@ -89,34 +104,36 @@ build() {
mv busybox busybox.static
}

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
# $1: $_dyndir or $_dyndir_extras
# $2: $pkgdir or $subpkgdir
_package_dynamic() {
cd "$1"
mkdir -p "$2"/usr/sbin "$2"/usr/bin "$2"/tmp \
"$2"/var/cache/misc "$2"/bin "$2"/sbin
chmod 1777 "$2"/tmp
install -m755 busybox "$2"/bin/busybox || return 1
# we need /bin/sh to be able to execute post-install
ln -s /bin/busybox "$pkgdir"/bin/sh
ln -s /bin/busybox "$2"/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 \
"$2"/etc/network/if-down.d \
"$2"/etc/network/if-post-down.d \
"$2"/etc/network/if-post-up.d \
"$2"/etc/network/if-pre-down.d \
"$2"/etc/network/if-pre-up.d \
"$2"/etc/network/if-up.d \
|| return 1
install -m775 "$srcdir"/dad.if-up "$pkgdir"/etc/network/if-up.d/dad \
install -m775 "$srcdir"/dad.if-up "$2"/etc/network/if-up.d/dad \
|| return 1

install -Dm644 "$srcdir"/acpid.logrotate \
"$pkgdir/etc/logrotate.d/acpid" || return 1
"$2/etc/logrotate.d/acpid" || return 1

mkdir -p "$pkgdir"/var/lib/udhcpd || return 1
mkdir -p "$2"/var/lib/udhcpd || return 1
install -Dm644 "$_sdir"/examples/udhcp/udhcpd.conf \
"$pkgdir"/etc/udhcpd.conf || return 1
cat >"$pkgdir"/etc/securetty <<EOF
"$2"/etc/udhcpd.conf || return 1
cat >"$2"/etc/securetty <<EOF
console
tty1
tty2
Expand All @@ -132,6 +149,16 @@ tty11
EOF
}

package() {
_package_dynamic "$_dyndir" "$pkgdir"
}

extras() {
pkgdesc="More programs enabled in Busybox"
provides="busybox=$pkgver"
_package_dynamic "$_dyndir_extras" "$subpkgdir"
}

suid() {
pkgdesc="suid binaries of Busybox"
depends="${pkgname}"
Expand Down Expand Up @@ -165,7 +192,8 @@ bf3e7c400e718fbc19fda19d7304ed938e5c59f45d5d1ba6eafd8f62a984d40419dbefd9f6840ac7
cb7aa4d5d22596bc8c6510cb653599dd8cf4c3a5312e93adfc6411d811376db2ad3b506a111322f46aa9929a5337e22a169da4ea250fd4b39e703adbc8792a2d 0014-ash-implement-exec-a-ARGV0-CMD-ARGV1.patch
f26e090f5de0096ba5c4d46989ebe0ab5fa64c8bf54cd37ddec302fddfde23eac914858d86cc52bf3b5780a8e81ea2612ef6e713df2828e52c606f86a6816f39 location-for-cpio.patch
a9b1403c844c51934637215307dd9e2adb9458921047acff0d86dcf229b6e0027f4b2c6cdaa25a58407aad9d098fb5685d58eb5ff8d2aa3de4912cdea21fe54c acpid.logrotate
d4b9f4a09dcf08ec9f7a66c5250465e3a6dd9beb15140a462a1464110824426c732399e4dab4e6a33073626d4db0e76085b218cd0521027e57ce9f918ff1af29 busyboxconfig
e54495f0c7473d77752a0d3856a7d3213bdcd81c716195bf6812556a24a152c22ed1858abb2384ad0b22eba73304894e6e26695f23df0ef13f81eedefa95b91e busyboxconfig
db820fbd0438453604e8f73d62c782ffa75ccfff151ee084ffaeee13b98b7370958c7bd03376836903751a6662dc8531f96addd539423858c2475299eca2f037 busyboxconfig-extras
c1dd56509277c59751907a27f067f1622191ddfd498acfe390d83136d36a41f2bdfc2fd4daf35af77219a66fb00fea20483f34112afd5df2ccd9f36ab548e66f bbsuid.c
a1127c8a384294135e11500fde7ead33b73d24b11c21911b08447a4c4ef71d7a9965d6466f60f2da64e3b877213b0a3e924a5add3c5333ee3ecde8c2a91c5e02 dad.if-up
4e7c291a70e879b74c0fc07c54a73ef50537d8be68fee6b2d409425c07afd2d67f9b6afcd8c33a7971014913cc5de85e45079681c9e77200c6cc2f34acfba6d2 nologin.c"
10 changes: 10 additions & 0 deletions main/busybox/busybox-extras.post-install
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/sh

# Uninstall note
echo "-> NOTE: To uninstall busybox-extras properly, do this:"
echo " # apk del busybox-extras"
echo " # apk add /var/cache/apk/busybox-1.26.2-r3...apk # pick latest"
echo " # apk add busybox"

# We need the symlinks early
exec /bin/busybox --install -s
1 change: 1 addition & 0 deletions main/busybox/busybox-extras.trigger
16 changes: 16 additions & 0 deletions main/busybox/busybox.post-install
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@
#!/bin/sh

# Remove links from busybox-extras (see also: busybox.post-upgrade)
for link in \
/usr/bin/ftpget \
/usr/bin/ftpput \
/usr/bin/telnet \
/usr/bin/tftp \
/usr/sbin/ftpd \
/usr/sbin/httpd \
/usr/sbin/telnetd \
/usr/sbin/tftpd \
; do
if [ -L "$link" ] && [ "$(readlink $link)" = "/bin/busybox" ]; then
rm "$link"
fi
done

# We need the symlinks early
exec /bin/busybox --install -s
17 changes: 16 additions & 1 deletion main/busybox/busybox.post-upgrade
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
#!/bin/sh

# remove links that has been relocated
# Remove links, that have been relocated (see also: busybox.post-install)
for link in \
/usr/bin/ftpget \
/usr/bin/ftpput \
/usr/bin/telnet \
/usr/bin/tftp \
/usr/sbin/ftpd \
/usr/sbin/httpd \
/usr/sbin/telnetd \
/usr/sbin/tftpd \
; do
if [ -L "$link" ] && [ "$(readlink $link)" = "/bin/busybox" ]; then
rm "$link"
echo "-> $(basename $link) is now in busybox-extras"
fi
done
for link in /bin/install /bin/ip /bin/vi /usr/bin/lspci; do
if [ -L "$link" ] && [ "$(readlink $link)" = "/bin/busybox" ]; then
rm "$link"
Expand Down
60 changes: 28 additions & 32 deletions main/busybox/busyboxconfig
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#
# Automatically generated make config: don't edit
# Busybox version: 1.26.1
# Tue Jan 3 09:59:23 2017
# Busybox version: 1.26.2
# Fri May 5 19:56:04 2017
#
CONFIG_HAVE_DOT_CONFIG=y

Expand Down Expand Up @@ -800,27 +800,27 @@ CONFIG_FEATURE_BRCTL_FANCY=y
CONFIG_FEATURE_BRCTL_SHOW=y
CONFIG_DNSD=y
CONFIG_ETHER_WAKE=y
CONFIG_FTPD=y
CONFIG_FEATURE_FTPD_WRITE=y
CONFIG_FEATURE_FTPD_ACCEPT_BROKEN_LIST=y
CONFIG_FEATURE_FTPD_AUTHENTICATION=y
CONFIG_FTPGET=y
CONFIG_FTPPUT=y
# CONFIG_FTPD is not set
# CONFIG_FEATURE_FTPD_WRITE is not set
# CONFIG_FEATURE_FTPD_ACCEPT_BROKEN_LIST is not set
# CONFIG_FEATURE_FTPD_AUTHENTICATION is not set
# CONFIG_FTPGET is not set
# CONFIG_FTPPUT is not set
# CONFIG_FEATURE_FTPGETPUT_LONG_OPTIONS is not set
CONFIG_HOSTNAME=y
CONFIG_DNSDOMAINNAME=y
CONFIG_HTTPD=y
CONFIG_FEATURE_HTTPD_RANGES=y
CONFIG_FEATURE_HTTPD_SETUID=y
CONFIG_FEATURE_HTTPD_BASIC_AUTH=y
CONFIG_FEATURE_HTTPD_AUTH_MD5=y
CONFIG_FEATURE_HTTPD_CGI=y
CONFIG_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR=y
CONFIG_FEATURE_HTTPD_SET_REMOTE_PORT_TO_ENV=y
CONFIG_FEATURE_HTTPD_ENCODE_URL_STR=y
CONFIG_FEATURE_HTTPD_ERROR_PAGES=y
CONFIG_FEATURE_HTTPD_PROXY=y
CONFIG_FEATURE_HTTPD_GZIP=y
# CONFIG_HTTPD is not set
# CONFIG_FEATURE_HTTPD_RANGES is not set
# CONFIG_FEATURE_HTTPD_SETUID is not set
# CONFIG_FEATURE_HTTPD_BASIC_AUTH is not set
# CONFIG_FEATURE_HTTPD_AUTH_MD5 is not set
# CONFIG_FEATURE_HTTPD_CGI is not set
# CONFIG_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR is not set
# CONFIG_FEATURE_HTTPD_SET_REMOTE_PORT_TO_ENV is not set
# CONFIG_FEATURE_HTTPD_ENCODE_URL_STR is not set
# CONFIG_FEATURE_HTTPD_ERROR_PAGES is not set
# CONFIG_FEATURE_HTTPD_PROXY is not set
# CONFIG_FEATURE_HTTPD_GZIP is not set
CONFIG_IFCONFIG=y
CONFIG_FEATURE_IFCONFIG_STATUS=y
CONFIG_FEATURE_IFCONFIG_SLIP=y
Expand Down Expand Up @@ -885,22 +885,18 @@ CONFIG_ROUTE=y
CONFIG_SLATTACH=y
# CONFIG_TCPSVD is not set
# CONFIG_UDPSVD is not set
CONFIG_TELNET=y
CONFIG_FEATURE_TELNET_TTYPE=y
CONFIG_FEATURE_TELNET_AUTOLOGIN=y
# CONFIG_TELNET is not set
# CONFIG_FEATURE_TELNET_TTYPE is not set
# CONFIG_FEATURE_TELNET_AUTOLOGIN is not set
# CONFIG_TELNETD is not set
# CONFIG_FEATURE_TELNETD_STANDALONE is not set
# CONFIG_FEATURE_TELNETD_INETD_WAIT is not set
CONFIG_TFTP=y
# CONFIG_TFTP is not set
# CONFIG_TFTPD is not set

#
# Common options for tftp/tftpd
#
CONFIG_FEATURE_TFTP_GET=y
CONFIG_FEATURE_TFTP_PUT=y
CONFIG_FEATURE_TFTP_BLOCKSIZE=y
CONFIG_FEATURE_TFTP_PROGRESS_BAR=y
# CONFIG_FEATURE_TFTP_GET is not set
# CONFIG_FEATURE_TFTP_PUT is not set
# CONFIG_FEATURE_TFTP_BLOCKSIZE is not set
# CONFIG_FEATURE_TFTP_PROGRESS_BAR is not set
# CONFIG_TFTP_DEBUG is not set
CONFIG_TRACEROUTE=y
CONFIG_TRACEROUTE6=y
Expand Down
Loading

0 comments on commit 4dfcdd0

Please sign in to comment.