diff options
author | Justin Davis <jrcd83@gmail.com> | 2011-09-25 19:04:35 +0200 |
---|---|---|
committer | Justin Davis <jrcd83@gmail.com> | 2011-09-25 19:04:35 +0200 |
commit | 7ae0983d9d33b797401fc8114f7441ee4555a2e7 (patch) | |
tree | d2bcdecae6a79491931104dd21124fd8b50ab897 /bin | |
parent | 43630edb189894cac94ee035c78976701b12ee01 (diff) | |
download | genpkg-7ae0983d9d33b797401fc8114f7441ee4555a2e7.tar.gz genpkg-7ae0983d9d33b797401fc8114f7441ee4555a2e7.tar.xz |
Implement prepending to PKGBUILD functions.
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/makepkgbuild | 36 |
1 files changed, 30 insertions, 6 deletions
diff --git a/bin/makepkgbuild b/bin/makepkgbuild index 4655e89..f2469bf 100755 --- a/bin/makepkgbuild +++ b/bin/makepkgbuild @@ -5,18 +5,37 @@ prog=makepkgbuild appendpb() { txt=$(awk -v f=$1 'BEGIN { FS = "\n"; RS = "" } - $1 == f "()" { for (i = 2; i <= NF; i++) print $i }' PKGMETA \ - | sed 's/^/ /') + $1 ~ "^" f "[(][)]<?$" { for (i = 2; i <= NF; i++) print $i }' \ + PKGMETA | sed 's/^/ /') case "$txt" in '') return 0 ;; - *) echo '/^ *'"${func}"'()[ \\n]*{ + *) echo "/^ *${func}()[ \\n]*{ /^} i -'"$txt"' +$txt . wq -' | ed PKGBUILD >/dev/null 2>&1 +" | ed PKGBUILD >/dev/null 2>&1 + return $? ;; + esac +} + +prependpb() +{ + txt=$(awk -v f=$1 'BEGIN { FS = "\n"; RS = "" } + $1 == ">" f "()" { for (i = 2; i <= NF; i++) print $i }' \ + PKGMETA | sed 's/^/ /') + + case "$txt" in + '') return 0 ;; + *) echo "/^ *${func}()[ \\n]*{ +/^[ \t]*cd/ +a +$txt +. +wq +" | ed PKGBUILD >/dev/null 2>&1 return $? ;; esac } @@ -55,7 +74,12 @@ for func in package check build do if ! appendpb $func then - echo "$prog: failed to append to the ${func}() function in PKGBUILD" 1>&2 + echo "$prog: error when trying to append to ${func}()" 1>&2 + exit 2 + fi + if ! prependpb $func + then + echo "$prog: error when trying to prepend to ${func}()" 1>&2 exit 2 fi done |