diff options
-rwxr-xr-x | moz-normalize-PKGBUILD | 34 |
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" |