summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--meta/recipes-core/busybox/busybox.inc96
1 files changed, 68 insertions, 28 deletions
diff --git a/meta/recipes-core/busybox/busybox.inc b/meta/recipes-core/busybox/busybox.inc
index 99d4e997b1..65e16424cc 100644
--- a/meta/recipes-core/busybox/busybox.inc
+++ b/meta/recipes-core/busybox/busybox.inc
@@ -12,6 +12,9 @@ LIC_FILES_CHKSUM = "file://LICENSE;md5=de10de48642ab74318e893a61105afbb"
12 12
13SECTION = "base" 13SECTION = "base"
14 14
15# Whether to split the suid apps into a seperate binary
16BUSYBOX_SPLIT_SUID ?= "1"
17
15export EXTRA_CFLAGS = "${CFLAGS}" 18export EXTRA_CFLAGS = "${CFLAGS}"
16export EXTRA_LDFLAGS = "${LDFLAGS}" 19export EXTRA_LDFLAGS = "${LDFLAGS}"
17 20
@@ -136,19 +139,43 @@ do_configure () {
136 139
137do_compile() { 140do_compile() {
138 unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS 141 unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS
139 oe_runmake busybox_unstripped 142 if [ "${BUSYBOX_SPLIT_SUID}" = "1" -a x`grep "CONFIG_FEATURE_INDIVIDUAL=y" .config` = x ]; then
140 cp busybox_unstripped busybox 143 # split the .config into two parts, and make two busybox binaries
144 cp .config .config.orig
145 oe_runmake busybox.cfg.suid
146 oe_runmake busybox.cfg.nosuid
147 for i in `cat busybox.cfg.suid busybox.cfg.nosuid`; do
148 echo "# $i is not set" >> .config.disable.apps
149 done
150 merge_config.sh -m .config.orig .config.disable.apps
151 cp .config .config.nonapps
152 for s in suid nosuid; do
153 cat busybox.cfg.$s | while read item; do
154 grep -w "$item" .config.orig
155 done > .config.app.$s
156 merge_config.sh -m .config.nonapps .config.app.$s
157 oe_runmake busybox_unstripped
158 mv busybox_unstripped busybox.$s
159 oe_runmake busybox.links
160 mv busybox.links busybox.links.$s
161 done
162 # copy .config.orig back to .config, because the install process may check this file
163 cp .config.orig .config
164 # cleanup
165 rm .config.orig .config.app.suid .config.app.nosuid .config.disable.apps .config.nonapps
166 else
167 oe_runmake busybox_unstripped
168 cp busybox_unstripped busybox
169 oe_runmake busybox.links
170 fi
141} 171}
142 172
143do_install () { 173do_install () {
144 oe_runmake busybox.links
145 if [ "${prefix}" != "/usr" ]; then 174 if [ "${prefix}" != "/usr" ]; then
146 sed "s:^/usr/:${prefix}/:" busybox.links > busybox.links.new 175 sed -i "s:^/usr/:${prefix}/:" busybox.links*
147 mv busybox.links.new busybox.links
148 fi 176 fi
149 if [ "${base_sbindir}" != "/sbin" ]; then 177 if [ "${base_sbindir}" != "/sbin" ]; then
150 sed "s:^/sbin/:${base_sbindir}/:" busybox.links > busybox.links.new 178 sed -i "s:^/sbin/:${base_sbindir}/:" busybox.links*
151 mv busybox.links.new busybox.links
152 fi 179 fi
153 180
154 install -d ${D}${sysconfdir}/init.d 181 install -d ${D}${sysconfdir}/init.d
@@ -157,12 +184,21 @@ do_install () {
157 # Install /bin/busybox, and the /bin/sh link so the postinst script 184 # Install /bin/busybox, and the /bin/sh link so the postinst script
158 # can run. Let update-alternatives handle the rest. 185 # can run. Let update-alternatives handle the rest.
159 install -d ${D}${base_bindir} 186 install -d ${D}${base_bindir}
160 if grep -q "CONFIG_FEATURE_SUID=y" ${B}/.config; then 187 if [ "${BUSYBOX_SPLIT_SUID}" = "1" ]; then
161 install -m 4755 ${B}/busybox ${D}${base_bindir} 188 install -m 4755 ${B}/busybox.suid ${D}${base_bindir}
189 install -m 0755 ${B}/busybox.nosuid ${D}${base_bindir}
190 install -m 0644 ${S}/busybox.links.suid ${D}${sysconfdir}
191 install -m 0644 ${S}/busybox.links.nosuid ${D}${sysconfdir}
192 ln -sf busybox.nosuid ${D}${base_bindir}/sh
162 else 193 else
163 install -m 0755 ${B}/busybox ${D}${base_bindir} 194 if grep -q "CONFIG_FEATURE_SUID=y" ${B}/.config; then
195 install -m 4755 ${B}/busybox ${D}${base_bindir}
196 else
197 install -m 0755 ${B}/busybox ${D}${base_bindir}
198 fi
199 install -m 0644 ${S}/busybox.links ${D}${sysconfdir}
200 ln -sf busybox ${D}${base_bindir}/sh
164 fi 201 fi
165 ln -sf busybox ${D}${base_bindir}/sh
166 else 202 else
167 install -d ${D}${base_bindir} ${D}${base_sbindir} 203 install -d ${D}${base_bindir} ${D}${base_sbindir}
168 install -d ${D}${libdir} ${D}${bindir} ${D}${sbindir} 204 install -d ${D}${libdir} ${D}${bindir} ${D}${sbindir}
@@ -181,6 +217,7 @@ do_install () {
181 if [ -f ${D}/linuxrc.${BPN} ]; then 217 if [ -f ${D}/linuxrc.${BPN} ]; then
182 mv ${D}/linuxrc.${BPN} ${D}/linuxrc 218 mv ${D}/linuxrc.${BPN} ${D}/linuxrc
183 fi 219 fi
220 install -m 0644 ${S}/busybox.links ${D}${sysconfdir}
184 fi 221 fi
185 222
186 if grep -q "CONFIG_SYSLOGD=y" ${B}/.config; then 223 if grep -q "CONFIG_SYSLOGD=y" ${B}/.config; then
@@ -217,7 +254,6 @@ do_install () {
217 install -m 644 ${WORKDIR}/mdev.conf ${D}${sysconfdir}/mdev.conf 254 install -m 644 ${WORKDIR}/mdev.conf ${D}${sysconfdir}/mdev.conf
218 fi 255 fi
219 fi 256 fi
220 install -m 0644 ${S}/busybox.links ${D}${sysconfdir}
221 257
222 if ${@base_contains('DISTRO_FEATURES','systemd','true','false',d)}; then 258 if ${@base_contains('DISTRO_FEATURES','systemd','true','false',d)}; then
223 install -d ${D}${systemd_unitdir}/system 259 install -d ${D}${systemd_unitdir}/system
@@ -248,22 +284,26 @@ python do_package_prepend () {
248 284
249 dvar = d.getVar('D', True) 285 dvar = d.getVar('D', True)
250 pn = d.getVar('PN', True) 286 pn = d.getVar('PN', True)
251 f = open('%s/etc/busybox.links' % (dvar), 'r') 287 def set_alternative_vars(links, target):
252 288 f = open('%s%s' % (dvar, links), 'r')
253 if os.path.exists('%s/bin/busybox' % (dvar)): 289 for alt_link_name in f:
254 d.setVar('ALTERNATIVE_TARGET', "/bin/busybox") 290 alt_link_name = alt_link_name.strip()
255 291 alt_name = os.path.basename(alt_link_name)
256 for alt_link_name in f: 292 # Match coreutils
257 alt_link_name = alt_link_name.strip() 293 if alt_name == '[':
258 alt_name = os.path.basename(alt_link_name) 294 alt_name = 'lbracket'
259 295 d.appendVar('ALTERNATIVE_%s' % (pn), ' ' + alt_name)
260 # Match coreutils 296 d.setVarFlag('ALTERNATIVE_LINK_NAME', alt_name, alt_link_name)
261 if alt_name == '[': 297 if os.path.exists('%s%s' % (dvar, target)):
262 alt_name = 'lbracket' 298 d.setVarFlag('ALTERNATIVE_TARGET', alt_name, target)
263 299 f.close()
264 d.appendVar('ALTERNATIVE_%s' % (pn), ' ' + alt_name) 300 return
265 d.setVarFlag('ALTERNATIVE_LINK_NAME', alt_name, alt_link_name) 301
266 f.close() 302 if os.path.exists('%s/etc/busybox.links' % (dvar)):
303 set_alternative_vars("/etc/busybox.links", "/bin/busybox")
304 else:
305 set_alternative_vars("/etc/busybox.links.nosuid", "/bin/busybox.nosuid")
306 set_alternative_vars("/etc/busybox.links.suid", "/bin/busybox.suid")
267} 307}
268 308
269pkg_prerm_${PN} () { 309pkg_prerm_${PN} () {