Skip to content

Commit

Permalink
Fix special chars in source-urls
Browse files Browse the repository at this point in the history
  • Loading branch information
Flamefire committed Dec 19, 2024
1 parent a6fdcbc commit 58d2450
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,8 @@ jobs:
- name: Install packages
if: startsWith(matrix.os, 'ubuntu')
run: |
SOURCE_KEYS=(${{join(matrix.source_keys, ' ')}})
SOURCES=(${{join(matrix.sources, ' ')}})
SOURCE_KEYS=("${{join(matrix.source_keys, '" "')}}")
SOURCES=("${{join(matrix.sources, '" "')}}")
# Add this by default
SOURCE_KEYS+=('http://keyserver.ubuntu.com/pks/lookup?op=get&search=0x1E9377A2BA9EF27F')
SOURCES+=(ppa:ubuntu-toolchain-r/test)
Expand Down
9 changes: 7 additions & 2 deletions ci/add-apt-keys.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#!/bin/bash
#
# Copyright 2023 Alexander Grund
# Copyright 2023-2024 Alexander Grund
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
#
# Add APT keys
# - Each argument should be a key URL
# - Each argument should be a key URL or a key ID (0x...)
# - $NET_RETRY_COUNT is the amount of retries attempted

set -eu
Expand All @@ -16,9 +16,13 @@ function do_add_key
key_url=$1
# If a keyserver URL (e.g. http://keyserver.ubuntu.com/pks/lookup?op=get&search=0x1E9377A2BA9EF27F)
# use the hash as the filename,
# if it is an ID, e.g. 0x1E9377A2BA9EF27F, use it as the filename, and http://keyserver.ubuntu.com/pks/lookup as the URL
# else assume the URL contains a filename, e.g. https://apt.llvm.org/llvm-snapshot.gpg.key
if [[ "$key_url" =~ .*keyserver.*search=0x([A-F0-9]+) ]]; then
keyfilename="${BASH_REMATCH[1]}.key"
elif [[ $key_url =~ ^0x[A-F0-9]+$ ]]; then
keyfilename=${key_url#0x}.key
key_url="http://keyserver.ubuntu.com/pks/lookup?op=get&search=$key_url"
else
keyfilename=$(basename -s .key "$key_url")
fi
Expand All @@ -30,5 +34,6 @@ function do_add_key
}

for key_url in "$@"; do
[[ -n $key_url ]] || continue
do_add_key "$key_url"
done
4 changes: 3 additions & 1 deletion ci/add-apt-repositories.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/bash
#
# Copyright 2023 Alexander Grund, Sam Darwin
# Copyright 2023 Sam Darwin
# Copyright 2023-2024 Alexander Grund
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
Expand Down Expand Up @@ -28,5 +29,6 @@ function do_add_repository {
}

for repo_name in "$@"; do
[[ -n $repo_name ]] || continue
do_add_repository "$repo_name"
done

0 comments on commit 58d2450

Please sign in to comment.