mirror of
https://gitlab.com/kupfer/kupferbootstrap.git
synced 2025-02-22 21:25:43 -05:00
chroot/build: add mount_gpg()
This commit is contained in:
parent
871c4f27c7
commit
07436a0ad2
1 changed files with 21 additions and 0 deletions
|
@ -1,3 +1,4 @@
|
|||
import atexit
|
||||
import logging
|
||||
import os
|
||||
import subprocess
|
||||
|
@ -7,6 +8,7 @@ from typing import ClassVar, Optional
|
|||
from config.state import config
|
||||
from constants import Arch, GCC_HOSTSPECS, CROSSDIRECT_PKGS, CHROOT_PATHS
|
||||
from distro.distro import get_kupfer_local
|
||||
from distro.gpg import GPG_HOME_DIR
|
||||
from exec.cmd import run_root_cmd
|
||||
from exec.file import makedir, remove_file, root_makedir, root_write_file, symlink
|
||||
|
||||
|
@ -159,6 +161,25 @@ class BuildChroot(Chroot):
|
|||
))
|
||||
return results
|
||||
|
||||
def mount_gpg(self, fail_if_mounted: bool = False, schedule_gpg_kill: bool = True) -> str:
|
||||
res = self.mount(
|
||||
absolute_source=config.get_path('gpg'),
|
||||
relative_destination=CHROOT_PATHS['gpg'].lstrip('/'),
|
||||
fail_if_mounted=fail_if_mounted,
|
||||
)
|
||||
if schedule_gpg_kill:
|
||||
atexit.register(self.kill_gpg_agent)
|
||||
return res
|
||||
|
||||
def get_gpg_home(self, host_path: bool = False) -> str:
|
||||
gpg_home = os.path.join(CHROOT_PATHS['gpg']. GPG_HOME_DIR)
|
||||
if host_path:
|
||||
gpg_home = self.get_path(gpg_home)
|
||||
return gpg_home
|
||||
|
||||
def kill_gpg_agent(self) -> subprocess.CompletedProcess:
|
||||
res = self.run_cmd(["timeout", "2s", "gpgconf", "--kill", "gpg-agent"], inner_env={"GNUPGHOME": self.get_gpg_home()})
|
||||
logging.debug(f"GPG agent killed: {res.returncode=}, {res.stdout=}, {res.stderr}")
|
||||
|
||||
def get_build_chroot(arch: Arch, add_kupfer_repos: bool = True, **kwargs) -> BuildChroot:
|
||||
name = build_chroot_name(arch)
|
||||
|
|
Loading…
Add table
Reference in a new issue