Fix: support repositories without component

This commit is contained in:
Salamandar 2024-07-09 23:46:07 +02:00
parent a735a6d296
commit bb25c6b15d
2 changed files with 25 additions and 13 deletions

View file

@ -469,18 +469,20 @@ ynh_install_extra_repo() {
wget_append="tee" wget_append="tee"
fi fi
# Split the repository into uri, suite and components. IFS=', ' read -r -a repo_parts <<< "$repo"
index=0
# Remove "deb " at the beginning of the repo. # Remove "deb " at the beginning of the repo.
repo="${repo#deb }" if [[ "${repo_parts[0]}" == "deb" ]]; then
index=1
# Get the uri fi
local uri="$(echo "$repo" | awk '{ print $1 }')" uri="${repo_parts[$index]}" ; index=$((index+1))
suite="${repo_parts[$index]}" ; index=$((index+1))
# Get the suite
local suite="$(echo "$repo" | awk '{ print $2 }')"
# Get the components # Get the components
local component="${repo##$uri $suite }" if (( "${#repo_parts[@]}" > 0 )); then
component="${repo_parts[*]:$index}"
fi
# Add the repository into sources.list.d # Add the repository into sources.list.d
ynh_add_repo --uri="$uri" --suite="$suite" --component="$component" --name="$name" $append ynh_add_repo --uri="$uri" --suite="$suite" --component="$component" --name="$name" $append

View file

@ -196,10 +196,20 @@ ynh_apt_install_dependencies_from_extra_repository() {
# =========================================== # ===========================================
# Split the repository into uri, suite and components. # Split the repository into uri, suite and components.
repo="${repo#deb }" IFS=', ' read -r -a repo_parts <<< "$repo"
local uri="$(echo "$repo" | awk '{ print $1 }')" index=0
local suite="$(echo "$repo" | awk '{ print $2 }')"
local component="${repo##$uri $suite }" # Remove "deb " at the beginning of the repo.
if [[ "${repo_parts[0]}" == "deb" ]]; then
index=1
fi
uri="${repo_parts[$index]}" ; index=$((index+1))
suite="${repo_parts[$index]}" ; index=$((index+1))
# Get the components
if (( "${#repo_parts[@]}" > 0 )); then
component="${repo_parts[*]:$index}"
fi
# Add the new repo in sources.list.d # Add the new repo in sources.list.d
mkdir --parents "/etc/apt/sources.list.d" mkdir --parents "/etc/apt/sources.list.d"