Some checks failed
Build RPM Package / Build RPM Packages (CentOS 7, Rocky 8/9/10) (push) Has been cancelled
- Suppression complète du support DEB (Debian/Ubuntu) - Builder Rocky Linux 9 pour compatibilité binaire maximale - Compilation dynamique avec libpcap comme dépendance runtime - Activation du dépôt CRB pour libpcap-devel - RPM générés pour el7, el8, el9, el10 - Mise à jour documentation et workflows GitHub Actions Fix: erreur 'libpcap.so.0.8: cannot open shared object file' sur Rocky Linux 9 Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
113 lines
3.3 KiB
Bash
Executable File
113 lines
3.3 KiB
Bash
Executable File
#!/bin/bash
|
|
# Test RPM package installation on CentOS 7, Rocky Linux 8/9/10
|
|
# Note: We don't use set -e here because we want to continue testing even if one fails
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
PROJECT_ROOT="$(dirname "$(dirname "$SCRIPT_DIR")")"
|
|
BUILD_DIR="${PROJECT_ROOT}/build/rpm"
|
|
|
|
echo "=========================================="
|
|
echo " Testing RPM Package Installation"
|
|
echo "=========================================="
|
|
|
|
# Colors for output
|
|
RED='\033[0;31m'
|
|
GREEN='\033[0;32m'
|
|
YELLOW='\033[1;33m'
|
|
NC='\033[0m' # No Color
|
|
|
|
# Function to test RPM installation on a specific distribution
|
|
test_rpm_install() {
|
|
local distro=$1
|
|
local image=$2
|
|
local rpm_dir=$3
|
|
|
|
echo ""
|
|
echo -e "${YELLOW}Testing on ${distro} (${image})...${NC}"
|
|
|
|
# Check if RPM files exist in the directory
|
|
if [ ! -d "${BUILD_DIR}/${rpm_dir}" ] || [ -z "$(ls -A ${BUILD_DIR}/${rpm_dir}/*.rpm 2>/dev/null)" ]; then
|
|
echo -e "${RED} Warning: No RPM packages found in ${BUILD_DIR}/${rpm_dir}${NC}"
|
|
echo " Skipping ${distro} test..."
|
|
return 1
|
|
fi
|
|
|
|
# Determine package manager and install command
|
|
# Note: libpcap is required at runtime (dynamically linked)
|
|
local setup_cmd=""
|
|
local install_cmd=""
|
|
case "$image" in
|
|
centos:7)
|
|
# CentOS 7 is EOL, need to configure vault.centos.org
|
|
setup_cmd="sed -i 's/mirror.centos.org/vault.centos.org/g' /etc/yum.repos.d/*.repo && sed -i 's/^#.*baseurl=http/baseurl=http/g' /etc/yum.repos.d/*.repo && sed -i 's/^mirrorlist=http/#mirrorlist=http/g' /etc/yum.repos.d/*.repo"
|
|
install_cmd="${setup_cmd} && yum install -y libpcap && yum install -y /packages/*.rpm"
|
|
;;
|
|
rockylinux:*|almalinux:*)
|
|
install_cmd="dnf install -y libpcap && dnf install -y /packages/*.rpm"
|
|
;;
|
|
*)
|
|
install_cmd="dnf install -y libpcap && dnf install -y /packages/*.rpm"
|
|
;;
|
|
esac
|
|
|
|
# Test installation
|
|
if docker run --rm \
|
|
-v "${BUILD_DIR}/${rpm_dir}:/packages:ro" \
|
|
"${image}" \
|
|
sh -c "${install_cmd}"; then
|
|
echo -e " ${GREEN}✓${NC} ${distro}: Installation successful"
|
|
return 0
|
|
else
|
|
echo -e " ${RED}✗${NC} ${distro}: Installation failed"
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
# Track test results
|
|
TESTS_PASSED=0
|
|
TESTS_FAILED=0
|
|
|
|
# Test on CentOS 7
|
|
if test_rpm_install "CentOS 7" "centos:7" "el7"; then
|
|
((TESTS_PASSED++))
|
|
else
|
|
((TESTS_FAILED++))
|
|
fi
|
|
|
|
# Test on Rocky Linux 8
|
|
if test_rpm_install "Rocky Linux 8" "rockylinux:8" "el8"; then
|
|
((TESTS_PASSED++))
|
|
else
|
|
((TESTS_FAILED++))
|
|
fi
|
|
|
|
# Test on Rocky Linux 9
|
|
if test_rpm_install "Rocky Linux 9" "rockylinux:9" "el9"; then
|
|
((TESTS_PASSED++))
|
|
else
|
|
((TESTS_FAILED++))
|
|
fi
|
|
|
|
# Test on AlmaLinux 10 (Rocky Linux 10 compatible)
|
|
if test_rpm_install "AlmaLinux 10" "almalinux:10" "el10"; then
|
|
((TESTS_PASSED++))
|
|
else
|
|
((TESTS_FAILED++))
|
|
fi
|
|
|
|
echo ""
|
|
echo "=========================================="
|
|
echo " Test Summary"
|
|
echo "=========================================="
|
|
echo -e " Passed: ${GREEN}${TESTS_PASSED}${NC}"
|
|
echo -e " Failed: ${RED}${TESTS_FAILED}${NC}"
|
|
echo "=========================================="
|
|
|
|
if [ ${TESTS_FAILED} -gt 0 ]; then
|
|
echo -e "${RED}Some tests failed!${NC}"
|
|
exit 1
|
|
else
|
|
echo -e "${GREEN}All RPM package tests passed!${NC}"
|
|
exit 0
|
|
fi
|