Skip to content

Commit ad5cc61

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 <[email protected]>
1 parent 102f2fa commit ad5cc61

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

container/Dockerfile-9.x

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ RUN dnf update -y \
1515
&& dnf install -y \
1616
gcc \
1717
gcc-c++ \
18+
ccache \
1819
git \
1920
make \
2021
rpm-build \

container/files/init-container.sh

Lines changed: 10 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
@@ -56,6 +60,12 @@ if [ -n "$ENABLEREPO" ]; then
5660
sudo $CFGMGR --enable "$ENABLEREPO"
5761
fi
5862

63+
# disable ccache unless its use was required
64+
if [ -z "$CCACHE_DIR" ]; then
65+
echo >&2 "Note: uninstalling not-requested ccache"
66+
sudo $DNF remove -y ccache
67+
fi
68+
5969
if [ -z "$NOUPDATE" ]; then
6070
# update to either install newer updates or to take packages from added repos into account
6171
sudo $DNF update -y --disablerepo=epel

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)