livefs-editor
livefs-editor copied to clipboard
resolv.conf is not correctly restored after add-autoinstall-config
Today I used this script to add a package and an autoinstall config to the installer. During the installation I noticed that the name resolution was not working and looking into /etc
showed me an incorrectly static resolv.conf
and a resolv.conf.tmp
symlink.
I looked into the source code and tracked it down to the setup_rootfs()
function. This function calls the context method add_sys_mounts()
which adds a _pre_repack
callback, to restore the original resolv.conf
. After this setup_rootfs()
addes a _pre_repack
callback too, which creates the custom squashfs. Since pre_repack hooks are later called in reverse by the repack()
method, the custom squashfs is build before the original resolv.conf
is restored.
For myself I fixed it by adding the pre_repack hook from setup_rootfs
to the front of the list. I don't know if there are any side effects doing it this way if a more complicated action.yaml is used, because mine is very simple:
- name: add-debs-to-pool
debs:
- helper/subiquity-speed-up_1_all.deb
- name: add-autoinstall-config
autoinstall_config: user-data
Adding it to the start of the whole list brought some other problems with it, so I added the _pre_repack
hook from setup_rootfs
before the one from add_sys_mounts
. These are my two patches to archive this:
diff --git a/livefs_edit/actions.py b/livefs_edit/actions.py
index 106cf64..2b45711 100644
--- a/livefs_edit/actions.py
+++ b/livefs_edit/actions.py
@@ -143,7 +143,7 @@ def setup_rootfs(ctxt, target='rootfs'):
fp.write(
f"LAYERFS_PATH={new_squash_name}.squashfs\n")
- ctxt.add_pre_repack_hook(_pre_repack)
+ ctxt.add_pre_repack_hook(_pre_repack, -1)
return target
diff --git a/livefs_edit/context.py b/livefs_edit/context.py
index b689bd4..48df2d7 100644
--- a/livefs_edit/context.py
+++ b/livefs_edit/context.py
@@ -185,8 +185,10 @@ class EditContext:
'overlay', 'overlay', mountpoint, options=options).p(),
upperdir=upperdir)
- def add_pre_repack_hook(self, hook):
- self._pre_repack_hooks.append(hook)
+ def add_pre_repack_hook(self, hook, place=None):
+ if place is None:
+ place = len(self._pre_repack_hooks) + 1
+ self._pre_repack_hooks.insert(place, hook)
def mount_squash(self, name):
target = self.p('old/' + name)
Since I don't know if this has some unknown effect on other actions, I leave this here instead of creating a PR.