summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2020-04-11 11:04:59 +0000
committerLars Wirzenius <liw@liw.fi>2020-04-11 11:04:59 +0000
commita52fbb7794bc4f851d37589993c092a22a230bb1 (patch)
tree0c7ccf5fcbafb58eb3e230a3e009b9b54a6ae3de
parentb5daa18fb9373eaa39c6a7370a8236d83962f80f (diff)
parent5ef668c05552dcd3c5d1c57b07c76c1ed2a3e4b9 (diff)
downloadvmdb2-a52fbb7794bc4f851d37589993c092a22a230bb1.tar.gz
Merge branch 'virts' into 'master'
Add step to mount virtual filesystems See merge request larswirzenius/vmdb2!16
-rw-r--r--NEWS15
-rw-r--r--contractor-fast.yaml32
-rw-r--r--uefi.vmdb2
-rw-r--r--vmdb/plugins/virtualfs.mdwn29
-rw-r--r--vmdb/plugins/virtualfs_plugin.py (renamed from vmdb/plugins/virtuals_plugin.py)4
-rw-r--r--vmdb/runcmd.py25
-rw-r--r--without-tests2
7 files changed, 83 insertions, 26 deletions
diff --git a/NEWS b/NEWS
index c6f3c48..2185635 100644
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,21 @@ NEWS for vmdb2, the Debian disk image builder
Version 0.14.1+git, not yet released
------------------------------------
+* Document and rename the `virtual-filesystems` plugin, and undo the
+ previous changes to have `/proc` automatically mounted in the
+ chroot, when running commands in the chroot. That wasn't enough
+ (e.g., it didn't cover Ansible), and `virtual-filesystems`
+ seems generally like the better solution.
+
+ The grub plugin handles the filesystems it needs itself, but doesn't
+ mind if they're already mounted. The `virtual-filesystems` step is
+ only needed when a Debian package is installed, possibly via
+ Ansible, or some other command is run that needs `/proc` or one of
+ the other virtual filesystems.
+
+ This change should NOT require changes to existing, working .vmdb
+ files.
+
Version 0.14.1, not yet released
------------------------------------
diff --git a/contractor-fast.yaml b/contractor-fast.yaml
new file mode 100644
index 0000000..531f452
--- /dev/null
+++ b/contractor-fast.yaml
@@ -0,0 +1,32 @@
+worker-image: ~/tmp/contractor/worker-vmdb2.img
+install:
+ - build-essential
+ - python3-all
+ - python3-coverage-test-runner
+ - python3-cliapp
+ - python3-jinja2
+ - python3-yaml
+ - qemu-utils
+ - parted
+ - kpartx
+ - debootstrap
+ - dosfstools
+ - ansible
+ - moreutils
+ - git
+ - cmdtest
+ - pandoc
+source: .
+workspace: ~/tmp/contractor/vmdb2
+build: |
+ export LC_ALL=C.UTF-8
+ ./check
+
+ sudo ./vmdb2 --rootfs-tarball /workspace/buster.tar.gz \
+ --verbose --log /workspace/check.log \
+ --output /workspace/uefi.img uefi.vmdb
+
+ cd /workspace
+ ls -lh
+ du -h *.img
+ rm -f *.img*
diff --git a/uefi.vmdb b/uefi.vmdb
index 0f20041..853d624 100644
--- a/uefi.vmdb
+++ b/uefi.vmdb
@@ -30,6 +30,8 @@ steps:
- mount: /
+ - virtual-filesystems: /
+
- unpack-rootfs: /
- debootstrap: buster
diff --git a/vmdb/plugins/virtualfs.mdwn b/vmdb/plugins/virtualfs.mdwn
new file mode 100644
index 0000000..a9ee6d9
--- /dev/null
+++ b/vmdb/plugins/virtualfs.mdwn
@@ -0,0 +1,29 @@
+Step: virtual-filesystems
+-----------------------------------------------------------------------------
+
+Mount the usual Linux virtual filesystems in the chroot:
+
+* `/proc`
+* `/dev`
+* `/dev/pts`
+* `/dev/shm`
+* `/run`
+* `/run/lock`
+* `/sys`
+
+They will be automatically unmounted at the end.
+
+Often, the virtual filesystems are unnecessary, but some Debian
+packages won't install without them. The grub boot loader needs them
+as well, but mounts what it needs itself, if necessary.
+
+Step keys:
+
+* `virtual-filesystems` &mdash; REQUIRED; value is the tag of
+ the root filesystem.
+
+Example (in the .vmdb file):
+
+~~~yaml
+- virtual-filesystem: rootfs
+~~~
diff --git a/vmdb/plugins/virtuals_plugin.py b/vmdb/plugins/virtualfs_plugin.py
index 71176f8..848d000 100644
--- a/vmdb/plugins/virtuals_plugin.py
+++ b/vmdb/plugins/virtualfs_plugin.py
@@ -45,11 +45,11 @@ class VirtualFilesystemMountStepRunner(vmdb.StepRunnerInterface):
def get_key_spec(self):
return {
- 'mount-virtual-filesystems': str,
+ 'virtual-filesystems': str,
}
def run(self, values, settings, state):
- fstag = values['mount-virtual-filesystems']
+ fstag = values['virtual-filesystems']
mount_point = state.tags.get_builder_mount_point(fstag)
self.mount_virtuals(mount_point, state)
diff --git a/vmdb/runcmd.py b/vmdb/runcmd.py
index 1ff374c..fb0d8b3 100644
--- a/vmdb/runcmd.py
+++ b/vmdb/runcmd.py
@@ -54,29 +54,8 @@ def runcmd(argv, *argvs, **kwargs):
def runcmd_chroot(chroot, argv, *argvs, **kwargs):
- _mount_proc(chroot)
- try:
- full_argv = ['chroot', chroot] + argv
- ret = runcmd(full_argv, *argvs, **kwargs)
- except Exception:
- _unmount_proc(chroot)
- raise
- _unmount_proc(chroot)
- return ret
-
-
-def _mount_proc(chroot):
- proc = _procdir(chroot)
- argv = ['chroot', chroot, 'mount', '-t', 'proc', 'proc', '/proc']
- progress('mounting proc: %r' % argv)
- subprocess.check_call(argv)
-
-
-def _unmount_proc(chroot):
- proc = _procdir(chroot)
- argv = ['chroot', chroot, 'umount', '/proc']
- progress('unmounting proc: %r' % argv)
- subprocess.check_call(argv)
+ full_argv = ['chroot', chroot] + argv
+ return runcmd(full_argv, *argvs, **kwargs)
def _procdir(chroot):
diff --git a/without-tests b/without-tests
index c6ec44d..8821505 100644
--- a/without-tests
+++ b/without-tests
@@ -25,7 +25,7 @@ vmdb/plugins/qemudebootstrap_plugin.py
vmdb/plugins/shell_plugin.py
vmdb/plugins/unpack_rootfs_plugin.py
vmdb/plugins/vgcreate_plugin.py
-vmdb/plugins/virtuals_plugin.py
+vmdb/plugins/virtualfs_plugin.py
vmdb/runcmd.py
vmdb/state.py
vmdb/version.py