Skip to content

Commit

Permalink
genimage.bbclass: clean ${B} completely before building
Browse files Browse the repository at this point in the history
Since do_deploy copies all files from ${B} to the deploy directory,
the latter quickly fills up when doing multiple builds. And those
files in turn get copied to images/${MACHINE}/ - filling the disk, and
making the do_deploy task take longer and longer.

Fix this by adding ${B} to do_genimage[cleandirs] so that we always
start in an empty directory. For that to work, we have to move the
responsibility of creating the copy of genimage.config from
do_configure to do_genimage itself (otherwise, a rebuild where none of
the inputs to do_configure had changed would break). But since
do_genimage now creates that copy itself, we can get rid of the extra
.tmp copy, and just use the ${B}/.config file.

I deliberately keep do_genimage's working directory set to ${B} (i.e.,
keeping the [dirs] line), because some users rely on that for using
`include()` inside genimage.config.

Reported-by: João Loureiro <joaofl@gmail.com>
Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
  • Loading branch information
Rasmus Villemoes authored and ejoerns committed Jun 23, 2021
1 parent 89958b5 commit 73c3252
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions classes/genimage.bbclass
Original file line number Diff line number Diff line change
Expand Up @@ -92,37 +92,34 @@ do_genimage[depends] += "${@'${GENIMAGE_ROOTFS_IMAGE}:do_image_complete' if '${G
GENIMAGE_TMPDIR = "${WORKDIR}/genimage-tmp"
GENIMAGE_ROOTDIR = "${WORKDIR}/root"

do_genimage[cleandirs] = "${GENIMAGE_TMPDIR} ${GENIMAGE_ROOTDIR}"
do_genimage[cleandirs] = "${GENIMAGE_TMPDIR} ${GENIMAGE_ROOTDIR} ${B}"

do_configure () {
if grep -vq "@IMAGE@" ${WORKDIR}/genimage.config; then
bbnote "genimage.config does not contain @IMAGE@ marker"
fi

cp ${WORKDIR}/genimage.config ${B}/.config
}

do_genimage[dirs] = "${B}"

fakeroot do_genimage () {
sed s:@IMAGE@:${GENIMAGE_IMAGE_NAME}.${GENIMAGE_IMAGE_SUFFIX}:g ${WORKDIR}/genimage.config > ${B}/.config

# unpack input rootfs image if given
if [ "x${GENIMAGE_ROOTFS_IMAGE}" != "x" ]; then
bbnote "Unpacking ${DEPLOY_DIR_IMAGE}/${GENIMAGE_ROOTFS_IMAGE}-${MACHINE}.${GENIMAGE_ROOTFS_IMAGE_FSTYPE} to ${GENIMAGE_ROOTDIR}"
tar -xf ${DEPLOY_DIR_IMAGE}/${GENIMAGE_ROOTFS_IMAGE}-${MACHINE}.${GENIMAGE_ROOTFS_IMAGE_FSTYPE} -C ${GENIMAGE_ROOTDIR}
fi

sed s:@IMAGE@:${GENIMAGE_IMAGE_NAME}.${GENIMAGE_IMAGE_SUFFIX}:g ${B}/.config > ${B}/.config.tmp

genimage \
--loglevel 2 \
--config ${B}/.config.tmp \
--config ${B}/.config \
--tmppath ${GENIMAGE_TMPDIR} \
--inputpath ${DEPLOY_DIR_IMAGE} \
--outputpath ${B} \
--rootpath ${GENIMAGE_ROOTDIR}

rm ${B}/.config.tmp
rm ${B}/.config
}
do_genimage[depends] += "virtual/fakeroot-native:do_populate_sysroot"

Expand Down

0 comments on commit 73c3252

Please sign in to comment.