Merge pull request #1344 from greut/patch-1

apt_key_fetch: use curl
This commit is contained in:
Pedro Algarvio 2019-05-15 17:58:20 +01:00 committed by GitHub
commit b05c284f62
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1866,6 +1866,26 @@ __apt_get_upgrade_noinput() {
} # ---------- end of function __apt_get_upgrade_noinput ----------
#--- FUNCTION -------------------------------------------------------------------------------------------------------
# NAME: __temp_gpg_pub
# DESCRIPTION: Create a temporary file for downloading a GPG public key.
#----------------------------------------------------------------------------------------------------------------------
__temp_gpg_pub() {
if __check_command_exists mktemp; then
tempfile="$(mktemp /tmp/salt-gpg-XXXXXXXX.pub 2>/dev/null)"
if [ -z "$tempfile" ]; then
echoerror "Failed to create temporary file in /tmp"
return 1
fi
else
tempfile="/tmp/salt-gpg-$$.pub"
fi
echo $tempfile
} # ----------- end of function __temp_gpg_pub -----------
#--- FUNCTION -------------------------------------------------------------------------------------------------------
# NAME: __apt_key_fetch
# DESCRIPTION: Download and import GPG public key for "apt-secure"
@ -1874,8 +1894,13 @@ __apt_get_upgrade_noinput() {
__apt_key_fetch() {
url=$1
# shellcheck disable=SC2086
__wait_for_apt apt-key adv ${_GPG_ARGS} --fetch-keys "$url"; return $?
tempfile="$(__temp_gpg_pub)"
__fetch_url "$tempfile" "$url" || return 1
apt-key add "$tempfile" || return 1
rm -f "$tempfile"
return 0
} # ---------- end of function __apt_key_fetch ----------
@ -1887,16 +1912,7 @@ __apt_key_fetch() {
__rpm_import_gpg() {
url=$1
if __check_command_exists mktemp; then
tempfile="$(mktemp /tmp/salt-gpg-XXXXXXXX.pub 2>/dev/null)"
if [ -z "$tempfile" ]; then
echoerror "Failed to create temporary file in /tmp"
return 1
fi
else
tempfile="/tmp/salt-gpg-$$.pub"
fi
tempfile="$(__temp_gpg_pub)"
__fetch_url "$tempfile" "$url" || return 1
rpm --import "$tempfile" || return 1