config: introduce per-arch persisted ccache dir
This commit is contained in:
parent
c0fd1f51b5
commit
47e74fb415
4 changed files with 17 additions and 1 deletions
|
@ -132,6 +132,16 @@ class BuildChroot(Chroot):
|
||||||
fail_if_mounted=fail_if_mounted,
|
fail_if_mounted=fail_if_mounted,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def mount_ccache(self, user: str = 'kupfer', fail_if_mounted: bool = False):
|
||||||
|
mount_source = os.path.join(config.file.paths.ccache, self.arch)
|
||||||
|
mount_dest = os.path.join(f'/home/{user}' if user != 'root' else '/root', '.ccache')
|
||||||
|
makedir(mount_source)
|
||||||
|
return self.mount(
|
||||||
|
absolute_source=mount_source,
|
||||||
|
relative_destination=mount_dest,
|
||||||
|
fail_if_mounted=fail_if_mounted,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def get_build_chroot(arch: Arch, add_kupfer_repos: bool = True, **kwargs) -> BuildChroot:
|
def get_build_chroot(arch: Arch, add_kupfer_repos: bool = True, **kwargs) -> BuildChroot:
|
||||||
name = build_chroot_name(arch)
|
name = build_chroot_name(arch)
|
||||||
|
|
|
@ -141,6 +141,7 @@ class PathsSection(DataClass):
|
||||||
pkgbuilds: str
|
pkgbuilds: str
|
||||||
jumpdrive: str
|
jumpdrive: str
|
||||||
images: str
|
images: str
|
||||||
|
ccache: str
|
||||||
|
|
||||||
|
|
||||||
class ProfilesSection(DataClass):
|
class ProfilesSection(DataClass):
|
||||||
|
|
|
@ -42,6 +42,7 @@ CONFIG_DEFAULTS_DICT = {
|
||||||
'pkgbuilds': os.path.join('%cache_dir%', 'pkgbuilds'),
|
'pkgbuilds': os.path.join('%cache_dir%', 'pkgbuilds'),
|
||||||
'jumpdrive': os.path.join('%cache_dir%', 'jumpdrive'),
|
'jumpdrive': os.path.join('%cache_dir%', 'jumpdrive'),
|
||||||
'images': os.path.join('%cache_dir%', 'images'),
|
'images': os.path.join('%cache_dir%', 'images'),
|
||||||
|
'ccache': os.path.join('%cache_dir%', 'ccache'),
|
||||||
},
|
},
|
||||||
'profiles': {
|
'profiles': {
|
||||||
'current': 'default',
|
'current': 'default',
|
||||||
|
|
|
@ -454,6 +454,7 @@ def build_package(
|
||||||
enable_crossdirect: bool = True,
|
enable_crossdirect: bool = True,
|
||||||
enable_ccache: bool = True,
|
enable_ccache: bool = True,
|
||||||
clean_chroot: bool = False,
|
clean_chroot: bool = False,
|
||||||
|
build_user: str = 'kupfer',
|
||||||
):
|
):
|
||||||
makepkg_compile_opts = ['--holdver']
|
makepkg_compile_opts = ['--holdver']
|
||||||
makepkg_conf_path = 'etc/makepkg.conf'
|
makepkg_conf_path = 'etc/makepkg.conf'
|
||||||
|
@ -482,6 +483,7 @@ def build_package(
|
||||||
env = deepcopy(get_makepkg_env(arch))
|
env = deepcopy(get_makepkg_env(arch))
|
||||||
if enable_ccache:
|
if enable_ccache:
|
||||||
env['PATH'] = f"/usr/lib/ccache:{env['PATH']}"
|
env['PATH'] = f"/usr/lib/ccache:{env['PATH']}"
|
||||||
|
native_chroot.mount_ccache(user=build_user)
|
||||||
logging.info('Setting up dependencies for cross-compilation')
|
logging.info('Setting up dependencies for cross-compilation')
|
||||||
# include crossdirect for ccache symlinks and qemu-user
|
# include crossdirect for ccache symlinks and qemu-user
|
||||||
results = native_chroot.try_install_packages(package.depends + CROSSDIRECT_PKGS + [f"{GCC_HOSTSPECS[native_chroot.arch][arch]}-gcc"])
|
results = native_chroot.try_install_packages(package.depends + CROSSDIRECT_PKGS + [f"{GCC_HOSTSPECS[native_chroot.arch][arch]}-gcc"])
|
||||||
|
@ -513,6 +515,8 @@ def build_package(
|
||||||
if failed_deps:
|
if failed_deps:
|
||||||
raise Exception(f'Dependencies failed to install: {failed_deps}')
|
raise Exception(f'Dependencies failed to install: {failed_deps}')
|
||||||
|
|
||||||
|
if enable_ccache:
|
||||||
|
build_root.mount_ccache(user=build_user)
|
||||||
setup_git_insecure_paths(build_root)
|
setup_git_insecure_paths(build_root)
|
||||||
makepkg_conf_absolute = os.path.join('/', makepkg_conf_path)
|
makepkg_conf_absolute = os.path.join('/', makepkg_conf_path)
|
||||||
setup_sources(package, build_root, makepkg_conf_path=makepkg_conf_absolute)
|
setup_sources(package, build_root, makepkg_conf_path=makepkg_conf_absolute)
|
||||||
|
@ -523,7 +527,7 @@ def build_package(
|
||||||
build_cmd,
|
build_cmd,
|
||||||
inner_env=env,
|
inner_env=env,
|
||||||
cwd=os.path.join(CHROOT_PATHS['pkgbuilds'], package.path),
|
cwd=os.path.join(CHROOT_PATHS['pkgbuilds'], package.path),
|
||||||
switch_user='kupfer',
|
switch_user=build_user,
|
||||||
)
|
)
|
||||||
assert isinstance(result, subprocess.CompletedProcess)
|
assert isinstance(result, subprocess.CompletedProcess)
|
||||||
if result.returncode != 0:
|
if result.returncode != 0:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue