From 6ce9ecead518fb6eb17d8f9ac8d3119b83b2319a Mon Sep 17 00:00:00 2001 From: Michael Hudson-Doyle Date: Thu, 31 Aug 2023 13:25:22 +1200 Subject: [PATCH] disable all apt sources during offline install The change in mantic to deb822 sources makes this more urgent but this was a bit of a landmine anyway. --- subiquity/server/apt.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/subiquity/server/apt.py b/subiquity/server/apt.py index d06a498d..bda184b7 100644 --- a/subiquity/server/apt.py +++ b/subiquity/server/apt.py @@ -68,6 +68,15 @@ def get_index_targets() -> List[str]: return [key for key in targets if key.count("::") == 3] +def apt_sourceparts_files(mp: Mountpoint) -> List[str]: + # Return the relative path of the files from + # mp("etc/apt/sources.list.d") that apt will read. + root = pathlib.Path(mp.p()) + sources_list_d = root / "etc/apt/sources.list.d" + paths = list(sources_list_d.glob("*.list")) + list(sources_list_d.glob("*.sources")) + return [str(p.relative_to(root)) for p in paths] + + class AptConfigurer: # We configure apt during installation so that installs from the pool on # the cdrom are preferred during installation but remove this again in the @@ -242,6 +251,8 @@ class AptConfigurer: proxy_path = self.install_tree.p("etc/apt/apt.conf.d/90curtin-aptproxy") if os.path.exists(proxy_path): os.unlink(proxy_path) + for relpath in apt_sourceparts_files(self.configured_tree): + os.unlink(self.install_tree.p(relpath)) codename = lsb_release(dry_run=self.app.opts.dry_run)["codename"] @@ -332,6 +343,8 @@ class AptConfigurer: private_mounts=True, ) else: + for relpath in apt_sourceparts_files(self.configured_tree): + _restore_file(relpath) await _restore_dir("var/lib/apt/lists") await self.cleanup()