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

Proposed by Michael Hudson-Doyle
Status: Merged
Approved by: Michael Hudson-Doyle
Approved revision: a93d1e7aa82a0b096c2beecb48b220bd4f57a88f
Merge reported by: Server Team CI bot
Merged at revision: not available
Proposed branch: ~mwhudson/curtin:non-root-apt
Merge into: curtin:master
Diff against target: 51 lines (+10/-6)
1 file modified
curtin/commands/apt_config.py (+10/-6)
Reviewer Review Type Date Requested Status
Server Team CI bot continuous-integration Approve
Dan Bungert Approve
Review via email: mp+410559@code.launchpad.net

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.

To post a comment you must log in.
Revision history for this message
Server Team CI bot (server-team-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Dan Bungert (dbungert) :
review: Approve
Revision history for this message
Server Team CI bot (server-team-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Server Team CI bot (server-team-bot) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/curtin/commands/apt_config.py b/curtin/commands/apt_config.py
2index 9f62c99..9ea2d30 100644
3--- a/curtin/commands/apt_config.py
4+++ b/curtin/commands/apt_config.py
5@@ -188,9 +188,11 @@ def mirrorurl_to_apt_fileprefix(mirror):
6 return string
7
8
9-def rename_apt_lists(new_mirrors, target=None):
10+def rename_apt_lists(new_mirrors, target=None, arch=None):
11 """rename_apt_lists - rename apt lists to preserve old cache data"""
12- default_mirrors = get_default_mirrors(distro.get_architecture(target))
13+ if arch is None:
14+ arch = distro.get_architecture(target)
15+ default_mirrors = get_default_mirrors(arch)
16
17 pre = paths.target_path(target, APT_LISTS)
18 for (name, omirror) in default_mirrors.items():
19@@ -213,10 +215,12 @@ def rename_apt_lists(new_mirrors, target=None):
20 LOG.warn("Failed to rename apt list:", exc_info=True)
21
22
23-def update_default_mirrors(entries, mirrors, target):
24+def update_default_mirrors(entries, mirrors, target, arch=None):
25 """replace existing default repos with the configured mirror"""
26
27- defaults = get_default_mirrors(distro.get_architecture(target))
28+ if arch is None:
29+ arch = distro.get_architecture(target)
30+ defaults = get_default_mirrors(arch)
31 mirrors_replacement = {
32 defaults['PRIMARY']: mirrors["MIRROR"],
33 defaults['SECURITY']: mirrors["SECURITY"],
34@@ -318,7 +322,7 @@ def entries_to_str(entries):
35 return ''.join([str(entry) + '\n' for entry in entries])
36
37
38-def generate_sources_list(cfg, release, mirrors, target=None):
39+def generate_sources_list(cfg, release, mirrors, target=None, arch=None):
40 """ generate_sources_list
41 create a source.list file based on a custom or default template
42 by replacing mirrors and release in the template
43@@ -337,7 +341,7 @@ def generate_sources_list(cfg, release, mirrors, target=None):
44 if from_file:
45 # when loading from an existing file, we also replace default
46 # URIs with configured mirrors
47- entries = update_default_mirrors(entries, mirrors, target)
48+ entries = update_default_mirrors(entries, mirrors, target, arch)
49
50 entries = update_mirrors(entries, mirrors)
51 entries = update_dist(entries, release)

Subscribers

People subscribed via source and target branches