Skip to content

Commit 4a0cf40

Browse files
authored
Merge pull request #1692 from master3395/v2.5.5-dev
fix: AlmaLinux 9 repo baseurl, EPEL fallback, and grep -O in WSGI Mak…
2 parents b2d5d97 + 7a2b169 commit 4a0cf40

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

cyberpanel_upgrade.sh

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,8 @@ if [[ "$Server_OS" = "CentOS" ]] || [[ "$Server_OS" = "AlmaLinux9" ]] ; then
444444
# For AlmaLinux 9: switch to repo.almalinux.org baseurl to avoid "Cannot find valid baseurl for repo: appstream"
445445
if [[ "$Server_OS" = "AlmaLinux9" ]] && [[ -d /etc/yum.repos.d ]]; then
446446
echo -e "[$(date +"%Y-%m-%d %H:%M:%S")] Fixing AlmaLinux 9 repos (appstream/baseos) for reliable mirror access" | tee -a /var/log/cyberpanel_upgrade_debug.log
447+
ALMA_VER="${Server_OS_Version:-9}"
448+
ARCH="x86_64"
447449
for repo in /etc/yum.repos.d/almalinux*.repo /etc/yum.repos.d/AlmaLinux*.repo; do
448450
[[ ! -f "$repo" ]] && continue
449451
if grep -q '^mirrorlist=' "$repo" 2>/dev/null; then
@@ -452,16 +454,21 @@ if [[ "$Server_OS" = "CentOS" ]] || [[ "$Server_OS" = "AlmaLinux9" ]] ; then
452454
sed -i 's|^#baseurl=\(.*repo\.almalinux\.org.*\)|baseurl=\1|' "$repo"
453455
fi
454456
done
455-
# Fallback: ensure appstream/baseos have explicit baseurl (avoids "Cannot find valid baseurl")
456-
ALMA_VER="${Server_OS_Version:-9}"
457-
ARCH="x86_64"
458-
for repofile in /etc/yum.repos.d/almalinux*.repo /etc/yum.repos.d/AlmaLinux*.repo; do
457+
# Ensure appstream/baseos have explicit baseurl (avoids "Cannot find valid baseurl"); process any .repo that has these sections
458+
for repofile in /etc/yum.repos.d/almalinux.repo /etc/yum.repos.d/almalinux*.repo /etc/yum.repos.d/AlmaLinux*.repo; do
459459
[[ ! -f "$repofile" ]] && continue
460460
if grep -q '^\[appstream\]' "$repofile" 2>/dev/null; then
461461
sed -i "/^\[appstream\]/,/^\[/ { s|^#\?baseurl=.*|baseurl=https://repo.almalinux.org/almalinux/${ALMA_VER}/AppStream/${ARCH}/os/|; s|^mirrorlist=.*|#mirrorlist=disabled| }" "$repofile"
462+
# Add baseurl if section had only mirrorlist (no baseurl line)
463+
if ! sed -n '/^\[appstream\]/,/^\[/p' "$repofile" | grep -q '^baseurl='; then
464+
sed -i "/^\[appstream\]/a baseurl=https://repo.almalinux.org/almalinux/${ALMA_VER}/AppStream/${ARCH}/os/" "$repofile"
465+
fi
462466
fi
463467
if grep -q '^\[baseos\]' "$repofile" 2>/dev/null; then
464468
sed -i "/^\[baseos\]/,/^\[/ { s|^#\?baseurl=.*|baseurl=https://repo.almalinux.org/almalinux/${ALMA_VER}/BaseOS/${ARCH}/os/|; s|^mirrorlist=.*|#mirrorlist=disabled| }" "$repofile"
469+
if ! sed -n '/^\[baseos\]/,/^\[/p' "$repofile" | grep -q '^baseurl='; then
470+
sed -i "/^\[baseos\]/a baseurl=https://repo.almalinux.org/almalinux/${ALMA_VER}/BaseOS/${ARCH}/os/" "$repofile"
471+
fi
465472
fi
466473
done
467474
fi
@@ -593,7 +600,13 @@ EOF
593600
dnf --nogpg install -y https://mirror.ghettoforge.net/distributions/gf/gf-release-latest.gf.el9.noarch.rpm
594601
fi
595602

596-
dnf install epel-release -y
603+
dnf install epel-release -y 2>/dev/null || {
604+
# Fallback when appstream was broken or epel-release not in repo (e.g. AlmaLinux 9)
605+
if [[ "$Server_OS_Version" = "9" ]]; then
606+
echo -e "[$(date +"%Y-%m-%d %H:%M:%S")] Installing EPEL from Fedora RPM (epel-release not in repo)..." | tee -a /var/log/cyberpanel_upgrade_debug.log
607+
dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm 2>/dev/null || true
608+
fi
609+
}
597610

598611
# AlmaLinux 9 specific package installation
599612
if [[ "$Server_OS" = "AlmaLinux9" ]] ; then
@@ -1308,7 +1321,7 @@ if [[ -f Makefile ]]; then
13081321
# Replace -O0 -g3 with -O2 -g to satisfy _FORTIFY_SOURCE
13091322
sed -i 's/-O0 -g3/-O2 -g/g' Makefile
13101323
# Ensure we have proper optimization flags
1311-
if grep -q "CFLAGS" Makefile && ! grep -q "-O2" Makefile; then
1324+
if grep -q "CFLAGS" Makefile && ! grep -q -e "-O2" Makefile; then
13121325
sed -i 's/CFLAGS =/CFLAGS = -O2/' Makefile
13131326
fi
13141327
echo -e "[$(date +"%Y-%m-%d %H:%M:%S")] Makefile optimized for proper compilation" | tee -a /var/log/cyberpanel_upgrade_debug.log

0 commit comments

Comments
 (0)