diff --git a/subiquity/server/apt.py b/subiquity/server/apt.py index 92ab34de3..fe4cdc247 100644 --- a/subiquity/server/apt.py +++ b/subiquity/server/apt.py @@ -262,11 +262,6 @@ async def _restore_dir(dir): 'cp', '-aT', self.configured_tree.p(dir), target_mnt.p(dir), ]) - await self.unmount( - Mountpoint(mountpoint=target_mnt.p('cdrom')), - remove=True) - os.rmdir(target_mnt.p('cdrom')) - await _restore_dir('etc/apt') if self.app.base_model.network.has_network: @@ -277,11 +272,14 @@ async def _restore_dir(dir): await _restore_dir('var/lib/apt/lists') await self.cleanup() + os.rmdir(target_mnt.p('cdrom')) - async def setup_target(self): + async def setup_target(self, context, target: str): # Call this after the rootfs has been extracted to the real target # system but before any configuration is applied to it. - await self.mount('/cdrom', '/target/cdrom', options='bind') + target_mnt = Mountpoint(mountpoint=target) + await self.mount( + '/cdrom', target_mnt.p('cdrom'), options='bind') class DryRunAptConfigurer(AptConfigurer): diff --git a/subiquity/server/controllers/install.py b/subiquity/server/controllers/install.py index 6b39b3347..3f46f1a26 100644 --- a/subiquity/server/controllers/install.py +++ b/subiquity/server/controllers/install.py @@ -190,7 +190,7 @@ async def configure_apt(self, *, context): async def setup_target(self, context): mirror = self.app.controllers.Mirror - await mirror.apt_configurer.setup_target() + await mirror.apt_configurer.setup_target(context, self.tpath()) @with_context( description="installing system", level="INFO", childlevel="DEBUG")