Make shasum independend from folder name

This commit is contained in:
Mario Hüttel 2022-07-30 12:29:12 +02:00
parent 241b943997
commit e5ded67a81
2 changed files with 6 additions and 2 deletions

View File

@ -6,7 +6,7 @@ arch=('i686' 'x86_64' 'arm')
pkgdesc="Script to calculate a sha256sum over an entire directory" pkgdesc="Script to calculate a sha256sum over an entire directory"
depends=('coreutils') depends=('coreutils')
provides=('dirsha256sum') provides=('dirsha256sum')
pkgver=bb2839e pkgver=1.0.0.r0.g241b943
pkgver () { pkgver () {
cd "$pkgname" cd "$pkgname"
git describe --long --always --tags | sed 's/^v//' | sed 's/\([^-]*-g\)/r\1/;s/-/./g' git describe --long --always --tags | sed 's/^v//' | sed 's/\([^-]*-g\)/r\1/;s/-/./g'

View File

@ -2,6 +2,9 @@
# This script calculates a sha256sum over all files in a dirextory including its subdirectories # This script calculates a sha256sum over all files in a dirextory including its subdirectories
# Length of the sha256 hash. Adapt when changing hash algorithm
hashlen=64
if [[ -z $1 ]]; then if [[ -z $1 ]]; then
echo "Usage: $0 <path to folder>" echo "Usage: $0 <path to folder>"
exit -1 exit -1
@ -23,7 +26,8 @@ echo "Found ${#filelist[@]} files"
# Calculate shasums over all files # Calculate shasums over all files
shasum=`for file in "${filelist[@]}"; do shasum=`for file in "${filelist[@]}"; do
sha256sum "$file" sha256sum "$file" | head -c $hashlen
echo ""
done | sha256sum | sed 's/\s-//'` done | sha256sum | sed 's/\s-//'`
echo "$shasum" echo "$shasum"