aboutsummaryrefslogtreecommitdiff
path: root/srcpkgs/busybox/template
blob: e9932b73ad329ac7641421e6d84aee9f4dcd83dc (plain) (blame)
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
# Template file for 'busybox'
pkgname=busybox
version=1.34.1
revision=6
hostmakedepends="perl"
checkdepends="tar which zip"
short_desc="Swiss Army Knife of Embedded Linux"
maintainer="Cameron Nemo <cam@nohom.org>"
license="GPL-2.0-only"
homepage="https://www.busybox.net"
distfiles="${homepage}/downloads/busybox-${version}.tar.bz2"
checksum=415fbd89e5344c96acf449d94a6f956dbed62e18e835fc83e064db33a34bd549

if [ "$XBPS_TARGET_LIBC" = "glibc" ]; then
	makedepends+=" libxcrypt-devel"
fi

_alternatives_core="
 ash:ash:/usr/bin/busybox
 awk:awk:/usr/bin/busybox
 hostname:hostname:/usr/bin/busybox
 sh:sh:/usr/bin/busybox
 vi:vi:/usr/bin/busybox
 logger:logger:/usr/bin/busybox"

_alternatives="
 ${_alternatives_core}
 ntpd:ntpd:/usr/bin/busybox
 ntpd:ntpd:/etc/sv/busybox-ntpd"

alternatives="${_alternatives}"
register_shell="/usr/bin/ash"

_patch_config() {
	local t="$1"
	shift
	while [ "$1" ]; do
		local p="$1"
		shift
		echo "Applying $p..."
		patch "${t}/.config" <"${FILESDIR}/dotconfig.d/${p}.patch"
	done
}

do_configure() {
	mkdir -p src
	mv * src || true

	local t
	for t in busybox busybox-static busybox-core busybox-huge; do
		mkdir -p $t
		cp -f ${FILESDIR}/dotconfig ${t}/.config

		case "$XBPS_TARGET_MACHINE" in
		*-musl) vsed -i -e /CONFIG_FEATURE_VI_REGEX_SEARCH/s/y/n/ \
				${t}/.config;;
		esac

		if [ "$CROSS_BUILD" ]; then
			vsed -i -e \
				"s,\(CONFIG_CROSS_COMPILER_PREFIX\).*,\1=\"${XBPS_CROSS_TRIPLET}-\",g" \
				${t}/.config
		fi
	done

	_patch_config busybox udhcpc ntpd
	_patch_config busybox-static udhcpc ntpd static
	_patch_config busybox-huge udhcpc ntpd httpd mdev sysklogd huge

	for t in busybox-core busybox busybox-static busybox-huge; do
		make -C "${t}" KBUILD_SRC="${wrksrc}/src" -f "${wrksrc}/src/Makefile" oldconfig
		make -C "${t}" KBUILD_SRC="${wrksrc}/src" -f "${wrksrc}/src/Makefile" prepare "${makejobs}"
	done

	if [ "$SOURCE_DATE_EPOCH" ]; then
		# rewrite date with the one from the date wrapper.
		d=$(date +"%F %T %Z")
		sed -i "s/\(#define AUTOCONF_TIMESTAMP\).*/\1 \"$d\"/" */include/autoconf.h
	fi
}

do_build() {
	for t in busybox-core busybox busybox-static busybox-huge; do
		make -C "${t}" SKIP_STRIP=y "${makejobs}"
	done
}

do_check() {
	for t in busybox-core busybox busybox-static busybox-huge; do
		make -C "${t}" "${makejobs}" \
			SKIP_KNOWN_BUGS=yes SKIP_INTERNET_TESTS=yes \
			check
	done
}

do_install() {
	vbin busybox/busybox_unstripped busybox
	vman busybox/docs/busybox.1
	vsv busybox-ntpd
}

busybox-core_package() {
	short_desc+=" (essential applets)"
	conflicts="busybox>=0 busybox-huge>=0"
	alternatives="${_alternatives_core}"
	register_shell="/usr/bin/ash"
	pkg_install() {
		vbin busybox-core/busybox_unstripped busybox
		vman busybox-core/docs/busybox.1
	}
}

busybox-static_package() {
	short_desc+=" (statically linked)"
	pkg_install() {
		vbin busybox-static/busybox busybox.static
	}
}

busybox-huge_package() {
	short_desc+=" (extra applets)"
	conflicts="busybox>=0 busybox-core>=0"
	alternatives="${_alternatives}"
	register_shell="/usr/bin/ash"
	pkg_install() {
		vbin busybox-huge/busybox_unstripped busybox
		vman busybox-huge/docs/busybox.1
		vsv busybox-ntpd
		vsv busybox-syslogd
		vsv busybox-klogd
	}
}