nodejs/install-rpms.sh
2025-01-14 14:02:47 +01:00

64 lines
2.3 KiB
Bash
Executable file

#!/bin/bash
set -e # Exit immediately on any command failure
set -u # Treat unset variables as errors
# Manual way to test any task or build locally
#KOJI_TASK_ID=2586515
KOJI_TASK_ID=${KOJI_TASK_ID:-} # Use environment variable or default to an empty string
# Check if KOJI_TASK_ID is set
if [ -z "$KOJI_TASK_ID" ]; then
echo "WARN: KOJI_TASK_ID not set!"
echo "WARN: RPMS will be pulled from the repo as fallback." >&2
echo "INFO: This variable should be either provided or passed from Testing Farm." >&2
exit 0
fi
# Get the current architecture
ARCH=$(uname -m)
echo "INFO: Detected architecture: $ARCH"
# Function to download build using `koji download-build` with progress
download_with_koji_build() {
echo "INFO: Attempting to download build for task ID $KOJI_TASK_ID using 'koji download-build'."
koji download-build --arch "$ARCH" "$KOJI_TASK_ID"
}
# Function to download using `koji download-task` as fallback
download_with_koji_task() {
echo "INFO: Attempting to download build for task ID $KOJI_TASK_ID using 'koji download-task'."
koji download-task --arch "$ARCH" "$KOJI_TASK_ID"
}
# Attempt both download methods
if ! download_with_koji_build && ! download_with_koji_task; then
echo "WARN: Failed to download RPMS from task $KOJI_TASK_ID for architecture $ARCH." >&2
echo "WARN: Proceeding with fallback mechanism."
exit 0
fi
# List downloaded RPMs
echo "INFO: Listing downloaded RPM files:"
ls -1 *.rpm || echo "INFO: No RPM files found in the current directory."
# Ensure required RPMs are downloaded
MAIN_RPM=$(ls nodejs-*.$ARCH.rpm 2>/dev/null | head -n 1)
DEPENDENCY_RPM=$(ls nodejs-libs-*.$ARCH.rpm 2>/dev/null | head -n 1)
NPM_RPM=$(ls nodejs-npm-*.$ARCH.rpm 2>/dev/null | head -n 1)
DEVEL_RPM=$(ls nodejs-devel-*.$ARCH.rpm 2>/dev/null | head -n 1)
if [ -z "$MAIN_RPM" ] || [ -z "$DEPENDENCY_RPM" ] || [ -z "$NPM_RPM" ] || [ -z "$DEVEL_RPM" ]; then
echo "WARN: Required RPMs not found for $ARCH architecture. Proceeding without installation." >&2
exit 0
fi
# Install the RPMs
echo "INFO: Installing RPMs:"
echo "INFO: $MAIN_RPM, $DEPENDENCY_RPM, $NPM_RPM, $DEVEL_RPM"
if ! dnf install -y --allowerasing "$MAIN_RPM" "$DEPENDENCY_RPM" "$NPM_RPM" "$DEVEL_RPM"; then
echo "WARN: Failed to install some RPMs using DNF. Continuing with tmt require standart installation." >&2
fi
echo "INFO: Script completed."