Skip to content

Commit b7db8be

Browse files
committed
Improve OS detection and installation for EL7, EL8, and EL9 systems
- Enterprise Linux distribution detection to handle all variants (CentOS, RHEL, AlmaLinux, Rocky Linux) - Add version-based dispatch to use appropriate package managers (yum for EL7, dnf for EL8/EL9) - Create separate functions for EL7 vs EL8/EL9 with correct KLayout package URLs - For Klayout, use CentOS_7 package for EL7, CentOS_8 package for EL8, RockyLinux_9 package for EL9 - Fix argument expansion issue that broke dependency installer calls Signed-off-by: kcaisley <[email protected]>
1 parent 1179c7d commit b7db8be

File tree

2 files changed

+101
-8
lines changed

2 files changed

+101
-8
lines changed

etc/DependencyInstaller.sh

Lines changed: 100 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,14 @@ _installCommon() {
6262
fi
6363
}
6464

65-
_installCentosCleanUp() {
65+
# Enterprise Linux 7 cleanup
66+
_install_EL7_CleanUp() {
6667
yum clean -y all
6768
rm -rf /var/lib/apt/lists/*
6869
}
6970

70-
_installCentosPackages() {
71+
# Enterprise Linux 7 package installation (EL7 = RHEL 7 or CentOS 7)
72+
_install_EL7_Packages() {
7173
yum -y update
7274
yum -y install \
7375
time \
@@ -88,6 +90,67 @@ _installCentosPackages() {
8890
fi
8991
}
9092

93+
94+
# Enterprise Linux 8/9 cleanup
95+
_install_EL8_EL9_CleanUp() {
96+
dnf clean -y all
97+
rm -rf /var/lib/apt/lists/*
98+
}
99+
100+
# Enterprise Linux 8/9 package installation (EL8/EL9 = RHEL, Rocky Linux, AlmaLinux, or CentOS 8 as no CentOS 9 exists)
101+
_install_EL8_EL9_Packages() {
102+
# Re-detect EL version for appropriate KLayout package
103+
if [[ -f /etc/os-release ]]; then
104+
elVersion=$(awk -F= '/^VERSION_ID/{print $2}' /etc/os-release | sed 's/"//g' | cut -d. -f1)
105+
else
106+
echo "ERROR: Could not detect Enterprise Linux version"
107+
exit 1
108+
fi
109+
110+
# EL8 and EL9 use `dnf`, instead of `yum`
111+
dnf -y update
112+
dnf -y install \
113+
time \
114+
ruby \
115+
ruby-devel
116+
117+
# Install KLayout based on EL version, note the different URLs
118+
case "${elVersion}" in
119+
"8")
120+
if ! [ -x "$(command -v klayout)" ]; then
121+
dnf -y install https://www.klayout.org/downloads/CentOS_8/klayout-${klayoutVersion}-0.x86_64.rpm
122+
else
123+
currentVersion=$(klayout -v | grep -o '[0-9]\+\.[0-9]\+\.[0-9]\+')
124+
if _versionCompare "$currentVersion" -ge $klayoutVersion; then
125+
echo "KLayout version greater than or equal to ${klayoutVersion}"
126+
else
127+
echo "KLayout version less than ${klayoutVersion}"
128+
sudo dnf remove -y klayout
129+
dnf -y install https://www.klayout.org/downloads/CentOS_8/klayout-${klayoutVersion}-0.x86_64.rpm
130+
fi
131+
fi
132+
;;
133+
"9")
134+
if ! [ -x "$(command -v klayout)" ]; then
135+
dnf -y install https://www.klayout.org/downloads/RockyLinux_9/klayout-${klayoutVersion}-0.x86_64.rpm
136+
else
137+
currentVersion=$(klayout -v | grep -o '[0-9]\+\.[0-9]\+\.[0-9]\+')
138+
if _versionCompare "$currentVersion" -ge $klayoutVersion; then
139+
echo "KLayout version greater than or equal to ${klayoutVersion}"
140+
else
141+
echo "KLayout version less than ${klayoutVersion}"
142+
sudo dnf remove -y klayout
143+
dnf -y install https://www.klayout.org/downloads/RockyLinux_9/klayout-${klayoutVersion}-0.x86_64.rpm
144+
fi
145+
fi
146+
;;
147+
*)
148+
echo "ERROR: Unsupported Enterprise Linux version: ${elVersion}"
149+
exit 1
150+
;;
151+
esac
152+
}
153+
91154
_installUbuntuCleanUp() {
92155
apt-get autoclean -y
93156
apt-get autoremove -y
@@ -355,15 +418,45 @@ case "${platform}" in
355418
esac
356419

357420
case "${os}" in
358-
"CentOS Linux" | "AlmaLinux" | "Rocky Linux" | "Red Hat Enterprise Linux" )
421+
"CentOS Linux" | "Red Hat Enterprise Linux Server" | "AlmaLinux" | "Rocky Linux" | "Red Hat Enterprise Linux" )
422+
# Enterprise Linux support - dispatch based on version
359423
if [[ ${CI} == "yes" ]]; then
360424
echo "WARNING: Installing CI dependencies is only supported on Ubuntu 22.04" >&2
361425
fi
362-
_installORDependencies
363-
if [[ "${option}" == "base" || "${option}" == "all" ]]; then
364-
_installCentosPackages
365-
_installCentosCleanUp
426+
427+
# Detect EL version to choose appropriate functions
428+
if [[ -f /etc/os-release ]]; then
429+
elVersion=$(awk -F= '/^VERSION_ID/{print $2}' /etc/os-release | sed 's/"//g' | cut -d. -f1)
430+
else
431+
echo "ERROR: Could not detect Enterprise Linux version" >&2
432+
exit 1
366433
fi
434+
435+
# First install OpenROAD base
436+
_installORDependencies
437+
438+
# Determine between EL7 vs EL8/9, since yum vs dnf should be used, and different Klayout builds exist
439+
case "${elVersion}" in
440+
"7")
441+
# EL7 = RHEL 7 or CentOS 7
442+
if [[ "${option}" == "base" || "${option}" == "all" ]]; then
443+
_install_EL7_Packages
444+
_install_EL7_CleanUp
445+
fi
446+
;;
447+
"8"|"9")
448+
# EL8/EL9 = RHEL, Rocky Linux, AlmaLinux, or CentOS 8+
449+
if [[ "${option}" == "base" || "${option}" == "all" ]]; then
450+
_install_EL8_EL9_Packages
451+
_install_EL8_EL9_CleanUp
452+
fi
453+
;;
454+
*)
455+
echo "ERROR: Unsupported Enterprise Linux version: ${elVersion}" >&2
456+
exit 1
457+
;;
458+
esac
459+
367460
if [[ "${option}" == "common" || "${option}" == "all" ]]; then
368461
_installCommon
369462
fi

tools/OpenROAD

0 commit comments

Comments
 (0)