2010-09-27 14:44:05 +00:00
SUMMARY = " Tiny versions of many common UNIX utilities in a single small executable. "
2010-06-30 06:46:52 +00:00
DESCRIPTION = " BusyBox combines tiny versions of many common UNIX utilities into a single small executable. It provides minimalist replacements for most of the utilities you usually find in GNU fileutils, shellutils, etc. The utilities in BusyBox generally have fewer options than their full-featured GNU cousins; however, the options that are included provide the expected functionality and behave very much like their GNU counterparts. BusyBox provides a fairly complete POSIX environment for any small or embedded system. "
2007-10-22 14:56:31 +00:00
HOMEPAGE = " http://www.busybox.net "
2010-06-30 06:46:52 +00:00
BUGTRACKER = " https://bugs.busybox.net/ "
2010-11-17 02:51:45 +00:00
2010-06-30 06:46:52 +00:00
# bzip2 applet in busybox is based on lightly-modified bzip2 source
2010-11-17 02:51:45 +00:00
# the GPL is version 2 only
2011-12-03 23:48:29 +00:00
# bzip2 is not a bzip2 license (no such thing)
LICENSE = " GPLv2 & BSD-4-Clause "
2010-11-17 02:51:45 +00:00
LIC_FILES_CHKSUM = " file://LICENSE;md5=de10de48642ab74318e893a61105afbb "
2007-10-22 14:56:31 +00:00
SECTION = " base "
export EXTRA_CFLAGS = " ${ CFLAGS } "
2011-07-13 17:04:07 +00:00
export EXTRA_LDFLAGS = " ${ LDFLAGS } "
2011-05-02 19:09:16 +00:00
PACKAGES =+ " ${ PN } -httpd ${ PN } -udhcpd ${ PN } -udhcpc ${ PN } -syslog ${ PN } -mdev "
2007-10-22 14:56:31 +00:00
FILES_ $ { PN } - httpd = " ${ sysconfdir } /init.d/busybox-httpd /srv/www "
2012-01-02 21:50:32 +00:00
FILES_ $ { PN } - syslog = " ${ sysconfdir } /init.d/syslog* ${ sysconfdir } /syslog-startup.conf* "
2011-05-02 19:09:16 +00:00
FILES_ $ { PN } - mdev = " ${ sysconfdir } /init.d/mdev ${ sysconfdir } /mdev.conf "
2007-10-22 14:56:31 +00:00
FILES_ $ { PN } - udhcpd = " ${ sysconfdir } /init.d/busybox-udhcpd "
2011-02-11 20:18:16 +00:00
FILES_ $ { PN } - udhcpc = " ${ sysconfdir } /udhcpc.d ${ datadir } /udhcpc ${ sysconfdir } /init.d/busybox-udhcpc "
2007-10-22 14:56:31 +00:00
2011-05-02 19:09:16 +00:00
INITSCRIPT_PACKAGES = " ${ PN } -httpd ${ PN } -syslog ${ PN } -udhcpd ${ PN } -udhcpc ${ PN } -mdev "
2007-10-22 14:56:31 +00:00
INITSCRIPT_NAME_ $ { PN } - httpd = " busybox-httpd "
2011-02-11 20:18:16 +00:00
INITSCRIPT_NAME_ $ { PN } - syslog = " syslog "
2011-05-02 19:09:16 +00:00
INITSCRIPT_NAME_ $ { PN } - mdev = " mdev "
INITSCRIPT_PARAMS_ $ { PN } - mdev = " start 06 S . "
2007-10-22 14:56:31 +00:00
INITSCRIPT_NAME_ $ { PN } - udhcpd = " busybox-udhcpd "
2011-02-11 20:18:16 +00:00
INITSCRIPT_NAME_ $ { PN } - udhcpc = " busybox-udhcpc "
2012-01-02 21:50:32 +00:00
CONFFILES_ $ { PN } - syslog = " ${ sysconfdir}/syslog-startup.conf.${BPN } "
2011-05-02 19:09:16 +00:00
CONFFILES_ $ { PN } - mdev = " ${ sysconfdir } /mdev.conf "
2011-02-11 20:18:16 +00:00
RRECOMMENDS_ $ { PN } = " ${ PN } -syslog ${ PN } -udhcpc "
2007-10-22 14:56:31 +00:00
inherit cml1 update - rc . d
2011-06-09 15:59:21 +00:00
# internal helper
def busybox_cfg ( feature , features , tokens , cnf , rem ) :
if type ( tokens ) == type ( " " ) :
tokens = [ tokens ]
rem . extend ([ '/^[# ]*' + token + '[ =]/d' for token in tokens ])
if type ( features ) == type ([]) and feature in features :
cnf . extend ([ token + '=y' for token in tokens ])
else :
cnf . extend ([ '# ' + token + ' is not set' for token in tokens ])
2012-01-17 11:28:31 +00:00
# Map distro features to config settings
2011-06-09 15:59:21 +00:00
def features_to_busybox_settings ( d ) :
cnf , rem = ([], [])
Convert to use direct access to the data store (instead of bb.data.*Var*())
This is the result of running the following over the metadata:
sed \
-e 's:bb.data.\(setVar([^,()]*,[^,()]*\), *\([^ )]*\) *):\2.\1):g' \
-e 's:bb.data.\(setVarFlag([^,()]*,[^,()]*,[^,()]*\), *\([^) ]*\) *):\2.\1):g' \
-e 's:bb.data.\(getVar([^,()]*\), *\([^(), ]*\) *,\([^)]*\)):\2.\1,\3):g' \
-e 's:bb.data.\(getVarFlag([^,()]*,[^,()]*\), *\([^(), ]*\) *,\([^)]*\)):\2.\1,\3):g' \
-e 's:bb.data.\(getVarFlag([^,()]*,[^,()]*\), *\([^() ]*\) *):\2.\1):g' \
-e 's:bb.data.\(getVar([^,()]*\), *\([^) ]*\) *):\2.\1):g' \
-i `grep -ril bb.data *`
(From OE-Core rev: b22831fd63164c4db9c0b72934d7d734a6585251)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2011-11-09 15:00:01 +00:00
distro_features = d . getVar ( 'DISTRO_FEATURES' , True ) . split ()
2011-06-09 15:59:21 +00:00
busybox_cfg ( 'ipv6' , distro_features , 'CONFIG_FEATURE_IPV6' , cnf , rem )
busybox_cfg ( 'largefile' , distro_features , 'CONFIG_LFS' , cnf , rem )
busybox_cfg ( 'largefile' , distro_features , 'CONFIG_FDISK_SUPPORT_LARGE_DISKS' , cnf , rem )
busybox_cfg ( 'nls' , distro_features , 'CONFIG_LOCALE_SUPPORT' , cnf , rem )
busybox_cfg ( 'ipv4' , distro_features , 'CONFIG_FEATURE_IFUPDOWN_IPV4' , cnf , rem )
busybox_cfg ( 'ipv6' , distro_features , 'CONFIG_FEATURE_IFUPDOWN_IPV6' , cnf , rem )
return " \n " . join ( cnf ), " \n " . join ( rem )
# X, Y = ${@features_to_uclibc_settings(d)}
# unfortunately doesn't seem to work with bitbake, workaround:
def features_to_busybox_conf ( d ) :
cnf , rem = features_to_busybox_settings ( d )
return cnf
def features_to_busybox_del ( d ) :
cnf , rem = features_to_busybox_settings ( d )
return rem
configmangle = ' / CROSS_COMPILER_PREFIX / d ; \
/ CONFIG_EXTRA_CFLAGS / d ; \
'
OE_FEATURES := " ${ @features_to_busybox_conf(d) } "
OE_DEL := " ${ @features_to_busybox_del(d) } "
2012-02-26 21:53:02 +00:00
DO_IPv4 := " $ { @base_contains('DISTRO_FEATURES', 'ipv4', 1, 0, d)} "
DO_IPv6 := " $ { @base_contains('DISTRO_FEATURES', 'ipv6', 1, 0, d)} "
2011-06-09 15:59:21 +00:00
python () {
if " ${ OE_DEL } " :
Convert to use direct access to the data store (instead of bb.data.*Var*())
This is the result of running the following over the metadata:
sed \
-e 's:bb.data.\(setVar([^,()]*,[^,()]*\), *\([^ )]*\) *):\2.\1):g' \
-e 's:bb.data.\(setVarFlag([^,()]*,[^,()]*,[^,()]*\), *\([^) ]*\) *):\2.\1):g' \
-e 's:bb.data.\(getVar([^,()]*\), *\([^(), ]*\) *,\([^)]*\)):\2.\1,\3):g' \
-e 's:bb.data.\(getVarFlag([^,()]*,[^,()]*\), *\([^(), ]*\) *,\([^)]*\)):\2.\1,\3):g' \
-e 's:bb.data.\(getVarFlag([^,()]*,[^,()]*\), *\([^() ]*\) *):\2.\1):g' \
-e 's:bb.data.\(getVar([^,()]*\), *\([^) ]*\) *):\2.\1):g' \
-i `grep -ril bb.data *`
(From OE-Core rev: b22831fd63164c4db9c0b72934d7d734a6585251)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2011-11-09 15:00:01 +00:00
d . setVar ( 'configmangle_append' , " ${ OE_DEL } " + " \n " )
2011-06-09 15:59:21 +00:00
if " ${ OE_FEATURES } " :
2011-11-25 14:25:16 +00:00
d . setVar ( 'configmangle_append' ,
2011-06-09 15:59:21 +00:00
" /^### DISTRO FEATURES $ /a \\ \n %s \n \n " %
2011-11-25 14:25:16 +00:00
( " \\ n " . join (( bb . data . expand ( " ${ OE_FEATURES } " , d ) . split ( " \n " )))))
d . setVar ( 'configmangle_append' ,
2011-06-09 15:59:21 +00:00
" /^### CROSS $ /a \\ \n %s \n " %
( " \\ n " . join ([ " CONFIG_CROSS_COMPILER_PREFIX= \" ${ TARGET_PREFIX } \" " ,
" CONFIG_EXTRA_CFLAGS= \" ${ CFLAGS } \" "
])
2011-11-25 14:25:16 +00:00
))
2011-06-09 15:59:21 +00:00
}
do_prepare_config () {
sed - e 's#@DATADIR@#${datadir}#g' \
< $ { WORKDIR } / defconfig > $ { S } /. config
sed - i - e '/CONFIG_STATIC/d' . config
echo " # CONFIG_STATIC is not set " >> . config
for i in 'CROSS' 'DISTRO FEATURES' ; do echo " ### $i " ; done >> \
$ { S } /. config
sed - i - e '${configmangle}' $ { S } /. config
if test $ { DO_IPv4 } - eq 0 && test $ { DO_IPv6 } - eq 0 ; then
# disable networking applets
mv $ { S } /. config $ { S } /. config . oe - tmp
awk ' BEGIN { net = 0 }
/^ # Networking Utilities/{net=1}
/^ #$/{if(net){net=net+1}}
{ if ( net == 2 && $ 0 !~ /^ #/&&$1){print("# "$1" is not set")}else{print}}' \
$ { S } /. config . oe - tmp > $ { S } /. config
fi
}
2010-05-25 14:36:14 +00:00
do_configure () {
2011-06-09 15:59:21 +00:00
do_prepare_config
2010-05-25 14:36:14 +00:00
cml1_do_configure
}
2008-03-03 17:51:29 +00:00
do_compile () {
unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS
2011-06-03 22:08:25 +00:00
oe_runmake busybox_unstripped
cp busybox_unstripped busybox
2007-10-22 14:56:31 +00:00
}
2008-03-03 17:51:29 +00:00
do_install () {
2011-05-26 10:08:01 +00:00
oe_runmake busybox . links
if [ " ${ prefix } " != " /usr " ]; then
sed " s:^/usr/: ${ prefix } /: " busybox . links > busybox . links . new
mv busybox . links . new busybox . links
fi
if [ " ${ base_sbindir } " != " /sbin " ]; then
sed " s:^/sbin/: ${ base_sbindir } /: " busybox . links > busybox . links . new
mv busybox . links . new busybox . links
fi
2008-03-03 17:51:29 +00:00
2011-05-26 10:08:01 +00:00
install - d $ { D } $ { sysconfdir } / init . d
2008-03-03 17:51:29 +00:00
2011-05-26 10:08:01 +00:00
if ! grep - q " CONFIG_FEATURE_INDIVIDUAL=y " $ { WORKDIR } / defconfig ; then
# Install /bin/busybox, and the /bin/sh link so the postinst script
# can run. Let update-alternatives handle the rest.
install - d $ { D } $ { base_bindir }
if grep - q " CONFIG_FEATURE_SUID=y " $ { WORKDIR } / defconfig ; then
install - m 4755 $ { S } / busybox $ { D } $ { base_bindir }
else
install - m 0755 $ { S } / busybox $ { D } $ { base_bindir }
fi
ln - sf busybox $ { D } $ { base_bindir } / sh
else
install - d $ { D } $ { base_bindir } $ { D } $ { base_sbindir }
install - d $ { D } $ { libdir } $ { D } $ { bindir } $ { D } $ { sbindir }
cat busybox . links | while read FILE ; do
NAME = `basename "$FILE"`
2011-08-17 08:51:52 +00:00
install - m 0755 " 0_lib/ $NAME " " ${ D}$FILE.${BPN } "
2011-05-26 10:08:01 +00:00
done
# add suid bit where needed
for i in `grep -E "APPLET.*_BB_SUID_((MAYBE|REQUIRE))" include/applets.h | grep -v _BB_SUID_DROP | cut -f 3 -d '(' | cut -f 1 -d ','` ; do
2011-08-17 08:51:52 +00:00
find $ { D } - name $i . $ { BPN } - exec chmod a + s {} \ ;
2011-05-26 10:08:01 +00:00
done
install - m 0755 0_ lib / libbusybox . so . $ { PV } $ { D } $ { libdir } / libbusybox . so . $ { PV }
2011-08-17 08:51:52 +00:00
ln - sf sh . $ { BPN } $ { D } $ { base_bindir } / sh
ln - sf ln . $ { BPN } $ { D } $ { base_bindir } / ln
ln - sf test . $ { BPN } $ { D } $ { bindir } / test
if [ - f $ { D } / linuxrc . $ { BPN } ]; then
mv $ { D } / linuxrc . $ { BPN } $ { D } / linuxrc
2011-05-26 10:08:01 +00:00
fi
fi
2008-03-03 17:51:29 +00:00
2011-05-26 10:08:01 +00:00
if grep - q " CONFIG_SYSLOGD=y " $ { WORKDIR } / defconfig ; then
2011-08-17 08:51:52 +00:00
install - m 0755 $ { WORKDIR } / syslog $ { D } $ { sysconfdir } / init . d / syslog . $ { BPN }
2012-01-02 21:50:32 +00:00
install - m 644 $ { WORKDIR } / syslog - startup . conf $ { D } $ { sysconfdir } / syslog - startup . conf . $ { BPN }
2011-05-26 10:08:01 +00:00
fi
2008-03-03 17:51:29 +00:00
if grep " CONFIG_CROND=y " $ { WORKDIR } / defconfig ; then
install - m 0755 $ { WORKDIR } / busybox - cron $ { D } $ { sysconfdir } / init . d /
fi
if grep " CONFIG_HTTPD=y " $ { WORKDIR } / defconfig ; then
install - m 0755 $ { WORKDIR } / busybox - httpd $ { D } $ { sysconfdir } / init . d /
install - d $ { D } / srv / www
fi
2010-07-06 07:33:31 +00:00
if grep " CONFIG_UDHCPD=y " $ { WORKDIR } / defconfig ; then
2008-03-03 17:51:29 +00:00
install - m 0755 $ { WORKDIR } / busybox - udhcpd $ { D } $ { sysconfdir } / init . d /
fi
if grep " CONFIG_HWCLOCK=y " $ { WORKDIR } / defconfig ; then
install - m 0755 $ { WORKDIR } / hwclock . sh $ { D } $ { sysconfdir } / init . d /
fi
2010-07-06 07:33:31 +00:00
if grep " CONFIG_UDHCPC=y " $ { WORKDIR } / defconfig ; then
2008-03-03 17:51:29 +00:00
install - d $ { D } $ { sysconfdir } / udhcpc . d
install - d $ { D } $ { datadir } / udhcpc
2011-05-26 10:08:01 +00:00
install - m 0755 $ { WORKDIR } / simple . script $ { D } $ { sysconfdir } / udhcpc . d / 50 default
2008-03-03 17:51:29 +00:00
install - m 0755 $ { WORKDIR } / default . script $ { D } $ { datadir } / udhcpc / default . script
2011-02-04 01:29:50 +00:00
install - m 0755 $ { WORKDIR } / busybox - udhcpc $ { D } $ { sysconfdir } / init . d /
2008-03-03 17:51:29 +00:00
fi
2011-05-26 10:08:01 +00:00
if grep " CONFIG_INETD=y " $ { WORKDIR } / defconfig ; then
2011-08-17 08:51:52 +00:00
install - m 0755 $ { WORKDIR } / inetd $ { D } $ { sysconfdir } / init . d / inetd . $ { BPN }
2011-05-26 10:08:01 +00:00
install - m 0644 $ { WORKDIR } / inetd . conf $ { D } $ { sysconfdir } /
fi
if grep " CONFIG_MDEV=y " $ { WORKDIR } / defconfig ; then
install - m 0755 $ { WORKDIR } / mdev $ { D } $ { sysconfdir } / init . d / mdev
if grep " CONFIG_FEATURE_MDEV_CONF=y " $ { WORKDIR } / defconfig ; then
install - m 644 $ { WORKDIR } / mdev . conf $ { D } $ { sysconfdir } / mdev . conf
fi
2011-05-02 19:09:16 +00:00
fi
2008-03-03 17:51:29 +00:00
install - m 0644 $ { S } / busybox . links $ { D } $ { sysconfdir }
}
2011-09-19 19:53:02 +00:00
python package_do_filedeps_append () {
# We need to load the full set of busybox provides from the /etc/busybox.links
# The pkg_postinst_ is what creates the actual links
pkg = d . getVar ( 'PN' , True )
f_busybox = " /bin/busybox "
f_busybox_links = " /etc/busybox.links "
requires_files = []
provides_files = []
# Load/backup original set
filerprovides = d . getVar ( 'FILERPROVIDES_%s_%s' % ( f_busybox , pkg ), True ) or " "
2012-02-10 00:10:38 +00:00
dep_pipe = os . popen ( 'sed -e "s,^,%s/%s%s Provides: ," %s/%s%s' % ( pkgdest , pkg , f_busybox , pkgdest , pkg , f_busybox_links ))
2011-09-19 19:53:02 +00:00
2012-02-10 00:10:38 +00:00
process_deps ( dep_pipe , pkg , provides_files , requires_files )
2011-09-19 19:53:02 +00:00
# Add the new set
filerprovides += d . getVar ( 'FILERPROVIDES_%s_%s' % ( f_busybox , pkg ), True ) or " "
# Make sure there is an entry for this item in the FILERPROVIDESFLIST...
filerprovidesflist = ( d . getVar ( 'FILERPROVIDESFLIST_%s' % pkg , True ) or " " ) . split ()
for file in provides_files :
if file not in filerprovidesflist :
filerprovidesflist . append ( file )
d . setVar ( 'FILERPROVIDESFLIST_%s' % pkg , " " . join ( filerprovidesflist ))
# Store the new provides
d . setVar ( 'FILERPROVIDES_%s_%s' % ( f_busybox , pkg ), filerprovides )
}
2007-10-22 14:56:31 +00:00
pkg_postinst_ $ { PN } () {
# If we are not making an image we create links for the utilities that doesn't exist
# so the update-alternatives script will get the utilities it needs
# (update-alternatives have no problem replacing links later anyway)
test - n 2 > / dev / null || alias test = 'busybox test'
if test " x $D " = " x " ; then while read link ; do if test ! - h " $link " ; then case " $link " in /*/*/ * ) to = " ../../bin/busybox " ;; / bin /*) to="busybox";; /*/ * ) to = " ../bin/busybox " ;; esac ; busybox ln - s $to $link ; fi ; done </ etc / busybox . links ; fi
# This adds the links, remember that this has to work when building an image too, hence the $D
while read link ; do case " $link " in /*/*/ * ) to = " ../../bin/busybox " ;; / bin /*) to="busybox";; /*/ * ) to = " ../bin/busybox " ;; esac ; bn = `basename $link` ; update - alternatives -- install $link $bn $to 50 ; done < $D / etc / busybox . links
2011-02-11 20:18:16 +00:00
}
2010-10-19 07:15:17 +00:00
2011-02-11 20:18:16 +00:00
pkg_postinst_ $ { PN } - syslog () {
2011-08-17 08:51:52 +00:00
update - alternatives -- install $ { sysconfdir } / init . d / syslog syslog - init syslog . $ { BPN } 50
2012-01-02 21:50:32 +00:00
update - alternatives -- install $ { sysconfdir } / syslog - startup . conf syslog - startup - conf syslog - startup . conf . $ { BPN } 50
2007-10-22 14:56:31 +00:00
}
2008-03-03 17:51:29 +00:00
pkg_prerm_ $ { PN } () {
# This is so you can make busybox commit suicide - removing busybox with no other packages
# providing its files, this will make update-alternatives work, but the update-rc.d part
# for syslog, httpd and/or udhcpd will fail if there is no other package providing sh
tmpdir = `mktemp -d /tmp/busyboxrm-XXXXXX`
ln - s / bin / busybox $tmpdir / [
ln - s / bin / busybox $tmpdir / test
ln - s / bin / busybox $tmpdir / head
ln - s / bin / busybox $tmpdir / sh
ln - s / bin / busybox $tmpdir / basename
ln - s / bin / busybox $tmpdir / echo
ln - s / bin / busybox $tmpdir / mv
ln - s / bin / busybox $tmpdir / ln
ln - s / bin / busybox $tmpdir / dirname
ln - s / bin / busybox $tmpdir / rm
ln - s / bin / busybox $tmpdir / sed
ln - s / bin / busybox $tmpdir / sort
2011-11-09 11:33:41 +00:00
ln - s / bin / busybox $tmpdir / grep
2008-03-03 17:51:29 +00:00
export PATH = $PATH : $tmpdir
while read link
do
case " $link " in
/*/*/ * ) to = " ../../bin/busybox " ;;
/ bin /* ) to = " busybox " ;;
/*/* ) to = " ../bin/busybox " ;;
esac
bn = `basename $link`
sh / usr / bin / update - alternatives -- remove $bn $to
done </ etc / busybox . links
2011-02-11 20:18:16 +00:00
}
2010-10-19 07:15:17 +00:00
2011-02-11 20:18:16 +00:00
pkg_prerm_ $ { PN } - syslog () {
2010-10-19 07:15:17 +00:00
# remove syslog
if test " x $D " = " x " ; then
if test " $ 1 " = " upgrade " - o " $ 1 " = " remove " ; then
/ etc / init . d / syslog stop
fi
fi
2011-08-17 08:51:52 +00:00
update - alternatives -- remove syslog - init syslog . $ { BPN }
2012-01-02 21:50:32 +00:00
update - alternatives -- remove syslog - startup - conf syslog - startup . conf . $ { BPN }
2008-03-03 17:51:29 +00:00
}