Skip to content

Commit 1b94640

Browse files
committed
(maint) Refactor package cache refresh out of task prep action
...and into the common.sh.
1 parent 708de48 commit 1b94640

File tree

3 files changed

+23
-21
lines changed

3 files changed

+23
-21
lines changed

.github/actions/container_task_prep/action.yaml

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,7 @@ runs:
1717
source openvox_bootstrap/files/common.sh
1818
1919
# Ensure wget is installed.
20-
if exists 'apt'; then
21-
exec_and_capture apt update
22-
elif exists 'apt-get'; then
23-
exec_and_capture apt-get update
24-
elif exists 'dnf'; then
25-
exec_and_capture dnf clean all
26-
elif exists 'yum'; then
27-
exec_and_capture yum clean all
28-
elif exists 'zypper'; then
29-
exec_and_capture zypper refresh
30-
else
31-
echo "No package manager found."
32-
exit 1
33-
fi
20+
refresh_package_cache
3421
install_package wget
3522
3623
# Deal with missing package dependencies in the containers.

files/common.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,3 +350,21 @@ install_package() {
350350
fail "Unable to install ${_package}. Neither dnf, yum, zypper, apt nor apt-get are installed."
351351
fi
352352
}
353+
354+
# Update the package manager cache.
355+
refresh_package_cache() {
356+
if exists 'apt'; then
357+
exec_and_capture apt update
358+
elif exists 'apt-get'; then
359+
exec_and_capture apt-get update
360+
elif exists 'dnf'; then
361+
exec_and_capture dnf clean all
362+
elif exists 'yum'; then
363+
exec_and_capture yum clean all
364+
elif exists 'zypper'; then
365+
exec_and_capture zypper refresh
366+
else
367+
echo "No package manager found."
368+
exit 1
369+
fi
370+
}

tasks/install_linux.sh

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,16 +61,13 @@ set_collection_url() {
6161
assigned 'package_url'
6262
}
6363

64-
# Installs the release package, and runs apt update if we are on a
65-
# Debian based platform.
64+
# Installs the release package, and refreshes the package manager's
65+
# cache.
6666
install_release_package() {
6767
local _release_package="$1"
68-
local _package_type="$2"
6968

7069
install_package_file "${_release_package}"
71-
if [[ "${_package_type}" == "deb" ]]; then
72-
exec_and_capture apt update
73-
fi
70+
refresh_package_cache
7471
}
7572

7673
# Get platform information
@@ -83,6 +80,6 @@ download "${package_url}" "${local_release_package}"
8380
# Install the release package.
8481
# The release package has the repository metadata needed to install
8582
# packages from the collection using the platform package manager.
86-
install_release_package "${local_release_package}" "${package_type}"
83+
install_release_package "${local_release_package}"
8784
# Use the platform package manager to install openvox-agent
8885
install_package "${package}" "${version}" "${os_family}" "${os_full_version}"

0 commit comments

Comments
 (0)