Skip to content

Commit 7698e16

Browse files
jbtrystramjoelcapitao
authored andcommitted
hermetic: adapt build-rootfs and buildroot-prep
In hermetic builds there is no access to the network. Detect this by looking for the `cachi2.repo` that is injected by konflux during the build. In this case we make sure to not use any of our own repo and rely on the repo created by hermeto.
1 parent 49c6537 commit 7698e16

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

build-rootfs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ import yaml
2121
ARCH = os.uname().machine
2222
SRCDIR = '/src'
2323
INPUTHASH = '/run/inputhash'
24+
HERMETIC_REPO = '/etc/yum.repos.d/cachi2.repo'
25+
IS_HERMETIC = os.path.exists(HERMETIC_REPO)
2426

2527

2628
def main():
@@ -47,7 +49,7 @@ def main():
4749
# Lockfile repos require special handling because we only want locked
4850
# NEVRAs to appear there. For lack of a generic solution for any repo
4951
# there, we only special-case the one place where we know we use this.
50-
if lockfile_repos == ['fedora-coreos-pool']:
52+
if lockfile_repos == ['fedora-coreos-pool'] and not IS_HERMETIC:
5153
modify_pool_repo(locked_nevras)
5254
repos += lockfile_repos
5355
elif len(lockfile_repos) > 0:
@@ -107,12 +109,15 @@ def inject_yumrepos():
107109
if os.path.basename(repo) == 'secret.repo':
108110
# this is a supported podman secret to inject repo files; see Containerfile
109111
continue
112+
if repo == HERMETIC_REPO:
113+
# this is the repo Konflux injects when hermetic build is enabled
114+
continue
110115
os.unlink(repo)
111116

112117
# and now inject our repos
113-
for repo in glob.glob(f'{SRCDIR}/*.repo'):
114-
shutil.copy(repo, "/etc/yum.repos.d")
115-
118+
if not IS_HERMETIC:
119+
for repo in glob.glob(f'{SRCDIR}/*.repo'):
120+
shutil.copy(repo, "/etc/yum.repos.d")
116121

117122
def build_rootfs(
118123
target_rootfs, manifest_path, packages, locked_nevras,

buildroot-prep

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,11 @@ set -euo pipefail
88
arch=$(uname -m)
99
. /etc/os-release
1010

11-
cp /src/fedora-coreos-continuous.repo /etc/yum.repos.d
12-
11+
# cachi2 is the repo Konflux injects when hermetic build is enabled and
12+
# is self-sufficient to pull all the required RPMs.
13+
if [ ! -f "/etc/yum.repos.d/cachi2.repo" ]; then
14+
cp /src/fedora-coreos-continuous.repo /etc/yum.repos.d
15+
fi
1316
# NOTE: try to remove anything that queries repos here once it's no longer
1417
# needed so that we don't unnecessarily pay for repo metadata.
1518

0 commit comments

Comments
 (0)