Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 65 additions & 11 deletions tests/greenboot-bootc-anaconda-iso.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@ SSH_KEY_PUB=$(cat "${SSH_KEY}".pub)
EDGE_USER=core
EDGE_USER_PASSWORD=foobar

# RPM acquisition mode:
# If DOWNLOAD_NODE and COMPOSE_ID are both set -> download from compose
# Otherwise -> build locally with make rpm (default)
USE_COMPOSE_RPMS=false
if [[ -n "${DOWNLOAD_NODE:-}" && -n "${COMPOSE_ID:-}" ]]; then
USE_COMPOSE_RPMS=true
fi
GREENBOOT_PACKAGES_URL=""

case "${ID}-${VERSION_ID}" in
"fedora-43")
OS_VARIANT="fedora-unknown"
Expand Down Expand Up @@ -66,15 +75,33 @@ case "${ID}-${VERSION_ID}" in
BIB_URL="registry.stage.redhat.io/rhel9/bootc-image-builder:9.8"
BOOT_ARGS="uefi"
sudo dnf install -y make rpm-build rust-toolset
sed -i "s/REPLACE_ME_HERE/${DOWNLOAD_NODE}/g" files/rhel-9-8.repo
if [[ "${USE_COMPOSE_RPMS}" == true ]]; then
{ set +x; } 2>/dev/null
GREENBOOT_PACKAGES_URL="https://${DOWNLOAD_NODE}/rhel-9/composes/RHEL-9/${COMPOSE_ID}/compose/AppStream/x86_64/os/Packages/"
set -x
fi
if [[ -n "${DOWNLOAD_NODE:-}" ]]; then
{ set +x; } 2>/dev/null
sed -i "s/REPLACE_ME_HERE/${DOWNLOAD_NODE}/g" files/rhel-9-8.repo
set -x
fi
;;
"rhel-10.2")
OS_VARIANT="rhel10-unknown"
BASE_IMAGE_URL="registry.stage.redhat.io/rhel10/rhel-bootc:10.2"
BIB_URL="registry.stage.redhat.io/rhel10/bootc-image-builder:10.2"
BOOT_ARGS="uefi"
sudo dnf install -y make rpm-build rust-toolset
sed -i "s/REPLACE_ME_HERE/${DOWNLOAD_NODE}/g" files/rhel-10-2.repo
if [[ "${USE_COMPOSE_RPMS}" == true ]]; then
{ set +x; } 2>/dev/null
GREENBOOT_PACKAGES_URL="https://${DOWNLOAD_NODE}/rhel-10/composes/RHEL-10/${COMPOSE_ID}/compose/AppStream/x86_64/os/Packages/"
set -x
fi
if [[ -n "${DOWNLOAD_NODE:-}" ]]; then
{ set +x; } 2>/dev/null
sed -i "s/REPLACE_ME_HERE/${DOWNLOAD_NODE}/g" files/rhel-10-2.repo
set -x
fi
;;
*)
echo "unsupported distro: ${ID}-${VERSION_ID}"
Expand Down Expand Up @@ -174,17 +201,44 @@ fi

