Skip to content

Commit

Permalink
refactors the prow build scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
cheesesashimi committed Apr 19, 2022
1 parent 1963562 commit 0221a60
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 6 deletions.
6 changes: 0 additions & 6 deletions ci/prow-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,3 @@ cosa buildfetch --url=${prev_build_url}
cosa fetch
cosa build
cosa buildextend-extensions

# Give the newly-built OCI archive a predictable filename to make OCI archive extraction simpler
arch="x86_64"
cosa_build_id="$(cat "${COSA_DIR}/builds/builds.json" | jq -r '.builds[0].id')"
current_build_dir="${COSA_DIR}/builds/latest/${arch}"
mv "${current_build_dir}/rhcos-${cosa_build_id}-ostree.${arch}.ociarchive" "${current_build_dir}/rhcos.${arch}.ociarchive"
24 changes: 24 additions & 0 deletions ci/set-openshift-user.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash

# This script is used to update the /etc/passwd file within the COSA container
# at test-time. The need for this comes from the fact that OpenShift will run a
# container with a randomized user ID by default to enhance security. Because
# COSA runs with an unprivileged user ("builder") instead of (container) root,
# this presents special challenges for file and disk permissions. This particular
# pattern was inspired by:
# - https://cloud.redhat.com/blog/jupyter-on-openshift-part-6-running-as-an-assigned-user-id
# - https://cloud.redhat.com/blog/a-guide-to-openshift-and-uids

set -xeuo

user_id="$(id -u)"
group_id="$(id -g)"

cat /etc/passwd | grep -v "^builder" > /tmp/passwd
echo "builder:x:${user_id}:${group_id}::/home/builder:/bin/bash" >> /tmp/passwd
cat /tmp/passwd > /etc/passwd
rm /tmp/passwd

# Not strictly required, but nice for debugging.
id
whoami
10 changes: 10 additions & 0 deletions ci/simplify-ociarchive-path.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash
# Give the newly-built OCI archive a predictable filename to make OCI archive
# extraction / ingestion simpler in Prow.

set -xeuo

arch="x86_64"
cosa_build_id="$(cat "${COSA_DIR}/builds/builds.json" | jq -r '.builds[0].id')"
current_build_dir="${COSA_DIR}/builds/latest/${arch}"
mv "${current_build_dir}/rhcos-${cosa_build_id}-ostree.${arch}.ociarchive" "${current_build_dir}/rhcos.${arch}.ociarchive"

0 comments on commit 0221a60

Please sign in to comment.