diff options
author | Richard Maw <richard.maw@codethink.co.uk> | 2012-10-26 13:48:57 +0000 |
---|---|---|
committer | Richard Maw <richard.maw@codethink.co.uk> | 2012-10-26 13:48:57 +0000 |
commit | 15243493b945d87bc56d625b722060dd10799d15 (patch) | |
tree | 6873b8fd2409852cea277d425ae242d0f55251dc /tests.as-root/lib | |
parent | 2bcc7ba44734c73a4a80b40b80a42b1376af5e00 (diff) | |
parent | c67afe0431f4abfc16eb9994239c3f21b56ad303 (diff) | |
download | morph-15243493b945d87bc56d625b722060dd10799d15.tar.gz |
Merge branch 'samthursfield/write-metadata-for-system' of git://git.baserock.org/baserock/morph
This includes a fixup of shell quoting in tests.as-root/lib.
Tests needs to be run with a larget TMPDIR than systemd's default,
since system images can be large.
Diffstat (limited to 'tests.as-root/lib')
-rw-r--r-- | tests.as-root/lib | 35 |
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..6818abde --- /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" +} |