summaryrefslogtreecommitdiffstats
path: root/meta
diff options
context:
space:
mode:
authorAndré Draszik <adraszik@tycoint.com>2016-06-10 16:11:38 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-06-12 23:47:18 +0100
commit9ac4c8b11cd28cc1d343f9b2a91a6666febe246d (patch)
tree065fa0868722b904071d86a875c220c3e0998d0d /meta
parent3332061f69ea03e1165f3c8b64197d3f35ffb95e (diff)
downloadpoky-9ac4c8b11cd28cc1d343f9b2a91a6666febe246d.tar.gz
image/image_types.bbclass: fix fatal error during cpio debugfs creation
If /init is just a symlink to /sbin/init, debugfs creation fails with the following error: ERROR: Error: The image creation script '<...>/debugfs.create_image.cpio' returned 1: touch: cannot touch '<...>/cpio_append/init': Permission denied WARNING: exit code 1 from a shell command. ERROR: Function failed: do_rootfs The reason is that IMAGE_CMD_cpio() is run twice on the same WORKDIR. The first run creates a symlink in WORKDIR/cpio_append/init to point to /sbin/init, while the 2nd run then tries to 'touch' that link, which will fail, of course since /sbin/init is not usually writable by non-root users. Fix this by providing knowledge to the IMAGE_CMD_xxx() scripts with regards to the fact that they are being executed in the context of debugfs creation. The IMAGE_CMD_cpio() can now be intelligent in the sense that it can avoid all additional symlink handling during the debugfs run. The symlinks do not need to be part of the debugfs, so we can skip that part altogether in that case. (From OE-Core rev: 659ae1d7df28115429f6f31450fad6d1f86e3031) Signed-off-by: André Draszik <adraszik@tycoint.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-rw-r--r--meta/classes/image.bbclass1
-rw-r--r--meta/classes/image_types.bbclass19
2 files changed, 14 insertions, 6 deletions
diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
index 9f4c83ffc6..65ce6bb524 100644
--- a/meta/classes/image.bbclass
+++ b/meta/classes/image.bbclass
@@ -287,6 +287,7 @@ def setup_debugfs_variables(d):
287 d.appendVar('IMAGE_ROOTFS', '-dbg') 287 d.appendVar('IMAGE_ROOTFS', '-dbg')
288 d.appendVar('IMAGE_LINK_NAME', '-dbg') 288 d.appendVar('IMAGE_LINK_NAME', '-dbg')
289 d.appendVar('IMAGE_NAME','-dbg') 289 d.appendVar('IMAGE_NAME','-dbg')
290 d.setVar('IMAGE_BUILDING_DEBUGFS', 'true')
290 debugfs_image_fstypes = d.getVar('IMAGE_FSTYPES_DEBUGFS', True) 291 debugfs_image_fstypes = d.getVar('IMAGE_FSTYPES_DEBUGFS', True)
291 if debugfs_image_fstypes: 292 if debugfs_image_fstypes:
292 d.setVar('IMAGE_FSTYPES', debugfs_image_fstypes) 293 d.setVar('IMAGE_FSTYPES', debugfs_image_fstypes)
diff --git a/meta/classes/image_types.bbclass b/meta/classes/image_types.bbclass
index ea45809a39..72e8ed34d5 100644
--- a/meta/classes/image_types.bbclass
+++ b/meta/classes/image_types.bbclass
@@ -101,13 +101,20 @@ IMAGE_CMD_tar = "${IMAGE_CMD_TAR} -cvf ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}${IMAGE_
101do_image_cpio[cleandirs] += "${WORKDIR}/cpio_append" 101do_image_cpio[cleandirs] += "${WORKDIR}/cpio_append"
102IMAGE_CMD_cpio () { 102IMAGE_CMD_cpio () {
103 (cd ${IMAGE_ROOTFS} && find . | cpio -o -H newc >${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.cpio) 103 (cd ${IMAGE_ROOTFS} && find . | cpio -o -H newc >${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.cpio)
104 if [ ! -L ${IMAGE_ROOTFS}/init -a ! -e ${IMAGE_ROOTFS}/init ]; then 104 # We only need the /init symlink if we're building the real
105 if [ -L ${IMAGE_ROOTFS}/sbin/init -o -e ${IMAGE_ROOTFS}/sbin/init ]; then 105 # image. The -dbg image doesn't need it! By being clever
106 ln -sf /sbin/init ${WORKDIR}/cpio_append/init 106 # about this we also avoid 'touch' below failing, as it
107 else 107 # might be trying to touch /sbin/init on the host since both
108 touch ${WORKDIR}/cpio_append/init 108 # the normal and the -dbg image share the same WORKDIR
109 if [ "${IMAGE_BUILDING_DEBUGFS}" != "true" ]; then
110 if [ ! -L ${IMAGE_ROOTFS}/init ] && [ ! -e ${IMAGE_ROOTFS}/init ]; then
111 if [ -L ${IMAGE_ROOTFS}/sbin/init ] || [ -e ${IMAGE_ROOTFS}/sbin/init ]; then
112 ln -sf /sbin/init ${WORKDIR}/cpio_append/init
113 else
114 touch ${WORKDIR}/cpio_append/init
115 fi
116 (cd ${WORKDIR}/cpio_append && echo ./init | cpio -oA -H newc -F ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.cpio)
109 fi 117 fi
110 (cd ${WORKDIR}/cpio_append && echo ./init | cpio -oA -H newc -F ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.cpio)
111 fi 118 fi
112} 119}
113 120