mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
Support trusted=yes repositories...
This commit is contained in:
parent
bb25c6b15d
commit
b96c530d2b
2 changed files with 30 additions and 9 deletions
|
@ -469,6 +469,12 @@ ynh_install_extra_repo() {
|
||||||
wget_append="tee"
|
wget_append="tee"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [[ "$key" == "trusted=yes" ]]; then
|
||||||
|
trusted="--trusted"
|
||||||
|
else
|
||||||
|
trusted=""
|
||||||
|
fi
|
||||||
|
|
||||||
IFS=', ' read -r -a repo_parts <<< "$repo"
|
IFS=', ' read -r -a repo_parts <<< "$repo"
|
||||||
index=0
|
index=0
|
||||||
|
|
||||||
|
@ -485,7 +491,7 @@ ynh_install_extra_repo() {
|
||||||
fi
|
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 $trusted
|
||||||
|
|
||||||
# Pin the new repo with the default priority, so it won't be used for upgrades.
|
# Pin the new repo with the default priority, so it won't be used for upgrades.
|
||||||
# Build $pin from the uri without http and any sub path
|
# Build $pin from the uri without http and any sub path
|
||||||
|
@ -498,7 +504,7 @@ ynh_install_extra_repo() {
|
||||||
ynh_pin_repo --package="*" --pin="origin \"$pin\"" $priority --name="$name" $append
|
ynh_pin_repo --package="*" --pin="origin \"$pin\"" $priority --name="$name" $append
|
||||||
|
|
||||||
# Get the public key for the repo
|
# Get the public key for the repo
|
||||||
if [ -n "$key" ]; then
|
if [ -n "$key" ] && [[ "$key" != "trusted=yes" ]]; then
|
||||||
mkdir --parents "/etc/apt/trusted.gpg.d"
|
mkdir --parents "/etc/apt/trusted.gpg.d"
|
||||||
# Timeout option is here to enforce the timeout on dns query and tcp connect (c.f. man wget)
|
# Timeout option is here to enforce the timeout on dns query and tcp connect (c.f. man wget)
|
||||||
wget --timeout 900 --quiet "$key" --output-document=- | gpg --dearmor | $wget_append /etc/apt/trusted.gpg.d/$name.gpg >/dev/null
|
wget --timeout 900 --quiet "$key" --output-document=- | gpg --dearmor | $wget_append /etc/apt/trusted.gpg.d/$name.gpg >/dev/null
|
||||||
|
@ -551,6 +557,7 @@ ynh_remove_extra_repo() {
|
||||||
# | arg: -c, --component= - Component of the repository.
|
# | arg: -c, --component= - Component of the repository.
|
||||||
# | arg: -n, --name= - Name for the files for this repo, $app as default value.
|
# | arg: -n, --name= - Name for the files for this repo, $app as default value.
|
||||||
# | arg: -a, --append - Do not overwrite existing files.
|
# | arg: -a, --append - Do not overwrite existing files.
|
||||||
|
# | arg: -t, --trusted - Add trusted=yes to the repository (not recommended)
|
||||||
#
|
#
|
||||||
# Example for a repo like deb http://forge.yunohost.org/debian/ stretch stable
|
# Example for a repo like deb http://forge.yunohost.org/debian/ stretch stable
|
||||||
# uri suite component
|
# uri suite component
|
||||||
|
@ -559,13 +566,14 @@ ynh_remove_extra_repo() {
|
||||||
# Requires YunoHost version 3.8.1 or higher.
|
# Requires YunoHost version 3.8.1 or higher.
|
||||||
ynh_add_repo() {
|
ynh_add_repo() {
|
||||||
# Declare an array to define the options of this helper.
|
# Declare an array to define the options of this helper.
|
||||||
local legacy_args=uscna
|
local legacy_args=uscnat
|
||||||
local -A args_array=([u]=uri= [s]=suite= [c]=component= [n]=name= [a]=append)
|
local -A args_array=([u]=uri= [s]=suite= [c]=component= [n]=name= [a]=append [t]=trusted)
|
||||||
local uri
|
local uri
|
||||||
local suite
|
local suite
|
||||||
local component
|
local component
|
||||||
local name
|
local name
|
||||||
local append
|
local append
|
||||||
|
local trusted
|
||||||
# Manage arguments with getopts
|
# Manage arguments with getopts
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
name="${name:-$app}"
|
name="${name:-$app}"
|
||||||
|
@ -576,10 +584,15 @@ ynh_add_repo() {
|
||||||
else
|
else
|
||||||
append="tee"
|
append="tee"
|
||||||
fi
|
fi
|
||||||
|
if [[ "$trusted" -eq 1 ]]; then
|
||||||
|
trust="[trusted=yes]"
|
||||||
|
else
|
||||||
|
trust=""
|
||||||
|
fi
|
||||||
|
|
||||||
mkdir --parents "/etc/apt/sources.list.d"
|
mkdir --parents "/etc/apt/sources.list.d"
|
||||||
# Add the new repo in sources.list.d
|
# Add the new repo in sources.list.d
|
||||||
echo "deb $uri $suite $component" \
|
echo "deb $trust $uri $suite $component" \
|
||||||
| $append "/etc/apt/sources.list.d/$name.list"
|
| $append "/etc/apt/sources.list.d/$name.list"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -211,9 +211,15 @@ ynh_apt_install_dependencies_from_extra_repository() {
|
||||||
component="${repo_parts[*]:$index}"
|
component="${repo_parts[*]:$index}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [[ "$key" == "trusted=yes" ]]; then
|
||||||
|
trust="[trusted=yes]"
|
||||||
|
else
|
||||||
|
trust=""
|
||||||
|
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"
|
||||||
echo "deb $uri $suite $component" > "/etc/apt/sources.list.d/$app.list"
|
echo "deb $trust $uri $suite $component" > "/etc/apt/sources.list.d/$app.list"
|
||||||
|
|
||||||
# Pin the new repo with the default priority, so it won't be used for upgrades.
|
# Pin the new repo with the default priority, so it won't be used for upgrades.
|
||||||
# Build $pin from the uri without http and any sub path
|
# Build $pin from the uri without http and any sub path
|
||||||
|
@ -228,9 +234,11 @@ Pin: origin $pin
|
||||||
Pin-Priority: 995
|
Pin-Priority: 995
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
mkdir --parents "/etc/apt/trusted.gpg.d"
|
if [ -n "$key" ] && [[ "$key" != "trusted=yes" ]]; then
|
||||||
# Timeout option is here to enforce the timeout on dns query and tcp connect (c.f. man wget)
|
mkdir --parents "/etc/apt/trusted.gpg.d"
|
||||||
wget --timeout 900 --quiet "$key" --output-document=- | gpg --dearmor > /etc/apt/trusted.gpg.d/$app.gpg
|
# Timeout option is here to enforce the timeout on dns query and tcp connect (c.f. man wget)
|
||||||
|
wget --timeout 900 --quiet "$key" --output-document=- | gpg --dearmor > /etc/apt/trusted.gpg.d/$app.gpg
|
||||||
|
fi
|
||||||
|
|
||||||
# Update the list of package with the new repo NB: we use -o
|
# Update the list of package with the new repo NB: we use -o
|
||||||
# Dir::Etc::sourcelist to only refresh this repo, because
|
# Dir::Etc::sourcelist to only refresh this repo, because
|
||||||
|
|
Loading…
Add table
Reference in a new issue