summarylogtreecommitdiffstats
path: root/update-sha.sh
blob: da9ab6ee1cc6233c02ed3252c33093a5f62dcfc7 (plain)
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
#!/usr/bin/env bash

main() {
	local file url pkgrel

	file="duo-desktop-latest.x86_64.rpm"
	url="https://desktop.pkg.duosecurity.com/${file}"

	wget -cO "${file}" "${url}"

	sum=$(sha512sum "${file}" | cut -d' ' -f1)
	old_sum=$(grep sha512sums PKGBUILD | cut -d= -f2 | sed -e 's/['\''"( )]//g')

	if [[ "${sum}" == "${old_sum}" ]]; then
		echo "File has not changed. Exiting..."
		exit 0
	fi

	old_pkgrel=$(grep pkgrel PKGBUILD | cut -d= -f2)
	pkgrel=$((old_pkgrel + 1))

	sed -i "s|sha512sums=('.*')|sha512sums=('${sum}')|" PKGBUILD
	sed -i "s|pkgrel=${old_pkgrel}|pkgrel=${pkgrel}|" PKGBUILD

	echo "Updated PKGBUILD with new checksum and incremented pkgrel to ${pkgrel}."
}

main "$@"