apt: in dry-run code, also copy etc/apt/sources.list.d

In dry-run mode, we used to only copy etc/apt/sources.list to the
fake overlay. However, if the host uses deb822, the sources.list file is
usually empty.

This patch also makes sure to copy the deb822 sources from
etc/apt/sources.list.d/

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
This commit is contained in:
Olivier Gayot 2023-01-11 14:21:24 +01:00
parent 9563b543ce
commit ec29fa9a0a
1 changed files with 5 additions and 1 deletions

View File

@ -199,7 +199,11 @@ class DryRunMounter(Mounter):
], check=True)
if os.path.isdir(f'{target}/etc/apt/sources.list.d'):
shutil.rmtree(f'{target}/etc/apt/sources.list.d')
os.mkdir(f'{target}/etc/apt/sources.list.d')
await arun_command([
'cp', '-aT',
f'{source}/etc/apt/sources.list.d',
f'{target}/etc/apt/sources.list.d',
], check=True)
return OverlayMountpoint(
lowers=[source],
mountpoint=target,