summaryrefslogtreecommitdiff
path: root/tests.as-root
diff options
context:
space:
mode:
authorRichard Maw <richard.maw@codethink.co.uk>2012-07-16 10:17:12 +0000
committerRichard Maw <richard.maw@codethink.co.uk>2012-07-16 12:23:44 +0000
commitfbf5a1027798d476482f56183c35bf71af8b3e33 (patch)
tree8decacfa4bd7643a2df7eb006976cbdca7e5eb21 /tests.as-root
parente4b1273d3ce11408663876a939c290fb77699d81 (diff)
downloadmorph-fbf5a1027798d476482f56183c35bf71af8b3e33.tar.gz
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.
Diffstat (limited to 'tests.as-root')
-rwxr-xr-xtests.as-root/make-patch.script28
1 files changed, 22 insertions, 6 deletions
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 /