Merge branch 'org.openembedded.dev' of git@git.openembedded.net:openembedded into...
[vuplus_openembedded] / packages / busybox / busybox_1.7.2.bb
1 require busybox.inc
2 PR = "r11"
3
4 SRC_URI = "http://www.busybox.net/downloads/busybox-${PV}.tar.gz \
5            file://busybox-cron \
6            file://busybox-httpd \
7            file://busybox-udhcpd \
8            file://default.script \
9            file://hwclock.sh \
10            file://mount.busybox \
11            file://syslog \
12            file://syslog.conf \
13            file://udhcpscript.patch;patch=1 \
14            file://umount.busybox \
15            file://run_parts.c"
16
17 SRC_URI += "http://busybox.net/downloads/fixes-1.7.2/busybox-1.7.2-ash.patch;patch=1 \
18             http://busybox.net/downloads/fixes-1.7.2/busybox-1.7.2-iptun.patch;patch=1 \
19             http://busybox.net/downloads/fixes-1.7.2/busybox-1.7.2-logger.patch;patch=1 \
20             http://busybox.net/downloads/fixes-1.7.2/busybox-1.7.2-tail.patch;patch=1 \
21             file://defconfig"
22
23 EXTRA_OEMAKE += "V=1 ARCH=${TARGET_ARCH} CROSS_COMPILE=${TARGET_PREFIX}"
24
25 do_configure () {
26         cp ${WORKDIR}/run_parts.c ${S}/debianutils/
27         install -m 0644 ${WORKDIR}/defconfig ${S}/.config
28         cml1_do_configure
29 }
30
31 do_compile () {
32         unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS
33         base_do_compile
34 }
35
36 do_install () {
37         unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS
38         install -d ${D}${sysconfdir}/init.d
39         oe_runmake "PREFIX=${D}" install
40         cp -pPR ${S}/_install/* ${D}/
41
42         # Move everything to /busybox (not supposed to end up in any package)
43         install -d ${D}/busybox
44         ls ${D} -R
45
46         cp -dPr ${D}${base_bindir} ${D}${base_sbindir} ${D}${prefix} ${D}/busybox/
47         # Move the busybox binary back to /bin
48         install -d ${D}${base_bindir}
49         mv ${D}/busybox${base_bindir}/busybox ${D}${base_bindir}/
50         # Move back the sh symlink
51         test -h ${D}/busybox${base_bindir}/sh && mv ${D}/busybox${base_bindir}/sh ${D}${base_bindir}/
52
53         install -m 0755 ${WORKDIR}/syslog ${D}${sysconfdir}/init.d/
54         install -m 644 ${WORKDIR}/syslog.conf ${D}${sysconfdir}/
55         if grep "CONFIG_CROND=y" ${WORKDIR}/defconfig; then
56                 # Move crond back to /usr/sbin/crond
57                 install -d ${D}${sbindir}
58                 mv ${D}/busybox${sbindir}/crond ${D}${sbindir}/
59
60                 install -m 0755 ${WORKDIR}/busybox-cron ${D}${sysconfdir}/init.d/
61         fi
62         if grep "CONFIG_HTTPD=y" ${WORKDIR}/defconfig; then
63                 # Move httpd back to /usr/sbin/httpd
64                 install -d ${D}${sbindir}
65                 mv ${D}/busybox${sbindir}/httpd ${D}${sbindir}/
66
67                 install -m 0755 ${WORKDIR}/busybox-httpd ${D}${sysconfdir}/init.d/
68                 install -d ${D}/srv/www
69         fi
70         if grep "CONFIG_APP_UDHCPD=y" ${WORKDIR}/defconfig; then
71                 # Move udhcpd back to /usr/sbin/udhcpd
72                 install -d ${D}${sbindir}
73                 mv ${D}/busybox${sbindir}/udhcpd ${D}${sbindir}/
74
75                 install -m 0755 ${WORKDIR}/busybox-udhcpd ${D}${sysconfdir}/init.d/
76         fi
77         if grep "CONFIG_HWCLOCK=y" ${WORKDIR}/defconfig; then
78                 # Move hwclock back to /sbin/hwclock
79                 install -d ${D}${base_sbindir}
80                 mv ${D}/busybox${base_sbindir}/hwclock ${D}${base_sbindir}/
81
82                 install -m 0755 ${WORKDIR}/hwclock.sh ${D}${sysconfdir}/init.d/
83         fi
84         if grep "CONFIG_APP_UDHCPC=y" ${WORKDIR}/defconfig; then
85                 # Move dhcpc back to /usr/sbin/udhcpc
86                 install -d ${D}${base_sbindir}
87                 mv ${D}/busybox${base_sbindir}/udhcpc ${D}${base_sbindir}/
88
89                 install -d ${D}${sysconfdir}/udhcpc.d
90                 install -d ${D}${datadir}/udhcpc
91                 install -m 0755 ${S}/examples/udhcp/simple.script ${D}${sysconfdir}/udhcpc.d/50default
92                 install -m 0755 ${WORKDIR}/default.script ${D}${datadir}/udhcpc/default.script
93         fi
94
95         install -m 0644 ${S}/busybox.links ${D}${sysconfdir}
96 }
97
98 pkg_prerm_${PN} () {
99         # This is so you can make busybox commit suicide - removing busybox with no other packages
100         # providing its files, this will make update-alternatives work, but the update-rc.d part
101         # for syslog, httpd and/or udhcpd will fail if there is no other package providing sh
102         tmpdir=`mktemp -d /tmp/busyboxrm-XXXXXX`
103         ln -s /bin/busybox $tmpdir/[
104         ln -s /bin/busybox $tmpdir/test
105         ln -s /bin/busybox $tmpdir/head
106         ln -s /bin/busybox $tmpdir/sh
107         ln -s /bin/busybox $tmpdir/basename
108         ln -s /bin/busybox $tmpdir/echo
109         ln -s /bin/busybox $tmpdir/mv
110         ln -s /bin/busybox $tmpdir/ln
111         ln -s /bin/busybox $tmpdir/dirname
112         ln -s /bin/busybox $tmpdir/rm
113         ln -s /bin/busybox $tmpdir/sed
114         ln -s /bin/busybox $tmpdir/sort
115         export PATH=$PATH:$tmpdir
116         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
117 }