apt: ensure we always drop CDROM info from sources.list
Back when sources.list was always present, we would: * move the contents of sources.list to sources.list.d/original.list * write the CDROM info to sources.list so the CDROM cat be used as an APT source * restore the original sources.list file when .deconfigure() is called, effectively discarding CDROM info Nowadays, there is no guarantee that sources.list exists. So restoring the contents of sources.list may mean deleting sources.list if it wasn't present in the first place. Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
This commit is contained in:
parent
3064343f45
commit
9b612dac34
|
@ -327,8 +327,10 @@ class AptConfigurer:
|
||||||
# The file only exists if we are online
|
# The file only exists if we are online
|
||||||
with contextlib.suppress(FileNotFoundError):
|
with contextlib.suppress(FileNotFoundError):
|
||||||
os.unlink(target_mnt.p("etc/apt/sources.list.d/original.list"))
|
os.unlink(target_mnt.p("etc/apt/sources.list.d/original.list"))
|
||||||
with contextlib.suppress(FileNotFoundError):
|
try:
|
||||||
_restore_file("etc/apt/sources.list")
|
_restore_file("etc/apt/sources.list")
|
||||||
|
except FileNotFoundError:
|
||||||
|
os.unlink(target_mnt.p("etc/apt/sources.list"))
|
||||||
|
|
||||||
with contextlib.suppress(FileNotFoundError):
|
with contextlib.suppress(FileNotFoundError):
|
||||||
_restore_file("etc/apt/apt.conf.d/90curtin-aptproxy")
|
_restore_file("etc/apt/apt.conf.d/90curtin-aptproxy")
|
||||||
|
|
Loading…
Reference in New Issue