summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJustin Davis <jrcd83@gmail.com>2011-10-08 18:10:21 +0200
committerJustin Davis <jrcd83@gmail.com>2011-10-08 18:10:21 +0200
commit4ebca0d9394747a8fc6e2ddeb5e5c57a3f4492b5 (patch)
treee7a4ccdf6305a38f8b976bf054967be03adb78b0
parente8e5cef0627ba2db59d73e35cca2b6639d6e1f45 (diff)
downloadgenpkg-4ebca0d9394747a8fc6e2ddeb5e5c57a3f4492b5.tar.gz
genpkg-4ebca0d9394747a8fc6e2ddeb5e5c57a3f4492b5.tar.xz
Add forgotten feature: replace version string with ${pkgver} in source.
-rwxr-xr-xbin/makepkgmeta76
1 files changed, 59 insertions, 17 deletions
diff --git a/bin/makepkgmeta b/bin/makepkgmeta
index 9c0a6c5..152df74 100755
--- a/bin/makepkgmeta
+++ b/bin/makepkgmeta
@@ -1,34 +1,76 @@
#!/bin/sh
+prog=makepkgmeta
+
+lazysource()
+{
+ awk -v prog="$prog" '
+BEGIN { FS = "\n"; RS = ""; OFS = ORS = "\n\n" }
+$1 == "pkgver" { ver = $2 }
+$1 == "source" {
+ len = NF - 1
+ for (i = 2; i <= NF; i++) sources[i - 1] = $i
+ next
+}
+1 # print everything but sources
+
+END {
+ # remember that metas emit no output when they cant match
+ # a package.
+ if (NR == 0) exit 0
+
+ ORS="\n"
+ if (!ver) {
+ print prog ": wtf? pkgver is empty!" | "cat 1>&2"
+ exit 1
+ }
+
+ # Replace any version strings in the source file with ${pkgver}.
+ gsub(/[.]/, "\\\\&", ver)
+
+ print "source"
+ for(i = 1; i <= len; i++) {
+ gsub(ver, "${pkgver}", sources[i])
+ print sources[i]
+ }
+ print ""
+}'
+ return $?
+} # end of lazysource()
+
+basicmeta()
+{
+ printf "pkgname\n%s\n\n" "$1"
+ printf "pkgrel\n%d\n\n" "${PKGREL:-1}"
+ printf "packager\n%s\n\n" "${PACKAGER:-Anonymous}"
+
+ if [ "$MAINTAINER" ]
+ then
+ printf "maintainer\n%s\n\n" "$MAINTAINER"
+ fi
+}
+
case $# in
-0) echo "Usage: makepkgmeta [pkgname]" 1>&2
+0) echo "Usage: $prog [pkgname]" 1>&2
exit 1
esac
case "$METABIN" in
-'') echo "makepkgmeta: set METABIN before calling makepkgmeta" 1>&2
+'') echo "$prog: set METABIN before calling $prog" 1>&2
exit 2
esac
-printf "pkgname\n%s\n\n" "$1"
-printf "pkgrel\n%d\n\n" "${PKGREL:-1}"
-printf "packager\n%s\n\n" "${PACKAGER:-Anonymous}"
-
-if [ "$MAINTAINER" ]
-then
- printf "maintainer\n%s\n\n" "$MAINTAINER"
-fi
-
for flav in "$METABIN"/*
do
- [ -x "$flav" ] || continue
- PATH="$PATH:$flav.d" "$flav" $1
+ [ -f "$flav" -a -x "$flav" ] || continue
+ PATH="$PATH:$flav.d" "$flav" $1 | lazysource
metaret=$?
case $metaret in
- 0) exit 0 ;;
- 1) ;;
- 2) echo "error: $flav encountered an error"; exit 2 ;;
- *) echo "error: $flav returned error code $metaret"; exit 2 ;;
+ 0) basicmeta $1
+ exit 0 ;;
+ 1) ;; # loop
+ 2) echo "error: $flav encountered an error"; exit 2 ;;
+ *) echo "error: $flav returned error code $metaret"; exit 2 ;;
esac
done