-
Notifications
You must be signed in to change notification settings - Fork 166
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This script will take an environment variable (NODE_VERSION) and download all of the files from `http://nodejs.org/dist/v<NODE_VERSION>/` It will then loop through the `SHASUMS256.txt` file to check if the SHA256SUMS match up. Initial issue here: #513
- Loading branch information
George Adams
committed
Jul 19, 2017
1 parent
5aea8f0
commit ba6a9c6
Showing
1 changed file
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#!/bin/bash | ||
|
||
while [[ $# -gt 1 ]] | ||
do | ||
key="$1" | ||
|
||
case $key in | ||
-t|--tap) | ||
TAP="$2" | ||
shift # past argument | ||
;; | ||
*) # unknown option | ||
;; | ||
esac | ||
shift # past argument or value | ||
done | ||
|
||
if [ -z ${NODE_VERSION} ]; then | ||
echo "NODE_VERSION is undefined! Please declare NODE_VERSION" | ||
exit 1 | ||
fi | ||
# Remove old files | ||
[ ! -z ${TAP} ]; rm -r ${TAP} || true | ||
#rm -r nodejs.org || true | ||
|
||
# Scrape the download server | ||
#wget -r --no-parent http://nodejs.org/dist/v${NODE_VERSION}/ | ||
|
||
num=1 | ||
cat nodejs.org/dist/v${NODE_VERSION}/SHASUMS256.txt | { while read line | ||
do | ||
sha=$(echo "${line}" | awk '{print $1}') | ||
file=$(echo "${line}" | awk '{print $2}') | ||
echo "Checking shasum for $file" | ||
remoteSHA=$(shasum -a 256 "nodejs.org/dist/v${NODE_VERSION}/${file}" | awk '{print $1}') | ||
if [ ${remoteSHA} != ${sha} ]; then | ||
echo "Error - SHASUMS256 does not match for ${file}" | ||
echo "Expected - ${sha}" | ||
echo "Found - ${remoteSHA}" | ||
[ ! -z ${TAP} ]; echo "not ok ${num} SHASUMS256 does not match for ${file}" >> ${TAP} | ||
return 1 | ||
else | ||
echo "Pass - SHASUMS256 for ${file} is correct" | ||
[ ! -z ${TAP} ]; echo "ok ${num} SHASUMS256 for ${file} is correct" >> ${TAP} | ||
fi | ||
let num++ | ||
done | ||
let num-- | ||
[ ! -z ${TAP} ]; echo "1..${num}" >> ${TAP} | ||
} |