diff --git a/imgutil/imgutil b/imgutil/imgutil index e8187531..4d6e5f4e 100644 --- a/imgutil/imgutil +++ b/imgutil/imgutil @@ -150,6 +150,11 @@ class FileMasker(): secontext = secontext.split(b'\x00', 1)[0].decode('utf8') subprocess.check_call(['chcon', secontext, tmaskwith]) +# What capture adds to an Ubuntu source to build the deployment initramfs. +# MODULES=list in there would also shrink the initramfs of the source and of +# installed clones to the hook's driver list. +CAPTURE_BOOT_FILES = ('/etc/initramfs-tools/hooks/confluent', + '/etc/initramfs-tools/conf.d/confluent.conf') # Directories whose contents are host specific leftovers (scratch space, # crash dumps, logs, caches, cached credentials). The directories themselves # are kept so their mode, ownership and labels survive. @@ -171,7 +176,7 @@ CAPTURE_DROP_FILES = ( # identity and stable privacy IPv6 addresses '/var/lib/dhcpcd/*.lease*', '/var/lib/dhcpcd/duid', '/var/lib/dhcpcd/secret', '/var/lib/NetworkManager/secret_key', - '/root/.*_history', '/root/.lesshst', '/root/.viminfo') + '/root/.*_history', '/root/.lesshst', '/root/.viminfo') + CAPTURE_BOOT_FILES # Network profiles with static addresses of the source, which would come up # on interfaces confignet does not configure (deployment writes the node's # own, as with the netplan files masked in capture_fs). Profiles without @@ -291,6 +296,11 @@ def capture_local_cleanup(): shutil.rmtree('/usr/lib/dracut/modules.d/97confluent') except Exception: pass + for bootfile in CAPTURE_BOOT_FILES: + try: + os.remove(bootfile) + except FileNotFoundError: + pass subprocess.check_call(['umount', '/run/imgutil/capout']) def build_boot_tree(targpath):