summaryrefslogtreecommitdiffstats
path: root/meta/recipes-core/busybox/busybox.inc
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-core/busybox/busybox.inc')
-rw-r--r--meta/recipes-core/busybox/busybox.inc140
1 files changed, 140 insertions, 0 deletions
diff --git a/meta/recipes-core/busybox/busybox.inc b/meta/recipes-core/busybox/busybox.inc
new file mode 100644
index 0000000000..8c258135c8
--- /dev/null
+++ b/meta/recipes-core/busybox/busybox.inc
@@ -0,0 +1,140 @@
1DESCRIPTION = "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."
2HOMEPAGE = "http://www.busybox.net"
3BUGTRACKER = "https://bugs.busybox.net/"
4# bzip2 applet in busybox is based on lightly-modified bzip2 source
5LICENSE = "GPLv2+ & bzip2"
6SECTION = "base"
7PRIORITY = "required"
8
9export EXTRA_CFLAGS = "${CFLAGS}"
10PACKAGES =+ "${PN}-httpd ${PN}-udhcpd"
11
12FILES_${PN}-httpd = "${sysconfdir}/init.d/busybox-httpd /srv/www"
13FILES_${PN}-udhcpd = "${sysconfdir}/init.d/busybox-udhcpd"
14
15FILES_${PN} += "${datadir}/udhcpc"
16
17INITSCRIPT_PACKAGES = "${PN} ${PN}-httpd ${PN}-udhcpd"
18INITSCRIPT_NAME_${PN}-httpd = "busybox-httpd"
19INITSCRIPT_NAME_${PN}-udhcpd = "busybox-udhcpd"
20INITSCRIPT_NAME_${PN} = "syslog"
21CONFFILES_${PN} = "${sysconfdir}/syslog.conf"
22
23# This disables the syslog startup links in slugos (see slugos-init)
24INITSCRIPT_PARAMS_${PN}_slugos = "start 20 ."
25
26inherit cml1 update-rc.d
27
28do_configure () {
29 install -m 0644 ${WORKDIR}/defconfig ${S}/.config
30 cml1_do_configure
31}
32
33do_compile() {
34 unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS
35 base_do_compile
36}
37
38do_install () {
39 unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS
40 install -d ${D}${sysconfdir}/init.d
41 oe_runmake "PREFIX=${D}" install
42 cp -pPR ${S}/_install/* ${D}/
43
44 # Move everything to /busybox (not supposed to end up in any package)
45 install -d ${D}/busybox
46 ls ${D} -R
47
48 cp -dPr ${D}${base_bindir} ${D}${base_sbindir} ${D}${prefix} ${D}/busybox/
49 # Move the busybox binary back to /bin
50 install -d ${D}${base_bindir}
51 mv ${D}/busybox${base_bindir}/busybox ${D}${base_bindir}/
52 # Move back the sh symlink
53 test -h ${D}/busybox${base_bindir}/sh && mv ${D}/busybox${base_bindir}/sh ${D}${base_bindir}/
54
55 install -m 0755 ${WORKDIR}/syslog ${D}${sysconfdir}/init.d/
56 install -m 644 ${WORKDIR}/syslog.conf ${D}${sysconfdir}/
57 if grep "CONFIG_CROND=y" ${WORKDIR}/defconfig; then
58 # Move crond back to /usr/sbin/crond
59 install -d ${D}${sbindir}
60 mv ${D}/busybox${sbindir}/crond ${D}${sbindir}/
61
62 install -m 0755 ${WORKDIR}/busybox-cron ${D}${sysconfdir}/init.d/
63 fi
64 if grep "CONFIG_HTTPD=y" ${WORKDIR}/defconfig; then
65 # Move httpd back to /usr/sbin/httpd
66 install -d ${D}${sbindir}
67 mv ${D}/busybox${sbindir}/httpd ${D}${sbindir}/
68
69 install -m 0755 ${WORKDIR}/busybox-httpd ${D}${sysconfdir}/init.d/
70 install -d ${D}/srv/www
71 fi
72 if grep "CONFIG_UDHCPD=y" ${WORKDIR}/defconfig; then
73 # Move udhcpd back to /usr/sbin/udhcpd
74 install -d ${D}${sbindir}
75 mv ${D}/busybox${sbindir}/udhcpd ${D}${sbindir}/
76
77 install -m 0755 ${WORKDIR}/busybox-udhcpd ${D}${sysconfdir}/init.d/
78 fi
79 if grep "CONFIG_HWCLOCK=y" ${WORKDIR}/defconfig; then
80 # Move hwclock back to /sbin/hwclock
81 install -d ${D}${base_sbindir}
82 mv ${D}/busybox${base_sbindir}/hwclock ${D}${base_sbindir}/
83
84 install -m 0755 ${WORKDIR}/hwclock.sh ${D}${sysconfdir}/init.d/
85 fi
86 if grep "CONFIG_UDHCPC=y" ${WORKDIR}/defconfig; then
87 # Move dhcpc back to /usr/sbin/udhcpc
88 install -d ${D}${base_sbindir}
89 mv ${D}/busybox${base_sbindir}/udhcpc ${D}${base_sbindir}/
90
91 install -d ${D}${sysconfdir}/udhcpc.d
92 install -d ${D}${datadir}/udhcpc
93 install -m 0755 ${S}/examples/udhcp/simple.script ${D}${sysconfdir}/udhcpc.d/50default
94 install -m 0755 ${WORKDIR}/default.script ${D}${datadir}/udhcpc/default.script
95 fi
96
97 install -m 0644 ${S}/busybox.links ${D}${sysconfdir}
98}
99
100pkg_postinst_${PN} () {
101 # If we are not making an image we create links for the utilities that doesn't exist
102 # so the update-alternatives script will get the utilities it needs
103 # (update-alternatives have no problem replacing links later anyway)
104 test -n 2> /dev/null || alias test='busybox test'
105 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
106
107 # This adds the links, remember that this has to work when building an image too, hence the $D
108 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
109}
110
111pkg_prerm_${PN} () {
112 # This is so you can make busybox commit suicide - removing busybox with no other packages
113 # providing its files, this will make update-alternatives work, but the update-rc.d part
114 # for syslog, httpd and/or udhcpd will fail if there is no other package providing sh
115 tmpdir=`mktemp -d /tmp/busyboxrm-XXXXXX`
116 ln -s /bin/busybox $tmpdir/[
117 ln -s /bin/busybox $tmpdir/test
118 ln -s /bin/busybox $tmpdir/head
119 ln -s /bin/busybox $tmpdir/sh
120 ln -s /bin/busybox $tmpdir/basename
121 ln -s /bin/busybox $tmpdir/echo
122 ln -s /bin/busybox $tmpdir/mv
123 ln -s /bin/busybox $tmpdir/ln
124 ln -s /bin/busybox $tmpdir/dirname
125 ln -s /bin/busybox $tmpdir/rm
126 ln -s /bin/busybox $tmpdir/sed
127 ln -s /bin/busybox $tmpdir/sort
128 export PATH=$PATH:$tmpdir
129
130 while read link
131 do
132 case "$link" in
133 /*/*/*) to="../../bin/busybox";;
134 /bin/*) to="busybox";;
135 /*/*) to="../bin/busybox";;
136 esac
137 bn=`basename $link`
138 sh /usr/bin/update-alternatives --remove $bn $to
139 done </etc/busybox.links
140}