Skip to content

Commit 23f935a

Browse files
Add add-arch action
1 parent dd74dee commit 23f935a

3 files changed

Lines changed: 26 additions & 1 deletion

File tree

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,3 +308,8 @@ target system.
308308
Mount all squashfses in `new/iso/casper` at `old/{squash_name}` (this
309309
is mostly to make poking at ISOs in a subsequent interactive `--shell`
310310
action easier).
311+
312+
### add-arch
313+
314+
Add support for extra architectures (multi-arch). This is equivalent of running `dpkg --add-architecture <arch>`.
315+
It receives exactly one argument.

livefs_edit/actions.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -491,8 +491,15 @@ def cache_for_dir(ctxt, dir):
491491
apt_pkg.config.clear(key)
492492
apt_pkg.config["Dir"] = dir
493493
apt_pkg.init_config()
494+
494495
apt_pkg.config["APT::Architecture"] = ctxt.get_arch()
495-
apt_pkg.config["APT::Architectures"] = ctxt.get_arch()
496+
497+
apt_pkg.config["APT::Architectures::"] = ctxt.get_arch()
498+
499+
# for multi-arch
500+
for arch in ctxt.get_extra_arches():
501+
apt_pkg.config["APT::Architectures::"] = arch
502+
496503
apt_pkg.init_system()
497504
return Cache()
498505

@@ -786,3 +793,9 @@ def mount_all_layers(ctxt, target='mounts'):
786793
squash_names = get_layer_part_names(squash.stem)
787794
lowers = [ctxt.mount_squash(name) for name in squash_names]
788795
ctxt.add_overlay(lowers, ctxt.p(f'{target}/{squash.stem}'))
796+
797+
@register_action()
798+
def add_arch(ctxt, arch=None):
799+
if arch is None:
800+
raise Exception("argument to --arch is mandatory")
801+
ctxt.add_arch(arch)

livefs_edit/context.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ def __init__(self, source_path, *, debug=False):
6969
self._mounts = []
7070
self._squash_mounts = {}
7171
self._xorriso_extra_args = []
72+
self._extra_arches = []
7273

7374
def run(self, cmd, check=True, **kw):
7475
if self.debug:
@@ -231,6 +232,12 @@ def get_arch(self):
231232
with open(self.p('new/iso/.disk/info')) as fp:
232233
return fp.read().strip().split()[-2]
233234

235+
def add_arch(self, arch):
236+
self._extra_arches.append(arch)
237+
238+
def get_extra_arches(self):
239+
return self._extra_arches
240+
234241
def get_suite(self):
235242
from deb822 import Deb822
236243
paths = glob.glob(self.p('old/iso/dists/*/Release'))

0 commit comments

Comments
 (0)