Skip to content

Commit bbe09b9

Browse files
committed
delay detecting package manager
Sometimes rpm can hang. So if we don't need to install anything, don't touch it.
1 parent b979cb5 commit bbe09b9

File tree

1 file changed

+21
-12
lines changed

1 file changed

+21
-12
lines changed

build/lib/init.sh

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -225,18 +225,26 @@ apt_install() {
225225
host_cmd apt-get install -y --allow-downgrades "$@"
226226
}
227227

228-
if host_cmd dnf --version; then
229-
echo "dnf is available"
230-
PKG_MGR=dnf
231-
SUPPORT_RPM=true
232-
elif host_cmd yum --version; then
233-
echo "yum is available"
234-
PKG_MGR=yum
235-
SUPPORT_RPM=true
236-
elif host_cmd apt-get --version; then
237-
echo "apt-get is available"
238-
PKG_MGR=apt
239-
fi
228+
PKG_MGR=NOT_INITIALIZED
229+
230+
detect_package_manager() {
231+
if [ "$PKG_MGR" != "NOT_INITIALIZED" ]; then
232+
return 0
233+
fi
234+
PKG_MGR=""
235+
if host_cmd dnf --version; then
236+
echo "dnf is available"
237+
PKG_MGR=dnf
238+
SUPPORT_RPM=true
239+
elif host_cmd yum --version; then
240+
echo "yum is available"
241+
PKG_MGR=yum
242+
SUPPORT_RPM=true
243+
elif host_cmd apt-get --version; then
244+
echo "apt-get is available"
245+
PKG_MGR=apt
246+
fi
247+
}
240248

241249
# idempotent package installation
242250
# downgrade if the already installed version is newer than the one we want to install
@@ -273,6 +281,7 @@ if [ "$ARCH" = "x86_64" ] && [ "$run_nas" = "true" ]; then
273281

274282
if [ $install_utils = "true" ]; then
275283
# cpfs-nas nas-rich-client common rpm
284+
detect_package_manager
276285
echo "installing aliyun-alinas-utils"
277286
if [ "$SUPPORT_RPM" = "true" ]; then
278287
PKG=aliyun-alinas-utils-1.1-8.20240527201444.2012cc.al7.noarch.rpm

0 commit comments

Comments
 (0)