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