Skip to content

Fix: detect http*_proxy for GPG #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion migrate-apt-keys
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,12 @@ process_line() { # modifies: $line; uses locals of process_repo()
[ -n "$keyid" ] || return 0

if ! glob_match "$sig_keys" "* $keyid *"; then # download key
if ! gpg --quiet --no-default-keyring --keyring gnupg-ring:"$sig_file" --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys "$keyid"; then
GPG_OPTS=''
find_proxy
if [ -n "$found_proxy" ]; then
GPG_OPTS="--keyserver-options http-proxy=$found_proxy"
fi
if ! gpg $GPG_OPTS --quiet --no-default-keyring --keyring gnupg-ring:"$sig_file" --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys "$keyid"; then
eecho "$sig_base: couldn't download $keyid from server"; return 0
fi
expiry=$(gpg --no-default-keyring --keyring="$sig_file" --list-keys --with-colons --fixed-list-mode | keyid=$keyid perl -wne 'if (/^(pub|sub):.*:$ENV{keyid}:/) { my @f = split /:/; print "$f[6]\n" }')
Expand All @@ -133,6 +138,20 @@ process_line() { # modifies: $line; uses locals of process_repo()
line=$m_line
}

# Check if http_proxy ir https_proxy or HTTP_PROXY or HTTPS_PROXY are set
find_proxy() { # args: None; out: found_proxy
found_proxy=
if [ -n "$http_proxy" ]; then
found_proxy="$http_proxy"
elif [ -n "$https_proxy" ]; then
found_proxy="$https_proxy"
elif [ -n "$HTTP_PROXY" ]; then
found_proxy="$HTTP_PROXY"
elif [ -n "$HTTPS_PROXY" ]; then
found_proxy="$HTTPS_PROXY"
fi
}

url2keyid() { # args: URL; out: keyid
keyid=
local url; url=$1; shift
Expand Down