install: remove zzzz-temp-installer-unattended-upgrade after running UU
On recent installations of Ubuntu, the zzzz-installer-unattended-upgrade file ended up in the etc/apt/apt.conf.d directory of the target system. It is supposed to be a temporary file intended for one time invocation of unattended-upgrade at the end of the installation. Let's remove the file after unattended-upgrades finishes using a try ... finally construct. The previous implementation was doing the call to UU inside the with open(...) block, after a manual call to .close(). This is unnecessary, the file is automatically closed at the end of the with block. Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
This commit is contained in:
parent
e54354b8a3
commit
092cbf14df
|
@ -751,10 +751,10 @@ class InstallController(SubiquityController):
|
||||||
apt_conf_contents += uu_apt_conf_update_all
|
apt_conf_contents += uu_apt_conf_update_all
|
||||||
else:
|
else:
|
||||||
apt_conf_contents += uu_apt_conf_update_security
|
apt_conf_contents += uu_apt_conf_update_security
|
||||||
fname = "zzzz-temp-installer-unattended-upgrade"
|
apt_conf_path = Path(aptdir) / "zzzz-temp-installer-unattended-upgrade"
|
||||||
with open(os.path.join(aptdir, fname), "wb") as apt_conf:
|
with open(apt_conf_path, "wb") as apt_conf:
|
||||||
apt_conf.write(apt_conf_contents)
|
apt_conf.write(apt_conf_contents)
|
||||||
apt_conf.close()
|
try:
|
||||||
self.unattended_upgrades_ctx = context
|
self.unattended_upgrades_ctx = context
|
||||||
self.unattended_upgrades_cmd = await start_curtin_command(
|
self.unattended_upgrades_cmd = await start_curtin_command(
|
||||||
self.app,
|
self.app,
|
||||||
|
@ -772,8 +772,10 @@ class InstallController(SubiquityController):
|
||||||
except subprocess.CalledProcessError as cpe:
|
except subprocess.CalledProcessError as cpe:
|
||||||
log_process_streams(logging.ERROR, cpe, "Unattended upgrades")
|
log_process_streams(logging.ERROR, cpe, "Unattended upgrades")
|
||||||
context.description = f"FAILED to apply {policy} updates"
|
context.description = f"FAILED to apply {policy} updates"
|
||||||
self.unattended_upgrades_cmd = None
|
finally:
|
||||||
self.unattended_upgrades_ctx = None
|
apt_conf_path.unlink()
|
||||||
|
self.unattended_upgrades_cmd = None
|
||||||
|
self.unattended_upgrades_ctx = None
|
||||||
|
|
||||||
async def stop_unattended_upgrades(self):
|
async def stop_unattended_upgrades(self):
|
||||||
with self.unattended_upgrades_ctx.parent.child(
|
with self.unattended_upgrades_ctx.parent.child(
|
||||||
|
|
Loading…
Reference in New Issue