summaryrefslogtreecommitdiff
path: root/tests.as-root/lib
diff options
context:
space:
mode:
authorSam Thursfield <sam.thursfield@codethink.co.uk>2012-10-25 11:06:57 +0100
committerSam Thursfield <sam.thursfield@codethink.co.uk>2012-10-26 13:43:58 +0100
commitc67afe0431f4abfc16eb9994239c3f21b56ad303 (patch)
tree4dcc13c491a68211e375f8ceda0f04491d66a4af /tests.as-root/lib
parent2bcc7ba44734c73a4a80b40b80a42b1376af5e00 (diff)
downloadmorph-c67afe0431f4abfc16eb9994239c3f21b56ad303.tar.gz
Write metadata for the rootfs itself into the rootfs
This makes it easier to identify what version of a system we are running. Tests are updated to check inside the contents of the rootfs we created, and the code to mount the rootfs as a loopback device was extracted out into tests.as-root/lib
Diffstat (limited to 'tests.as-root/lib')
-rw-r--r--tests.as-root/lib35
1 files changed, 35 insertions, 0 deletions
diff --git a/tests.as-root/lib b/tests.as-root/lib
new file mode 100644
index 00000000..ec5e52f9
--- /dev/null
+++ b/tests.as-root/lib
@@ -0,0 +1,35 @@
+#!/bin/sh
+#
+# Copyright (C) 2012 Codethink Limited
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+# Helper functions for as-root tests
+
+loopback_rootfs() {
+ # Find offset partition offset in a rootfs and mount it
+ ROOTFS="$1"
+
+ mv $ROOTFS $ROOTFS-unzipped.gz
+ gunzip $ROOTFS-unzipped.gz
+
+ OFFSET=$(sfdisk -d $ROOTFS-unzipped | \
+ grep -m 1 -o 'start=\s\+\([0-9]\+\)' | awk '{ print $2 }')
+ OFFSET=$(expr $OFFSET '*' 512)
+
+ DEVICE=$(losetup --show -o "$OFFSET" -f "$ROOTFS-unzipped")
+ udevadm settle
+
+ echo $DEVICE
+}