Skip to content

Commit ffe764a

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 2013dca commit ffe764a

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

build-rootfs

Lines changed: 11 additions & 5 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():
@@ -48,8 +50,9 @@ def main():
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.
5052
if lockfile_repos == ['fedora-coreos-pool']:
51-
modify_pool_repo(locked_nevras)
52-
repos += lockfile_repos
53+
if not HERMETIC:
54+
modify_pool_repo(locked_nevras)
55+
repos += lockfile_repos
5356
elif len(lockfile_repos) > 0:
5457
raise Exception(f"unknown lockfile-repo found in {lockfile_repos}")
5558

@@ -107,12 +110,15 @@ def inject_yumrepos():
107110
if os.path.basename(repo) == 'secret.repo':
108111
# this is a supported podman secret to inject repo files; see Containerfile
109112
continue
113+
if repo == HERMETIC_REPO:
114+
# this is the repo Konflux injects when hermetic build is enabled
115+
continue
110116
os.unlink(repo)
111117

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

117123
def build_rootfs(
118124
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)