Gentoo Archives: gentoo-commits

From: "Anthony G. Basile" <blueness@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/hardened-dev:musl commit in: sys-apps/busybox/, sys-apps/busybox/files/
Date: Sat, 01 Mar 2014 18:27:58
Message-Id: 1393698576.bcdf44deee76438355382b6c54f53ea343f4e0a7.blueness@gentoo
1 commit: bcdf44deee76438355382b6c54f53ea343f4e0a7
2 Author: Anthony G. Basile <blueness <AT> gentoo <DOT> org>
3 AuthorDate: Sat Mar 1 18:27:20 2014 +0000
4 Commit: Anthony G. Basile <blueness <AT> gentoo <DOT> org>
5 CommitDate: Sat Mar 1 18:29:36 2014 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/hardened-dev.git;a=commit;h=bcdf44de
7
8 sys-apps/busybox: bump 1.22.1 for mips
9
10 ---
11 sys-apps/busybox/busybox-1.22.1-r99.ebuild | 304 +++++++++++++++++++++
12 sys-apps/busybox/files/busybox-1.22.1-ash.patch | 11 +
13 sys-apps/busybox/files/busybox-1.22.1-date.patch | 30 ++
14 sys-apps/busybox/files/busybox-1.22.1-iplink.patch | 19 ++
15 4 files changed, 364 insertions(+)
16
17 diff --git a/sys-apps/busybox/busybox-1.22.1-r99.ebuild b/sys-apps/busybox/busybox-1.22.1-r99.ebuild
18 new file mode 100644
19 index 0000000..da3efe1
20 --- /dev/null
21 +++ b/sys-apps/busybox/busybox-1.22.1-r99.ebuild
22 @@ -0,0 +1,304 @@
23 +# Copyright 1999-2014 Gentoo Foundation
24 +# Distributed under the terms of the GNU General Public License v2
25 +# $Header: /var/cvsroot/gentoo-x86/sys-apps/busybox/busybox-1.22.1.ebuild,v 1.2 2014/02/02 08:17:37 vapier Exp $
26 +
27 +# See `man savedconfig.eclass` for info on how to use USE=savedconfig.
28 +
29 +EAPI="4"
30 +inherit eutils flag-o-matic savedconfig toolchain-funcs multilib
31 +
32 +DESCRIPTION="Utilities for rescue and embedded systems"
33 +HOMEPAGE="http://www.busybox.net/"
34 +if [[ ${PV} == "9999" ]] ; then
35 + MY_P=${PN}
36 + EGIT_REPO_URI="git://busybox.net/busybox.git"
37 + inherit git-2
38 +else
39 + MY_P=${PN}-${PV/_/-}
40 + SRC_URI="http://www.busybox.net/downloads/${MY_P}.tar.bz2"
41 + KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~amd64-linux ~arm-linux ~x86-linux"
42 +fi
43 +
44 +LICENSE="GPL-2"
45 +SLOT="0"
46 +
47 +IUSE="ipv6 livecd make-symlinks math mdev -pam selinux sep-usr +static syslog systemd"
48 +RESTRICT="test"
49 +
50 +RDEPEND="!static? ( selinux? ( sys-libs/libselinux ) )
51 + pam? ( sys-libs/pam )"
52 +DEPEND="${RDEPEND}
53 + static? ( selinux? ( sys-libs/libselinux[static-libs(+)] ) )
54 + >=sys-kernel/linux-headers-2.6.39"
55 +
56 +S=${WORKDIR}/${MY_P}
57 +
58 +busybox_config_option() {
59 + local flag=$1 ; shift
60 + if [[ ${flag} != [yn] ]] ; then
61 + busybox_config_option $(usex ${flag} y n) "$@"
62 + return
63 + fi
64 + while [[ $# -gt 0 ]] ; do
65 + if [[ ${flag} == "y" ]] ; then
66 + sed -i -e "s:.*\<CONFIG_$1\>.*set:CONFIG_$1=y:g" .config
67 + else
68 + sed -i -e "s:CONFIG_$1=y:# CONFIG_$1 is not set:g" .config
69 + fi
70 + einfo $(grep "CONFIG_$1[= ]" .config || echo Could not find CONFIG_$1 ...)
71 + shift
72 + done
73 +}
74 +
75 +busybox_config_enabled() {
76 + local val=$(sed -n "/^CONFIG_$1=/s:^[^=]*=::p" .config)
77 + case ${val} in
78 + "") return 1 ;;
79 + y) return 0 ;;
80 + *) echo "${val}" | sed -r 's:^"(.*)"$:\1:' ;;
81 + esac
82 +}
83 +
84 +src_prepare() {
85 + unset KBUILD_OUTPUT #88088
86 + append-flags -fno-strict-aliasing #310413
87 + use ppc64 && append-flags -mminimal-toc #130943
88 +
89 + # patches go here!
90 + epatch "${FILESDIR}"/${PN}-1.19.0-bb.patch
91 + epatch "${FILESDIR}"/${P}-*.patch
92 + cp "${FILESDIR}"/ginit.c init/ || die
93 +
94 + # flag cleanup
95 + sed -i -r \
96 + -e 's:[[:space:]]?-(Werror|Os|falign-(functions|jumps|loops|labels)=1|fomit-frame-pointer)\>::g' \
97 + Makefile.flags || die
98 + #sed -i '/bbsh/s:^//::' include/applets.h
99 + sed -i '/^#error Aborting compilation./d' applets/applets.c || die
100 + use elibc_glibc && sed -i 's:-Wl,--gc-sections::' Makefile
101 + sed -i \
102 + -e "/^CROSS_COMPILE/s:=.*:= ${CHOST}-:" \
103 + -e "/^AR\>/s:=.*:= $(tc-getAR):" \
104 + -e "/^CC\>/s:=.*:= $(tc-getCC):" \
105 + -e "/^HOSTCC/s:=.*:= $(tc-getBUILD_CC):" \
106 + -e "/^PKG_CONFIG\>/s:=.*:= $(tc-getPKG_CONFIG):" \
107 + Makefile || die
108 + sed -i \
109 + -e 's:-static-libgcc::' \
110 + Makefile.flags || die
111 +}
112 +
113 +src_configure() {
114 + # check for a busybox config before making one of our own.
115 + # if one exist lets return and use it.
116 +
117 + restore_config .config
118 + if [ -f .config ]; then
119 + yes "" | emake -j1 oldconfig > /dev/null
120 + return 0
121 + else
122 + ewarn "Could not locate user configfile, so we will save a default one"
123 + fi
124 +
125 + # setup the config file
126 + emake -j1 allyesconfig > /dev/null
127 + # nommu forces a bunch of things off which we want on #387555
128 + busybox_config_option n NOMMU
129 + sed -i '/^#/d' .config
130 + yes "" | emake -j1 oldconfig >/dev/null
131 +
132 + # now turn off stuff we really don't want
133 + busybox_config_option n DMALLOC
134 + busybox_config_option n FEATURE_SUID_CONFIG
135 + busybox_config_option n BUILD_AT_ONCE
136 + busybox_config_option n BUILD_LIBBUSYBOX
137 + busybox_config_option n FEATURE_CLEAN_UP
138 + busybox_config_option n MONOTONIC_SYSCALL
139 + busybox_config_option n USE_PORTABLE_CODE
140 + busybox_config_option n WERROR
141 +
142 + # turn off some options causing trouble with musl
143 + busybox_config_option n EXTRA_COMPAT
144 + busybox_config_option n FEATURE_VI_REGEX_SEARCH
145 + busybox_config_option n IFPLUGD
146 +
147 + # If these are not set and we are using a uclibc/busybox setup
148 + # all calls to system() will fail.
149 + busybox_config_option y ASH
150 + busybox_config_option n HUSH
151 +
152 + # disable ipv6 applets
153 + if ! use ipv6; then
154 + busybox_config_option n FEATURE_IPV6
155 + busybox_config_option n TRACEROUTE6
156 + busybox_config_option n PING6
157 + fi
158 +
159 + if use static && use pam ; then
160 + ewarn "You cannot have USE='static pam'. Assuming static is more important."
161 + fi
162 + busybox_config_option $(usex static n pam) PAM
163 + busybox_config_option static STATIC
164 + busybox_config_option syslog {K,SYS}LOGD LOGGER
165 + busybox_config_option systemd FEATURE_SYSTEMD
166 + busybox_config_option math FEATURE_AWK_LIBM
167 +
168 + # all the debug options are compiler related, so punt them
169 + busybox_config_option n DEBUG
170 + busybox_config_option y NO_DEBUG_LIB
171 + busybox_config_option n DMALLOC
172 + busybox_config_option n EFENCE
173 +
174 + busybox_config_option selinux SELINUX
175 +
176 + # this opt only controls mounting with <linux-2.6.23
177 + busybox_config_option n FEATURE_MOUNT_NFS
178 +
179 + # default a bunch of uncommon options to off
180 + local opt
181 + for opt in \
182 + ADD_SHELL \
183 + BEEP BOOTCHARTD \
184 + CRONTAB \
185 + DC DEVFSD DNSD DPKG{,_DEB} \
186 + FAKEIDENTD FBSPLASH FOLD FSCK_MINIX FTP{GET,PUT} \
187 + FEATURE_DEVFS \
188 + HOSTID HUSH \
189 + INETD INOTIFYD IPCALC \
190 + LOCALE_SUPPORT LOGNAME LPD \
191 + MAKEMIME MKFS_MINIX MSH \
192 + OD \
193 + RDEV READPROFILE REFORMIME REMOVE_SHELL RFKILL RUN_PARTS RUNSV{,DIR} \
194 + SLATTACH SMEMCAP SULOGIN SV{,LOGD} \
195 + TASKSET TCPSVD \
196 + RPM RPM2CPIO \
197 + UDPSVD UUDECODE UUENCODE
198 + do
199 + busybox_config_option n ${opt}
200 + done
201 +
202 + emake -j1 oldconfig > /dev/null
203 +}
204 +
205 +src_compile() {
206 + unset KBUILD_OUTPUT #88088
207 + export SKIP_STRIP=y
208 +
209 + emake V=1 busybox
210 +}
211 +
212 +src_install() {
213 + unset KBUILD_OUTPUT #88088
214 + save_config .config
215 +
216 + into /
217 + dodir /bin
218 + if use sep-usr ; then
219 + # install /ginit to take care of mounting stuff
220 + exeinto /
221 + newexe busybox_unstripped ginit
222 + dosym /ginit /bin/bb
223 + dosym bb /bin/busybox
224 + else
225 + newbin busybox_unstripped busybox
226 + dosym busybox /bin/bb
227 + fi
228 + if use mdev ; then
229 + dodir /$(get_libdir)/mdev/
230 + use make-symlinks || dosym /bin/bb /sbin/mdev
231 + cp "${S}"/examples/mdev_fat.conf "${ED}"/etc/mdev.conf
232 +
233 + exeinto /$(get_libdir)/mdev/
234 + doexe "${FILESDIR}"/mdev/*
235 +
236 + newinitd "${FILESDIR}"/mdev.rc.1 mdev
237 + fi
238 + if use livecd ; then
239 + dosym busybox /bin/vi
240 + fi
241 +
242 + # add busybox daemon's, bug #444718
243 + if busybox_config_enabled FEATURE_NTPD_SERVER; then
244 + newconfd "${FILESDIR}/ntpd.confd" "busybox-ntpd"
245 + newinitd "${FILESDIR}/ntpd.initd" "busybox-ntpd"
246 + fi
247 + if busybox_config_enabled SYSLOGD; then
248 + newconfd "${FILESDIR}/syslogd.confd" "busybox-syslogd"
249 + newinitd "${FILESDIR}/syslogd.initd" "busybox-syslogd"
250 + fi
251 + if busybox_config_enabled KLOGD; then
252 + newconfd "${FILESDIR}/klogd.confd" "busybox-klogd"
253 + newinitd "${FILESDIR}/klogd.initd" "busybox-klogd"
254 + fi
255 + if busybox_config_enabled WATCHDOG; then
256 + newconfd "${FILESDIR}/watchdog.confd" "busybox-watchdog"
257 + newinitd "${FILESDIR}/watchdog.initd" "busybox-watchdog"
258 + fi
259 + if busybox_config_enabled UDHCPC; then
260 + local path=$(busybox_config_enabled UDHCPC_DEFAULT_SCRIPT)
261 + exeinto "${path%/*}"
262 + newexe examples/udhcp/simple.script "${path##*/}"
263 + fi
264 + if busybox_config_enabled UDHCPD; then
265 + insinto /etc
266 + doins examples/udhcp/udhcpd.conf
267 + fi
268 +
269 + # bundle up the symlink files for use later
270 + emake DESTDIR="${ED}" install
271 + rm _install/bin/busybox
272 + # for compatibility, provide /usr/bin/env
273 + mkdir -p _install/usr/bin
274 + ln -s /bin/env _install/usr/bin/env
275 + tar cf busybox-links.tar -C _install . || : #;die
276 + insinto /usr/share/${PN}
277 + use make-symlinks && doins busybox-links.tar
278 +
279 + dodoc AUTHORS README TODO
280 +
281 + cd docs
282 + docinto txt
283 + dodoc *.txt
284 + docinto pod
285 + dodoc *.pod
286 + dohtml *.html
287 +
288 + cd ../examples
289 + docinto examples
290 + dodoc inittab depmod.pl *.conf *.script undeb unrpm
291 +}
292 +
293 +pkg_preinst() {
294 + if use make-symlinks && [[ ! ${VERY_BRAVE_OR_VERY_DUMB} == "yes" ]] && [[ ${ROOT} == "/" ]] ; then
295 + ewarn "setting USE=make-symlinks and emerging to / is very dangerous."
296 + ewarn "it WILL overwrite lots of system programs like: ls bash awk grep (bug 60805 for full list)."
297 + ewarn "If you are creating a binary only and not merging this is probably ok."
298 + ewarn "set env VERY_BRAVE_OR_VERY_DUMB=yes if this is really what you want."
299 + die "silly options will destroy your system"
300 + fi
301 +
302 + if use make-symlinks ; then
303 + mv "${ED}"/usr/share/${PN}/busybox-links.tar "${T}"/ || die
304 + fi
305 +}
306 +
307 +pkg_postinst() {
308 + savedconfig_pkg_postinst
309 +
310 + if use make-symlinks ; then
311 + cd "${T}" || die
312 + mkdir _install
313 + tar xf busybox-links.tar -C _install || die
314 + cp -vpPR _install/* "${ROOT}"/ || die "copying links for ${x} failed"
315 + fi
316 +
317 + if use sep-usr ; then
318 + elog "In order to use the sep-usr support, you have to update your"
319 + elog "kernel command line. Add the option:"
320 + elog " init=/ginit"
321 + elog "To launch a different init than /sbin/init, use:"
322 + elog " init=/ginit /sbin/yourinit"
323 + elog "To get a rescue shell, you may boot with:"
324 + elog " init=/ginit bb"
325 + fi
326 +}
327
328 diff --git a/sys-apps/busybox/files/busybox-1.22.1-ash.patch b/sys-apps/busybox/files/busybox-1.22.1-ash.patch
329 new file mode 100644
330 index 0000000..301e942
331 --- /dev/null
332 +++ b/sys-apps/busybox/files/busybox-1.22.1-ash.patch
333 @@ -0,0 +1,11 @@
334 +--- busybox-1.22.1/shell/ash.c
335 ++++ busybox-1.22.1-ash/shell/ash.c
336 +@@ -13014,7 +13014,7 @@ init(void)
337 + setvar2("PPID", utoa(getppid()));
338 + #if ENABLE_ASH_BASH_COMPAT
339 + p = lookupvar("SHLVL");
340 +- setvar2("SHLVL", utoa(p ? atoi(p) + 1 : 1));
341 ++ setvar("SHLVL", utoa((p ? atoi(p) : 0) + 1), VEXPORT);
342 + #endif
343 + p = lookupvar("PWD");
344 + if (p) {
345
346 diff --git a/sys-apps/busybox/files/busybox-1.22.1-date.patch b/sys-apps/busybox/files/busybox-1.22.1-date.patch
347 new file mode 100644
348 index 0000000..6380d87
349 --- /dev/null
350 +++ b/sys-apps/busybox/files/busybox-1.22.1-date.patch
351 @@ -0,0 +1,30 @@
352 +--- busybox-1.22.1/libbb/time.c
353 ++++ busybox-1.22.1-date/libbb/time.c
354 +@@ -68,15 +68,23 @@ void FAST_FUNC parse_datestr(const char
355 + /* else end != NUL and we error out */
356 + }
357 + } else
358 +- /* yyyy-mm-dd HH */
359 +- if (sscanf(date_str, "%u-%u-%u %u%c", &ptm->tm_year,
360 ++ if (strchr(date_str, '-')
361 ++ /* Why strchr('-') check?
362 ++ * sscanf below will trash ptm->tm_year, this breaks
363 ++ * if parse_str is "10101010" (iow, "MMddhhmm" form)
364 ++ * because we destroy year. Do these sscanf
365 ++ * only if we saw a dash in parse_str.
366 ++ */
367 ++ /* yyyy-mm-dd HH */
368 ++ && (sscanf(date_str, "%u-%u-%u %u%c", &ptm->tm_year,
369 + &ptm->tm_mon, &ptm->tm_mday,
370 + &ptm->tm_hour,
371 + &end) >= 4
372 +- /* yyyy-mm-dd */
373 +- || sscanf(date_str, "%u-%u-%u%c", &ptm->tm_year,
374 ++ /* yyyy-mm-dd */
375 ++ || sscanf(date_str, "%u-%u-%u%c", &ptm->tm_year,
376 + &ptm->tm_mon, &ptm->tm_mday,
377 + &end) >= 3
378 ++ )
379 + ) {
380 + ptm->tm_year -= 1900; /* Adjust years */
381 + ptm->tm_mon -= 1; /* Adjust month from 1-12 to 0-11 */
382
383 diff --git a/sys-apps/busybox/files/busybox-1.22.1-iplink.patch b/sys-apps/busybox/files/busybox-1.22.1-iplink.patch
384 new file mode 100644
385 index 0000000..dbd76c5
386 --- /dev/null
387 +++ b/sys-apps/busybox/files/busybox-1.22.1-iplink.patch
388 @@ -0,0 +1,19 @@
389 +--- busybox-1.22.1/networking/libiproute/iplink.c
390 ++++ busybox-1.22.1-iplink/networking/libiproute/iplink.c
391 +@@ -31,6 +31,16 @@
392 + #ifndef IFLA_LINKINFO
393 + # define IFLA_LINKINFO 18
394 + # define IFLA_INFO_KIND 1
395 ++# define IFLA_INFO_DATA 2
396 ++#endif
397 ++
398 ++#ifndef IFLA_VLAN_MAX
399 ++# define IFLA_VLAN_ID 1
400 ++# define IFLA_VLAN_FLAGS 2
401 ++struct ifla_vlan_flags {
402 ++ uint32_t flags;
403 ++ uint32_t mask;
404 ++};
405 + #endif
406 +
407 + /* taken from linux/sockios.h */