summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2020-04-11 12:11:31 +0300
committerLars Wirzenius <liw@liw.fi>2020-04-11 13:57:21 +0300
commit5ef668c05552dcd3c5d1c57b07c76c1ed2a3e4b9 (patch)
tree0c7ccf5fcbafb58eb3e230a3e009b9b54a6ae3de
parent4f8be92782155289620e257942e216e55768a641 (diff)
downloadvmdb2-5ef668c05552dcd3c5d1c57b07c76c1ed2a3e4b9.tar.gz
Add: rename to virtual-filesystems, make use of it, fix bugs
The mount-virtual-filesystems step is renamed to virtual-fileystems, so that step sorting in documentation works consistently. (Does mount or mount-virtual-filesystems come first? Seems to depend on which tool you ask. I love computers.) Add use of the virtual-filesystems step to uefi.vmdb, but only that one. The other .vmdb files stay as they were to make sure they work without the new step. Fix problems found by using the other changes.
-rw-r--r--NEWS15
-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
6 files changed, 51 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/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