Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 939404
Collapse All | Expand All

(-)a/sys-apps/busybox/busybox-1.36.1-r4.ebuild (+393 lines)
Line 0 Link Here
1
# Copyright 1999-2024 Gentoo Authors
2
# Distributed under the terms of the GNU General Public License v2
3
4
# See `man savedconfig.eclass` for info on how to use USE=savedconfig.
5
6
EAPI=8
7
8
inherit flag-o-matic readme.gentoo-r1 savedconfig toolchain-funcs
9
10
DESCRIPTION="Utilities for rescue and embedded systems"
11
HOMEPAGE="https://www.busybox.net/"
12
if [[ ${PV} == "9999" ]] ; then
13
	MY_P="${P}"
14
	EGIT_REPO_URI="https://git.busybox.net/busybox"
15
	inherit git-r3
16
else
17
	MY_P="${PN}-${PV/_/-}"
18
	SRC_URI="https://www.busybox.net/downloads/${MY_P}.tar.bz2"
19
	KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~loong ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86 ~amd64-linux ~x86-linux"
20
fi
21
S="${WORKDIR}/${MY_P}"
22
23
LICENSE="GPL-2" # GPL-2 only
24
SLOT="0"
25
IUSE="debug livecd make-symlinks math mdev pam selinux sep-usr static syslog systemd"
26
REQUIRED_USE="pam? ( !static )"
27
RESTRICT="test"
28
29
# TODO: Could make pkgconfig conditional on selinux? bug #782829
30
RDEPEND="
31
	!static? (
32
		virtual/libc
33
		virtual/libcrypt:=
34
		selinux? ( sys-libs/libselinux )
35
	)
36
	pam? ( sys-libs/pam )
37
"
38
DEPEND="${RDEPEND}
39
	static? (
40
		virtual/libcrypt[static-libs]
41
		selinux? ( sys-libs/libselinux[static-libs(+)] )
42
	)
43
	sys-kernel/linux-headers"
44
BDEPEND="virtual/pkgconfig"
45
46
DISABLE_AUTOFORMATTING=yes
47
DOC_CONTENTS='
48
If you want a smaller executable, add `-Oz` to your busybox `CFLAGS`.'
49
50
busybox_config_option() {
51
	local flag=$1 ; shift
52
	if [[ ${flag} != [yn] && ${flag} != \"* ]] ; then
53
		busybox_config_option $(usex ${flag} y n) "$@"
54
		return
55
	fi
56
	local expr
57
	while [[ $# -gt 0 ]] ; do
58
		case ${flag} in
59
		y) expr="s:.*\<CONFIG_$1\>.*set:CONFIG_$1=y:g" ;;
60
		n) expr="s:CONFIG_$1=y:# CONFIG_$1 is not set:g" ;;
61
		*) expr="s:.*\<CONFIG_$1\>.*:CONFIG_$1=${flag}:g" ;;
62
		esac
63
		sed -i -e "${expr}" .config || die
64
		einfo "$(grep "CONFIG_$1[= ]" .config || echo "Could not find CONFIG_$1 ...")"
65
		shift
66
	done
67
}
68
69
busybox_config_enabled() {
70
	local val=$(sed -n "/^CONFIG_$1=/s:^[^=]*=::p" .config)
71
	case ${val} in
72
	"") return 1 ;;
73
	y)  return 0 ;;
74
	*)  echo "${val}" | sed -r 's:^"(.*)"$:\1:' ;;
75
	esac
