File tree Expand file tree Collapse file tree 2 files changed +36
-5
lines changed
Expand file tree Collapse file tree 2 files changed +36
-5
lines changed Original file line number Diff line number Diff line change 11#! /usr/bin/env bash
22# Usage: script/mirror update <COMMIT-RANGE>
3+ # script/mirror verify <COMMIT-RANGE>
34# script/mirror stats
45set -e
56
6- commit_range=" ${1?} "
7-
87eval " $( 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+
1013test_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+
6783stats () {
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
Original file line number Diff line number Diff line change @@ -8,6 +8,8 @@ bats -t test || STATUS="$?"
88
99if [ " $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 "
1113fi
1214
1315exit " $STATUS "
You can’t perform that action at this time.
0 commit comments