Update Checkgit.sh
I did a rough sketch of how this would work. Please consider changing revising where appropriate. - What does this change do? Basic checking of sha256 of a file. My change calculates the hash of the file it downloads and also downloads a list of hashes, we then compare the first 64 characters, the hash, that the pc calculates to the hash it downloaded. Should there be a mismatch or if a file fails to download, the script will exit 1. Please change as you feel necessary. *ps. I'm not sure if the script should eval the hashes right before it compares them or if the way I evaluate the variables is ok. Also I did not use grep as I have been told it was bad.
This commit is contained in:
parent
9979455652
commit
bfaf99afeb
|
@ -20,9 +20,19 @@ set -e
|
|||
|
||||
if [ ! -f ${projectFolder}/git-${gitVersion}.tar.gz ]
|
||||
then
|
||||
curl -s https://codeload.github.com/git/git/zip/v${gitVersion} > git.zip
|
||||
unzip -q git.zip
|
||||
|
||||
list_hash=$(sed -n -e "/git-${gitVersion}.tar.gz/p" sha256sums.asc | cut -c 1-64)
|
||||
file_hash=$(shasum -a 256 git.tar.gz | cut -c 1-64)
|
||||
|
||||
curl -s https://www.kernel.org/pub/software/scm/git/git-${gitVersion}.tar.gz > git.tar.gz
|
||||
curl -s https://www.kernel.org/pub/software/scm/git/sha256sums.asc > sha256sums.asc
|
||||
|
||||
test -e git.tar.gz || {echo "Failed to download git"; exit 1}
|
||||
test -e sha256sums.asc || {echo "Failed to download hash list"; exit 1}
|
||||
|
||||
test "$file_hash" = "$list_hash" || {echo "SHA256 Mistmatch" ;exit 1}
|
||||
|
||||
tar xf git.tar.gz
|
||||
cd git-${gitVersion}
|
||||
|
||||
make configure
|
||||
|
@ -33,5 +43,5 @@ then
|
|||
tar cfz git-${gitVersion}.tar.gz git
|
||||
rm -rf git
|
||||
rm -rf git-${gitVersion}
|
||||
rm git.zip
|
||||
rm git.tar.gz
|
||||
fi
|
||||
|
|
Loading…
Reference in a new issue