76
}
77
78
# patches go here!
79
PATCHES=(
80
	"${FILESDIR}"/${PN}-1.26.2-bb.patch
81
	"${FILESDIR}"/${PN}-1.34.1-skip-selinux-search.patch
82
83
	"${FILESDIR}"/${PN}-1.36.0-fortify-source-3-fixdep.patch
84
	"${FILESDIR}"/${PN}-1.36.1-kernel-6.8.patch
85
86
	"${FILESDIR}"/${PN}-1.36.1-skip-dynamic-relocations.patch
87
88
	# "${FILESDIR}"/${P}-*.patch
89
)
90
91
src_prepare() {
92
	default
93
94
	cp "${FILESDIR}"/ginit.c init/ || die
95
96
	# flag cleanup
97
	sed -i -r \
98
		-e 's:[[:space:]]?-(Werror|Os|Oz|falign-(functions|jumps|loops|labels)=1|fomit-frame-pointer)\>::g' \
99
		Makefile.flags || die
100
	sed -i \
101
		-e 's:-static-libgcc::' \
102
		Makefile.flags || die
103
104
	# Print all link lines too
105
	sed -i -e 's:debug=false:debug=true:' scripts/trylink || die
106
}
107
108
bbmake() {
109
	local args=(
110
		V=1
111
		CROSS_COMPILE="${CHOST}-"
112
		AR="${AR}"
113
		CC="${CC}"
114
		HOSTCC="${BUILD_CC}"
115
		HOSTCFLAGS="${BUILD_CFLAGS}"
116
		PKG_CONFIG="${PKG_CONFIG}"
117
	)
118
	emake "${args[@]}" "$@"
119
}
120
121
src_configure() {
122
	unset KBUILD_OUTPUT #88088
123
	export SKIP_STRIP=y
124
125
	tc-export AR CC BUILD_CC PKG_CONFIG
126
127
	tc-is-cross-compiler || BUILD_CFLAGS=${CFLAGS}
128
	BUILD_CFLAGS+=" -D_FILE_OFFSET_BITS=64" #930513
129
130
	append-flags -fno-strict-aliasing #310413
131
	use ppc64 && append-flags -mminimal-toc #130943
132
133
	# check for a busybox config before making one of our own.
134
	# if one exist lets return and use it.
135
136
	restore_config .config
137
	if [ -f .config ]; then
138
		yes "" | bbmake -j1 oldconfig
139
		return 0
140
	else
141
		ewarn "Could not locate user configfile, so we will save a default one"
142
	fi
143
144
	# setting SKIP_SELINUX skips searching for selinux at this stage. We don't
145
	# need to search now in case we end up not needing it after all.
146
	# setup the config file
147
	bbmake -j1 allyesconfig SKIP_SELINUX=$(usex selinux n y) #620918
148
	# nommu forces a bunch of things off which we want on #387555
149
	busybox_config_option n NOMMU
150
	sed -i '/^#/d' .config
151
	yes "" | bbmake -j1 oldconfig SKIP_SELINUX=$(usex selinux n y) #620918
152
153
	# now turn off stuff we really don't want
154
	busybox_config_option n DMALLOC
155
	busybox_config_option n FEATURE_2_4_MODULES #607548
156
	busybox_config_option n FEATURE_SUID_CONFIG
157
	busybox_config_option n BUILD_AT_ONCE
158
	busybox_config_option n BUILD_LIBBUSYBOX
159
	busybox_config_option n FEATURE_CLEAN_UP
160
	busybox_config_option n MONOTONIC_SYSCALL
161
	busybox_config_option n USE_PORTABLE_CODE
162
	busybox_config_option n WERROR
163
	# CONFIG_MODPROBE_SMALL=y disables depmod.c and uses a smaller one that
164
	# does not support -b. Setting this to no creates slightly larger and
165
	# slightly more useful modutils
166
	busybox_config_option n MODPROBE_SMALL #472464
167
	# triming the BSS size may be dangerous
168
	busybox_config_option n FEATURE_USE_BSS_TAIL
169
	# a conforming implementation of cp(1) will not create a new inode for
170
	# cases such as `cp ./file ./existing-file`
171
	busybox_config_option n FEATURE_NON_POSIX_CP
172
173
	# These cause trouble with musl.
174
	if use elibc_musl; then
175
		busybox_config_option n FEATURE_UTMP
176
		busybox_config_option n EXTRA_COMPAT
177
		busybox_config_option n FEATURE_VI_REGEX_SEARCH
178
	fi
179
180
	# Disable standalone shell mode when using make-symlinks, else Busybox calls its
181
	# applets by default without looking up in PATH.
182
	# This also enables users to disable a builtin by deleting the corresponding symlink.
183
	if use make-symlinks; then
184
		busybox_config_option n FEATURE_PREFER_APPLETS
185
		busybox_config_option n FEATURE_SH_STANDALONE
186
	fi
187
188
	# If these are not set and we are using a busybox setup
189
	# all calls to system() will fail.
190
	busybox_config_option y ASH
191
	busybox_config_option y SH_IS_ASH
192
	busybox_config_option n HUSH
193
	busybox_config_option n SH_IS_HUSH
194
195
	busybox_config_option '"/run"' PID_FILE_PATH
196
	busybox_config_option '"/run/ifstate"' IFUPDOWN_IFSTATE_PATH
197
198
	busybox_config_option pam PAM
199
	busybox_config_option static STATIC
200
	busybox_config_option syslog {K,SYS}LOGD LOGGER
201
	busybox_config_option systemd FEATURE_SYSTEMD
202
	busybox_config_option math FEATURE_AWK_LIBM
203
204
	# all the debug options are compiler related, so punt them
205
	busybox_config_option n DEBUG_SANITIZE
206
	busybox_config_option n DEBUG
207
	busybox_config_option y NO_DEBUG_LIB
208
	busybox_config_option n DMALLOC
209
	busybox_config_option n EFENCE
210
	busybox_config_option $(usex debug y n) TFTP_DEBUG
211
212
	busybox_config_option selinux SELINUX
213
214
	# this opt only controls mounting with <linux-2.6.23
215
	busybox_config_option n FEATURE_MOUNT_NFS
216
217
	# glibc-2.26 and later does not ship RPC implientation
218
	busybox_config_option n FEATURE_HAVE_RPC
219
	busybox_config_option n FEATURE_INETD_RPC
220
221
	# default a bunch of uncommon options to off
222
	local opt
223
	for opt in \
224
		ADD_SHELL \
225
		BEEP BOOTCHARTD \
226
		CRONTAB \
227
		DC DEVFSD DNSD DPKG{,_DEB} \
228
		FAKEIDENTD FBSPLASH FOLD FSCK_MINIX FTP{GET,PUT} \
229
		FEATURE_DEVFS \
230
		HOSTID HUSH \
231
		INETD INOTIFYD IPCALC \
232
		LOCALE_SUPPORT LOGNAME LPD \
233
		MAKEMIME MKFS_MINIX MSH \
234
		OD \
235
		RDEV READPROFILE REFORMIME REMOVE_SHELL RFKILL RUN_PARTS RUNSV{,DIR} \
236
		SLATTACH SMEMCAP SULOGIN SV{,LOGD} \
237
		TASKSET TCPSVD \
238
		RPM RPM2CPIO \
239
		UDPSVD UUDECODE UUENCODE
240
	do
241
		busybox_config_option n ${opt}
242
	done
243
244
	bbmake -j1 oldconfig
245
}
246
247
src_compile() {
248
	bbmake busybox
249
250
	# bug #701512
251
	bbmake doc
252
}
253
254
src_install() {
255
	unset KBUILD_OUTPUT #88088
256
	save_config .config
257
258
	into /
259
	dodir /bin
260
	if use sep-usr ; then
261
		# install /ginit to take care of mounting stuff
262
		exeinto /
263
		newexe busybox_unstripped ginit
264
		dosym /ginit /bin/bb
265
		dosym bb /bin/busybox
266
	else
267
		newbin busybox_unstripped busybox
268
		dosym busybox /bin/bb
269
	fi
270
	if use mdev ; then
271
		dodir /$(get_libdir)/mdev/
272
		use make-symlinks || dosym /bin/bb /sbin/mdev
273
		cp "${S}"/examples/mdev_fat.conf "${ED}"/etc/mdev.conf || die
274
		if [[ ! "$(get_libdir)" == "lib" ]]; then
275
			#831251 - replace lib with lib64 where appropriate
276
			sed -i -e "s:/lib/:/$(get_libdir)/:g" "${ED}"/etc/mdev.conf || die
277
		fi
278
279
		exeinto /$(get_libdir)/mdev/
280
		doexe "${FILESDIR}"/mdev/*
281
282
		newinitd "${FILESDIR}"/mdev.initd mdev
283
	fi
284
	if use livecd ; then
285
		dosym busybox /bin/vi
286
	fi
287
288
	# add busybox daemon's, bug #444718
289
	if busybox_config_enabled FEATURE_NTPD_SERVER; then
290
		newconfd "${FILESDIR}"/ntpd.confd busybox-ntpd
291
		newinitd "${FILESDIR}"/ntpd.initd busybox-ntpd
292
	fi
293
	if busybox_config_enabled SYSLOGD; then
294
		newconfd "${FILESDIR}"/syslogd.confd busybox-syslogd
295
		newinitd "${FILESDIR}"/syslogd.initd busybox-syslogd
296
	fi
297
	if busybox_config_enabled KLOGD; then
298
		newconfd "${FILESDIR}"/klogd.confd busybox-klogd
299
		newinitd "${FILESDIR}"/klogd.initd busybox-klogd
300
	fi
301
	if busybox_config_enabled WATCHDOG; then
302
		newconfd "${FILESDIR}"/watchdog.confd busybox-watchdog
303
		newinitd "${FILESDIR}"/watchdog.initd busybox-watchdog
304
	fi
305
	if busybox_config_enabled UDHCPC; then
306
		sed -i 's:$((metric++)):$metric; metric=$((metric + 1)):' examples/udhcp/simple.script || die #801535
307
		local path=$(busybox_config_enabled UDHCPC_DEFAULT_SCRIPT)
308
		exeinto "${path%/*}"
309
		newexe examples/udhcp/simple.script "${path##*/}"
