busybox: fix udhcpc default script location when prefix is not "/usr"
[openembedded.git] / recipes / busybox / busybox_1.7.2.bb
1 require busybox.inc
2 PR = "${INC_PR}.1"
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://mountall \
12            file://syslog \
13            file://syslog.conf \
14            file://udhcpscript.patch;patch=1 \
15            file://busybox-appletlib-dependency.patch;patch=1 \
16            file://umount.busybox \
17            file://run_parts.c"
18
19 SRC_URI += "http://busybox.net/downloads/fixes-1.7.2/busybox-1.7.2-ash.patch;patch=1 \
20             http://busybox.net/downloads/fixes-1.7.2/busybox-1.7.2-iptun.patch;patch=1 \
21             http://busybox.net/downloads/fixes-1.7.2/busybox-1.7.2-logger.patch;patch=1 \
22             http://busybox.net/downloads/fixes-1.7.2/busybox-1.7.2-tail.patch;patch=1 \
23             file://defconfig"
24
25 EXTRA_OEMAKE += "V=1 ARCH=${TARGET_ARCH} CROSS_COMPILE=${TARGET_PREFIX}"
26
27 do_configure () {
28         cp ${WORKDIR}/run_parts.c ${S}/debianutils/
29         install -m 0644 ${WORKDIR}/defconfig ${S}/.config
30         cml1_do_configure
31 }
32
33 do_compile () {
34         unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS
35         base_do_compile
36 }
37
38 do_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_APP_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_APP_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
100 pkg_prerm_${PN} () {
101         # This is so you can make busybox commit suicide - removing busybox with no other packages
102         # providing its files, this will make update-alternatives work, but the update-rc.d part
103         # for syslog, httpd and/or udhcpd will fail if there is no other package providing sh
104         tmpdir=`mktemp -d /tmp/busyboxrm-XXXXXX`
105         ln -s /bin/busybox $tmpdir/[
106         ln -s /bin/busybox $tmpdir/test
107         ln -s /bin/busybox $tmpdir/head
108         ln -s /bin/busybox $tmpdir/sh
109         ln -s /bin/busybox $tmpdir/basename
110         ln -s /bin/busybox $tmpdir/echo
111         ln -s /bin/busybox $tmpdir/mv
112         ln -s /bin/busybox $tmpdir/ln
113         ln -s /bin/busybox $tmpdir/dirname
114         ln -s /bin/busybox $tmpdir/rm
115         ln -s /bin/busybox $tmpdir/sed
116         ln -s /bin/busybox $tmpdir/sort
117         export PATH=$PATH:$tmpdir
118         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
119 }