busybox: fix udhcpc default script location when prefix is not "/usr"
[openembedded.git] / recipes / busybox / busybox_1.2.1.bb
1 require busybox.inc
2
3 PR = "${INC_PR}.1"
4
5 SRC_URI += "file://wget-long-options.patch;patch=1 \
6            file://df_rootfs.patch;patch=1 \
7            file://defconfig"
8 SRC_URI_append_avr32 = " file://install-should-unlink-dest-if-it-exists.patch;patch=1"
9
10 do_configure () {
11         install -m 0644 ${WORKDIR}/defconfig ${S}/.config.oe
12
13         echo "CROSS_COMPILER_PREFIX=\"${TARGET_PREFIX}\"" > ${S}/.config
14         echo "USING_CROSS_COMPILER=y" >> ${S}/.config
15
16         sed -e  '/CROSS_COMPILER_PREFIX/d' \
17             -e  '/USING_CROSS_COMPILER/d' \
18                 '${S}/.config.oe' >>'${S}/.config'
19         cml1_do_configure
20 }
21
22 do_install () {
23         install -d ${D}${sysconfdir}/init.d
24         oe_runmake "PREFIX=${D}" install
25         cp -pPR ${S}/_install/* ${D}/
26
27         # Move everything to /busybox (not supposed to end up in any package)
28         install -d ${D}/busybox
29         ls ${D} -R
30
31         cp -dPr ${D}${base_bindir} ${D}${base_sbindir} ${D}${prefix} ${D}/busybox/
32         # Move the busybox binary back to /bin
33         install -d ${D}${base_bindir}
34         mv ${D}/busybox${base_bindir}/busybox ${D}${base_bindir}/
35         # Move back the sh symlink
36         test -h ${D}/busybox${base_bindir}/sh && mv ${D}/busybox${base_bindir}/sh ${D}${base_bindir}/
37
38         install -m 0755 ${WORKDIR}/syslog ${D}${sysconfdir}/init.d/
39         install -m 644 ${WORKDIR}/syslog.conf ${D}${sysconfdir}/
40         if grep "CONFIG_CROND=y" ${WORKDIR}/defconfig; then
41                 # Move crond back to /usr/sbin/crond
42                 install -d ${D}${sbindir}
43                 mv ${D}/busybox${sbindir}/crond ${D}${sbindir}/
44
45                 install -m 0755 ${WORKDIR}/busybox-cron ${D}${sysconfdir}/init.d/
46         fi
47         if grep "CONFIG_HTTPD=y" ${WORKDIR}/defconfig; then
48                 # Move httpd back to /usr/sbin/httpd
49                 install -d ${D}${sbindir}
50                 mv ${D}/busybox${sbindir}/httpd ${D}${sbindir}/
51
52                 install -m 0755 ${WORKDIR}/busybox-httpd ${D}${sysconfdir}/init.d/
53                 install -d ${D}/srv/www
54         fi
55         if grep "CONFIG_APP_UDHCPD=y" ${WORKDIR}/defconfig; then
56                 # Move udhcpd back to /usr/sbin/udhcpd
57                 install -d ${D}${sbindir}
58                 mv ${D}/busybox${sbindir}/udhcpd ${D}${sbindir}/
59
60                 install -m 0755 ${WORKDIR}/busybox-udhcpd ${D}${sysconfdir}/init.d/
61         fi
62         if grep "CONFIG_HWCLOCK=y" ${WORKDIR}/defconfig; then
63                 # Move hwclock back to /sbin/hwclock
64                 install -d ${D}${base_sbindir}
65                 mv ${D}/busybox${base_sbindir}/hwclock ${D}${base_sbindir}/
66
67                 install -m 0755 ${WORKDIR}/hwclock.sh ${D}${sysconfdir}/init.d/
68         fi
69         if grep "CONFIG_APP_UDHCPC=y" ${WORKDIR}/defconfig; then
70                 # Move dhcpc back to /usr/sbin/udhcpc
71                 install -d ${D}${base_sbindir}
72                 mv ${D}/busybox${base_sbindir}/udhcpc ${D}${base_sbindir}/
73
74                 install -d ${D}${sysconfdir}/udhcpc.d
75                 install -d ${D}${datadir}/udhcpc
76                 install -m 0755 ${S}/examples/udhcp/simple.script ${D}${sysconfdir}/udhcpc.d/50default
77                 install -m 0755 ${WORKDIR}/default.script ${D}${datadir}/udhcpc/default.script
78         fi
79
80         install -m 0644 ${S}/busybox.links ${D}${sysconfdir}
81 }
82
83 pkg_prerm_${PN} () {
84         # This is so you can make busybox commit suicide - removing busybox with no other packages
85         # providing its files, this will make update-alternatives work, but the update-rc.d part
86         # for syslog, httpd and/or udhcpd will fail if there is no other package providing sh
87         tmpdir=`mktemp -d /tmp/busyboxrm-XXXXXX`
88         ln -s /bin/busybox $tmpdir/[
89         ln -s /bin/busybox $tmpdir/test
90         ln -s /bin/busybox $tmpdir/head
91         ln -s /bin/busybox $tmpdir/sh
92         ln -s /bin/busybox $tmpdir/basename
93         ln -s /bin/busybox $tmpdir/echo
94         ln -s /bin/busybox $tmpdir/mv
95         ln -s /bin/busybox $tmpdir/ln
96         ln -s /bin/busybox $tmpdir/dirname
97         ln -s /bin/busybox $tmpdir/rm
98         ln -s /bin/busybox $tmpdir/sed
99         ln -s /bin/busybox $tmpdir/sort
100         export PATH=$PATH:$tmpdir
101         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
102 }