From 89951dace08bd8fa9d15a8ff17d9e96deccf5f0f Mon Sep 17 00:00:00 2001 From: Yann Dirson Date: Wed, 9 Jul 2025 18:16:39 +0200 Subject: [PATCH] New --ccache option to cache build artifacts Quite necessary for upcoming rebuilds of the kernel package. Includes a new PATH_PREPEND interface to the container. Signed-off-by: Yann Dirson --- container/Dockerfile-9.x | 1 + container/files/init-container.sh | 4 ++++ src/xcp_ng_dev/cli.py | 8 ++++++++ 3 files changed, 13 insertions(+) diff --git a/container/Dockerfile-9.x b/container/Dockerfile-9.x index be318d0..0b0726a 100644 --- a/container/Dockerfile-9.x +++ b/container/Dockerfile-9.x @@ -27,6 +27,7 @@ RUN dnf update -y \ && dnf install -y \ epel-rpm-macros \ almalinux-git-utils \ + ccache \ # Niceties && dnf install -y \ bash-completion \ diff --git a/container/files/init-container.sh b/container/files/init-container.sh index 27f8ef0..c9eecff 100755 --- a/container/files/init-container.sh +++ b/container/files/init-container.sh @@ -17,6 +17,10 @@ os_release() ) } +if [ -n "${PATH_PREPEND}" ]; then + PATH="${PATH_PREPEND}:${PATH}" +fi + OS_RELEASE=$(os_release) # get list of user repos diff --git a/src/xcp_ng_dev/cli.py b/src/xcp_ng_dev/cli.py index 6b0d072..4a4e9e2 100755 --- a/src/xcp_ng_dev/cli.py +++ b/src/xcp_ng_dev/cli.py @@ -46,6 +46,8 @@ def add_common_args(parser): group.add_argument('-e', '--env', action='append', help='Environment variables passed directly to ' f'{RUNNER} -e') + parser.add_argument('--ccache', action='store', + help="Use given directory as a cache for ccache") group.add_argument('-a', '--enablerepo', help='additional repositories to enable before installing build dependencies. ' 'Same syntax as yum\'s --enablerepo parameter. Available additional repositories: ' @@ -169,6 +171,12 @@ def container(args): if args.env: for env in args.env: docker_args += ["-e", env] + if args.ccache: + os.makedirs(args.ccache, exist_ok=True) + docker_args += ["-v", f"{os.path.realpath(args.ccache)}:/home/builder/ccachedir", + "-e", "CCACHE_DIR=/home/builder/ccachedir", + "-e", "PATH_PREPEND=/usr/lib64/ccache", + ] if args.enablerepo: docker_args += ["-e", "ENABLEREPO=%s" % args.enablerepo] if args.disablerepo: