1 |
commit: 075de5139ea88e09e3020ef531f94f23426b2cfc |
2 |
Author: Felix Janda <felix.janda <AT> posteo <DOT> de> |
3 |
AuthorDate: Sat Feb 22 09:15:51 2014 +0000 |
4 |
Commit: Anthony G. Basile <blueness <AT> gentoo <DOT> org> |
5 |
CommitDate: Sat Feb 22 14:28:13 2014 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/hardened-dev.git;a=commit;h=075de513 |
7 |
|
8 |
sys-apps/busybox: move to tree |
9 |
|
10 |
--- |
11 |
sys-apps/busybox/busybox-1.21.0-r99.ebuild | 304 +++++++++++++++++++++ |
12 |
sys-apps/busybox/files/busybox-1.19.0-bb.patch | 22 ++ |
13 |
.../busybox/files/busybox-1.21.0-ifconfig.patch | 11 + |
14 |
sys-apps/busybox/files/busybox-1.21.0-iplink.patch | 12 + |
15 |
sys-apps/busybox/files/busybox-1.21.0-mdev.patch | 35 +++ |
16 |
.../busybox/files/busybox-1.21.0-platform.patch | 24 ++ |
17 |
sys-apps/busybox/files/busybox-1.21.0-xz.patch | 84 ++++++ |
18 |
sys-apps/busybox/files/ginit.c | 124 +++++++++ |
19 |
sys-apps/busybox/files/klogd.confd | 9 + |
20 |
sys-apps/busybox/files/klogd.initd | 12 + |
21 |
sys-apps/busybox/files/mdev-start.sh | 125 +++++++++ |
22 |
sys-apps/busybox/files/mdev.rc | 9 + |
23 |
sys-apps/busybox/files/mdev.rc.1 | 98 +++++++ |
24 |
sys-apps/busybox/files/mdev/dvbdev | 18 ++ |
25 |
sys-apps/busybox/files/mdev/ide_links | 23 ++ |
26 |
sys-apps/busybox/files/mdev/usbdev | 62 +++++ |
27 |
sys-apps/busybox/files/mdev/usbdisk_link | 34 +++ |
28 |
sys-apps/busybox/files/ntpd.confd | 6 + |
29 |
sys-apps/busybox/files/ntpd.initd | 13 + |
30 |
sys-apps/busybox/files/syslogd.confd | 9 + |
31 |
sys-apps/busybox/files/syslogd.initd | 13 + |
32 |
sys-apps/busybox/files/watchdog.confd | 9 + |
33 |
sys-apps/busybox/files/watchdog.initd | 8 + |
34 |
sys-apps/busybox/metadata.xml | 13 + |
35 |
24 files changed, 1077 insertions(+) |
36 |
|
37 |
diff --git a/sys-apps/busybox/busybox-1.21.0-r99.ebuild b/sys-apps/busybox/busybox-1.21.0-r99.ebuild |
38 |
new file mode 100644 |
39 |
index 0000000..57c2bb4 |
40 |
--- /dev/null |
41 |
+++ b/sys-apps/busybox/busybox-1.21.0-r99.ebuild |
42 |
@@ -0,0 +1,304 @@ |
43 |
+# Copyright 1999-2013 Gentoo Foundation |
44 |
+# Distributed under the terms of the GNU General Public License v2 |
45 |
+# $Header: /var/cvsroot/gentoo-x86/sys-apps/busybox/busybox-1.21.0.ebuild,v 1.21 2013/09/14 10:38:45 ago Exp $ |
46 |
+ |
47 |
+# See `man savedconfig.eclass` for info on how to use USE=savedconfig. |
48 |
+ |
49 |
+EAPI="4" |
50 |
+inherit eutils flag-o-matic savedconfig toolchain-funcs multilib |
51 |
+ |
52 |
+DESCRIPTION="Utilities for rescue and embedded systems" |
53 |
+HOMEPAGE="http://www.busybox.net/" |
54 |
+if [[ ${PV} == "9999" ]] ; then |
55 |
+ MY_P=${PN} |
56 |
+ EGIT_REPO_URI="git://busybox.net/busybox.git" |
57 |
+ inherit git-2 |
58 |
+else |
59 |
+ MY_P=${PN}-${PV/_/-} |
60 |
+ SRC_URI="http://www.busybox.net/downloads/${MY_P}.tar.bz2" |
61 |
+ KEYWORDS="amd64 arm x86" |
62 |
+fi |
63 |
+ |
64 |
+LICENSE="GPL-2" |
65 |
+SLOT="0" |
66 |
+ |
67 |
+IUSE="ipv6 livecd make-symlinks math mdev -pam selinux sep-usr +static syslog systemd" |
68 |
+RESTRICT="test" |
69 |
+ |
70 |
+RDEPEND="!static? ( selinux? ( sys-libs/libselinux ) ) |
71 |
+ pam? ( sys-libs/pam )" |
72 |
+DEPEND="${RDEPEND} |
73 |
+ static? ( selinux? ( sys-libs/libselinux[static-libs(+)] ) ) |
74 |
+ >=sys-kernel/linux-headers-2.6.39" |
75 |
+ |
76 |
+S=${WORKDIR}/${MY_P} |
77 |
+ |
78 |
+busybox_config_option() { |
79 |
+ local flag=$1 ; shift |
80 |
+ if [[ ${flag} != [yn] ]] ; then |
81 |
+ busybox_config_option $(usex ${flag} y n) "$@" |
82 |
+ return |
83 |
+ fi |
84 |
+ while [[ $# -gt 0 ]] ; do |
85 |
+ if [[ ${flag} == "y" ]] ; then |
86 |
+ sed -i -e "s:.*\<CONFIG_$1\>.*set:CONFIG_$1=y:g" .config |
87 |
+ else |
88 |
+ sed -i -e "s:CONFIG_$1=y:# CONFIG_$1 is not set:g" .config |
89 |
+ fi |
90 |
+ einfo $(grep "CONFIG_$1[= ]" .config || echo Could not find CONFIG_$1 ...) |
91 |
+ shift |
92 |
+ done |
93 |
+} |
94 |
+ |
95 |
+busybox_config_enabled() { |
96 |
+ local val=$(sed -n "/^CONFIG_$1=/s:^[^=]*=::p" .config) |
97 |
+ case ${val} in |
98 |
+ "") return 1 ;; |
99 |
+ y) return 0 ;; |
100 |
+ *) echo "${val}" | sed -r 's:^"(.*)"$:\1:' ;; |
101 |
+ esac |
102 |
+} |
103 |
+ |
104 |
+src_prepare() { |
105 |
+ unset KBUILD_OUTPUT #88088 |
106 |
+ append-flags -fno-strict-aliasing #310413 |
107 |
+ use ppc64 && append-flags -mminimal-toc #130943 |
108 |
+ |
109 |
+ # patches go here! |
110 |
+ epatch "${FILESDIR}"/${PN}-1.19.0-bb.patch |
111 |
+ epatch "${FILESDIR}"/${P}-*.patch |
112 |
+ cp "${FILESDIR}"/ginit.c init/ || die |
113 |
+ |
114 |
+ # flag cleanup |
115 |
+ sed -i -r \ |
116 |
+ -e 's:[[:space:]]?-(Werror|Os|falign-(functions|jumps|loops|labels)=1|fomit-frame-pointer)\>::g' \ |
117 |
+ Makefile.flags || die |
118 |
+ #sed -i '/bbsh/s:^//::' include/applets.h |
119 |
+ sed -i '/^#error Aborting compilation./d' applets/applets.c || die |
120 |
+ use elibc_glibc && sed -i 's:-Wl,--gc-sections::' Makefile |
121 |
+ sed -i \ |
122 |
+ -e "/^CROSS_COMPILE/s:=.*:= ${CHOST}-:" \ |
123 |
+ -e "/^AR\>/s:=.*:= $(tc-getAR):" \ |
124 |
+ -e "/^CC\>/s:=.*:= $(tc-getCC):" \ |
125 |
+ -e "/^HOSTCC/s:=.*:= $(tc-getBUILD_CC):" \ |
126 |
+ -e "/^PKG_CONFIG\>/s:=.*:= $(tc-getPKG_CONFIG):" \ |
127 |
+ Makefile || die |
128 |
+ sed -i \ |
129 |
+ -e 's:-static-libgcc::' \ |
130 |
+ Makefile.flags || die |
131 |
+} |
132 |
+ |
133 |
+src_configure() { |
134 |
+ # check for a busybox config before making one of our own. |
135 |
+ # if one exist lets return and use it. |
136 |
+ |
137 |
+ restore_config .config |
138 |
+ if [ -f .config ]; then |
139 |
+ yes "" | emake -j1 oldconfig > /dev/null |
140 |
+ return 0 |
141 |
+ else |
142 |
+ ewarn "Could not locate user configfile, so we will save a default one" |
143 |
+ fi |
144 |
+ |
145 |
+ # setup the config file |
146 |
+ emake -j1 allyesconfig > /dev/null |
147 |
+ # nommu forces a bunch of things off which we want on #387555 |
148 |
+ busybox_config_option n NOMMU |
149 |
+ sed -i '/^#/d' .config |
150 |
+ yes "" | emake -j1 oldconfig >/dev/null |
151 |
+ |
152 |
+ # now turn off stuff we really don't want |
153 |
+ busybox_config_option n DMALLOC |
154 |
+ busybox_config_option n FEATURE_SUID_CONFIG |
155 |
+ busybox_config_option n BUILD_AT_ONCE |
156 |
+ busybox_config_option n BUILD_LIBBUSYBOX |
157 |
+ busybox_config_option n FEATURE_CLEAN_UP |
158 |
+ busybox_config_option n MONOTONIC_SYSCALL |
159 |
+ busybox_config_option n USE_PORTABLE_CODE |
160 |
+ busybox_config_option n WERROR |
161 |
+ |
162 |
+ # turn off some options causing trouble with musl |
163 |
+ busybox_config_option n EXTRA_COMPAT |
164 |
+ busybox_config_option n FEATURE_VI_REGEX_SEARCH |
165 |
+ busybox_config_option n IFPLUGD |
166 |
+ |
167 |
+ # If these are not set and we are using a uclibc/busybox setup |
168 |
+ # all calls to system() will fail. |
169 |
+ busybox_config_option y ASH |
170 |
+ busybox_config_option n HUSH |
171 |
+ |
172 |
+ # disable ipv6 applets |
173 |
+ if ! use ipv6; then |
174 |
+ busybox_config_option n FEATURE_IPV6 |
175 |
+ busybox_config_option n TRACEROUTE6 |
176 |
+ busybox_config_option n PING6 |
177 |
+ fi |
178 |
+ |
179 |
+ if use static && use pam ; then |
180 |
+ ewarn "You cannot have USE='static pam'. Assuming static is more important." |
181 |
+ fi |
182 |
+ busybox_config_option $(usex static n pam) PAM |
183 |
+ busybox_config_option static STATIC |
184 |
+ busybox_config_option syslog {K,SYS}LOGD LOGGER |
185 |
+ busybox_config_option systemd FEATURE_SYSTEMD |
186 |
+ busybox_config_option math FEATURE_AWK_LIBM |
187 |
+ |
188 |
+ # all the debug options are compiler related, so punt them |
189 |
+ busybox_config_option n DEBUG |
190 |
+ busybox_config_option y NO_DEBUG_LIB |
191 |
+ busybox_config_option n DMALLOC |
192 |
+ busybox_config_option n EFENCE |
193 |
+ |
194 |
+ busybox_config_option selinux SELINUX |
195 |
+ |
196 |
+ # this opt only controls mounting with <linux-2.6.23 |
197 |
+ busybox_config_option n FEATURE_MOUNT_NFS |
198 |
+ |
199 |
+ # default a bunch of uncommon options to off |
200 |
+ local opt |
201 |
+ for opt in \ |
202 |
+ ADD_SHELL \ |
203 |
+ BEEP BOOTCHARTD \ |
204 |
+ CRONTAB \ |
205 |
+ DC DEVFSD DNSD DPKG{,_DEB} \ |
206 |
+ FAKEIDENTD FBSPLASH FOLD FSCK_MINIX FTP{GET,PUT} \ |
207 |
+ FEATURE_DEVFS \ |
208 |
+ HOSTID HUSH \ |
209 |
+ INETD INOTIFYD IPCALC \ |
210 |
+ LOCALE_SUPPORT LOGNAME LPD \ |
211 |
+ MAKEMIME MKFS_MINIX MSH \ |
212 |
+ OD \ |
213 |
+ RDEV READPROFILE REFORMIME REMOVE_SHELL RFKILL RUN_PARTS RUNSV{,DIR} \ |
214 |
+ SLATTACH SMEMCAP SULOGIN SV{,LOGD} \ |
215 |
+ TASKSET TCPSVD \ |
216 |
+ RPM RPM2CPIO \ |
217 |
+ UDPSVD UUDECODE UUENCODE |
218 |
+ do |
219 |
+ busybox_config_option n ${opt} |
220 |
+ done |
221 |
+ |
222 |
+ emake -j1 oldconfig > /dev/null |
223 |
+} |
224 |
+ |
225 |
+src_compile() { |
226 |
+ unset KBUILD_OUTPUT #88088 |
227 |
+ export SKIP_STRIP=y |
228 |
+ |
229 |
+ emake V=1 busybox |
230 |
+} |
231 |
+ |
232 |
+src_install() { |
233 |
+ unset KBUILD_OUTPUT #88088 |
234 |
+ save_config .config |
235 |
+ |
236 |
+ into / |
237 |
+ dodir /bin |
238 |
+ if use sep-usr ; then |
239 |
+ # install /ginit to take care of mounting stuff |
240 |
+ exeinto / |
241 |
+ newexe busybox_unstripped ginit |
242 |
+ dosym /ginit /bin/bb |
243 |
+ dosym bb /bin/busybox |
244 |
+ else |
245 |
+ newbin busybox_unstripped busybox |
246 |
+ dosym busybox /bin/bb |
247 |
+ fi |
248 |
+ if use mdev ; then |
249 |
+ dodir /$(get_libdir)/mdev/ |
250 |
+ use make-symlinks || dosym /bin/bb /sbin/mdev |
251 |
+ cp "${S}"/examples/mdev_fat.conf "${ED}"/etc/mdev.conf |
252 |
+ |
253 |
+ exeinto /$(get_libdir)/mdev/ |
254 |
+ doexe "${FILESDIR}"/mdev/* |
255 |
+ |
256 |
+ newinitd "${FILESDIR}"/mdev.rc.1 mdev |
257 |
+ fi |
258 |
+ if use livecd ; then |
259 |
+ dosym busybox /bin/vi |
260 |
+ fi |
261 |
+ |
262 |
+ # add busybox daemon's, bug #444718 |
263 |
+ if busybox_config_enabled FEATURE_NTPD_SERVER; then |
264 |
+ newconfd "${FILESDIR}/ntpd.confd" "busybox-ntpd" |
265 |
+ newinitd "${FILESDIR}/ntpd.initd" "busybox-ntpd" |
266 |
+ fi |
267 |
+ if busybox_config_enabled SYSLOGD; then |
268 |
+ newconfd "${FILESDIR}/syslogd.confd" "busybox-syslogd" |
269 |
+ newinitd "${FILESDIR}/syslogd.initd" "busybox-syslogd" |
270 |
+ fi |
271 |
+ if busybox_config_enabled KLOGD; then |
272 |
+ newconfd "${FILESDIR}/klogd.confd" "busybox-klogd" |
273 |
+ newinitd "${FILESDIR}/klogd.initd" "busybox-klogd" |
274 |
+ fi |
275 |
+ if busybox_config_enabled WATCHDOG; then |
276 |
+ newconfd "${FILESDIR}/watchdog.confd" "busybox-watchdog" |
277 |
+ newinitd "${FILESDIR}/watchdog.initd" "busybox-watchdog" |
278 |
+ fi |
279 |
+ if busybox_config_enabled UDHCPC; then |
280 |
+ local path=$(busybox_config_enabled UDHCPC_DEFAULT_SCRIPT) |
281 |
+ exeinto "${path%/*}" |
282 |
+ newexe examples/udhcp/simple.script "${path##*/}" |
283 |
+ fi |
284 |
+ if busybox_config_enabled UDHCPD; then |
285 |
+ insinto /etc |
286 |
+ doins examples/udhcp/udhcpd.conf |
287 |
+ fi |
288 |
+ |
289 |
+ # bundle up the symlink files for use later |
290 |
+ emake DESTDIR="${ED}" install |
291 |
+ rm _install/bin/busybox |
292 |
+ # for compatibility, provide /usr/bin/env |
293 |
+ mkdir -p _install/usr/bin |
294 |
+ ln -s /bin/env _install/usr/bin/env |
295 |
+ tar cf busybox-links.tar -C _install . || : #;die |
296 |
+ insinto /usr/share/${PN} |
297 |
+ use make-symlinks && doins busybox-links.tar |
298 |
+ |
299 |
+ dodoc AUTHORS README TODO |
300 |
+ |
301 |
+ cd docs |
302 |
+ docinto txt |
303 |
+ dodoc *.txt |
304 |
+ docinto pod |
305 |
+ dodoc *.pod |
306 |
+ dohtml *.html |
307 |
+ |
308 |
+ cd ../examples |
309 |
+ docinto examples |
310 |
+ dodoc inittab depmod.pl *.conf *.script undeb unrpm |
311 |
+} |
312 |
+ |
313 |
+pkg_preinst() { |
314 |
+ if use make-symlinks && [[ ! ${VERY_BRAVE_OR_VERY_DUMB} == "yes" ]] && [[ ${ROOT} == "/" ]] ; then |
315 |
+ ewarn "setting USE=make-symlinks and emerging to / is very dangerous." |
316 |
+ ewarn "it WILL overwrite lots of system programs like: ls bash awk grep (bug 60805 for full list)." |
317 |
+ ewarn "If you are creating a binary only and not merging this is probably ok." |
318 |
+ ewarn "set env VERY_BRAVE_OR_VERY_DUMB=yes if this is really what you want." |
319 |
+ die "silly options will destroy your system" |
320 |
+ fi |
321 |
+ |
322 |
+ if use make-symlinks ; then |
323 |
+ mv "${ED}"/usr/share/${PN}/busybox-links.tar "${T}"/ || die |
324 |
+ fi |
325 |
+} |
326 |
+ |
327 |
+pkg_postinst() { |
328 |
+ savedconfig_pkg_postinst |
329 |
+ |
330 |
+ if use make-symlinks ; then |
331 |
+ cd "${T}" || die |
332 |
+ mkdir _install |
333 |
+ tar xf busybox-links.tar -C _install || die |
334 |
+ cp -vpPR _install/* "${ROOT}"/ || die "copying links for ${x} failed" |
335 |
+ fi |
336 |
+ |
337 |
+ if use sep-usr ; then |
338 |
+ elog "In order to use the sep-usr support, you have to update your" |
339 |
+ elog "kernel command line. Add the option:" |
340 |
+ elog " init=/ginit" |
341 |
+ elog "To launch a different init than /sbin/init, use:" |
342 |
+ elog " init=/ginit /sbin/yourinit" |
343 |
+ elog "To get a rescue shell, you may boot with:" |
344 |
+ elog " init=/ginit bb" |
345 |
+ fi |
346 |
+} |
347 |
|
348 |
diff --git a/sys-apps/busybox/files/busybox-1.19.0-bb.patch b/sys-apps/busybox/files/busybox-1.19.0-bb.patch |
349 |
new file mode 100644 |
350 |
index 0000000..a66b45a |
351 |
--- /dev/null |
352 |
+++ b/sys-apps/busybox/files/busybox-1.19.0-bb.patch |
353 |
@@ -0,0 +1,22 @@ |
354 |
+--- a/shell/ash.c |
355 |
++++ b/shell/ash.c |
356 |
+@@ -75,6 +75,8 @@ |
357 |
+ //applet:IF_ASH(APPLET(ash, BB_DIR_BIN, BB_SUID_DROP)) |
358 |
+ //applet:IF_FEATURE_SH_IS_ASH(APPLET_ODDNAME(sh, ash, BB_DIR_BIN, BB_SUID_DROP, sh)) |
359 |
+ //applet:IF_FEATURE_BASH_IS_ASH(APPLET_ODDNAME(bash, ash, BB_DIR_BIN, BB_SUID_DROP, bash)) |
360 |
++//applet:IF_ASH(APPLET_ODDNAME(bb, ash, BB_DIR_BIN, BB_SUID_DROP, ash)) |
361 |
++//applet:IF_ASH(APPLET_ODDNAME(bbsh, ash, BB_DIR_BIN, BB_SUID_DROP, ash)) |
362 |
+ |
363 |
+ //kbuild:lib-$(CONFIG_ASH) += ash.o ash_ptr_hack.o shell_common.o |
364 |
+ //kbuild:lib-$(CONFIG_ASH_RANDOM_SUPPORT) += random.o |
365 |
+--- a/shell/ash.c |
366 |
++++ b/shell/ash.c |
367 |
+@@ -7255,6 +7255,8 @@ |
368 |
+ } |
369 |
+ /* re-exec ourselves with the new arguments */ |
370 |
+ execve(bb_busybox_exec_path, argv, envp); |
371 |
++ execve("/bin/busybox.static", argv, envp); |
372 |
++ execve("/bin/busybox", argv, envp); |
373 |
+ /* If they called chroot or otherwise made the binary no longer |
374 |
+ * executable, fall through */ |
375 |
+ } |
376 |
|
377 |
diff --git a/sys-apps/busybox/files/busybox-1.21.0-ifconfig.patch b/sys-apps/busybox/files/busybox-1.21.0-ifconfig.patch |
378 |
new file mode 100644 |
379 |
index 0000000..bc74904 |
380 |
--- /dev/null |
381 |
+++ b/sys-apps/busybox/files/busybox-1.21.0-ifconfig.patch |
382 |
@@ -0,0 +1,11 @@ |
383 |
+--- a/busybox-1.21.0/networking/ifconfig.c |
384 |
++++ b/busybox-1.21.0/networking/ifconfig.c |
385 |
+@@ -56,7 +56,7 @@ |
386 |
+ #endif |
387 |
+ |
388 |
+ #if ENABLE_FEATURE_IFCONFIG_SLIP |
389 |
+-# include <net/if_slip.h> |
390 |
++# include <linux/if_slip.h> |
391 |
+ #endif |
392 |
+ |
393 |
+ /* I don't know if this is needed for busybox or not. Anyone? */ |
394 |
|
395 |
diff --git a/sys-apps/busybox/files/busybox-1.21.0-iplink.patch b/sys-apps/busybox/files/busybox-1.21.0-iplink.patch |
396 |
new file mode 100644 |
397 |
index 0000000..80d8e5d |
398 |
--- /dev/null |
399 |
+++ b/sys-apps/busybox/files/busybox-1.21.0-iplink.patch |
400 |
@@ -0,0 +1,12 @@ |
401 |
+--- a/busybox-1.21.0/networking/libiproute/iplink.c |
402 |
++++ b/busybox-1.21.0/networking/libiproute/iplink.c |
403 |
+@@ -5,8 +5,7 @@ |
404 |
+ * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
405 |
+ */ |
406 |
+ #include <net/if.h> |
407 |
+-#include <net/if_packet.h> |
408 |
+-#include <netpacket/packet.h> |
409 |
++#include <linux/if_packet.h> |
410 |
+ #include <netinet/if_ether.h> |
411 |
+ |
412 |
+ #include "ip_common.h" /* #include "libbb.h" is inside */ |
413 |
|
414 |
diff --git a/sys-apps/busybox/files/busybox-1.21.0-mdev.patch b/sys-apps/busybox/files/busybox-1.21.0-mdev.patch |
415 |
new file mode 100644 |
416 |
index 0000000..cb873fa |
417 |
--- /dev/null |
418 |
+++ b/sys-apps/busybox/files/busybox-1.21.0-mdev.patch |
419 |
@@ -0,0 +1,35 @@ |
420 |
+--- busybox-1.21.0/util-linux/mdev.c |
421 |
++++ busybox-1.21.0-mdev/util-linux/mdev.c |
422 |
+@@ -661,6 +661,8 @@ static void make_device(char *device_nam |
423 |
+ if (mknod(node_name, rule->mode | type, makedev(major, minor)) && errno != EEXIST) |
424 |
+ bb_perror_msg("can't create '%s'", node_name); |
425 |
+ if (ENABLE_FEATURE_MDEV_CONF) { |
426 |
++ if (G.verbose) |
427 |
++ bb_error_msg("chmod: %o chown: %u:%u", rule->mode, rule->ugid.uid, rule->ugid.gid); |
428 |
+ chmod(node_name, rule->mode); |
429 |
+ chown(node_name, rule->ugid.uid, rule->ugid.gid); |
430 |
+ } |
431 |
+@@ -813,6 +815,7 @@ static void load_firmware(const char *fi |
432 |
+ full_write(loading_fd, "-1", 2); |
433 |
+ |
434 |
+ out: |
435 |
++ xchdir("/dev"); |
436 |
+ if (ENABLE_FEATURE_CLEAN_UP) { |
437 |
+ close(firmware_fd); |
438 |
+ close(loading_fd); |
439 |
+@@ -919,11 +922,13 @@ int mdev_main(int argc UNUSED_PARAM, cha |
440 |
+ } |
441 |
+ |
442 |
+ { |
443 |
+- int logfd = open("/dev/mdev.log", O_WRONLY | O_APPEND); |
444 |
++ int logfd = open("mdev.log", O_WRONLY | O_APPEND); |
445 |
+ if (logfd >= 0) { |
446 |
+ xmove_fd(logfd, STDERR_FILENO); |
447 |
+ G.verbose = 1; |
448 |
+- bb_error_msg("seq: %s action: %s", seq, action); |
449 |
++ if (seq) |
450 |
++ applet_name = xasprintf("%s[%s]", applet_name, seq); |
451 |
++ bb_error_msg("action: %s", action); |
452 |
+ } |
453 |
+ } |
454 |
+ |
455 |
|
456 |
diff --git a/sys-apps/busybox/files/busybox-1.21.0-platform.patch b/sys-apps/busybox/files/busybox-1.21.0-platform.patch |
457 |
new file mode 100644 |
458 |
index 0000000..9be6cb8 |
459 |
--- /dev/null |
460 |
+++ b/sys-apps/busybox/files/busybox-1.21.0-platform.patch |
461 |
@@ -0,0 +1,24 @@ |
462 |
+--- busybox-1.21.0/archival/libarchive/decompress_unxz.c |
463 |
++++ busybox-1.21.0-platform/archival/libarchive/decompress_unxz.c |
464 |
+@@ -30,8 +30,8 @@ static uint32_t xz_crc32(const uint8_t * |
465 |
+ /* We use arch-optimized unaligned accessors */ |
466 |
+ #define get_unaligned_le32(buf) ({ uint32_t v; move_from_unaligned32(v, buf); SWAP_LE32(v); }) |
467 |
+ #define get_unaligned_be32(buf) ({ uint32_t v; move_from_unaligned32(v, buf); SWAP_BE32(v); }) |
468 |
+-#define put_unaligned_le32(val, buf) move_to_unaligned16(buf, SWAP_LE32(val)) |
469 |
+-#define put_unaligned_be32(val, buf) move_to_unaligned16(buf, SWAP_BE32(val)) |
470 |
++#define put_unaligned_le32(val, buf) move_to_unaligned32(buf, SWAP_LE32(val)) |
471 |
++#define put_unaligned_be32(val, buf) move_to_unaligned32(buf, SWAP_BE32(val)) |
472 |
+ |
473 |
+ #include "unxz/xz_dec_bcj.c" |
474 |
+ #include "unxz/xz_dec_lzma2.c" |
475 |
+--- busybox-1.21.0/include/platform.h |
476 |
++++ busybox-1.21.0-platform/include/platform.h |
477 |
+@@ -228,7 +228,7 @@ typedef uint32_t bb__aliased_uint32_t FI |
478 |
+ # define move_from_unaligned32(v, u32p) (memcpy(&(v), (u32p), 4)) |
479 |
+ # define move_to_unaligned16(u16p, v) do { \ |
480 |
+ uint16_t __t = (v); \ |
481 |
+- memcpy((u16p), &__t, 4); \ |
482 |
++ memcpy((u16p), &__t, 2); \ |
483 |
+ } while (0) |
484 |
+ # define move_to_unaligned32(u32p, v) do { \ |
485 |
+ uint32_t __t = (v); \ |
486 |
|
487 |
diff --git a/sys-apps/busybox/files/busybox-1.21.0-xz.patch b/sys-apps/busybox/files/busybox-1.21.0-xz.patch |
488 |
new file mode 100644 |
489 |
index 0000000..56ba1a2 |
490 |
--- /dev/null |
491 |
+++ b/sys-apps/busybox/files/busybox-1.21.0-xz.patch |
492 |
@@ -0,0 +1,84 @@ |
493 |
+--- busybox-1.21.0/archival/libarchive/decompress_unxz.c |
494 |
++++ busybox-1.21.0-xz/archival/libarchive/decompress_unxz.c |
495 |
+@@ -40,6 +40,7 @@ static uint32_t xz_crc32(const uint8_t * |
496 |
+ IF_DESKTOP(long long) int FAST_FUNC |
497 |
+ unpack_xz_stream(transformer_aux_data_t *aux, int src_fd, int dst_fd) |
498 |
+ { |
499 |
++ enum xz_ret xz_result; |
500 |
+ struct xz_buf iobuf; |
501 |
+ struct xz_dec *state; |
502 |
+ unsigned char *membuf; |
503 |
+@@ -63,9 +64,8 @@ unpack_xz_stream(transformer_aux_data_t |
504 |
+ /* Limit memory usage to about 64 MiB. */ |
505 |
+ state = xz_dec_init(XZ_DYNALLOC, 64*1024*1024); |
506 |
+ |
507 |
++ xz_result = X_OK; |
508 |
+ while (1) { |
509 |
+- enum xz_ret r; |
510 |
+- |
511 |
+ if (iobuf.in_pos == iobuf.in_size) { |
512 |
+ int rd = safe_read(src_fd, membuf, BUFSIZ); |
513 |
+ if (rd < 0) { |
514 |
+@@ -73,28 +73,57 @@ unpack_xz_stream(transformer_aux_data_t |
515 |
+ total = -1; |
516 |
+ break; |
517 |
+ } |
518 |
++ if (rd == 0 && xz_result == XZ_STREAM_END) |
519 |
++ break; |
520 |
+ iobuf.in_size = rd; |
521 |
+ iobuf.in_pos = 0; |
522 |
+ } |
523 |
++ if (xz_result == XZ_STREAM_END) { |
524 |
++ /* |
525 |
++ * Try to start decoding next concatenated stream. |
526 |
++ * Stream padding must always be a multiple of four |
527 |
++ * bytes to preserve four-byte alignment. To keep the |
528 |
++ * code slightly smaller, we aren't as strict here as |
529 |
++ * the .xz spec requires. We just skip all zero-bytes |
530 |
++ * without checking the alignment and thus can accept |
531 |
++ * files that aren't valid, e.g. the XZ utils test |
532 |
++ * files bad-0pad-empty.xz and bad-0catpad-empty.xz. |
533 |
++ */ |
534 |
++ do { |
535 |
++ if (membuf[iobuf.in_pos] != 0) { |
536 |
++ xz_dec_reset(state); |
537 |
++ goto do_run; |
538 |
++ } |
539 |
++ iobuf.in_pos++; |
540 |
++ } while (iobuf.in_pos < iobuf.in_size); |
541 |
++ } |
542 |
++ do_run: |
543 |
+ // bb_error_msg(">in pos:%d size:%d out pos:%d size:%d", |
544 |
+ // iobuf.in_pos, iobuf.in_size, iobuf.out_pos, iobuf.out_size); |
545 |
+- r = xz_dec_run(state, &iobuf); |
546 |
++ xz_result = xz_dec_run(state, &iobuf); |
547 |
+ // bb_error_msg("<in pos:%d size:%d out pos:%d size:%d r:%d", |
548 |
+-// iobuf.in_pos, iobuf.in_size, iobuf.out_pos, iobuf.out_size, r); |
549 |
++// iobuf.in_pos, iobuf.in_size, iobuf.out_pos, iobuf.out_size, xz_result); |
550 |
+ if (iobuf.out_pos) { |
551 |
+ xwrite(dst_fd, iobuf.out, iobuf.out_pos); |
552 |
+ IF_DESKTOP(total += iobuf.out_pos;) |
553 |
+ iobuf.out_pos = 0; |
554 |
+ } |
555 |
+- if (r == XZ_STREAM_END) { |
556 |
+- break; |
557 |
++ if (xz_result == XZ_STREAM_END) { |
558 |
++ /* |
559 |
++ * Can just "break;" here, if not for concatenated |
560 |
++ * .xz streams. |
561 |
++ * Checking for padding may require buffer |
562 |
++ * replenishment. Can't do it here. |
563 |
++ */ |
564 |
++ continue; |
565 |
+ } |
566 |
+- if (r != XZ_OK && r != XZ_UNSUPPORTED_CHECK) { |
567 |
++ if (xz_result != XZ_OK && xz_result != XZ_UNSUPPORTED_CHECK) { |
568 |
+ bb_error_msg("corrupted data"); |
569 |
+ total = -1; |
570 |
+ break; |
571 |
+ } |
572 |
+ } |
573 |
++ |
574 |
+ xz_dec_end(state); |
575 |
+ free(membuf); |
576 |
+ |
577 |
|
578 |
diff --git a/sys-apps/busybox/files/ginit.c b/sys-apps/busybox/files/ginit.c |
579 |
new file mode 100644 |
580 |
index 0000000..de98e4a |
581 |
--- /dev/null |
582 |
+++ b/sys-apps/busybox/files/ginit.c |
583 |
@@ -0,0 +1,124 @@ |
584 |
+/* |
585 |
+ * simple init to bootstrap sep-/usr |
586 |
+ * |
587 |
+ * Copyright (C) 2012-2013 Mike Frysinger <vapier@g.o> |
588 |
+ * |
589 |
+ * Licensed under GPLv2 or later |
590 |
+ */ |
591 |
+ |
592 |
+//applet:IF_GINIT(APPLET(ginit, BB_DIR_SBIN, BB_SUID_DROP)) |
593 |
+ |
594 |
+//kbuild:lib-$(CONFIG_GINIT) += ginit.o |
595 |
+ |
596 |
+//config:config GINIT |
597 |
+//config: bool "ginit" |
598 |
+//config: default y |
599 |
+//config: select MKDIR |
600 |
+//config: select MDEV |
601 |
+//config: select MOUNT |
602 |
+//config: select MOUNTPOINT |
603 |
+//config: help |
604 |
+//config: sep-/usr bootstrapper |
605 |
+ |
606 |
+//usage:#define ginit_trivial_usage NOUSAGE_STR |
607 |
+//usage:#define ginit_full_usage "" |
608 |
+ |
609 |
+#include "libbb.h" |
610 |
+ |
611 |
+#define eprintf(fmt, args...) printf("%s" fmt, "sep-usr init: ", ## args) |
612 |
+ |
613 |
+static void process_args(char **args) |
614 |
+{ |
615 |
+ size_t i; |
616 |
+ |
617 |
+ eprintf("running: "); |
618 |
+ for (i = 0; args[i]; ++i) { |
619 |
+ /* String needs to be writable, so dupe it */ |
620 |
+ args[i] = xstrdup(args[i]); |
621 |
+ printf("'%s' ", args[i]); |
622 |
+ } |
623 |
+ printf("\n"); |
624 |
+} |
625 |
+ |
626 |
+int ginit_main(int argc UNUSED_PARAM, char **argv) MAIN_EXTERNALLY_VISIBLE; |
627 |
+int ginit_main(int argc UNUSED_PARAM, char **argv) |
628 |
+{ |
629 |
+ FILE *mntlist; |
630 |
+ bool ismnted_dev, ismnted_sys, ismnted_usr; |
631 |
+ struct mntent *mntent; |
632 |
+ |
633 |
+ /* |
634 |
+ int fd = open("/dev/console", O_RDWR); |
635 |
+ if (fd >= 0) { |
636 |
+ dup2(fd, 0); |
637 |
+ dup2(fd, 1); |
638 |
+ dup2(fd, 2); |
639 |
+ } |
640 |
+ */ |
641 |
+ |
642 |
+ /* If given an argv[] with an applet name, run it instead. |
643 |
+ * Makes recovering simple by doing: init=/ginit bb |
644 |
+ */ |
645 |
+ if (argv[1] && argv[1][0] != '/') { |
646 |
+ eprintf("running user requested applet %s\n", argv[1]); |
647 |
+ return spawn_and_wait(argv+1); |
648 |
+ } |
649 |
+ |
650 |
+#define saw(argv...) \ |
651 |
+ ({ \ |
652 |
+ static const char *args[] = { argv, NULL }; \ |
653 |
+ /* These casts are fine -- see process_args for mem setup */ \ |
654 |
+ process_args((void *)args); \ |
655 |
+ spawn_and_wait((void *)args); \ |
656 |
+ }) |
657 |
+ |
658 |
+ /* First setup basic /dev */ |
659 |
+ if (saw("mountpoint", "-q", "/dev") != 0) { |
660 |
+ /* Try /etc/fstab */ |
661 |
+ if (saw("mount", "-n", "/dev")) |
662 |
+ /* Then devtmpfs */ |
663 |
+ if (saw("mount", "-n", "-t", "devtmpfs", "devtmpfs", "/dev")) |
664 |
+ /* Finally normal tmpfs */ |
665 |
+ saw("mount", "-n", "-t", "tmpfs", "dev", "/dev"); |
666 |
+ } else { |
667 |
+ eprintf("%s appears to be mounted; skipping its setup\n", "/dev"); |
668 |
+ } |
669 |
+ |
670 |
+ /* If /dev is empty (e.g. tmpfs), run mdev to seed things */ |
671 |
+ if (access("/dev/console", F_OK) != 0) { |
672 |
+ if (saw("mountpoint", "-q", "/sys") != 0) { |
673 |
+ if (saw("mount", "-n", "/sys")) |
674 |
+ saw("mount", "-n", "-t", "sysfs", "sysfs", "/sys"); |
675 |
+ } else { |
676 |
+ eprintf("%s appears to be mounted; skipping its setup\n", "/sys"); |
677 |
+ } |
678 |
+ |
679 |
+ /* Mount /proc as mdev will fork+exec /proc/self/exe */ |
680 |
+ if (saw("mountpoint", "-q", "/proc") != 0) { |
681 |
+ /* Try /etc/fstab */ |
682 |
+ if (saw("mount", "-n", "/proc")) |
683 |
+ saw("mount", "-n", "-t", "proc", "proc", "/proc"); |
684 |
+ } |
685 |
+ |
686 |
+ saw("mdev", "-s"); |
687 |
+ } |
688 |
+ |
689 |
+ /* Then seed the stuff we care about */ |
690 |
+ saw("mkdir", "-p", "/dev/pts", "/dev/shm"); |
691 |
+ |
692 |
+ /* Then mount /usr */ |
693 |
+ if (saw("mountpoint", "-q", "/usr") != 0) { |
694 |
+ saw("mount", "-n", "/usr", "-o", "ro"); |
695 |
+ } else { |
696 |
+ eprintf("%s appears to be mounted; skipping its setup\n", "/usr"); |
697 |
+ } |
698 |
+ |
699 |
+ /* Now that we're all done, exec the real init */ |
700 |
+ if (!argv[1]) { |
701 |
+ argv[0] = (void *)"/sbin/init"; |
702 |
+ argv[1] = NULL; |
703 |
+ } else |
704 |
+ ++argv; |
705 |
+ process_args(argv); |
706 |
+ return execv(argv[0], argv); |
707 |
+} |
708 |
|
709 |
diff --git a/sys-apps/busybox/files/klogd.confd b/sys-apps/busybox/files/klogd.confd |
710 |
new file mode 100644 |
711 |
index 0000000..4c16096 |
712 |
--- /dev/null |
713 |
+++ b/sys-apps/busybox/files/klogd.confd |
714 |
@@ -0,0 +1,9 @@ |
715 |
+# Config file for /etc/init.d/busybox-sysklogd |
716 |
+ |
717 |
+# run "/sbin/klogd --help" to see all possible options. |
718 |
+ |
719 |
+# activate if you need remote logging |
720 |
+#rc_need="net" |
721 |
+ |
722 |
+# send warnings and above to the console |
723 |
+KLOGD_OPTS="-c 3" |
724 |
|
725 |
diff --git a/sys-apps/busybox/files/klogd.initd b/sys-apps/busybox/files/klogd.initd |
726 |
new file mode 100644 |
727 |
index 0000000..4c6dbbc |
728 |
--- /dev/null |
729 |
+++ b/sys-apps/busybox/files/klogd.initd |
730 |
@@ -0,0 +1,12 @@ |
731 |
+#!/sbin/runscript |
732 |
+# Copyright 1999-2012 Gentoo Foundation |
733 |
+# Distributed under the terms of the GNU General Public License v2 |
734 |
+# $Header: /var/cvsroot/gentoo-x86/sys-apps/busybox/files/klogd.initd,v 1.2 2012/12/21 03:15:28 blueness Exp $ |
735 |
+ |
736 |
+command="/bin/busybox klogd" |
737 |
+command_args="${KLOGD_OPTS}" |
738 |
+pidfile="/var/run/klogd.pid" |
739 |
+ |
740 |
+depend() { |
741 |
+ need clock hostname |
742 |
+} |
743 |
|
744 |
diff --git a/sys-apps/busybox/files/mdev-start.sh b/sys-apps/busybox/files/mdev-start.sh |
745 |
new file mode 100755 |
746 |
index 0000000..8784cd5 |
747 |
--- /dev/null |
748 |
+++ b/sys-apps/busybox/files/mdev-start.sh |
749 |
@@ -0,0 +1,125 @@ |
750 |
+# Copyright 1999-2008 Gentoo Foundation |
751 |
+# Distributed under the terms of the GNU General Public License v2 |
752 |
+ |
753 |
+find_mdev() |
754 |
+{ |
755 |
+ if [ -x /sbin/mdev ] ; then |
756 |
+ echo "/sbin/mdev" |
757 |
+ else |
758 |
+ echo "/bin/busybox mdev" |
759 |
+ fi |
760 |
+} |
761 |
+ |
762 |
+populate_mdev() |
763 |
+{ |
764 |
+ # populate /dev with devices already found by the kernel |
765 |
+ |
766 |
+ if get_bootparam "nocoldplug" ; then |
767 |
+ RC_COLDPLUG="no" |
768 |
+ ewarn "Skipping mdev coldplug as requested in kernel cmdline" |
769 |
+ fi |
770 |
+ |
771 |
+ ebegin "Populating /dev with existing devices with mdev -s" |
772 |
+ $(find_mdev) -s |
773 |
+ eend $? |
774 |
+ |
775 |
+ return 0 |
776 |
+} |
777 |
+ |
778 |
+seed_dev() |
779 |
+{ |
780 |
+ # Seed /dev with some things that we know we need |
781 |
+ |
782 |
+ # creating /dev/console and /dev/tty1 to be able to write |
783 |
+ # to $CONSOLE with/without bootsplash before mdev creates it |
784 |
+ [ -c /dev/console ] || mknod /dev/console c 5 1 |
785 |
+ [ -c /dev/tty1 ] || mknod /dev/tty1 c 4 1 |
786 |
+ |
787 |
+ # udevd will dup its stdin/stdout/stderr to /dev/null |
788 |
+ # and we do not want a file which gets buffered in ram |
789 |
+ [ -c /dev/null ] || mknod /dev/null c 1 3 |
790 |
+ |
791 |
+ # copy over any persistant things |
792 |
+ if [ -d /lib/mdev/devices ] ; then |
793 |
+ cp -RPp /lib/mdev/devices/* /dev 2>/dev/null |
794 |
+ fi |
795 |
+ |
796 |
+ # Not provided by sysfs but needed |
797 |
+ ln -snf /proc/self/fd /dev/fd |
798 |
+ ln -snf fd/0 /dev/stdin |
799 |
+ ln -snf fd/1 /dev/stdout |
800 |
+ ln -snf fd/2 /dev/stderr |
801 |
+ [ -e /proc/kcore ] && ln -snf /proc/kcore /dev/core |
802 |
+ |
803 |
+ # Create problematic directories |
804 |
+ mkdir -p /dev/pts /dev/shm |
805 |
+} |
806 |
+ |
807 |
+mount_it_b1() |
808 |
+{ |
809 |
+ if [ "${RC_USE_FSTAB}" = "yes" ] ; then |
810 |
+ mntcmd=$(get_mount_fstab /dev) |
811 |
+ else |
812 |
+ unset mntcmd |
813 |
+ fi |
814 |
+ if [ -n "${mntcmd}" ] ; then |
815 |
+ try mount -n ${mntcmd} |
816 |
+ else |
817 |
+ if grep -Eq "[[:space:]]+tmpfs$" /proc/filesystems ; then |
818 |
+ mntcmd="tmpfs" |
819 |
+ else |
820 |
+ mntcmd="ramfs" |
821 |
+ fi |
822 |
+ # many video drivers require exec access in /dev #92921 |
823 |
+ try mount -n -t "${mntcmd}" -o exec,nosuid,mode=0755 mdev /dev |
824 |
+ fi |
825 |
+} |
826 |
+mount_it_b2() |
827 |
+{ |
828 |
+ if fstabinfo --quiet /dev ; then |
829 |
+ mount -n /dev |
830 |
+ else |
831 |
+ # Some devices require exec, Bug #92921 |
832 |
+ mount -n -t tmpfs -o "exec,nosuid,mode=0755,size=10M" mdev /dev |
833 |
+ fi |
834 |
+} |
835 |
+mount_it() |
836 |
+{ |
837 |
+ type fstabinfo && mount_it_b2 || mount_it_b1 |
838 |
+} |
839 |
+ |
840 |
+main() |
841 |
+{ |
842 |
+ # Setup temporary storage for /dev |
843 |
+ ebegin "Mounting /dev for mdev" |
844 |
+ mount_it |
845 |
+ eend $? |
846 |
+ |
847 |
+ # Create a file so that our rc system knows it's still in sysinit. |
848 |
+ # Existance means init scripts will not directly run. |
849 |
+ # rc will remove the file when done with sysinit. |
850 |
+ touch /dev/.rcsysinit |
851 |
+ |
852 |
+ # Selinux lovin; /selinux should be mounted by selinux-patched init |
853 |
+ if [ -x /sbin/restorecon ] && [ -c /selinux/null ] ; then |
854 |
+ restorecon /dev > /selinux/null |
855 |
+ fi |
856 |
+ |
857 |
+ seed_dev |
858 |
+ |
859 |
+ # Setup hotplugging (if possible) |
860 |
+ if [ -e /proc/sys/kernel/hotplug ] ; then |
861 |
+ ebegin "Setting up proper hotplug agent" |
862 |
+ eindent |
863 |
+ einfo "Setting /sbin/mdev as hotplug agent ..." |
864 |
+ echo $(find_mdev) > /proc/sys/kernel/hotplug |
865 |
+ eoutdent |
866 |
+ eend 0 |
867 |
+ fi |
868 |
+ |
869 |
+ populate_mdev |
870 |
+} |
871 |
+ |
872 |
+main |
873 |
+ |
874 |
+# vim:ts=4 |
875 |
|
876 |
diff --git a/sys-apps/busybox/files/mdev.rc b/sys-apps/busybox/files/mdev.rc |
877 |
new file mode 100755 |
878 |
index 0000000..5470404 |
879 |
--- /dev/null |
880 |
+++ b/sys-apps/busybox/files/mdev.rc |
881 |
@@ -0,0 +1,9 @@ |
882 |
+#!/sbin/runscript |
883 |
+# Copyright 1999-2010 Gentoo Foundation |
884 |
+# Distributed under the terms of the GNU General Public License v2 |
885 |
+# $Header: /var/cvsroot/gentoo-x86/sys-apps/busybox/files/mdev.rc,v 1.1 2010/08/15 03:55:29 vapier Exp $ |
886 |
+ |
887 |
+start() |
888 |
+{ |
889 |
+ . /lib/rcscripts/addons/mdev-start.sh |
890 |
+} |
891 |
|
892 |
diff --git a/sys-apps/busybox/files/mdev.rc.1 b/sys-apps/busybox/files/mdev.rc.1 |
893 |
new file mode 100755 |
894 |
index 0000000..569d540 |
895 |
--- /dev/null |
896 |
+++ b/sys-apps/busybox/files/mdev.rc.1 |
897 |
@@ -0,0 +1,98 @@ |
898 |
+#!/sbin/runscript |
899 |
+# Copyright 1999-2012 Gentoo Foundation |
900 |
+# Distributed under the terms of the GNU General Public License v2 |
901 |
+# $Header: /var/cvsroot/gentoo-x86/sys-apps/busybox/files/mdev.rc.1,v 1.2 2012/09/26 21:25:23 robbat2 Exp $ |
902 |
+ |
903 |
+depend() |
904 |
+{ |
905 |
+ provide dev dev-mount |
906 |
+ need sysfs |
907 |
+} |
908 |
+ |
909 |
+find_mdev() |
910 |
+{ |
911 |
+ if [ -x /sbin/mdev ] ; then |
912 |
+ echo "/sbin/mdev" |
913 |
+ else |
914 |
+ echo "/bin/busybox mdev" |
915 |
+ fi |
916 |
+} |
917 |
+ |
918 |
+populate_mdev() |
919 |
+{ |
920 |
+ # populate /dev with devices already found by the kernel |
921 |
+ |
922 |
+ if get_bootparam "nocoldplug" ; then |
923 |
+ RC_COLDPLUG="no" |
924 |
+ ewarn "Skipping mdev coldplug as requested in kernel cmdline" |
925 |
+ fi |
926 |
+ |
927 |
+ ebegin "Populating /dev with existing devices with mdev -s" |
928 |
+ $(find_mdev) -s |
929 |
+ eend $? |
930 |
+ |
931 |
+ return 0 |
932 |
+} |
933 |
+ |
934 |
+seed_dev() |
935 |
+{ |
936 |
+ # Seed /dev with some things that we know we need |
937 |
+ |
938 |
+ # creating /dev/console and /dev/tty1 to be able to write |
939 |
+ # to $CONSOLE with/without bootsplash before mdev creates it |
940 |
+ [ -c /dev/console ] || mknod /dev/console c 5 1 |
941 |
+ [ -c /dev/tty1 ] || mknod /dev/tty1 c 4 1 |
942 |
+ |
943 |
+ # udevd will dup its stdin/stdout/stderr to /dev/null |
944 |
+ # and we do not want a file which gets buffered in ram |
945 |
+ [ -c /dev/null ] || mknod /dev/null c 1 3 |
946 |
+ |
947 |
+ # copy over any persistant things |
948 |
+ if [ -d /lib/mdev/devices ] ; then |
949 |
+ cp -RPp /lib/mdev/devices/* /dev 2>/dev/null |
950 |
+ fi |
951 |
+ |
952 |
+ # Not provided by sysfs but needed |
953 |
+ ln -snf /proc/self/fd /dev/fd |
954 |
+ ln -snf fd/0 /dev/stdin |
955 |
+ ln -snf fd/1 /dev/stdout |
956 |
+ ln -snf fd/2 /dev/stderr |
957 |
+ [ -e /proc/kcore ] && ln -snf /proc/kcore /dev/core |
958 |
+ |
959 |
+ # Create problematic directories |
960 |
+ mkdir -p /dev/pts /dev/shm |
961 |
+} |
962 |
+ |
963 |
+mount_it() |
964 |
+{ |
965 |
+ if fstabinfo --quiet /dev ; then |
966 |
+ mount -n /dev |
967 |
+ else |
968 |
+ # Some devices require exec, Bug #92921 |
969 |
+ mount -n -t tmpfs -o "exec,nosuid,mode=0755,size=10M" mdev /dev |
970 |
+ fi |
971 |
+} |
972 |
+ |
973 |
+start() |
974 |
+{ |
975 |
+ # Setup temporary storage for /dev |
976 |
+ ebegin "Mounting /dev for mdev" |
977 |
+ mount_it |
978 |
+ eend $? |
979 |
+ |
980 |
+ # Create a file so that our rc system knows it's still in sysinit. |
981 |
+ # Existance means init scripts will not directly run. |
982 |
+ # rc will remove the file when done with sysinit. |
983 |
+ touch /dev/.rcsysinit |
984 |
+ |
985 |
+ seed_dev |
986 |
+ |
987 |
+ # Setup hotplugging (if possible) |
988 |
+ if [ -e /proc/sys/kernel/hotplug ] ; then |
989 |
+ ebegin "Setting up mdev as hotplug agent" |
990 |
+ echo $(find_mdev) > /proc/sys/kernel/hotplug |
991 |
+ eend 0 |
992 |
+ fi |
993 |
+ |
994 |
+ populate_mdev |
995 |
+} |
996 |
|
997 |
diff --git a/sys-apps/busybox/files/mdev/dvbdev b/sys-apps/busybox/files/mdev/dvbdev |
998 |
new file mode 100644 |
999 |
index 0000000..f0186c1 |
1000 |
--- /dev/null |
1001 |
+++ b/sys-apps/busybox/files/mdev/dvbdev |
1002 |
@@ -0,0 +1,18 @@ |
1003 |
+#!/bin/sh |
1004 |
+ |
1005 |
+# MDEV=dvb0.demux1 -> ADAPTER=dvb0 -> N=0 |
1006 |
+ADAPTER=${MDEV%.*} |
1007 |
+N=${ADAPTER#dvb} |
1008 |
+# MDEV=dvb0.demux1 -> DEVB_DEV=demux1 |
1009 |
+DVB_DEV=${MDEV#*.} |
1010 |
+ |
1011 |
+case "$ACTION" in |
1012 |
+ add|"") |
1013 |
+ mkdir -p dvb/adapter${N} |
1014 |
+ mv ${MDEV} dvb/adapter${N}/${DVB_DEV} |
1015 |
+ ;; |
1016 |
+ remove) |
1017 |
+ rm -f dvb/adapter${N}/${DVB_DEV} |
1018 |
+ rmdir dvb/adapter${N} 2>/dev/null |
1019 |
+ rmdir dvb/ 2>/dev/null |
1020 |
+esac |
1021 |
|
1022 |
diff --git a/sys-apps/busybox/files/mdev/ide_links b/sys-apps/busybox/files/mdev/ide_links |
1023 |
new file mode 100644 |
1024 |
index 0000000..be0c95a |
1025 |
--- /dev/null |
1026 |
+++ b/sys-apps/busybox/files/mdev/ide_links |
1027 |
@@ -0,0 +1,23 @@ |
1028 |
+#!/bin/sh |
1029 |
+ |
1030 |
+[ -f /proc/ide/$MDEV/media ] || exit |
1031 |
+ |
1032 |
+media=`cat /proc/ide/$MDEV/media` |
1033 |
+for i in $media $media[0-9]* ; do |
1034 |
+ if [ "`readlink $i 2>/dev/null`" = $MDEV ] ; then |
1035 |
+ LINK=$i |
1036 |
+ break |
1037 |
+ fi |
1038 |
+done |
1039 |
+ |
1040 |
+# link exist, remove if necessary and exit |
1041 |
+if [ "$LINK" ] ; then |
1042 |
+ [ "$ACTION" = remove ] && rm $LINK |
1043 |
+ exit |
1044 |
+fi |
1045 |
+ |
1046 |
+# create a link |
1047 |
+num=`ls $media[0-9]* 2>/dev/null | wc -l` |
1048 |
+ln -sf $MDEV "$media`echo $num`" |
1049 |
+[ -e "$media" ] || ln -sf $MDEV "$media" |
1050 |
+ |
1051 |
|
1052 |
diff --git a/sys-apps/busybox/files/mdev/usbdev b/sys-apps/busybox/files/mdev/usbdev |
1053 |
new file mode 100644 |
1054 |
index 0000000..ea5b915 |
1055 |
--- /dev/null |
1056 |
+++ b/sys-apps/busybox/files/mdev/usbdev |
1057 |
@@ -0,0 +1,62 @@ |
1058 |
+#!/bin/sh |
1059 |
+ |
1060 |
+# script is buggy; until patched just do exit 0 |
1061 |
+#exit 0 |
1062 |
+ |
1063 |
+# add zeros to device or bus |
1064 |
+add_zeros () { |
1065 |
+ case "$(echo $1 | wc -L)" in |
1066 |
+ 1) echo "00$1" ;; |
1067 |
+ 2) echo "0$1" ;; |
1068 |
+ *) echo "$1" |
1069 |
+ esac |
1070 |
+ exit 0 |
1071 |
+} |
1072 |
+ |
1073 |
+ |
1074 |
+# bus and device dirs in /sys |
1075 |
+USB_PATH=$(echo $MDEV | sed -e 's/usbdev\([0-9]\).[0-9]/usb\1/') |
1076 |
+USB_PATH=$(find /sys/devices -type d -name "$USB_PATH") |
1077 |
+USB_DEV_DIR=$(echo $MDEV | sed -e 's/usbdev\([0-9]\).\([0-9]\)/\1-\2/') |
1078 |
+ |
1079 |
+# dir names in /dev |
1080 |
+BUS=$(add_zeros $(echo $MDEV | sed -e 's/^usbdev\([0-9]\).[0-9]/\1/')) |
1081 |
+USB_DEV=$(add_zeros $(echo $MDEV | sed -e 's/^usbdev[0-9].\([0-9]\)/\1/')) |
1082 |
+ |
1083 |
+ |
1084 |
+# try to load the proper driver for usb devices |
1085 |
+case "$ACTION" in |
1086 |
+ add|"") |
1087 |
+ # load usb bus driver |
1088 |
+ for i in $USB_PATH/*/modalias ; do |
1089 |
+ modprobe `cat $i` 2>/dev/null |
1090 |
+ done |
1091 |
+ # load usb device driver if existent |
1092 |
+ if [ -d $USB_PATH/$USB_DEV_DIR ]; then |
1093 |
+ for i in $USB_PATH/$USB_DEV_DIR/*/modalias ; do |
1094 |
+ modprobe `cat $i` 2>/dev/null |
1095 |
+ done |
1096 |
+ fi |
1097 |
+ # move usb device file |
1098 |
+ mkdir -p bus/usb/$BUS |
1099 |
+ mv $MDEV bus/usb/$BUS/$USB_DEV |
1100 |
+ ;; |
1101 |
+ remove) |
1102 |
+ # unload device driver, if device dir is existent |
1103 |
+ if [ -d $USB_PATH/$USB_DEV_DIR ]; then |
1104 |
+ for i in $USB_PATH/$USB_DEV_DIR/*/modalias ; do |
1105 |
+ modprobe -r `cat $i` 2>/dev/null |
1106 |
+ done |
1107 |
+ fi |
1108 |
+ # unload usb bus driver. Does this make sense? |
1109 |
+ # what happens, if two usb devices are plugged in |
1110 |
+ # and one is removed? |
1111 |
+ for i in $USB_PATH/*/modalias ; do |
1112 |
+ modprobe -r `cat $i` 2>/dev/null |
1113 |
+ done |
1114 |
+ # remove device file and possible empty dirs |
1115 |
+ rm -f bus/usb/$BUS/$USB_DEV |
1116 |
+ rmdir bus/usb/$BUS/ 2>/dev/null |
1117 |
+ rmdir bus/usb/ 2>/dev/null |
1118 |
+ rmdir bus/ 2>/dev/null |
1119 |
+esac |
1120 |
|
1121 |
diff --git a/sys-apps/busybox/files/mdev/usbdisk_link b/sys-apps/busybox/files/mdev/usbdisk_link |
1122 |
new file mode 100644 |
1123 |
index 0000000..6bb0692 |
1124 |
--- /dev/null |
1125 |
+++ b/sys-apps/busybox/files/mdev/usbdisk_link |
1126 |
@@ -0,0 +1,34 @@ |
1127 |
+#!/bin/sh |
1128 |
+ |
1129 |
+# NOTE: since mdev -s only provide $MDEV, don't depend on any hotplug vars. |
1130 |
+ |
1131 |
+current=$(readlink usbdisk) |
1132 |
+ |
1133 |
+if [ "$current" = "$MDEV" ] && [ "$ACTION" = "remove" ]; then |
1134 |
+ rm -f usbdisk usba1 |
1135 |
+fi |
1136 |
+[ -n "$current" ] && exit |
1137 |
+ |
1138 |
+if [ -e /sys/block/$MDEV ]; then |
1139 |
+ SYSDEV=$(readlink -f /sys/block/$MDEV/device) |
1140 |
+ # if /sys device path contains '/usb[0-9]' then we assume its usb |
1141 |
+ # also, if it's a usb without partitions we require FAT |
1142 |
+ if [ "${SYSDEV##*/usb[0-9]}" != "$SYSDEV" ]; then |
1143 |
+ # do not create link if there is not FAT |
1144 |
+ dd if=/dev/$MDEV bs=512 count=1 2>/dev/null | strings | grep FAT >/dev/null || exit 0 |
1145 |
+ |
1146 |
+ ln -sf $MDEV usbdisk |
1147 |
+ # keep this for compat. people have it in fstab |
1148 |
+ ln -sf $MDEV usba1 |
1149 |
+ fi |
1150 |
+ |
1151 |
+elif [ -e /sys/block/*/$MDEV ] ; then |
1152 |
+ PARENT=$(dirname /sys/block/*/$MDEV) |
1153 |
+ SYSDEV=$(readlink -f $PARENT/device) |
1154 |
+ if [ "${SYSDEV##*/usb[0-9]}" != "$SYSDEV" ]; then |
1155 |
+ ln -sf $MDEV usbdisk |
1156 |
+ # keep this for compat. people have it in fstab |
1157 |
+ ln -sf $MDEV usba1 |
1158 |
+ fi |
1159 |
+fi |
1160 |
+ |
1161 |
|
1162 |
diff --git a/sys-apps/busybox/files/ntpd.confd b/sys-apps/busybox/files/ntpd.confd |
1163 |
new file mode 100644 |
1164 |
index 0000000..f50d4c2 |
1165 |
--- /dev/null |
1166 |
+++ b/sys-apps/busybox/files/ntpd.confd |
1167 |
@@ -0,0 +1,6 @@ |
1168 |
+# Config file for /etc/init.d/busybox-ntpd |
1169 |
+ |
1170 |
+# run "/sbin/ntpd --help" to see all possible options. |
1171 |
+ |
1172 |
+# Get time from specified server and run in background |
1173 |
+NTPD_OPTS="-N -p pool.ntp.org" |
1174 |
|
1175 |
diff --git a/sys-apps/busybox/files/ntpd.initd b/sys-apps/busybox/files/ntpd.initd |
1176 |
new file mode 100644 |
1177 |
index 0000000..5a05c31 |
1178 |
--- /dev/null |
1179 |
+++ b/sys-apps/busybox/files/ntpd.initd |
1180 |
@@ -0,0 +1,13 @@ |
1181 |
+#!/sbin/runscript |
1182 |
+# Copyright 1999-2012 Gentoo Foundation |
1183 |
+# Distributed under the terms of the GNU General Public License v2 |
1184 |
+# $Header: /var/cvsroot/gentoo-x86/sys-apps/busybox/files/ntpd.initd,v 1.2 2012/12/21 03:15:28 blueness Exp $ |
1185 |
+ |
1186 |
+command="/bin/busybox ntpd" |
1187 |
+command_args="${NTPD_OPTS}" |
1188 |
+pidfile="/var/run/ntpd.pid" |
1189 |
+ |
1190 |
+depend() { |
1191 |
+ use net dns logger |
1192 |
+ after ntp-client |
1193 |
+} |
1194 |
|
1195 |
diff --git a/sys-apps/busybox/files/syslogd.confd b/sys-apps/busybox/files/syslogd.confd |
1196 |
new file mode 100644 |
1197 |
index 0000000..7df6885 |
1198 |
--- /dev/null |
1199 |
+++ b/sys-apps/busybox/files/syslogd.confd |
1200 |
@@ -0,0 +1,9 @@ |
1201 |
+# Config file for /etc/init.d/busybox-sysklogd |
1202 |
+ |
1203 |
+# run "/sbin/syslogd --help" to see all possible options. |
1204 |
+ |
1205 |
+# activate if you need remote logging |
1206 |
+#rc_need="net" |
1207 |
+ |
1208 |
+# Log to shared mem buffer (use logread to read it) |
1209 |
+SYSLOGD_OPTS="-C128" |
1210 |
|
1211 |
diff --git a/sys-apps/busybox/files/syslogd.initd b/sys-apps/busybox/files/syslogd.initd |
1212 |
new file mode 100644 |
1213 |
index 0000000..f14224a |
1214 |
--- /dev/null |
1215 |
+++ b/sys-apps/busybox/files/syslogd.initd |
1216 |
@@ -0,0 +1,13 @@ |
1217 |
+#!/sbin/runscript |
1218 |
+# Copyright 1999-2012 Gentoo Foundation |
1219 |
+# Distributed under the terms of the GNU General Public License v2 |
1220 |
+# $Header: /var/cvsroot/gentoo-x86/sys-apps/busybox/files/syslogd.initd,v 1.2 2012/12/21 03:15:28 blueness Exp $ |
1221 |
+ |
1222 |
+command="/bin/busybox syslogd" |
1223 |
+command_args="${SYSLOGD_OPTS}" |
1224 |
+pidfile="/var/run/syslogd.pid" |
1225 |
+ |
1226 |
+depend() { |
1227 |
+ need clock hostname |
1228 |
+ provide logger |
1229 |
+} |
1230 |
|
1231 |
diff --git a/sys-apps/busybox/files/watchdog.confd b/sys-apps/busybox/files/watchdog.confd |
1232 |
new file mode 100644 |
1233 |
index 0000000..bd6aec0 |
1234 |
--- /dev/null |
1235 |
+++ b/sys-apps/busybox/files/watchdog.confd |
1236 |
@@ -0,0 +1,9 @@ |
1237 |
+# Config file for /etc/init.d/busybox-watchdog |
1238 |
+ |
1239 |
+# run "/sbin/watchdog --help" to see all possible options. |
1240 |
+ |
1241 |
+# Periodically write to watchdog device |
1242 |
+WATCHDOG_OPTS="/dev/watchdog" |
1243 |
+ |
1244 |
+# optionally set the nice-level |
1245 |
+#SSD_NICELEVEL="-20" |
1246 |
|
1247 |
diff --git a/sys-apps/busybox/files/watchdog.initd b/sys-apps/busybox/files/watchdog.initd |
1248 |
new file mode 100644 |
1249 |
index 0000000..214468a |
1250 |
--- /dev/null |
1251 |
+++ b/sys-apps/busybox/files/watchdog.initd |
1252 |
@@ -0,0 +1,8 @@ |
1253 |
+#!/sbin/runscript |
1254 |
+# Copyright 1999-2013 Gentoo Foundation |
1255 |
+# Distributed under the terms of the GNU General Public License v2 |
1256 |
+# $Header: /var/cvsroot/gentoo-x86/sys-apps/busybox/files/watchdog.initd,v 1.3 2013/04/27 07:47:23 vapier Exp $ |
1257 |
+ |
1258 |
+command="/bin/busybox watchdog" |
1259 |
+command_args="${WATCHDOG_OPTS}" |
1260 |
+pidfile="/var/run/watchdog.pid" |
1261 |
|
1262 |
diff --git a/sys-apps/busybox/metadata.xml b/sys-apps/busybox/metadata.xml |
1263 |
new file mode 100644 |
1264 |
index 0000000..72850fb |
1265 |
--- /dev/null |
1266 |
+++ b/sys-apps/busybox/metadata.xml |
1267 |
@@ -0,0 +1,13 @@ |
1268 |
+<?xml version="1.0" encoding="UTF-8"?> |
1269 |
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd"> |
1270 |
+<pkgmetadata> |
1271 |
+<herd>embedded</herd> |
1272 |
+<use> |
1273 |
+<flag name="make-symlinks">Create all the appropriate symlinks in /bin and /sbin.</flag> |
1274 |
+<flag name="math">Enable math support in gawk (requires libm)</flag> |
1275 |
+<flag name="mdev">Create the appropriate symlink in /sbin and install mdev.conf and support files</flag> |
1276 |
+<flag name="sep-usr">Support a separate /usr without needing an initramfs by booting with init=/ginit</flag> |
1277 |
+<flag name="static">Make the system rescue shell (/bin/bb) static so you can recover even when glibc is broken</flag> |
1278 |
+<flag name="systemd">Support systemd</flag> |
1279 |
+</use> |
1280 |
+</pkgmetadata> |