From 49c0099331e38522af9042cfcba5355aa10b177c Mon Sep 17 00:00:00 2001 From: Ettore Di Giacinto Date: Thu, 11 Nov 2021 12:31:54 +0100 Subject: [PATCH] Fixup Signed-off-by: Ettore Di Giacinto --- packages/installer/cos.sh | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/packages/installer/cos.sh b/packages/installer/cos.sh index 74a5952f785..ef817c7cd72 100755 --- a/packages/installer/cos.sh +++ b/packages/installer/cos.sh @@ -57,8 +57,6 @@ load_config() { prepare_chroot() { local dir=$1 - ensure_chroot_structure $dir - for mnt in /dev /dev/pts /proc /sys do mount -o bind $mnt $dir/$mnt @@ -331,19 +329,23 @@ do_mount() echo "Mounting critical endpoints.." mkdir -p ${TARGET} - ensure_dir_structure + ensure_dir_structure $TARGET prepare_statedir "install" - STATEDIR=/tmp/mnt/STATE - mkdir -p $STATEDIR || true - mount ${STATE} $STATEDIR + mkdir -p ${STATEDIR}/cOS || true + + if [ -e "${STATEDIR}/cOS/active.img" ]; then + rm -rf ${STATEDIR}/cOS/active.img + fi - mkdir -p ${STATEDIR}/cOS - # TODO: Size should be tweakable dd if=/dev/zero of=${STATEDIR}/cOS/active.img bs=1M count=$DEFAULT_IMAGE_SIZE mkfs.ext2 ${STATEDIR}/cOS/active.img -L COS_ACTIVE - sync + + if [ -z "$COS_ACTIVE" ]; then + sync + fi + LOOP=$(losetup --show -f ${STATEDIR}/cOS/active.img) mount -t ext2 $LOOP $TARGET @@ -713,18 +715,13 @@ switch_recovery() { fi } -ensure_chroot_structure() { +ensure_dir_structure() { local target=$1 mkdir ${target}/proc || true mkdir ${target}/dev || true mkdir ${target}/sys || true -} - -ensure_dir_structure() { - local target=$1 - ensure_chroot_structure $target - mkdir ${target}/boot || true mkdir ${target}/tmp || true + mkdir ${target}/boot || true mkdir ${target}/usr/local || true mkdir ${target}/oem || true } @@ -747,6 +744,8 @@ create_rootfs() { target=$2 temp_dir=$3 + ensure_dir_structure $target + upgrade_state_dir="$temp_dir" temp_upgrade=$upgrade_state_dir/tmp/upgrade rm -rf $upgrade_state_dir || true