Merge commit 'opendreambox/opendreambox-1.6' into vuplus-1.6
[vuplus_openembedded] / recipes / busybox / busybox_1.01.bb
1 DESCRIPTION = "BusyBox combines tiny versions of many common UNIX utilities into a single \
2 small executable. It provides minimalist replacements for most of the \
3 utilities you usually find in GNU fileutils, shellutils, etc. The utilities \
4 in BusyBox generally have fewer options than their full-featured GNU \
5 cousins; however, the options that are included provide the expected \
6 functionality and behave very much like their GNU counterparts. BusyBox \
7 provides a fairly complete POSIX environment for any small or embedded \
8 system."
9 HOMEPAGE = "http://www.busybox.net"
10 LICENSE = "GPL"
11 SECTION = "base"
12 PRIORITY = "required"
13 PR = "r15"
14
15 SRC_URI = "http://www.busybox.net/downloads/busybox-${PV}.tar.gz \
16            file://udhcppidfile.patch;patch=1 \
17            file://udhcppidfile-breakage.patch;patch=1 \
18            file://add-getkey-applet.patch;patch=1 \
19            file://below.patch;patch=1 \
20            file://dhcp-hostname.patch;patch=1 \
21            file://dhcpretrytime.patch;patch=1 \
22            file://fbset.patch;patch=1 \
23            file://hdparm_M.patch;patch=1 \
24            file://nptl_task.patch;patch=1 \
25            file://ifupdown-spurious-environ.patch;patch=1 \
26            file://iproute-flush-cache.patch;patch=1;pnum=0 \
27            file://mount-all-type.patch;patch=1 \
28            file://readlink.patch;patch=1 \
29            file://rmmod.patch;patch=1 \
30            file://udhcpscript.patch;patch=1 \
31            file://zeroconf.patch;patch=1 \
32            file://thumb-bsdlabel.patch;patch=1 \
33            file://glibc2.4-icmp6.patch;patch=1 \
34            file://uclibc_posix.patch;patch=1 \
35            file://keymap_endianess.patch;patch=1 \
36            file://defconfig \
37            file://busybox-cron \
38            file://busybox-httpd \
39            file://busybox-udhcpd \
40            file://syslog \
41            file://hwclock.sh \
42            file://default.script \
43            file://syslog.conf \
44            file://mount.busybox \
45            file://umount.busybox"
46 SRC_URI_append_slugos += " file://sysctl.conf "
47 SRC_URI_append_opendreambox += " file://default_gw.patch;patch=1;pnum=1"
48
49 S = "${WORKDIR}/busybox-${PV}"
50
51 export EXTRA_CFLAGS = "${CFLAGS}"
52 EXTRA_OEMAKE_append = " CROSS=${HOST_PREFIX}"
53 PACKAGES =+ "${PN}-httpd ${PN}-udhcpd"
54
55 FILES_${PN}-httpd = "${sysconfdir}/init.d/busybox-httpd /srv/www"
56 FILES_${PN}-udhcpd = "${sysconfdir}/init.d/busybox-udhcpd"
57
58 FILES_${PN} += " ${datadir}/udhcpc"
59
60 INITSCRIPT_PACKAGES = "${PN} ${PN}-httpd ${PN}-udhcpd"
61 INITSCRIPT_NAME_${PN}-httpd = "busybox-httpd"
62 INITSCRIPT_NAME_${PN}-udhcpd = "busybox-udhcpd" 
63 INITSCRIPT_NAME_${PN} = "syslog"
64 CONFFILES_${PN} = "${sysconfdir}/syslog.conf"
65
66 # This disables the syslog startup links in slugos (see slugos-init)
67 INITSCRIPT_PARAMS_${PN}_slugos = "start 20 ."
68
69 inherit cml1 update-rc.d
70
71 do_configure () {
72         install -m 0644 ${WORKDIR}/defconfig ${S}/.config
73         cml1_do_configure
74 }
75
76 do_compile () {
77         unset CFLAGS
78         base_do_compile
79 }
80
81 do_install () {
82         install -d ${D}${sysconfdir}/init.d
83         oe_runmake 'PREFIX=${D}' install
84
85         # Move everything to /busybox (not supposed to end up in any package)
86         install -d ${D}/busybox
87         mv ${D}${base_bindir} ${D}${base_sbindir} ${D}${prefix} ${D}/busybox/
88         # Move the busybox binary back to /bin
89         install -d ${D}${base_bindir}
90         mv ${D}/busybox${base_bindir}/busybox ${D}${base_bindir}/
91         # Move back the sh symlink
92         test -f ${D}/busybox${base_bindir}/sh && mv ${D}/busybox${base_bindir}/sh ${D}${base_bindir}/
93
94         install -m 0755 ${WORKDIR}/syslog ${D}${sysconfdir}/init.d/
95         install -m 644 ${WORKDIR}/syslog.conf ${D}${sysconfdir}/
96         if grep "CONFIG_CROND=y" ${WORKDIR}/defconfig; then 
97                 # Move crond back to /usr/sbin/crond
98                 install -d ${D}${sbindir}
99                 mv ${D}/busybox${sbindir}/crond ${D}${sbindir}/
100
101                 install -m 0755 ${WORKDIR}/busybox-cron ${D}${sysconfdir}/init.d/
102         fi
103         if grep "CONFIG_HTTPD=y" ${WORKDIR}/defconfig; then 
104                 # Move httpd back to /usr/sbin/httpd
105                 install -d ${D}${sbindir}
106                 mv ${D}/busybox${sbindir}/httpd ${D}${sbindir}/
107                                         
108                 install -m 0755 ${WORKDIR}/busybox-httpd ${D}${sysconfdir}/init.d/
109                 install -d ${D}/srv/www
110         fi
111         if grep "CONFIG_UDHCPD=y" ${WORKDIR}/defconfig; then 
112                 # Move udhcpd back to /usr/sbin/udhcpd
113                 install -d ${D}${sbindir}
114                 mv ${D}/busybox${sbindir}/udhcpd ${D}${sbindir}/
115                                         
116                 install -m 0755 ${WORKDIR}/busybox-udhcpd ${D}${sysconfdir}/init.d/
117         fi
118         if grep "CONFIG_HWCLOCK=y" ${WORKDIR}/defconfig; then 
119                 # Move hwclock back to /sbin/hwclock
120                 install -d ${D}${base_sbindir}
121                 mv ${D}/busybox${base_sbindir}/hwclock ${D}${base_sbindir}/
122                                         
123                 install -m 0755 ${WORKDIR}/hwclock.sh ${D}${sysconfdir}/init.d/
124         fi
125         if grep "CONFIG_UDHCPC=y" ${WORKDIR}/defconfig; then 
126                 # Move dhcpc back to /usr/sbin/udhcpc
127                 install -d ${D}${base_sbindir}
128                 mv ${D}/busybox${base_sbindir}/udhcpc ${D}${base_sbindir}/
129
130                 install -d ${D}${sysconfdir}/udhcpc.d
131                 install -d ${D}${datadir}/udhcpc
132                 install -m 0755 ${S}/examples/udhcp/simple.script ${D}${sysconfdir}/udhcpc.d/50default
133                 install -m 0755 ${WORKDIR}/default.script ${D}${datadir}/udhcpc/default.script
134         fi
135
136         install -m 0644 ${S}/busybox.links ${D}${sysconfdir}
137 }
138
139 do_install_append_slugos() {
140         install -m 0644 ${WORKDIR}/sysctl.conf ${D}${sysconfdir}
141 }
142
143 pkg_postinst_${PN} () {
144         # If we are not making an image we create links for the utilities that doesn't exist
145         # so the update-alternatives script will get the utilities it needs
146         # (update-alternatives have no problem replacing links later anyway)
147         test -n 2> /dev/null || alias test='busybox test'
148         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
149         
150         # This adds the links, remember that this has to work when building an image too, hence the $D
151         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
152 }
153
154 pkg_prerm_${PN} () {
155         # This is so you can make busybox commit suicide - removing busybox with no other packages
156         # providing its files, this will make update-alternatives work, but the update-rc.d part
157         # for syslog, httpd and/or udhcpd will fail if there is no other package providing sh
158         tmpdir=`mktemp -d /tmp/busyboxrm-XXXXXX`
159         ln -s /bin/busybox $tmpdir/[
160         ln -s /bin/busybox $tmpdir/test
161         ln -s /bin/busybox $tmpdir/head
162         ln -s /bin/busybox $tmpdir/sh
163         ln -s /bin/busybox $tmpdir/basename
164         ln -s /bin/busybox $tmpdir/echo
165         ln -s /bin/busybox $tmpdir/mv
166         ln -s /bin/busybox $tmpdir/ln
167         ln -s /bin/busybox $tmpdir/dirname
168         ln -s /bin/busybox $tmpdir/rm
169         ln -s /bin/busybox $tmpdir/sed
170         ln -s /bin/busybox $tmpdir/sort
171         export PATH=$PATH:$tmpdir
172         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
173 }