From e3e92ddb466d04608a4d07e00dda435f9ccd31b1 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Tue, 8 Jan 2013 14:56:46 -0500 Subject: initial version of moz-normalize-PKGBUILD --- moz-normalize-PKGBUILD | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100755 moz-normalize-PKGBUILD 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" -- cgit v1.2.3-2-g168b