Skip to content

Commit

Permalink
Fixup
Browse files Browse the repository at this point in the history
Signed-off-by: Ettore Di Giacinto <edigiacinto@suse.com>
  • Loading branch information
mudler committed Nov 11, 2021
1 parent 8e8441f commit 49c0099
Showing 1 changed file with 15 additions and 16 deletions.
31 changes: 15 additions & 16 deletions packages/installer/cos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
}
Expand All @@ -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
Expand Down

0 comments on commit 49c0099

Please sign in to comment.