curtin-dev team mailing list archive
-
curtin-dev team
-
Mailing list archive
-
Message #04064
[Merge] ~dbungert/curtin:flash-kernel-on-reconfigure into curtin:master
Dan Bungert has proposed merging ~dbungert/curtin:flash-kernel-on-reconfigure into curtin:master.
Commit message:
curthooks: set FK env vars for dpkg-reconfigure of the kernel
LP: #2106682
Requested reviews:
curtin developers (curtin-dev)
Related bugs:
Bug #2106682 in subiquity (Ubuntu): "Subiquity does not invoke flash-kernel and grub-update"
https://bugs.launchpad.net/ubuntu/+source/subiquity/+bug/2106682
For more details, see:
https://code.launchpad.net/~dbungert/curtin/+git/curtin/+merge/484244
--
Your team curtin developers is requested to review the proposed merge of ~dbungert/curtin:flash-kernel-on-reconfigure into curtin:master.
diff --git a/curtin/commands/curthooks.py b/curtin/commands/curthooks.py
index 0c4d7fd..5be7904 100644
--- a/curtin/commands/curthooks.py
+++ b/curtin/commands/curthooks.py
@@ -359,13 +359,7 @@ def setup_kernel_img_conf(target):
def install_kernel(cfg, target):
def install(pkg):
- env = os.environ.copy()
- # recent flash_kernel has checks to prevent it running in cases like
- # containers or chroots, but we actually want that as curtin
- # is mostly or always doing chroot installs. LP: #1992990
- env["FK_FORCE"] = "yes"
- env["FK_FORCE_CONTAINER"] = "yes"
- distro.install_packages([pkg], target=target, env=env)
+ distro.install_packages([pkg], target=target, env=fk_env())
kernel_cfg_d = cfg.get('kernel', {})
if kernel_cfg_d is None:
@@ -1693,13 +1687,25 @@ def configure_kernel_crash_dumps(cfg, target: pathlib.Path) -> None:
kernel_crash_dumps.manual_disable(target)
+def fk_env():
+ env = os.environ.copy()
+ # recent flash_kernel has checks to prevent it running in cases
+ # like containers or chroots, but we actually want that as curtin
+ # is mostly or always doing chroot installs. LP: #1992990
+ env["FK_FORCE"] = "yes"
+ env["FK_FORCE_CONTAINER"] = "yes"
+
+ return env
+
+
def reconfigure_kernel(target: pathlib.Path) -> None:
with util.ChrootableTarget(target) as in_chroot:
# re-run kernel postinstall hooks
for kernel in distro.dpkg_query_list_kernels(target):
in_chroot.subp(
['dpkg-reconfigure', '--frontend=noninteractive', kernel],
- target=target
+ target=target,
+ env=fk_env(),
)
diff --git a/tests/unittests/test_curthooks.py b/tests/unittests/test_curthooks.py
index f1bccdb..fffd335 100644
--- a/tests/unittests/test_curthooks.py
+++ b/tests/unittests/test_curthooks.py
@@ -2759,14 +2759,18 @@ class TestDpkgReconfigure(CiTestCase):
kernel_a = self.random_string()
kernel_b = self.random_string()
self.m_list_kernels.return_value = [kernel_a, kernel_b]
- curthooks.reconfigure_kernel(self.target)
+ with patch.dict(os.environ, clear=True):
+ curthooks.reconfigure_kernel(self.target)
+ fk_env = {'FK_FORCE': 'yes', 'FK_FORCE_CONTAINER': 'yes'}
self.m_subp.assert_any_call(
['dpkg-reconfigure', '--frontend=noninteractive', kernel_a],
target=self.target,
+ env=fk_env,
)
self.m_subp.assert_any_call(
['dpkg-reconfigure', '--frontend=noninteractive', kernel_b],
target=self.target,
+ env=fk_env,
)
# vi: ts=4 expandtab syntax=python
Follow ups