Skip to content

Commit 8544f88

Browse files
committed
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 a7f0a30 commit 8544f88

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

build-rootfs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import yaml
2121
ARCH = os.uname().machine
2222
SRCDIR = '/src'
2323
INPUTHASH = '/run/inputhash'
24+
HERMETIC = os.path.exists("/etc/yum.repos.d/cachi2.repo")
2425

2526

2627
def main():
@@ -48,8 +49,9 @@ def main():
4849
# NEVRAs to appear there. For lack of a generic solution for any repo
4950
# there, we only special-case the one place where we know we use this.
5051
if lockfile_repos == ['fedora-coreos-pool']:
51-
modify_pool_repo(locked_nevras)
52-
repos += lockfile_repos
52+
if not HERMETIC:
53+
modify_pool_repo(locked_nevras)
54+
repos += lockfile_repos
5355
elif len(lockfile_repos) > 0:
5456
raise Exception(f"unknown lockfile-repo found in {lockfile_repos}")
5557

@@ -104,12 +106,16 @@ def inject_yumrepos():
104106
if os.path.basename(repo) == 'secret.repo':
105107
# this is a supported podman secret to inject repo files; see Containerfile
106108
continue
109+
# cachi2 is an injected repo by konflux for hermetic build.
110+
# We want to keep it active.
111+
if os.path.basename(repo) == 'cachi2.repo':
112+
continue
107113
os.unlink(repo)
108114

109115
# and now inject our repos
110-
for repo in glob.glob(f'{SRCDIR}/*.repo'):
111-
shutil.copy(repo, "/etc/yum.repos.d")
112-
116+
if not HERMETIC:
117+
for repo in glob.glob(f'{SRCDIR}/*.repo'):
118+
shutil.copy(repo, "/etc/yum.repos.d")
113119

114120
def build_rootfs(target_rootfs, manifest_path, packages, locked_nevras, overlays, repos, nodocs):
115121
passwd_group_dir = os.getenv('PASSWD_GROUP_DIR')

buildroot-prep

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@ 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+
# in hermetic mode we can't reach out to internet
12+
if [ ! -f "/etc/yum.repos.d/cachi2.repo" ]; then
13+
cp /src/fedora-coreos-continuous.repo /etc/yum.repos.d
14+
fi
1315
# NOTE: try to remove anything that queries repos here once it's no longer
1416
# needed so that we don't unnecessarily pay for repo metadata.
1517

0 commit comments

Comments
 (0)