[elbe-devel] [PATCH v2] elbepack: create initvm repositories late during installation
Thomas Weißschuh
thomas.weissschuh at linutronix.de
Tue Mar 5 12:02:29 CET 2024
The repositories in the initvm are supposed to contain *all* packages
used by the initvm.
Steps executed by debian-installer however may install additional
packages that can be missed when creating the package during preseeding.
One notable example is 08hwdetect which installs microcode and the qemu
guest agent.
Instead generate the repository very late.
Signed-off-by: Thomas Weißschuh <thomas.weissschuh at linutronix.de>
---
Link to v1: https://lists.linutronix.de/pipermail/elbe-devel/2024-February/006603.html
---
elbepack/commands/init.py | 33 +++++++++++++++++++++++++++++++--
elbepack/init/init-elbe.sh.mako | 19 -------------------
2 files changed, 31 insertions(+), 21 deletions(-)
diff --git a/elbepack/commands/init.py b/elbepack/commands/init.py
index 4e2f28ef62ec..356df71885fb 100644
--- a/elbepack/commands/init.py
+++ b/elbepack/commands/init.py
@@ -148,11 +148,17 @@ def run_command(argv):
initvm_http_proxy = http_proxy.replace('http://localhost:',
'http://10.0.2.2:')
- d = {'elbe_version': elbe_version,
+ elbe_exe = '/usr/bin/elbe'
+ if opt.devel:
+ elbe_exe = '/var/cache/elbe/devel/elbe'
+ prj = xml.node('/initvm')
+
+ d = {'elbe_exe': elbe_exe,
+ 'elbe_version': elbe_version,
'defs': defs,
'opt': opt,
'xml': xml,
- 'prj': xml.node('/initvm'),
+ 'prj': prj,
'http_proxy': initvm_http_proxy,
'pkgs': xml.node('/initvm/pkg-list') or [],
'preseed': get_initvm_preseed(xml),
@@ -270,3 +276,26 @@ def run_command(argv):
except FileExistsError:
pass
shutil.copy(src, dst)
+
+ os.makedirs(elbe_in.fname('initrd-tree/usr/lib/finish-install.d'), exist_ok=True)
+
+ def create_as_exec(file, flags):
+ return os.open(file, flags, mode=0o755)
+
+ buildrepo_opts = ''
+
+ if not opt.build_bin:
+ buildrepo_opts += '--skip-build-bin '
+
+ if not opt.build_sources:
+ buildrepo_opts += '--skip-build-source '
+
+ cdrom_opts = ''
+ if prj.has("mirror/cdrom"):
+ cdrom_opts = '--cdrom-device /dev/sr0 --cdrom-mount-path /media/cdrom0'
+
+ with open(elbe_in.fname('initrd-tree/usr/lib/finish-install.d/93initvm-repo'),
+ mode='x', opener=create_as_exec) as f:
+
+ f.write(f'in-target {elbe_exe} '
+ f'fetch_initvm_pkgs {buildrepo_opts} {cdrom_opts} /var/cache/elbe/source.xml')
diff --git a/elbepack/init/init-elbe.sh.mako b/elbepack/init/init-elbe.sh.mako
index 20992bc44250..968d33827384 100644
--- a/elbepack/init/init-elbe.sh.mako
+++ b/elbepack/init/init-elbe.sh.mako
@@ -4,19 +4,6 @@
##
#! /bin/sh
<%
-elbe_exe = '/usr/bin/elbe'
-
-if opt.devel:
- elbe_exe = '/var/cache/elbe/devel/elbe'
-
-buildrepo_opts = ''
-
-if not opt.build_bin:
- buildrepo_opts += '--skip-build-bin'
-
-if not opt.build_sources:
- buildrepo_opts += '--skip-build-source'
-
nicmac = prj.text('buildimage/NIC/MAC', default=defs, key='nicmac')
%>
@@ -68,12 +55,6 @@ in-target update-initramfs -u
in-target haveged
-% if prj.has("mirror/cdrom"):
- in-target ${elbe_exe} fetch_initvm_pkgs ${buildrepo_opts} --cdrom-device /dev/sr0 --cdrom-mount-path /media/cdrom0 /var/cache/elbe/source.xml
-% else:
- in-target ${elbe_exe} fetch_initvm_pkgs ${buildrepo_opts} /var/cache/elbe/source.xml
-% endif
-
% if prj.has("finetuning"):
% for node in prj.all("./finetuning/"):
% if "command" == node.tag:
--
2.44.0
More information about the elbe-devel
mailing list