summarylogtreecommitdiffstats
path: root/pre-commit.sh
diff options
context:
space:
mode:
Diffstat (limited to 'pre-commit.sh')
-rwxr-xr-xpre-commit.sh24
1 files changed, 18 insertions, 6 deletions
diff --git a/pre-commit.sh b/pre-commit.sh
index 2663b34cdba0..56706677ce22 100755
--- a/pre-commit.sh
+++ b/pre-commit.sh
@@ -1,17 +1,18 @@
-#!/bin/bash
+#!/usr/bin/env bash
# git pre-commit hook:
-# - Generate the sha256sums in the PKGBUILD file and add it to the commit if needed
+# - Generate the checksums in the PKGBUILD file and add it to the commit if needed
# - Generate the .SRCINFO file and add it to the commit if needed
+# - Validate the PKGBUILD file
-# Generate the sha256sums in the PKGBUILD file
+# Generate the checksums in the PKGBUILD file
updpkgsums
# Remove the archive downloaded by updpkgsums
rm *.tar.gz
-# Check if the sha256sums in the PKGBUILD file changed
-if [ -n "$(git diff PKGBUILD | grep '^+sha256sums=(.*)$')" ]; then
- printf "Updated the sha256sums in the PKGBUILD file\n"
+# Check if the checksums in the PKGBUILD file changed
+if [ -n "$(git diff PKGBUILD | grep '^+md5sums')" ]; then
+ printf "Updated the checksums in the PKGBUILD file\n"
git add PKGBUILD
printf "Added the PKGBUILD file to the commit\n"
fi
@@ -25,3 +26,14 @@ if [ -n "$(git status --short | grep ' .SRCINFO$')" ]; then
git add .SRCINFO
printf "Added the .SRCINFO file to the commit\n"
fi
+
+# Validate the PKGBUILD file by "making" it
+makepkg
+
+# Check if the package was successfully built
+if [ $? -eq 0 ]; then
+ printf "The package was successfully built\n"
+fi
+
+# Remove directories and files created/downloaded by makepkg
+rm --force --recursive pkg src *.pkg.tar.xz *.tar.gz