From 23f935a99f308eda76c3c2d2fa53452cd00bb223 Mon Sep 17 00:00:00 2001 From: Leandro Santiago Date: Tue, 13 Aug 2024 11:35:32 +0200 Subject: [PATCH] Add add-arch action --- README.md | 5 +++++ livefs_edit/actions.py | 15 ++++++++++++++- livefs_edit/context.py | 7 +++++++ 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 7a527ca..2e4e47a 100644 --- a/README.md +++ b/README.md @@ -308,3 +308,8 @@ target system. Mount all squashfses in `new/iso/casper` at `old/{squash_name}` (this is mostly to make poking at ISOs in a subsequent interactive `--shell` action easier). + +### add-arch + +Add support for extra architectures (multi-arch). This is equivalent of running `dpkg --add-architecture `. +It receives exactly one argument. diff --git a/livefs_edit/actions.py b/livefs_edit/actions.py index 1c56648..fc1b0f5 100644 --- a/livefs_edit/actions.py +++ b/livefs_edit/actions.py @@ -491,8 +491,15 @@ def cache_for_dir(ctxt, dir): apt_pkg.config.clear(key) apt_pkg.config["Dir"] = dir apt_pkg.init_config() + apt_pkg.config["APT::Architecture"] = ctxt.get_arch() - apt_pkg.config["APT::Architectures"] = ctxt.get_arch() + + apt_pkg.config["APT::Architectures::"] = ctxt.get_arch() + + # for multi-arch + for arch in ctxt.get_extra_arches(): + apt_pkg.config["APT::Architectures::"] = arch + apt_pkg.init_system() return Cache() @@ -786,3 +793,9 @@ def mount_all_layers(ctxt, target='mounts'): squash_names = get_layer_part_names(squash.stem) lowers = [ctxt.mount_squash(name) for name in squash_names] ctxt.add_overlay(lowers, ctxt.p(f'{target}/{squash.stem}')) + +@register_action() +def add_arch(ctxt, arch=None): + if arch is None: + raise Exception("argument to --arch is mandatory") + ctxt.add_arch(arch) diff --git a/livefs_edit/context.py b/livefs_edit/context.py index aa73850..e6a84ab 100644 --- a/livefs_edit/context.py +++ b/livefs_edit/context.py @@ -69,6 +69,7 @@ def __init__(self, source_path, *, debug=False): self._mounts = [] self._squash_mounts = {} self._xorriso_extra_args = [] + self._extra_arches = [] def run(self, cmd, check=True, **kw): if self.debug: @@ -231,6 +232,12 @@ def get_arch(self): with open(self.p('new/iso/.disk/info')) as fp: return fp.read().strip().split()[-2] + def add_arch(self, arch): + self._extra_arches.append(arch) + + def get_extra_arches(self): + return self._extra_arches + def get_suite(self): from deb822 import Deb822 paths = glob.glob(self.p('old/iso/dists/*/Release'))