summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2013-01-08 14:56:46 -0500
committerLuke Shumaker <LukeShu@sbcglobal.net>2013-01-08 15:04:27 -0500
commite3e92ddb466d04608a4d07e00dda435f9ccd31b1 (patch)
treee4d57a74de87f874250904dbdccbe555474fca34
parent1e124f434caaf3a8725f3519d17ebb64bfcc9e0f (diff)
initial version of moz-normalize-PKGBUILD
-rwxr-xr-xmoz-normalize-PKGBUILD34
1 files changed, 34 insertions, 0 deletions
diff --git a/moz-normalize-PKGBUILD b/moz-normalize-PKGBUILD
new file mode 100755
index 0000000..54f15a7
--- /dev/null
+++ b/moz-normalize-PKGBUILD
@@ -0,0 +1,34 @@
+#!/bin/bash
+
+tempdir="$(mktemp -d --tmpdir mozilla-normalize.XXXXXXXXXXX)"
+
+cat > "$tempdir/PKGBUILD"
+for var in {make,check,}depends; do
+ # extract, normalize the data
+ {
+ sed -nr "
+ /^$var=\(/,/\)/{ # select the variable array
+ s/.*\(/ / # remove the opening 'var=(' bit
+ s/\).*// # remove the trailing ')' bit
+ s/\s+/\n /g # delimit array elements with '\n '
+ /./p # print array elements
+ }" \
+ | sed '/^\s*$/d' \
+ | sort -u
+ } < "$tempdir/PKGBUILD" > "$tempdir/$var"
+ # remove it from the file
+ sed -i -e "/^$var=(/i @$var@" -e "/^$var=/,/)/d" "$tempdir/PKGBUILD"
+ # re-insert it into the file
+ sed -i \
+ -e "/^@$var@/a$var=(" \
+ -e "/^@$var@/r$tempdir/$var" \
+ -e "/^@$var@/a)" \
+ -e "/^@$var@/d" \
+ "$tempdir/PKGBUILD"
+done
+
+# clean up whitespace
+sed -ri 's/\s+$//' "$tempdir/PKGBUILD"
+
+cat "$tempdir/PKGBUILD"
+rm -rf "$tempdir"