@@ -12,7 +12,7 @@ if [ "$#" -lt 1 ] || [ "$#" -gt 2 ]; then
1212 exit 1
1313fi
1414
15- dest=" $1 "
15+ dest=$1
1616if [ ! -d " ${dest} " ]; then
1717 echo " ${dest} must be a directory"
1818 exit 1
@@ -22,9 +22,9 @@ if [ ! -w "${dest}" ]; then
2222 echo " you must be able to write to ${dest} "
2323 exit 1
2424fi
25- dest=" $( realpath " ${dest} " ) "
25+ dest=$( realpath " ${dest} " )
2626
27- state=" $2 "
27+ state=$2
2828if [ " ${state} " = " " ]; then
2929 state=" ${PWD} /mirrorstate"
3030fi
@@ -34,8 +34,8 @@ state="$(realpath "${state}")"
3434
3535# Download a HTTP file
3636download_file () {
37- url=" ${1} "
38- out=" ${2} "
37+ url=${1}
38+ out=${2}
3939 # Download the file
4040 continue_arg=" "
4141 if [ -e " ${out} " ]; then
@@ -47,8 +47,8 @@ download_file() {
4747
4848# Check if a git reference exists in a given repository
4949git_ref_exists () {
50- repo=" ${1} "
51- ref=" ${2} "
50+ repo=${1}
51+ ref=${2}
5252 # change this to git show-ref once it is sufficiently not-new
5353 ( cd " ${repo} " || exit && git cat-file -t " ${ref} " > /dev/null 2>&1 )
5454 return $?
@@ -59,21 +59,21 @@ checksum_file() {
5959}
6060
6161do_file () {
62- uri=" ${1} "
62+ uri=${1}
6363 echo " ${uri} "
6464
6565 if echo " ${uri} " | grep -qE " ^https?://" ; then
6666 # HTTP file
67- checksum=" ${2} "
68- filename=" ${3} "
67+ checksum=${2}
68+ filename=${3}
6969 if [ " ${filename} " = " " ]; then
70- filename=" $( basename " ${uri} " ) "
70+ filename=$( basename " ${uri} " )
7171 fi
7272
7373 # Check if the file is already downloaded & the checksum is the same
74- dest_file=" ${dest} /${filename} "
74+ dest_file=${dest} /${filename}
7575 if [ -e " ${dest_file} " ]; then
76- existing_checksum=" $( checksum_file " ${dest_file} " ) "
76+ existing_checksum=$( checksum_file " ${dest_file} " )
7777 if [ " ${checksum} " = " ${existing_checksum} " ]; then
7878 # There is nothing we need to do here
7979 return
@@ -82,10 +82,10 @@ do_file() {
8282
8383 # Attempt up to 2 times
8484 retries=2
85- matching=" no "
85+ matching=no
8686 while [ " ${retries} " -gt 0 ]; do
8787 download_file " ${uri} " " ${dest} /${filename} "
88- my_checksum=" $( checksum_file " ${dest_file} " ) "
88+ my_checksum=$( checksum_file " ${dest_file} " )
8989 if [ " ${checksum} " = " ${my_checksum} " ]; then
9090 matching=" yes"
9191 break
@@ -105,28 +105,28 @@ do_file() {
105105 # Creating a tarball from a git repository
106106
107107 # Very unfortunately, different sites have different rules.
108- uri_path=" ${uri# git:// } "
108+ uri_path=${uri# git:// }
109109 # GitHub does not have git:// protocol support
110110 if echo " ${uri} " | grep -Eq " ^git://github.com" ; then
111- uri=" https://${uri_path} "
111+ uri=https://${uri_path}
112112 fi
113- repo=" ${uri% ~* } "
114- outdir=" ${state} /git/${repo#*:// } "
115- reference=" ${uri##* ~} "
113+ repo=${uri% ~* }
114+ outdir=${state} /git/${repo#*:// }
115+ reference=${uri##* ~}
116116
117- http_src=" ${2} "
118- checksum=" ${3} "
119- tarball=" ${4:- $(basename " ${http_src} " )} "
117+ http_src=${2}
118+ checksum=${3}
119+ tarball=${4:- $(basename " ${http_src} " )}
120120 if [ " ${tarball} " = " _" ]; then
121121 echo " ${uri} : ERROR! Must have tarball name if no http source."
122122 exit 1
123123 fi
124- tarball=" ${dest} /${tarball} "
124+ tarball=${dest} /${tarball}
125125
126126 # Check if tarball already generated + matches checksum
127- checksum=" ${3} "
127+ checksum=${3}
128128 if [ -e " ${tarball} " ]; then
129- existing_checksum=" $( checksum_file " ${tarball} " ) "
129+ existing_checksum=$( checksum_file " ${tarball} " )
130130 if [ " ${existing_checksum} " = " ${checksum} " ]; then
131131 return
132132 fi
@@ -151,13 +151,13 @@ do_file() {
151151 fi
152152
153153 # Generate the prefix for the tarball
154- prefix_ref=" ${reference} "
154+ prefix_ref=${reference}
155155 # All git repositories we already use remove "v"s from the beginning
156156 # of branch/tag names in the tarball prefix
157157 if echo " ${reference} " | grep -Eq " ^v[0-9]" ; then
158- prefix_ref=" $( echo " ${reference} " | sed " s/^v//" ) "
158+ prefix_ref=$( echo " ${reference} " | sed " s/^v//" )
159159 fi
160- prefix=" $( basename " ${repo} " | sed " s/.git$//" ) -${prefix_ref} "
160+ prefix=$( basename " ${repo} " | sed " s/.git$//" ) -${prefix_ref}
161161
162162 (
163163 cd " ${outdir} " || exit
@@ -168,7 +168,7 @@ do_file() {
168168 git archive " ${reference} " -o " ${tarball} " --prefix " ${prefix} /"
169169 )
170170
171- my_checksum=" $( sha256sum " ${tarball} " | cut -d' ' -f1) "
171+ my_checksum=$( sha256sum " ${tarball} " | cut -d' ' -f1)
172172 if [ " ${my_checksum} " != " ${checksum} " ]; then
173173 echo " ${uri} : generated tarball does not match checksum"
174174 exit 1
@@ -180,6 +180,6 @@ for src in steps/*/sources; do
180180 while read -r line; do
181181 # shellcheck disable=SC2086
182182 do_file ${line}
183- uri=" $( echo " ${line} " | cut -d' ' -f1) "
183+ uri=$( echo " ${line} " | cut -d' ' -f1)
184184 done < " ${src} "
185185done
0 commit comments