Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add add-arch action #67

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <arch>`.
It receives exactly one argument.
15 changes: 14 additions & 1 deletion livefs_edit/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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)
7 changes: 7 additions & 0 deletions livefs_edit/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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'))
Expand Down