I'd like to see support for split packages, too, maybe I'll add it some time. 
Using it locally, while improving my dwm patches.
Different approaches include playing around with $PATH, use absolute start 
paths for testing, but once I got used to this way, I just can't resist it any 
more... :)

cheers!
mar77i

---
 contrib/pkgdigest.sh |   39 +++++++++++++++++++++++++++++++++++++++
 1 files changed, 39 insertions(+), 0 deletions(-)
 create mode 100755 contrib/pkgdigest.sh

diff --git a/contrib/pkgdigest.sh b/contrib/pkgdigest.sh
new file mode 100755
index 0000000..278a838
--- /dev/null
+++ b/contrib/pkgdigest.sh
@@ -0,0 +1,39 @@
+#!/bin/bash
+
+if ! [[ -w PKGBUILD ]]; then
+       echo "Error: no PKGBUILD found." >&2
+       exit 1
+fi
+
+cp PKGBUILD PKGBUILD~
+i=0
+lines=()
+marker=
+contexts=0
+md5context=0
+while read -r; do
+       if [[ "$REPLY" =~ (build|check|package)(_.*)?\(\) ]]; then
+               (( ${#marker} )) || marker=$i
+       fi
+       # only ever replace one sum
+       [[ "${REPLY,,}" == "md5sums="* ]] && (( md5context=1, contexts+= 1 ))
+       if (( md5context && contexts < 2 )); then
+               # no one ever would do parameter expansion in md5sums
+               # comments however that contain parens are possible
+               [[ "$REPLY" =~ [^#]*\) ]] && md5context=0
+       else
+               lines+=("$REPLY") && (( i++ ))
+       fi
+done < PKGBUILD
+
+while [[ "${lines[marker - 1]}" == '' ]]; do
+       (( marker -= 1 ))
+done
+
+for (( i=0; i < marker; i++ )); do
+       echo "${lines[i]}"
+done > PKGBUILD
+echo "$(makepkg -g)" >> PKGBUILD
+for (( i=marker; i < ${#lines[@]}; i++ )); do
+       echo "${lines[i]}"
+done >> PKGBUILD
-- 
1.7.7.1


Reply via email to