From 940873e6cb8ca716b6619ad66a82f8a74c26e22c Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Lallement Date: Thu, 8 Nov 2018 18:33:41 +0100 Subject: [PATCH] live-build/lb_chroot_layered: overlayfs supports only 2 stacked layers. Changed the code to use several lower dirs instead like casper does --- live-build/lb_chroot_layered | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/live-build/lb_chroot_layered b/live-build/lb_chroot_layered index 2b7f13e3..089b3ceb 100755 --- a/live-build/lb_chroot_layered +++ b/live-build/lb_chroot_layered @@ -41,25 +41,16 @@ Setup_cleanup . config/functions -teardownPath="config/teardown_chroot_layered" -cat >> $teardownPath << EOF -#!/bin/sh -set -e -EOF -chmod +x $teardownPath - PASSES="${PASSES:-install live}" CURPASS=1 LASTPASS=$(echo $PASSES|wc -w) +LOWER_LAYERS="" for _PASS in $PASSES do if [ $CURPASS -gt 1 ]; then mkdir chroot.${_PASS} - mount_overlay chroot/ "chroot.${_PASS}/" chroot/ - cat >> $teardownPath << EOF -umount chroot/ -EOF + mount_overlay $LOWER_LAYERS "chroot.${_PASS}/" chroot/ fi # Configuring chroot @@ -129,13 +120,25 @@ EOF lb chroot_cache save ${*} if [ $CURPASS -eq 1 ]; then - cp -a chroot chroot.${_PASS} + mv chroot chroot.${_PASS} + mkdir chroot + elif [ $CURPASS -ne $LASTPASS ]; then + # we will unmount chroot/ at teardown for upper layer + umount chroot fi + LOWER_LAYERS="chroot.${_PASS}:$LOWER_LAYERS" + LOWER_LAYERS="${LOWER_LAYERS%:}" CURPASS=$(( CURPASS + 1 )) done # Remove unused chroot binary corresponding to bottom layer (once everything is unmount) -cat >> $teardownPath << EOF + +TEARDOWNPATH="config/teardown_chroot_layered" +cat > $TEARDOWNPATH << EOF +#!/bin/sh +set -e +umount chroot rm -rf chroot/ EOF +chmod +x $TEARDOWNPATH