chroot/device.py: Use exec.file.get_temp_dir() for pacman.conf

This commit is contained in:
InsanePrawn 2022-08-16 17:52:05 +02:00
parent 1bf397f29f
commit 5eda60c14d

View file

@ -2,12 +2,11 @@ import atexit
import os import os
from typing import Optional from typing import Optional
from tempfile import mktemp
from config import config from config import config
from constants import Arch, BASE_PACKAGES from constants import Arch, BASE_PACKAGES
from distro.distro import get_kupfer_local, get_kupfer_https from distro.distro import get_kupfer_local, get_kupfer_https
from exec.file import makedir, root_makedir from exec.file import get_temp_dir, makedir, root_makedir
from utils import check_findmnt from utils import check_findmnt
from .base import BaseChroot from .base import BaseChroot
@ -25,10 +24,8 @@ class DeviceChroot(BuildChroot):
makedir(config.get_path('chroots')) makedir(config.get_path('chroots'))
root_makedir(self.get_path()) root_makedir(self.get_path())
if not self.copy_base: if not self.copy_base:
name = mktemp() pacman_conf_target = os.path.join(get_temp_dir(register_cleanup=True), f'pacman-{self.name}.conf')
pacman_conf_target = name
self.write_pacman_conf(in_chroot=False, absolute_path=pacman_conf_target) self.write_pacman_conf(in_chroot=False, absolute_path=pacman_conf_target)
atexit.register(os.unlink, pacman_conf_target)
clss.create_rootfs(self, reset, pacman_conf_target, active_previously) clss.create_rootfs(self, reset, pacman_conf_target, active_previously)