From fbf5a1027798d476482f56183c35bf71af8b3e33 Mon Sep 17 00:00:00 2001 From: Richard Maw Date: Mon, 16 Jul 2012 10:17:12 +0000 Subject: tests/make-patch: mount disk image for test Previously it would extract the stratum tarballs, since it was easier than mounting the disk image. Then when strata became chunk lists, this created the tarball, then extracted it. Now systems may contain files that aren't in the component strata, this causes problems for tbdiff-deploy, since it tries to alter a file that isn't there. So to fix this, it mounts the disk image, like it should have from the beginning. --- tests.as-root/make-patch.script | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) (limited to 'tests.as-root/make-patch.script') diff --git a/tests.as-root/make-patch.script b/tests.as-root/make-patch.script index b5385fc0..9a159a48 100755 --- a/tests.as-root/make-patch.script +++ b/tests.as-root/make-patch.script @@ -46,7 +46,6 @@ EOF # Build first image. Remember the stratum. "$SRCDIR/scripts/test-morph" build test:morphs-repo master hello-system.morph img1=$(find "$DATADIR/cache/artifacts" -maxdepth 1 -name '*.system.*') -stratum1=$(find "$DATADIR/cache/artifacts" -maxdepth 1 -name '*.hello-stratum') # Modify the chunk, in a new branch. "$SRCDIR/scripts/run-git-in" "$DATADIR/chunk-repo" checkout --quiet farrokh @@ -73,12 +72,28 @@ patch="$DATADIR/patch" test:morphs-repo master hello-system.morph \ test:morphs-repo alfred hello-system.morph -# Unpack the original stratum and run the program. +# find out the offset of the partition in the disk image +# udevadm settle is used to wait until devices have appeared +loop=$(losetup -f --show "$img1") +udevadm settle +offset=$(sfdisk -d "$loop" | + sed -n '/start=/s/^.*start=\s*\([0-9]\+\)[^0-9].*$/\1/p' | + head -n 1) +ssz=`cat "/sys/devices/virtual/block/$(basename "$loop")/queue/hw_sector_size"` +losetup -d "$loop" +udevadm settle + +# mount the disk mkdir "$DATADIR/unpacked" +# this has to be done by losetup then mount, because busybox mount doesn't +# accept the -o offset= option +loop=$(losetup -o "$(expr "$offset" '*' "$ssz")" -f --show "$img1") +udevadm settle +trap 'losetup -d "$loop"' INT TERM EXIT +mount -o subvol=factory-run -t btrfs "$loop" "$DATADIR/unpacked" +trap 'umount "$DATADIR/unpacked"; losetup -d "$loop"' INT TERM EXIT + cd "$DATADIR/unpacked" -"$SRCDIR/scripts/assemble-stratum" --cachedir "$DATADIR/cache" "$stratum1" \ - "$DATADIR/stratum.tar" hello-stratum -tar -xf "$DATADIR/stratum.tar" echo "old version:" ./bin/hello @@ -89,4 +104,5 @@ echo "new version:" # Done. echo "Done." - +# chdir out of mounted folder, so it can be unmounted +cd / -- cgit v1.2.1