-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
53 additions
and
7 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
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
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
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
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,31 @@ | ||
#!/bin/bash | ||
# Unzips the given zip file, then generates a checksum of the zip file that ignores | ||
# the timestamps by extracting it and SHA'ing a file of all SHAs. This is not recursive:- | ||
# zips within the zip will not be extracted, and therefore the timestamps of the "inner" zip | ||
# will be a part of the hash. | ||
# Usage: ./sha-of-zip.sh <zipFilepath> <OS: Windows, MacOS, or Linux> <sha version: 1, 256, or 512> | ||
set -e | ||
|
||
zipFilepath=$1 | ||
os=$2 | ||
a=$3 | ||
|
||
parentPath=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P ) | ||
|
||
# Make a temporary directory to extract zip, and a temporary file to hold SHAs | ||
tempDirectory=$(mktemp -d) | ||
tempAllChecksumsFile=$(mktemp) | ||
touch $tempAllChecksumsFile | ||
|
||
# Extract the zip | ||
unzip -q $zipFilepath -d $tempDirectory 2>/dev/null | ||
|
||
# Get a checksum for each file in the zip | ||
cd $tempDirectory | ||
for filename in $(find * -type f | sort); do | ||
checksum=$($parentPath/sha.sh $filename $os $a) | ||
echo $checksum >> $tempAllChecksumsFile | ||
done | ||
|
||
# Echo the checksum of the checksums | ||
echo $($parentPath/sha.sh $tempAllChecksumsFile $os $a) |
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
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