Skip to content

Commit

Permalink
Add ability to set repo priority
Browse files Browse the repository at this point in the history
  • Loading branch information
iliajie committed Jan 27, 2025
1 parent 800f427 commit 717e95f
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions install-ci-cd-repo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,37 @@ set_virtualmin_package_preferences() {
return 0
}

set_virtualmin_repo_preferences() {
type="$1"
prefix="$2"
param="$3"
rpm_virtualmin_repo_preferences() {
type="$1"
param="$2"

# Handle priority parameter
if [ "$param" = "priority" ]; then
case "$type" in
"unstable")
echo "rpm:priority=10"
;;
"prerelease")
echo "rpm:priority=20"
;;
esac
fi
}

# Construct the function name
func_name="${prefix}_virtualmin_repo_preferences"

# Check if the function exists using POSIX compatible method
if command -v "$func_name" >/dev/null 2>&1; then
# Call the function with type and param
"$func_name" "$type" "$param"
fi
}

setup_repo() {
product="$1"
type="$2"
Expand All @@ -71,6 +102,13 @@ setup_repo() {
pkg_prefs=$(eval "$func" "$auth_user" "$auth_pass")
fi

# Call repo preference function if it exists
repo_prefs=""
func="set_${product}_repo_preferences"
if command -v "$func" >/dev/null 2>&1; then
repo_prefs=$(eval "$func" "$type" "rpm" "priority")
fi

case "$product" in
webmin)
case "$type" in
Expand All @@ -94,6 +132,7 @@ setup_repo() {
[ -n "$auth_user" ] && set -- "$@" "$auth_user"
[ -n "$auth_pass" ] && set -- "$@" "$auth_pass"
[ -n "$pkg_prefs" ] && set -- "$@" "--pkg-prefs=$pkg_prefs"
[ -n "$repo_prefs" ] && set -- "$@" "--repo-prefs=$repo_prefs"

sh "$script" "$@"
;;
Expand All @@ -111,6 +150,7 @@ setup_repo() {
[ -n "$auth_user" ] && set -- "$@" "$auth_user"
[ -n "$auth_pass" ] && set -- "$@" "$auth_pass"
[ -n "$pkg_prefs" ] && set -- "$@" "--pkg-prefs=$pkg_prefs"
[ -n "$repo_prefs" ] && set -- "$@" "--repo-prefs=$repo_prefs"

sh "$script" "$@"
;;
Expand Down

0 comments on commit 717e95f

Please sign in to comment.