-
Notifications
You must be signed in to change notification settings - Fork 161
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
apt: Only backup/restore sources.list if it exists #1885
apt: Only backup/restore sources.list if it exists #1885
Conversation
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.
I haven't tested this, this is a proof of concept. I actually need to learn again how to build images yet to test the changes in https://code.launchpad.net/~juliank/livecd-rootfs/+git/livecd-rootfs/+merge/458366 |
Reading this more I'm not sure if this actually deletes the /etc/apt/sources.list with the |
Related to LP:#2026647 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Julian!
Reading this more I'm not sure if this actually deletes the /etc/apt/sources.list with the
cdrom
line, I guess the_restore_file
is weird and should always succeed or something.
Yes, the presence of etc/apt/sources.lists
containing the cdrom entry is unconditional
subiquity/subiquity/server/apt.py
Lines 259 to 262 in 753ce9f
write_file( | |
self.install_tree.p("etc/apt/sources.list"), | |
f"deb [check-date=no] file:///cdrom {codename} main restricted\n", | |
mode=0o644, |
I'm not sure if it would be a huge deal to leave this file on the target system, but for now, I think it's better to keep the current behavior - which means removing the file if it does not exist in the source overlay.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I pushed a change to drop sources.list from the target if it wasn't present in the configured tree.
Also added a set of tests for the .deconfigure method.
Marking "Approved" since I requested changes earlier. But it would be fair to get a second approval before merging since I authored some of the changes.
Signed-off-by: Olivier Gayot <[email protected]>
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 <[email protected]>
d49244b
to
9b612da
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this, and for adding tests!
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.