310
	fi
311
	if busybox_config_enabled UDHCPD; then
312
		insinto /etc
313
		doins examples/udhcp/udhcpd.conf
314
	fi
315
	if busybox_config_enabled ASH && ! use make-symlinks; then
316
		dosym -r /bin/busybox /bin/ash
317
	fi
318
	if busybox_config_enabled CROND; then
319
		newconfd "${FILESDIR}"/crond.confd busybox-crond
320
		newinitd "${FILESDIR}"/crond.initd busybox-crond
321
	fi
322
323
	# bundle up the symlink files for use later
324
	bbmake DESTDIR="${ED}" install
325
	# for compatibility, provide /usr/bin/env
326
	mkdir -p _install/usr/bin || die
327
	if [[ ! -e _install/usr/bin/env ]]; then
328
		ln -s /bin/env _install/usr/bin/env || die
329
	fi
330
	rm _install/bin/busybox || die
331
	tar cf busybox-links.tar -C _install . || : #;die
332
	insinto /usr/share/${PN}
333
	use make-symlinks && doins busybox-links.tar
334
335
	dodoc AUTHORS README TODO
336
337
	cd docs || die
338
	doman busybox.1
339
	docinto txt
340
	dodoc *.txt
341
	docinto pod
342
	dodoc *.pod
