surpport seeking the recorded video
[vuplus_openembedded] / recipes / busybox / busybox.inc
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
14 INC_PR = "r24"
15
16 SRC_URI = "\
17   http://www.busybox.net/downloads/busybox-${PV}.tar.gz \
18   file://busybox-cron \
19   file://busybox-httpd \
20   file://busybox-udhcpd \
21   file://default.script file://simple.script \
22   file://dhcp-hostname.patch;patch=1 \
23   file://hwclock.sh \
24   file://ifupdown-spurious-environ.patch;patch=1 \
25   file://mount.busybox \
26   file://syslog \
27   file://syslog.conf \
28   file://udhcpscript.patch;patch=1 \
29   file://umount.busybox \
30 "
31
32 SRC_URI_append_nylon = " file://xargs-double-size.patch;patch=1"
33
34 export EXTRA_CFLAGS = "${CFLAGS}"
35 EXTRA_OEMAKE_append = " CROSS=${HOST_PREFIX}"
36 PACKAGES =+ "${PN}-mountall ${PN}-httpd ${PN}-syslog ${PN}-udhcpd"
37
38 # We need this RRECOMMENDS because libc dlopens libgcc
39 # and shlib mechanism can not detect it because its not
40 # listed in the NEEDED field.
41 RRECOMMENDS += "libgcc"
42
43 FILES_${PN}-mountall = "${sysconfdir}/default/mountall"
44 RDEPENDS_${PN} += "${PN}-mountall"
45
46 # Make busybox recommend busybox-syslog for those images that expect it
47 RRECOMMENDS_${PN} += "libgcc ${PN}-syslog"
48
49 FILES_${PN}-httpd = "${sysconfdir}/init.d/busybox-httpd /srv/www"
50 FILES_${PN}-syslog = "${sysconfdir}/init.d/syslog ${sysconfdir}/syslog.conf"
51 FILES_${PN}-udhcpd = "${sysconfdir}/init.d/busybox-udhcpd"
52
53 FILES_${PN} += "${datadir}/udhcpc"
54
55 INITSCRIPT_PACKAGES = "${PN}-httpd ${PN}-syslog ${PN}-udhcpd"
56 INITSCRIPT_NAME_${PN}-httpd = "busybox-httpd"
57 INITSCRIPT_NAME_${PN}-syslog = "syslog"
58 INITSCRIPT_NAME_${PN}-udhcpd = "busybox-udhcpd" 
59 CONFFILES_${PN}-syslog = "${sysconfdir}/syslog.conf"
60
61 # This disables the syslog startup links in slugos (see slugos-init)
62 INITSCRIPT_PARAMS_${PN}-syslog_slugos = "start 20 ."
63
64 RDEPENDS_${PN}-httpd += "${PN}"
65 RDEPENDS_${PN}-syslog += "${PN}"
66 RDEPENDS_${PN}-udhcpd += "${PN}"
67
68 # Use gcc for linking so LDFLAGS actually makes sense
69 LD = "${CC} -nostdlib"
70
71 inherit cml1 update-rc.d
72
73 do_configure () {
74         sed -e 's#@DATADIR@#${datadir}#g' \
75                 < ${WORKDIR}/defconfig > ${S}/.config
76         cml1_do_configure
77 }
78
79 do_compile() {
80         unset CFLAGS CPPFLAGS CXXFLAGS
81         base_do_compile
82 }
83
84 do_install () {
85         oe_runmake busybox.links
86         if [ "${prefix}" != "/usr" ]; then
87                 sed "s:^/usr/:${prefix}/:" busybox.links > busybox.links.new
88                 mv busybox.links.new busybox.links
89         fi
90         if [ "${base_sbindir}" != "/sbin" ]; then
91                 sed "s:^/sbin/:${base_sbindir}/:" busybox.links > busybox.links.new
92                 mv busybox.links.new busybox.links
93         fi
94
95         install -d ${D}${sysconfdir}/init.d
96
97         # Install /bin/busybox, and the /bin/sh link so the postinst script
98         # can run. Let update-alternatives handle the rest.
99         install -d ${D}${base_bindir}
100         install -m 0755 ${S}/busybox ${D}${base_bindir}
101         ln -sf busybox ${D}${base_bindir}/sh
102
103         if grep -q "CONFIG_SYSLOGD=y" ${WORKDIR}/defconfig; then
104                 install -m 0755 ${WORKDIR}/syslog ${D}${sysconfdir}/init.d/
105                 install -m 644 ${WORKDIR}/syslog.conf ${D}${sysconfdir}/
106         fi
107         if grep "CONFIG_CROND=y" ${WORKDIR}/defconfig; then
108                 install -m 0755 ${WORKDIR}/busybox-cron ${D}${sysconfdir}/init.d/
109         fi
110         if grep "CONFIG_HTTPD=y" ${WORKDIR}/defconfig; then
111                 install -m 0755 ${WORKDIR}/busybox-httpd ${D}${sysconfdir}/init.d/
112                 install -d ${D}/srv/www
113         fi
114         if grep "CONFIG_APP_UDHCPD=y" ${WORKDIR}/defconfig; then
115                 install -m 0755 ${WORKDIR}/busybox-udhcpd ${D}${sysconfdir}/init.d/
116         fi
117         if grep "CONFIG_HWCLOCK=y" ${WORKDIR}/defconfig; then
118                 install -m 0755 ${WORKDIR}/hwclock.sh ${D}${sysconfdir}/init.d/
119         fi
120         if grep "CONFIG_APP_UDHCPC=y" ${WORKDIR}/defconfig; then
121                 install -d ${D}${sysconfdir}/udhcpc.d
122                 install -d ${D}${datadir}/udhcpc
123                 install -m 0755 ${WORKDIR}/simple.script ${D}${sysconfdir}/udhcpc.d/50default
124                 install -m 0755 ${WORKDIR}/default.script ${D}${datadir}/udhcpc/default.script
125         fi
126         if grep "CONFIG_FEATURE_MOUNT_FSTAB=y" ${WORKDIR}/defconfig; then
127                 install -d ${D}${sysconfdir}/default
128                 install -m 644 ${WORKDIR}/mountall ${D}${sysconfdir}/default/
129         fi
130
131         install -m 0644 ${S}/busybox.links ${D}${sysconfdir}
132 }
133
134 pkg_postinst_${PN} () {
135         # If we are not making an image we create links for the utilities that doesn't exist
136         # so the update-alternatives script will get the utilities it needs
137         # (update-alternatives have no problem replacing links later anyway)
138         test -n 2> /dev/null || alias test='busybox test'
139         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";; /*) to="/bin/busybox";; esac; busybox ln -s $to $link; fi; done </etc/busybox.links; fi
140         
141         # This adds the links, remember that this has to work when building an image too, hence the $D
142         while read link; do case "$link" in /*/*/*) to="../../bin/busybox";; /bin/*) to="busybox";; /*/*) to="../bin/busybox";; /*) to="/bin/busybox";; esac; bn=`basename $link`; update-alternatives --install $link $bn $to 50; done <$D/etc/busybox.links
143 }
144
145 pkg_prerm_${PN} () {
146         # This is so you can make busybox commit suicide - removing busybox with no other packages
147         # providing its files, this will make update-alternatives work, but the update-rc.d part
148         # for syslog, httpd and/or udhcpd will fail if there is no other package providing sh
149         tmpdir=`mktemp -d /tmp/busyboxrm-XXXXXX`
150         ln -s /bin/busybox $tmpdir/[
151         ln -s /bin/busybox $tmpdir/test
152         ln -s /bin/busybox $tmpdir/head
153         ln -s /bin/busybox $tmpdir/sh
154         ln -s /bin/busybox $tmpdir/basename
155         ln -s /bin/busybox $tmpdir/echo
156         ln -s /bin/busybox $tmpdir/mv
157         ln -s /bin/busybox $tmpdir/ln
158         ln -s /bin/busybox $tmpdir/dirname
159         ln -s /bin/busybox $tmpdir/rm
160         ln -s /bin/busybox $tmpdir/sed
161         ln -s /bin/busybox $tmpdir/sort
162         export PATH=$PATH:$tmpdir
163
164         while read link
165         do
166                 case "$link" in
167                         /*/*/*) to="../../bin/busybox";;
168                         /bin/*) to="busybox";;
169                         /*/*) to="../bin/busybox";;
170                         /*) to="/bin/busybox";;         
171                 esac
172                 bn=`basename $link`
173                 sh /usr/bin/update-alternatives --remove $bn $to
174         done </etc/busybox.links
175 }
176
177 PACKAGES =+ "${PN}-mdev"
178 FILES_${PN}-mdev = "${sysconfdir}/mdev ${sysconfdir}/mdev.conf ${sysconfdir}/init.d/mdev"
179 RDEPENDS_${PN}-mdev += "${PN}"
180
181 PACKAGES =+ "${PN}-linuxrc"
182 FILES_${PN}-linuxrc = "linuxrc"
183 RDEPENDS_${PN}-linuxrc += "${PN}"
184
185 pkg_postinst_${PN}-mdev() {
186 if test "x$D" != "x"; then
187         OPT="-r $D"
188 else
189         OPT="-s"
190 fi
191         update-rc.d $OPT mdev start 06 S .
192 }
193