summaryrefslogtreecommitdiffstats
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
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.
-rw-r--r--Makefile8
-rwxr-xr-xbin/makepkgbuild35
-rwxr-xr-xbin/templ/pbfields6
-rwxr-xr-xbin/templ/perl-pkg19
-rwxr-xr-xpushpkgs46
5 files changed, 71 insertions, 43 deletions
diff --git a/Makefile b/Makefile
index 068c845..762980f 100644
--- a/Makefile
+++ b/Makefile
@@ -3,12 +3,17 @@ PKGS = $(PWD)/pkg
BIN = $(PWD)/bin
PKGVAR = $(PWD)/var
-.PHONY: checkpkgarg package tweakmeta
+.PHONY: checkpkgarg package tweakmeta PKGBUILD
package: $(PKGS)/$(PKG)/PKGBUILD
# cd "$(PKGS)/$(PKG)"; makepkg --clean
+PKGBUILD: $(PKGS)/$(PKG)/PKGBUILD
+
$(PKGS)/$(PKG)/PKGBUILD: tweakmeta
+ @cd '$(PKGS)/$(PKG)'; \
+ TDIR='$(BIN)/templ' $(BIN)/makepkgbuild >PKGBUILD
+ @echo 'Built pkg/$(PKG)/PKGBUILD.'
tweakmeta: $(PKGS)/$(PKG)/PKGMETA
@if [ -r '$(TWEAKS)/$(PKG)' ]; \
@@ -17,6 +22,7 @@ tweakmeta: $(PKGS)/$(PKG)/PKGMETA
$(BIN)/tweakmeta >PKGMETA.new <'$(TWEAKS)/$(PKG)'; \
mv PKGMETA PKGMETA.old; \
mv PKGMETA.new PKGMETA; \
+ echo 'Tweaked PKGMETA with tweaks/$(PKG)'; \
fi
$(PKGS)/$(PKG)/PKGMETA: prepare
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";
diff --git a/pushpkgs b/pushpkgs
index ff00c11..3463c67 100755
--- a/pushpkgs
+++ b/pushpkgs
@@ -2,46 +2,46 @@
prependid()
{
- awk '!/^#/ && ! done { print "# $Id$"; done = 1 } 1' PKGBUILD \
- > PKGBUILD.new
- mv PKGBUILD.new PKGBUILD
+ awk '!/^#/ && ! done { print "# $Id$"; done = 1 } 1' PKGBUILD \
+ > PKGBUILD.new
+ mv PKGBUILD.new PKGBUILD
}
# Make sure that the package directories are added to the SVN repo.
syncsvn()
{
- svn add --parents PKGBUILD ../repos
- # Make sure that the Id keyword-property is active.
- svn propset svn:keywords Id PKGBUILD
+ svn add --parents PKGBUILD ../repos
+ # Make sure that the Id keyword-property is active.
+ svn propset svn:keywords Id PKGBUILD
}
if [ -z "$DEST" ] ; then
- echo "Specify the destination directory with the DEST env var." 1>&2
- exit 1
+ echo "Specify the destination directory with the DEST env var." 1>&2
+ exit 1
fi
cd pkg || exit 1
pkgdir=$(pwd)
while [ $# -gt 0 ] ; do
- pkg=$1 ; shift
- if [ ! -d "$pkg" ] ; then
- echo "pkg/$pkg was not found." 1>&2
- continue
- fi
+ pkg=$1 ; shift
+ if [ ! -d "$pkg" ] ; then
+ echo "pkg/$pkg was not found." 1>&2
+ continue
+ fi
- echo "$DEST/$pkg"
- if [ -d "$DEST/$pkg" ] ; then
- rm -rf "$DEST/$pkg/trunk/"*
- fi
+ echo "$DEST/$pkg"
+ if [ -d "$DEST/$pkg" ] ; then
+ rm -rf "$DEST/$pkg/trunk/"*
+ fi
- mkdir -p "$DEST/$pkg/"{trunk,repos}
- cp -r -t "$DEST/$pkg/trunk" "$pkg"/*
+ mkdir -p "$DEST/$pkg/"{trunk,repos}
+ cp -r -t "$DEST/$pkg/trunk" "$pkg"/*
- cd "$DEST/$pkg/trunk"
- prependid
- syncsvn >/dev/null 2>&1
+ cd "$DEST/$pkg/trunk"
+ prependid
+ syncsvn >/dev/null 2>&1
- cd "$pkgdir"
+ cd "$pkgdir"
done