summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorJustin Davis <jrcd83@gmail.com>2011-09-21 23:18:58 +0200
committerJustin Davis <jrcd83@gmail.com>2011-09-21 23:18:58 +0200
commitd4ad6bae77cfd68d4ac79471ee6f977621fb9b31 (patch)
treefaa5ccc3d3c01efc94a93691df7fc2a3517c29c9 /bin
parentc3f405c8f1af4a06661584e12f8449e86389a772 (diff)
downloadgenpkg-d4ad6bae77cfd68d4ac79471ee6f977621fb9b31.tar.gz
genpkg-d4ad6bae77cfd68d4ac79471ee6f977621fb9b31.tar.xz
Refinish PKGBUILD generation.
Adds makepkgbuild script. The call to pbfields is moved from perl-pkg to makepkgbuild. pbfields prints the PKGBUILD header now, too. makepkgbuild is called from the Makefile with the proper env var set. Pretty close to 100% working again.
Diffstat (limited to 'bin')
-rwxr-xr-xbin/makepkgbuild35
-rwxr-xr-xbin/templ/pbfields6
-rwxr-xr-xbin/templ/perl-pkg19
3 files changed, 41 insertions, 19 deletions
diff --git a/bin/makepkgbuild b/bin/makepkgbuild
new file mode 100755
index 0000000..9ecfb80
--- /dev/null
+++ b/bin/makepkgbuild
@@ -0,0 +1,35 @@
+#!/bin/sh
+
+prog=makepkgbuild
+
+if ! [ -f PKGMETA ]
+then
+ echo "$prog: PKGMETA could not be read." 1>&2
+ exit 1
+fi
+
+case "$TDIR" in
+'') echo "$prog: TDIR env variable is not set." 1>&2
+ exit 1
+esac
+
+tcmd=$(awk '
+ BEGIN { FS = "\n"; RS = "" }
+ $1 == "template" { for (i = 2; i <= NF; i++) print $i }' PKGMETA | \
+ while read line
+ do
+ set -- $line
+ cmd="$TDIR/$1"
+ if ! [ -x $cmd ]
+ then
+ echo "$prog: Unknown template command: $cmd" \
+ 1>&2
+ exit 2
+ fi
+ echo "$TDIR/$*"
+ done | tr '\n' '|' | sed 's/\|$//')
+
+echo "\$tcmd = $tcmd" 1>&2
+"$TDIR/pbfields" <PKGMETA >PKGBUILD
+$tcmd <PKGMETA >>PKGBUILD
+
diff --git a/bin/templ/pbfields b/bin/templ/pbfields
index 4bbfdfc..980dc7a 100755
--- a/bin/templ/pbfields
+++ b/bin/templ/pbfields
@@ -19,6 +19,8 @@ BEGIN {
NF < 2 { next }
+$1 ~ "packager" { packager = $2 }
+
$1 ~ /depends$|conflicts|provides|source/ { quotevals() }
$1 == "pkgdesc" {
@@ -33,6 +35,10 @@ arrfield[$1] {
}
END {
+ if (!packager) { packager = "Anonymous" }
+ print "# Maintainer: " packager
+ print ""
+
OFS = "="; ORS = "\n";
for (i=1; i<=max; i++) {
name = fields[i]
diff --git a/bin/templ/perl-pkg b/bin/templ/perl-pkg
index b008cbd..790a798 100755
--- a/bin/templ/perl-pkg
+++ b/bin/templ/perl-pkg
@@ -16,11 +16,6 @@ my %ACTIONS_OF = ('MM',
'package' => [ q{./Build install} ]
} );
-my $PBBEG = <<'END_BEG';
-# Maintainer : %s
-# Generator : pbjam %s
-END_BEG
-
my %FUNCFMTS;
$FUNCFMTS{'build'} = <<'END_FMT';
build() {
@@ -91,20 +86,6 @@ sub printpb
my $acts = $ACTIONS_OF{$btype}
or die "$0: unknown build type ($btype)\n";
- my $pkger = $pbvars->{'packager'}[0] || 'Anonymous';
- printf $PBBEG, $pkger, $pbvars->{'pbjver'}[0];
- print "\n";
-
- # 'pbfields' will recognize and PKGBUILD fields in the data
- # and print them out in order, wordwrapping arrays.
- open my $pbfields, '|pbfields' or die "failed to pipe to pbfields: $!";
- while (my ($name, $vals) = each %$pbvars) {
- print $pbfields $name, "\n";
- print $pbfields $_, "\n" for @$vals;
- print $pbfields "\n";
- }
- close $pbfields;
-
my $distdir = $pbvars->{'distdir'}[0];
print qq{_distdir="\${srcdir}/$distdir"\n};
print "\n";