343
	docinto html
344
	dodoc *.html
345
346
	cd ../examples || die
347
	docinto examples
348
	dodoc inittab depmod.pl *.conf *.script undeb unrpm
349
350
	cd ../networking || die
351
	dodoc httpd_indexcgi.c httpd_post_upload.cgi
352
353
	readme.gentoo_create_doc
354
}
355
356
pkg_preinst() {
357
	if use make-symlinks ; then
358
		mv "${ED}"/usr/share/${PN}/busybox-links.tar "${T}"/ || die
359
	fi
360
}
361
362
pkg_postinst() {
363
	savedconfig_pkg_postinst
364
365
	if use make-symlinks ; then
366
		cd "${T}" || die
367
		mkdir _install
368
		tar xf busybox-links.tar -C _install || die
369
		# 907432: cp -n returns error if it skips any file, but that is expected here
370
		# TODO: check if a new coreutils release has a replacement option
371
		cp -nvpPR _install/* "${ROOT}"/
372
	fi
373
374
	if use sep-usr ; then
375
		elog "In order to use the sep-usr support, you have to update your"
376
		elog "kernel command line.  Add the option:"
377
		elog "     init=/ginit"
378
		elog "To launch a different init than /sbin/init, use:"
379
		elog "     init=/ginit /sbin/yourinit"
380
		elog "To get a rescue shell, you may boot with:"
381
		elog "     init=/ginit bb"
382
	fi
383
384
	if [[ ${MERGE_TYPE} != binary ]] && ! is-flagq -Oz; then
385
		for v in ${REPLACING_VERSIONS}; do
386
			if ver_test ${v} -le 1.36.1; then
387
				FORCE_PRINT_ELOG=yes
388
			fi
389
		done
390
391
		readme.gentoo_print_elog
392
	fi
393
}
(-)a/sys-apps/busybox/busybox-9999.ebuild (-1 / +3 lines)
Lines 164-169 src_configure() { Link Here
164
	busybox_config_option n MODPROBE_SMALL #472464
164
	busybox_config_option n MODPROBE_SMALL #472464
165
	# triming the BSS size may be dangerous
165
	# triming the BSS size may be dangerous
166
	busybox_config_option n FEATURE_USE_BSS_TAIL
166
	busybox_config_option n FEATURE_USE_BSS_TAIL
167
	# a conforming implementation of cp(1) will not create a new inode for
168
	# cases such as `cp ./file ./existing-file`
169
	busybox_config_option n FEATURE_NON_POSIX_CP
167
170
168
	# These cause trouble with musl.
171
	# These cause trouble with musl.
169
	if use elibc_musl; then
172
	if use elibc_musl; then
170
- 

Return to bug 939404