← Back to team overview

curtin-dev team mailing list archive

[Merge] ~mwhudson/curtin:non-root-apt into curtin:master

 

Michael Hudson-Doyle has proposed merging ~mwhudson/curtin:non-root-apt into curtin:master.

Commit message:
apt_config: tweaks to allow some functionality in partial tree as non-root

Subiquity is going to start doing apt configuration outside of curtin
soon and I want to emulate this in dry-run mode by copying only the apt
config to a temporary directory and configuring that as indicated in the
UI. It's (probably?) too much to ask to be able to run the full
apt-config command but the stuff around generating the sources.list file
doesn't really need to do anything special -- it only depends on non-apt
stuff in target to determine the architecture, which can be passed as a
parameter.


Requested reviews:
  curtin developers (curtin-dev)

For more details, see:
https://code.launchpad.net/~mwhudson/curtin/+git/curtin/+merge/410559
-- 
Your team curtin developers is requested to review the proposed merge of ~mwhudson/curtin:non-root-apt into curtin:master.
diff --git a/curtin/commands/apt_config.py b/curtin/commands/apt_config.py
index 9f62c99..9ea2d30 100644
--- a/curtin/commands/apt_config.py
+++ b/curtin/commands/apt_config.py
@@ -188,9 +188,11 @@ def mirrorurl_to_apt_fileprefix(mirror):
     return string
 
 
-def rename_apt_lists(new_mirrors, target=None):
+def rename_apt_lists(new_mirrors, target=None, arch=None):
     """rename_apt_lists - rename apt lists to preserve old cache data"""
-    default_mirrors = get_default_mirrors(distro.get_architecture(target))
+    if arch is None:
+        arch = distro.get_architecture(target)
+    default_mirrors = get_default_mirrors(arch)
 
     pre = paths.target_path(target, APT_LISTS)
     for (name, omirror) in default_mirrors.items():
@@ -213,10 +215,12 @@ def rename_apt_lists(new_mirrors, target=None):
                 LOG.warn("Failed to rename apt list:", exc_info=True)
 
 
-def update_default_mirrors(entries, mirrors, target):
+def update_default_mirrors(entries, mirrors, target, arch=None):
     """replace existing default repos with the configured mirror"""
 
-    defaults = get_default_mirrors(distro.get_architecture(target))
+    if arch is None:
+        arch = distro.get_architecture(target)
+    defaults = get_default_mirrors(arch)
     mirrors_replacement = {
         defaults['PRIMARY']: mirrors["MIRROR"],
         defaults['SECURITY']: mirrors["SECURITY"],
@@ -318,7 +322,7 @@ def entries_to_str(entries):
     return ''.join([str(entry) + '\n' for entry in entries])
 
 
-def generate_sources_list(cfg, release, mirrors, target=None):
+def generate_sources_list(cfg, release, mirrors, target=None, arch=None):
     """ generate_sources_list
         create a source.list file based on a custom or default template
         by replacing mirrors and release in the template
@@ -337,7 +341,7 @@ def generate_sources_list(cfg, release, mirrors, target=None):
     if from_file:
         # when loading from an existing file, we also replace default
         # URIs with configured mirrors
-        entries = update_default_mirrors(entries, mirrors, target)
+        entries = update_default_mirrors(entries, mirrors, target, arch)
 
     entries = update_mirrors(entries, mirrors)
     entries = update_dist(entries, release)

Follow ups