###########################################################
##
## Build greenboot rpm packages
## Get greenboot rpm packages
##
###########################################################
greenprint "Building greenboot packages"
pushd .. && \
make rpm
cp rpmbuild/RPMS/x86_64/*.rpm tests/
cp testing_assets/passing_script.sh tests/
cp testing_assets/passing_binary tests/
cp testing_assets/failing_script.sh tests/
cp testing_assets/failing_binary tests/ && popd
if [[ "${USE_COMPOSE_RPMS}" == true && -n "${GREENBOOT_PACKAGES_URL}" ]]; then
{ set +x; } 2>/dev/null
greenprint "Downloading greenboot RPMs from compose"
rm -f greenboot-*.rpm

GREENBOOT_RPM="$(curl -kfsSL --retry 5 --retry-delay 2 --retry-all-errors \
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would explain why the option -k is needed.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The following command could be extracted into a variable to download the page once. It applies to all occurrences.

curl -kfsSL --retry 5 --retry-delay 2 --retry-all-errors \  
        "${GREENBOOT_PACKAGES_URL}"

"${GREENBOOT_PACKAGES_URL}" \
| grep -oE 'greenboot-[0-9][^"]*\.rpm' \
| grep -vE 'debug(info|source)' \
| sort -V | tail -n 1)"
echo "Selected greenboot RPM: ${GREENBOOT_RPM}"

GREENBOOT_DEFAULT_RPM="$(curl -kfsSL --retry 5 --retry-delay 2 --retry-all-errors \
"${GREENBOOT_PACKAGES_URL}" \
| grep -oE 'greenboot-default-health-checks-[0-9][^"]*\.rpm' \
| sort -V | tail -n 1)"
echo "Selected greenboot-default-health-checks RPM: ${GREENBOOT_DEFAULT_RPM}"

curl -kfsSL --retry 5 --retry-delay 2 --retry-all-errors \
"${GREENBOOT_PACKAGES_URL}${GREENBOOT_RPM}" -o "${GREENBOOT_RPM}"
curl -kfsSL --retry 5 --retry-delay 2 --retry-all-errors \
"${GREENBOOT_PACKAGES_URL}${GREENBOOT_DEFAULT_RPM}" -o "${GREENBOOT_DEFAULT_RPM}"
set -x
else
greenprint "Building greenboot packages with make rpm"
pushd ..
make rpm
cp rpmbuild/RPMS/x86_64/*.rpm tests/
popd
fi

cp ../testing_assets/passing_script.sh .
cp ../testing_assets/passing_binary .
cp ../testing_assets/failing_script.sh .
cp ../testing_assets/failing_binary .

###########################################################
##
Expand Down
76 changes: 65 additions & 11 deletions tests/greenboot-bootc-qcow2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@ SSH_KEY_PUB=$(cat "${SSH_KEY}".pub)
EDGE_USER=core
EDGE_USER_PASSWORD=foobar

# RPM acquisition mode:
# If DOWNLOAD_NODE and COMPOSE_ID are both set -> download from compose
# Otherwise -> build locally with make rpm (default)
USE_COMPOSE_RPMS=false
if [[ -n "${DOWNLOAD_NODE:-}" && -n "${COMPOSE_ID:-}" ]]; then
USE_COMPOSE_RPMS=true
fi
GREENBOOT_PACKAGES_URL=""

case "${ID}-${VERSION_ID}" in
"fedora-43")
OS_VARIANT="fedora-unknown"
Expand Down Expand Up @@ -66,15 +75,33 @@ case "${ID}-${VERSION_ID}" in
BIB_URL="registry.stage.redhat.io/rhel9/bootc-image-builder:9.8"
BOOT_ARGS="uefi"
sudo dnf install -y make rpm-build rust-toolset
sed -i "s/REPLACE_ME_HERE/${DOWNLOAD_NODE}/g" files/rhel-9-8.repo
if [[ "${USE_COMPOSE_RPMS}" == true ]]; then
{ set +x; } 2>/dev/null
GREENBOOT_PACKAGES_URL="https://${DOWNLOAD_NODE}/rhel-9/composes/RHEL-9/${COMPOSE_ID}/compose/AppStream/x86_64/os/Packages/"
set -x
fi
if [[ -n "${DOWNLOAD_NODE:-}" ]]; then
{ set +x; } 2>/dev/null
sed -i "s/REPLACE_ME_HERE/${DOWNLOAD_NODE}/g" files/rhel-9-8.repo
set -x
fi
;;
"rhel-10.2")
OS_VARIANT="rhel10-unknown"
BASE_IMAGE_URL="registry.stage.redhat.io/rhel10/rhel-bootc:10.2"
BIB_URL="registry.stage.redhat.io/rhel10/bootc-image-builder:10.2"
BOOT_ARGS="uefi"
sudo dnf install -y make rpm-build rust-toolset
sed -i "s/REPLACE_ME_HERE/${DOWNLOAD_NODE}/g" files/rhel-10-2.repo
if [[ "${USE_COMPOSE_RPMS}" == true ]]; then
{ set +x; } 2>/dev/null
GREENBOOT_PACKAGES_URL="https://${DOWNLOAD_NODE}/rhel-10/composes/RHEL-10/${COMPOSE_ID}/compose/AppStream/x86_64/os/Packages/"
set -x
fi
if [[ -n "${DOWNLOAD_NODE:-}" ]]; then
{ set +x; } 2>/dev/null
sed -i "s/REPLACE_ME_HERE/${DOWNLOAD_NODE}/g" files/rhel-10-2.repo
set -x
fi
;;
*)
echo "unsupported distro: ${ID}-${VERSION_ID}"
Expand Down Expand Up @@ -174,17 +201,44 @@ fi

###########################################################
##
## Build greenboot rpm packages
## Get greenboot rpm packages
##
###########################################################
greenprint "Building greenboot packages"
pushd .. && \
make rpm
cp rpmbuild/RPMS/x86_64/*.rpm tests/
cp testing_assets/passing_script.sh tests/
cp testing_assets/passing_binary tests/
cp testing_assets/failing_script.sh tests/
cp testing_assets/failing_binary tests/ && popd
if [[ "${USE_COMPOSE_RPMS}" == true && -n "${GREENBOOT_PACKAGES_URL}" ]]; then
{ set +x; } 2>/dev/null
greenprint "Downloading greenboot RPMs from compose"
rm -f greenboot-*.rpm

GREENBOOT_RPM="$(curl -kfsSL --retry 5 --retry-delay 2 --retry-all-errors \
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would explain why the option -k is needed.

"${GREENBOOT_PACKAGES_URL}" \
| grep -oE 'greenboot-[0-9][^"]*\.rpm' \
| grep -vE 'debug(info|source)' \
| sort -V | tail -n 1)"
echo "Selected greenboot RPM: ${GREENBOOT_RPM}"

GREENBOOT_DEFAULT_RPM="$(curl -kfsSL --retry 5 --retry-delay 2 --retry-all-errors \
"${GREENBOOT_PACKAGES_URL}" \
| grep -oE 'greenboot-default-health-checks-[0-9][^"]*\.rpm' \
| sort -V | tail -n 1)"
echo "Selected greenboot-default-health-checks RPM: ${GREENBOOT_DEFAULT_RPM}"

curl -kfsSL --retry 5 --retry-delay 2 --retry-all-errors \
"${GREENBOOT_PACKAGES_URL}${GREENBOOT_RPM}" -o "${GREENBOOT_RPM}"
curl -kfsSL --retry 5 --retry-delay 2 --retry-all-errors \
"${GREENBOOT_PACKAGES_URL}${GREENBOOT_DEFAULT_RPM}" -o "${GREENBOOT_DEFAULT_RPM}"
set -x
else
greenprint "Building greenboot packages with make rpm"
pushd ..
make rpm
cp rpmbuild/RPMS/x86_64/*.rpm tests/
popd
fi

cp ../testing_assets/passing_script.sh .
cp ../testing_assets/passing_binary .
cp ../testing_assets/failing_script.sh .
cp ../testing_assets/failing_binary .

###########################################################
##
Expand Down
47 changes: 41 additions & 6 deletions tests/greenboot-ostree.sh
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,15 @@ for _ in $(seq 0 30); do
sleep 10
done

# RPM acquisition mode:
# If DOWNLOAD_NODE and COMPOSE_ID are both set -> download from compose
# Otherwise -> build locally with make rpm (default)
USE_COMPOSE_RPMS=false
if [[ -n "${DOWNLOAD_NODE:-}" && -n "${COMPOSE_ID:-}" ]]; then
USE_COMPOSE_RPMS=true
fi
GREENBOOT_PACKAGES_URL=""

# Customize repository
sudo mkdir -p /etc/osbuild-composer/repositories

Expand All @@ -93,20 +102,46 @@ case "${ID}-${VERSION_ID}" in
OS_VARIANT="rhel9-unknown"
BOOT_ARGS="uefi"
BOOT_LOCATION="http://${DOWNLOAD_NODE}/rhel-9/nightly/RHEL-9/latest-RHEL-9.8.0/compose/BaseOS/x86_64/os/"
if [[ "${USE_COMPOSE_RPMS}" == true ]]; then
GREENBOOT_PACKAGES_URL="https://${DOWNLOAD_NODE}/rhel-9/composes/RHEL-9/${COMPOSE_ID}/compose/AppStream/x86_64/os/Packages/"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that { set +x; } 2>/dev/null ... set -x is missing here.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, for sake of consistency with the other scripts we can have it here...

fi
sed "s/REPLACE_ME_HERE/${DOWNLOAD_NODE}/g" files/rhel-9-8-0.json | sudo tee /etc/osbuild-composer/repositories/rhel-98.json > /dev/null;;
*)
echo "unsupported distro: ${ID}-${VERSION_ID}"
exit 1;;
esac

# Build greenboot RPMs
greenprint "Building greenboot packages"
pushd .. && \
make rpm
# Get greenboot RPMs
mkdir -p /var/www/html/packages
cp rpmbuild/RPMS/x86_64/*.rpm /var/www/html/packages/
if [[ "${USE_COMPOSE_RPMS}" == true && -n "${GREENBOOT_PACKAGES_URL}" ]]; then
greenprint "Downloading greenboot RPMs from compose: ${GREENBOOT_PACKAGES_URL}"

GREENBOOT_RPM="$(curl -kfsSL --retry 5 --retry-delay 2 --retry-all-errors \
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would explain why the option -k is needed.

"${GREENBOOT_PACKAGES_URL}" \
| grep -oE 'greenboot-[0-9][^"]*\.rpm' \
| grep -vE 'debug(info|source)' \
| sort -V | tail -n 1)"
echo "Selected greenboot RPM: ${GREENBOOT_RPM}"

GREENBOOT_DEFAULT_RPM="$(curl -kfsSL --retry 5 --retry-delay 2 --retry-all-errors \
"${GREENBOOT_PACKAGES_URL}" \
| grep -oE 'greenboot-default-health-checks-[0-9][^"]*\.rpm' \
| sort -V | tail -n 1)"
echo "Selected greenboot-default-health-checks RPM: ${GREENBOOT_DEFAULT_RPM}"

curl -kfsSL --retry 5 --retry-delay 2 --retry-all-errors \
"${GREENBOOT_PACKAGES_URL}${GREENBOOT_RPM}" -o "/var/www/html/packages/${GREENBOOT_RPM}"
curl -kfsSL --retry 5 --retry-delay 2 --retry-all-errors \
"${GREENBOOT_PACKAGES_URL}${GREENBOOT_DEFAULT_RPM}" -o "/var/www/html/packages/${GREENBOOT_DEFAULT_RPM}"
Comment on lines +117 to +135
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that { set +x; } 2>/dev/null ... set -x is missing here.

else
greenprint "Building greenboot packages with make rpm"
pushd ..
make rpm
cp rpmbuild/RPMS/x86_64/*.rpm /var/www/html/packages/
popd
fi
sudo createrepo_c /var/www/html/packages
sudo restorecon -Rv /var/www/html/packages && popd
sudo restorecon -Rv /var/www/html/packages

# Check ostree_key permissions
KEY_PERMISSION_PRE=$(stat -L -c "%a %G %U" key/ostree_key | grep -oP '\d+' | head -n 1)
Expand Down
Loading