Skip to content

Commit 29f1a19

Browse files
committed
Merge branch 'pr-checksum'
2 parents 66fd3ec + 95b32ac commit 29f1a19

File tree

2 files changed

+36
-5
lines changed

2 files changed

+36
-5
lines changed

script/mirror

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
#!/usr/bin/env bash
22
# Usage: script/mirror update <COMMIT-RANGE>
3+
# script/mirror verify <COMMIT-RANGE>
34
# script/mirror stats
45
set -e
56

6-
commit_range="${1?}"
7-
87
eval "$(grep RUBY_BUILD_MIRROR_URL= ./bin/ruby-build | head -1)"
98

9+
help_text() {
10+
sed -ne '/^#/!q;s/.\{1,2\}//;1d;p' < "$0"
11+
}
12+
1013
test_mirrored() {
1114
curl -qsSfIL "$RUBY_BUILD_MIRROR_URL/$1" >/dev/null 2>&1
1215
}
@@ -64,6 +67,19 @@ update() {
6467
done
6568
}
6669

70+
verify() {
71+
local url
72+
local checksum
73+
local file
74+
for url in $(potentially_new_packages "$1"); do
75+
checksum="${url#*#}"
76+
url="${url%#*}"
77+
echo "Verifying checksum for $url"
78+
file="${TMPDIR:-/tmp}/$checksum"
79+
download_and_verify "$url" "$file" "$checksum"
80+
done
81+
}
82+
6783
stats() {
6884
local packages=( $(extract_urls ./share/ruby-build/*) )
6985
local total="${#packages[@]}"
@@ -82,6 +98,19 @@ stats() {
8298
echo "$confirmed/$total mirrored"
8399
}
84100

85-
cmd="${1?}"
86-
shift 1
87-
"$cmd" "$@"
101+
cmd="$1"
102+
103+
case "$cmd" in
104+
update | verify | stats )
105+
shift 1
106+
"$cmd" "$@"
107+
;;
108+
-h | --help )
109+
help_text
110+
exit 0
111+
;;
112+
* )
113+
help_text >&2
114+
exit 1
115+
;;
116+
esac

script/test

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ bats -t test || STATUS="$?"
88

99
if [ "$TRAVIS_SECURE_ENV_VARS" = "true" ]; then
1010
./script/mirror update "$TRAVIS_COMMIT_RANGE"
11+
elif [ "$TRAVIS_PULL_REQUEST" != "false" ]; then
12+
./script/mirror verify "$TRAVIS_COMMIT_RANGE"
1113
fi
1214

1315
exit "$STATUS"

0 commit comments

Comments
 (0)