Skip to content

Commit 89951da

Browse files
committed
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 <yann.dirson@vates.tech>
1 parent 102f2fa commit 89951da

3 files changed

Lines changed: 13 additions & 0 deletions

File tree

container/Dockerfile-9.x

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ RUN dnf update -y \
2727
&& dnf install -y \
2828
epel-rpm-macros \
2929
almalinux-git-utils \
30+
ccache \
3031
# Niceties
3132
&& dnf install -y \
3233
bash-completion \

container/files/init-container.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ os_release()
1717
)
1818
}
1919

20+
if [ -n "${PATH_PREPEND}" ]; then
21+
PATH="${PATH_PREPEND}:${PATH}"
22+
fi
23+
2024
OS_RELEASE=$(os_release)
2125

2226
# get list of user repos

src/xcp_ng_dev/cli.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ def add_common_args(parser):
4646
group.add_argument('-e', '--env', action='append',
4747
help='Environment variables passed directly to '
4848
f'{RUNNER} -e')
49+
parser.add_argument('--ccache', action='store',
50+
help="Use given directory as a cache for ccache")
4951
group.add_argument('-a', '--enablerepo',
5052
help='additional repositories to enable before installing build dependencies. '
5153
'Same syntax as yum\'s --enablerepo parameter. Available additional repositories: '
@@ -169,6 +171,12 @@ def container(args):
169171
if args.env:
170172
for env in args.env:
171173
docker_args += ["-e", env]
174+
if args.ccache:
175+
os.makedirs(args.ccache, exist_ok=True)
176+
docker_args += ["-v", f"{os.path.realpath(args.ccache)}:/home/builder/ccachedir",
177+
"-e", "CCACHE_DIR=/home/builder/ccachedir",
178+
"-e", "PATH_PREPEND=/usr/lib64/ccache",
179+
]
172180
if args.enablerepo:
173181
docker_args += ["-e", "ENABLEREPO=%s" % args.enablerepo]
174182
if args.disablerepo:

0 commit comments

Comments
 (0)