Skip to content

Commit

Permalink
Update Checkgit.sh
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
orien3243 committed Jul 11, 2016
1 parent 521b71f commit 2c116da
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions SparkleShare/Mac/checkGit.sh
Expand Up @@ -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
Expand All @@ -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

0 comments on commit 2c116da

Please sign in to comment.