|
| 1 | +#!/bin/bash |
| 2 | +set -exuo pipefail |
| 3 | + |
| 4 | +# Check environment |
| 5 | +printenv |
| 6 | +# Check repos |
| 7 | +# Leave this checking here to find the changing in repo folder |
| 8 | +ls -al /etc/yum.repos.d |
| 9 | + |
| 10 | +# This script only runs on Packit and gating environment |
| 11 | +case $TMT_REBOOT_COUNT in |
| 12 | +0) |
| 13 | + # temp folder to save building files and folders |
| 14 | + BOOTC_TEMPDIR=$(mktemp -d) |
| 15 | + trap 'rm -rf -- "$BOOTC_TEMPDIR"' EXIT |
| 16 | + |
| 17 | + # Copy files and folders in hack to TEMPDIR |
| 18 | + cp -a ../../hack/* "$BOOTC_TEMPDIR" |
| 19 | + |
| 20 | + # Keep testing farm run folder |
| 21 | + cp -r /var/ARTIFACTS "$BOOTC_TEMPDIR" |
| 22 | + |
| 23 | + # Copy bootc repo |
| 24 | + cp -r /var/share/test-artifacts "$BOOTC_TEMPDIR" |
| 25 | + |
| 26 | + ARCH=$(uname -m) |
| 27 | + # Get OS info |
| 28 | + source /etc/os-release |
| 29 | + |
| 30 | + # Some rhts-*, rstrnt-* and tmt-* commands are in /usr/local/bin |
| 31 | + if [[ -d /var/lib/tmt/scripts ]]; then |
| 32 | + cp -r /var/lib/tmt/scripts "$BOOTC_TEMPDIR" |
| 33 | + else |
| 34 | + cp -r /usr/local/bin "$BOOTC_TEMPDIR" |
| 35 | + fi |
| 36 | + |
| 37 | + case "$ID" in |
| 38 | + "centos") |
| 39 | + BASE="quay.io/centos-bootc/centos-bootc:stream${VERSION_ID}" |
| 40 | + ;; |
| 41 | + "fedora") |
| 42 | + BASE="quay.io/fedora/fedora-bootc:${VERSION_ID}" |
| 43 | + ;; |
| 44 | + "rhel") |
| 45 | + # OSCI gating only |
| 46 | + BASE="images.paas.redhat.com/bootc/rhel-bootc:latest-${VERSION_ID}" |
| 47 | + CURRENT_COMPOSE_ID=$(skopeo inspect --no-tags --retry-times=5 --tls-verify=false "docker://${BASE}" | jq -r '.Labels."redhat.compose-id"') |
| 48 | + |
| 49 | + if [[ -n ${CURRENT_COMPOSE_ID} ]]; then |
| 50 | + if [[ ${CURRENT_COMPOSE_ID} == *-updates-* ]]; then |
| 51 | + BATCH_COMPOSE="updates/" |
| 52 | + else |
| 53 | + BATCH_COMPOSE="" |
| 54 | + fi |
| 55 | + else |
| 56 | + BATCH_COMPOSE="updates/" |
| 57 | + CURRENT_COMPOSE_ID=latest-RHEL-$VERSION_ID |
| 58 | + fi |
| 59 | + |
| 60 | + # use latest compose if specific compose is not accessible |
| 61 | + RC=$(curl -skIw '%{http_code}' -o /dev/null "http://${NIGHTLY_COMPOSE_SITE}/rhel-${VERSION_ID%%.*}/nightly/${BATCH_COMPOSE}RHEL-${VERSION_ID%%.*}/${CURRENT_COMPOSE_ID}/STATUS") |
| 62 | + if [[ $RC != "200" ]]; then |
| 63 | + CURRENT_COMPOSE_ID=latest-RHEL-${VERSION_ID%%} |
| 64 | + fi |
| 65 | + |
| 66 | + # generate rhel repo |
| 67 | + tee "${BOOTC_TEMPDIR}/rhel.repo" >/dev/null <<REPOEOF |
| 68 | +[rhel-baseos] |
| 69 | +name=baseos |
| 70 | +baseurl=http://${NIGHTLY_COMPOSE_SITE}/rhel-${VERSION_ID%%.*}/nightly/${BATCH_COMPOSE}RHEL-${VERSION_ID%%.*}/${CURRENT_COMPOSE_ID}/compose/BaseOS/${ARCH}/os/ |
| 71 | +enabled=1 |
| 72 | +gpgcheck=0 |
| 73 | +
|
| 74 | +[rhel-appstream] |
| 75 | +name=appstream |
| 76 | +baseurl=http://${NIGHTLY_COMPOSE_SITE}/rhel-${VERSION_ID%%.*}/nightly/${BATCH_COMPOSE}RHEL-${VERSION_ID%%.*}/${CURRENT_COMPOSE_ID}/compose/AppStream/${ARCH}/os/ |
| 77 | +enabled=1 |
| 78 | +gpgcheck=0 |
| 79 | +REPOEOF |
| 80 | + cp "${BOOTC_TEMPDIR}/rhel.repo" /etc/yum.repos.d |
| 81 | + ;; |
| 82 | + esac |
| 83 | + |
| 84 | + # Fedora CI: https://github.com/fedora-ci/dist-git-pipeline/blob/master/Jenkinsfile#L145 |
| 85 | + # OSCI: https://gitlab.cee.redhat.com/osci-pipelines/dist-git-pipeline/-/blob/master/Jenkinsfile?ref_type=heads#L93 |
| 86 | + if [[ -v KOJI_TASK_ID ]] || [[ -v CI_KOJI_TASK_ID ]]; then |
| 87 | + # Just left those ls commands here to ring the bell for me when something changed |
| 88 | + echo "$TMT_SOURCE_DIR" |
| 89 | + ls -al "$TMT_SOURCE_DIR" |
| 90 | + ls -al "$TMT_SOURCE_DIR/SRPMS" |
| 91 | + fi |
| 92 | + |
| 93 | + ls -al /etc/yum.repos.d |
| 94 | + cat /etc/yum.repos.d/test-artifacts.repo |
| 95 | + ls -al /var/share/test-artifacts |
| 96 | + |
| 97 | + # copy bootc rpm repo into image building root |
| 98 | + cp /etc/yum.repos.d/test-artifacts.repo "$BOOTC_TEMPDIR" |
| 99 | + |
| 100 | + # Let's check things in hack folder |
| 101 | + ls -al "$BOOTC_TEMPDIR" "${BOOTC_TEMPDIR}/bin" |
| 102 | + |
| 103 | + # Do not use just because it's only available on Fedora, not on CS and RHEL |
| 104 | + podman build --jobs=4 --from "$BASE" -v "$BOOTC_TEMPDIR":/bootc-test:z -t localhost/bootc-integration -f "${BOOTC_TEMPDIR}/Containerfile.packit" "$BOOTC_TEMPDIR" |
| 105 | + |
| 106 | + # Keep these in sync with what's used in hack/lbi |
| 107 | + podman pull -q --retry 5 --retry-delay 5s quay.io/curl/curl:latest quay.io/curl/curl-base:latest registry.access.redhat.com/ubi9/podman:latest |
| 108 | + |
| 109 | + # Run system-reinstall-bootc |
| 110 | + # TODO make it more scriptable instead of expect + send |
| 111 | + system-reinstall/system-reinstall-bootc.exp |
| 112 | + |
| 113 | + # Reboot |
| 114 | + tmt-reboot |
| 115 | + ;; |
| 116 | +1) |
| 117 | + # Some simple and fast checkings |
| 118 | + bootc status |
| 119 | + ls -al /var/ARTIFACTS |
| 120 | + ls -al /usr/local/bin |
| 121 | + echo "Bootc system on TMT/TF runner" |
| 122 | + exit 0 |
| 123 | + ;; |
| 124 | +*) |
| 125 | + echo "Invalid TMT_REBOOT_COUNT $TMT_REBOOT_COUNT" |
| 126 | + exit 1 |
| 127 | + ;; |
| 128 | + |
| 129 | +esac |
0 commit comments