apt: Only backup/restore sources.list if it exists
We backup the sources.list to a file in sources.list.d to be able to insert our source first; if we do not have a sources.list this is not necessary. If an image uses ubuntu.sources, this logic also works fine as sources.list that we write will be sourced before the ubuntu.sources.
This commit is contained in:
parent
753ce9f701
commit
5db34f84c8
|
@ -243,6 +243,7 @@ class AptConfigurer:
|
|||
await self.mounter.mount("/cdrom", self.install_tree.p("cdrom"), options="bind")
|
||||
|
||||
if self.app.base_model.network.has_network:
|
||||
with contextlib.suppress(FileNotFoundError):
|
||||
os.rename(
|
||||
self.install_tree.p("etc/apt/sources.list"),
|
||||
self.install_tree.p("etc/apt/sources.list.d/original.list"),
|
||||
|
@ -326,6 +327,7 @@ class AptConfigurer:
|
|||
# The file only exists if we are online
|
||||
with contextlib.suppress(FileNotFoundError):
|
||||
os.unlink(target_mnt.p("etc/apt/sources.list.d/original.list"))
|
||||
with contextlib.suppress(FileNotFoundError):
|
||||
_restore_file("etc/apt/sources.list")
|
||||
|
||||
with contextlib.suppress(FileNotFoundError):
|
||||
|
|
Loading…
Reference in New Issue