-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPKGBUILD_sum_update.sh
36 lines (31 loc) · 1.1 KB
/
PKGBUILD_sum_update.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/bin/bash
PKGBUILD_FILE=./packaging/PKGBUILD
VERSION=0.4.1
SOURCE="https://github.com/Neurofibromin/bookmark-dlp/archive/refs/tags/${VERSION}.tar.gz"
TAR_FILE=./"${VERSION}.tar.gz"
if ! command -v b2sum 2>&1 >/dev/null
then
echo "b2sum not installed"
exit 1
fi
if ! command -v wget 2>&1 >/dev/null
then
echo "wget not installed"
exit 1
fi
# Validate the PKGBUILD file exists
if [ ! -f "$PKGBUILD_FILE" ]; then
echo "Error: File '$PKGBUILD_FILE' not found."
exit 1
fi
wget -O "$TAR_FILE" "$SOURCE"
# get b2sum of tar.gz:
# e.g. b2sum 0.4.1.tar.gz
# 5d6d98068b0a330f09144e916bcc99d2aac92ae83efe0fa19f2ea5065f299d8140242771c5d7755898ac720b86fbc42e8407eccbda811870671460b568f695fb 0.4.1.tar.gz
NEW_HASH=$(b2sum "$TAR_FILE" | awk '{print $1}')
rm $TAR_FILE
# Replace old hash in the PKGBUILD file
# e.g. old hash in PKGBUILD:
# b2sums=('e8407eccbda811870671460b568f695fb5d6d98068b0a330f09144e916bcc99d2aac92ae83efe0fa19f2ea5065f299d8140242771c5d7755898ac720b86fbc42')
sed -i -E "s#(b2sums=\()'.*'#\1'${NEW_HASH}'#" "$PKGBUILD_FILE"
echo "Hash updated to $NEW_HASH in $PKGBUILD_FILE."