summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNeil Williams <codehelp@debian.org>2016-03-14 19:40:56 +0000
committerNeil Williams <codehelp@debian.org>2016-03-14 19:42:13 +0000
commit3d683971875f4b9fbc98fa03148aa37b3e4fd820 (patch)
treee4bde21c6bf88cf871b365b61fbee26dcad6a868
parentb5fcad38d623d2a5f6bc0b36d53d2d7b3dbf9f83 (diff)
downloadvmdebootstrap-3d683971875f4b9fbc98fa03148aa37b3e4fd820.tar.gz
Add support for user-specific bootflagsvmdebootstrap-1.5
(Only for the first partition).
-rwxr-xr-xbin/vmdebootstrap7
-rw-r--r--doc/overview.rst4
-rw-r--r--yarns/200-fast-tests.yarn8
-rw-r--r--yarns/300-slow-build-tests.yarn10
-rw-r--r--yarns/900-implements.yarn5
5 files changed, 34 insertions, 0 deletions
diff --git a/bin/vmdebootstrap b/bin/vmdebootstrap
index 81cc7bf..00c77f8 100755
--- a/bin/vmdebootstrap
+++ b/bin/vmdebootstrap
@@ -74,6 +74,7 @@ class VmDebootstrap(cliapp.Application): # pylint: disable=too-many-public-meth
self.settings.bytesize(['bootsize'], 'create boot partition of size '
'SIZE (%default)', metavar='BOOTSIZE', default='0%')
self.settings.string(['boottype'], 'specify file system type for /boot/', default='ext2')
+ self.settings.string(['bootflag'], 'specify flag to set for /boot/', default='')
self.settings.bytesize(['bootoffset'], 'Space to leave at start of the '
'image for bootloader', default='0')
self.settings.boolean(['use-uefi'], 'Setup image for UEFI boot', default=False)
@@ -227,6 +228,12 @@ class VmDebootstrap(cliapp.Application): # pylint: disable=too-many-public-meth
os.mkdir(self.bootdir)
self.mount(bootdev, self.bootdir)
+ # set user-specified flags, e.g. lba
+ if self.settings['bootflag']:
+ base.message("Setting '%s' flag on first partition." % self.settings['bootflag'])
+ runcmd(['parted', '-s', self.settings['image'],
+ 'set', '1', self.settings['bootflag'], 'on'])
+
def _image_operations(self, rootdir, rootdev):
if not self.settings['image']:
return
diff --git a/doc/overview.rst b/doc/overview.rst
index 59df7af..670c898 100644
--- a/doc/overview.rst
+++ b/doc/overview.rst
@@ -100,6 +100,7 @@ Options
likely to need two or three times the space of the
installed kernel.
--boottype=FSTYPE Filesystem to use for the /boot partition. (default ext2)
+ --bootflag=FLAG Flag to set on the first partition. (default none)
--roottype=FSTYPE Filesystem to use for the / (root) partition. (default ext4)
--swap=SWAPSIZE If specified, create a swap partition of the given
size within the image. Debootstrapping will fail
@@ -318,6 +319,9 @@ typically support requires adding ``u-boot`` using ``--package`` and then
copying or manipulating the relevant ``u-boot`` files in the customisation
script. Examples are included for beaglebone-black.
+Some ``u-boot`` examples recommend the use of the ``lba`` flag on the
+boot partition, so use the --bootflag option where relevant.
+
.. _installation_images:
Installation images and virtual machines
diff --git a/yarns/200-fast-tests.yarn b/yarns/200-fast-tests.yarn
index dc6ddf8..92f543f 100644
--- a/yarns/200-fast-tests.yarn
+++ b/yarns/200-fast-tests.yarn
@@ -188,3 +188,11 @@ verify that vmdebootstrap parses the command line correctly.
... --image=FOO --roottype btrfs --dry-run
THEN vmdebootstrap exited with a non-zero exit code
AND vmdebootstrap wrote an error message matching not yet supported
+
+ SCENARIO bootflag requires argument
+ ASSUMING fast tests are requested
+ WHEN user attempts to run vmdebootstrap
+ ... --bootflag
+ THEN vmdebootstrap exited with a non-zero exit code
+ AND vmdebootstrap wrote an error message matching bootflag
+ AND vmdebootstrap wrote an error message matching requires an argument
diff --git a/yarns/300-slow-build-tests.yarn b/yarns/300-slow-build-tests.yarn
index 1934217..b4b0dd3 100644
--- a/yarns/300-slow-build-tests.yarn
+++ b/yarns/300-slow-build-tests.yarn
@@ -60,3 +60,13 @@ These tests are slow, since building images is slow.
AND partition 2 has an ext4 filesystem
AND partition 2 has file /etc/fstab matching ^\S+\s+\/\s+ext4\s+errors=remount-ro\s+\d\s+\d$
AND partition 2 has file /etc/fstab matching ^\S+\s+\/boot\s+ext3\s+errors=remount-ro\s+\d\s+\d$
+
+ SCENARIO build a Debian 8 armhf image with boot flag lba
+ ASSUMING build tests are requested
+ GIVEN user wants to build an image FOO.img that is 2GiB in size
+ WHEN the user runs vmdebootstrap --bootflag=lba --arch armhf
+ ... --foreign /usr/bin/qemu-arm-static --bootsize 100mib --boottype vfat
+ THEN the image has the correct size
+ AND the partition count of the image is 2
+ AND partition 1 has the boot flag set
+ AND partition 1 has the lba flag set
diff --git a/yarns/900-implements.yarn b/yarns/900-implements.yarn
index 57889ab..a629dc9 100644
--- a/yarns/900-implements.yarn
+++ b/yarns/900-implements.yarn
@@ -112,6 +112,11 @@ Check partition boot flag.
awk -v "PART=$MATCH_1" '/^ [0-9]+ / && $1 == PART && $7 ~ "^boot,?$"' |
grep .
+ IMPLEMENTS THEN partition (\d+) has the lba flag set
+ parted --script "$IMAGE" print |
+ awk -v "PART=$MATCH_1" '/^ [0-9]+ / && $1 == PART && $8 ~ "^lba?$"' |
+ grep .
+
Check filesystem on a partition. This checks the actual filesystem,
not a type declared in the partition table.