Skip to content
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: reset only diverted files on deconfigure #1701

Merged
merged 1 commit into from
Jun 23, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions subiquity/server/apt.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,10 @@ class AptConfigurer:
#
# 1. Removing /cdrom from the installed system.
#
# 2. Copying /etc/apt from the 'configured' overlay to the installed
# system.
# 2. Copying a set of diverted /etc/apt files from the 'configured' overlay
# to the installed system. Some packages such as OEM meta-packages and
# keyrings will install files in /etc/apt so we cannot simply discard
# everything.
#
# 3. If the network is working, run apt-get update in the installed
# system, or if it is not, just copy /var/lib/apt/lists from the
Expand Down Expand Up @@ -288,7 +290,16 @@ async def _restore_dir(dir):
'cp', '-aT', self.configured_tree.p(dir), target_mnt.p(dir),
])

await _restore_dir('etc/apt')
def _restore_file(path: str) -> None:
shutil.copyfile(self.configured_tree.p(path), target_mnt.p(path))

# The file only exists if we are online
with contextlib.suppress(FileNotFoundError):
os.unlink(target_mnt.p('etc/apt/sources.list.d/original.list'))
_restore_file('etc/apt/sources.list')

with contextlib.suppress(FileNotFoundError):
_restore_file('etc/apt/apt.conf.d/90curtin-aptproxy')

if self.app.base_model.network.has_network:
await run_curtin_command(
Expand Down