From 6a64f1e970411510c51165da83fdece602649f1c Mon Sep 17 00:00:00 2001 From: Justin Davis Date: Tue, 17 Jan 2012 11:30:28 -0500 Subject: Better error check/report in genpkg and perl-dist. metas/perl was not returning the right error. metas/perl.d/perl-dist now reports a better error when ~/.genpkg/var/corelist is missing. genpkg was also not examining the right error code. --- bin/makepkgbuild | 71 -------------------------------------------------- bin/mkpkgbuild | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++ bin/mkpkgdata | 14 +++++----- metas/perl | 2 +- metas/perl.d/perl-dist | 11 +++++++- 5 files changed, 88 insertions(+), 81 deletions(-) delete mode 100755 bin/makepkgbuild create mode 100755 bin/mkpkgbuild diff --git a/bin/makepkgbuild b/bin/makepkgbuild deleted file mode 100755 index 67077fc..0000000 --- a/bin/makepkgbuild +++ /dev/null @@ -1,71 +0,0 @@ -#!/bin/sh - -prog=makepkgbuild - -die() -{ - rc=$1; shift - echo "$prog: $*" 1>&2 - exit $rc -} - -editpb() -{ - op=$1 func=$2 - - case "$op" in - append) - regexp="^${func}[(][)]${func}()" - edin="/^ *$func() *{ -/^[ \t]*cd/ -a" ;; - *) die 1 "unknown editpb operation: $op" - esac - - txt=$(awk -v r="$regexp" 'BEGIN { FS = "\n"; RS = "" } - $1 ~ r { for (i = 2; i <= NF; i++) print $i }' PKGDATA |\ - sed 's/^/ /') - [ "$txt" ] || return 0 - - cat << END | ed -s PKGBUILD >/dev/null -$edin -$txt -. -wq -END - return $? -} - -[ -r PKGDATA ] || die 1 "PKGDATA could not be read." - -[ "$TDIR" ] || die 1 "TDIR env. var is unset." -[ -d "$TDIR" ] || die 1 "template dir ($TDIR) not found." - -tcmd=$(awk 'BEGIN { FS="\n"; RS="" } $1 == "template" { print $2 }' PKGDATA) -[ "$tcmd" ] || die 1 "PKGDATA is missing 'template' entry." - -set -- $tcmd -cmd="$TDIR/$1" -[ -f "$cmd" -a -x "$cmd" ] \ - || die 2 "template command ($1) not in template dir ($TDIR)" - -# Generate the PKGBUILD using basic pbfields script plus custom template. -"$TDIR/pbfields" < PKGDATA > PKGBUILD || die 1 "pbfields returned error ${?}." -"$TDIR"/$tcmd < PKGDATA >> PKGBUILD || die 1 "template pipeline ($tcmd) failed" - -# Prepand/append text to the package, check, or build functions. -for func in package check build -do - for op in append prepend - do - editpb $op $func \ - || die 2 "error $? when trying to $op to ${func}()" - done -done - -exit 0 diff --git a/bin/mkpkgbuild b/bin/mkpkgbuild new file mode 100755 index 0000000..67077fc --- /dev/null +++ b/bin/mkpkgbuild @@ -0,0 +1,71 @@ +#!/bin/sh + +prog=makepkgbuild + +die() +{ + rc=$1; shift + echo "$prog: $*" 1>&2 + exit $rc +} + +editpb() +{ + op=$1 func=$2 + + case "$op" in + append) + regexp="^${func}[(][)]${func}()" + edin="/^ *$func() *{ +/^[ \t]*cd/ +a" ;; + *) die 1 "unknown editpb operation: $op" + esac + + txt=$(awk -v r="$regexp" 'BEGIN { FS = "\n"; RS = "" } + $1 ~ r { for (i = 2; i <= NF; i++) print $i }' PKGDATA |\ + sed 's/^/ /') + [ "$txt" ] || return 0 + + cat << END | ed -s PKGBUILD >/dev/null +$edin +$txt +. +wq +END + return $? +} + +[ -r PKGDATA ] || die 1 "PKGDATA could not be read." + +[ "$TDIR" ] || die 1 "TDIR env. var is unset." +[ -d "$TDIR" ] || die 1 "template dir ($TDIR) not found." + +tcmd=$(awk 'BEGIN { FS="\n"; RS="" } $1 == "template" { print $2 }' PKGDATA) +[ "$tcmd" ] || die 1 "PKGDATA is missing 'template' entry." + +set -- $tcmd +cmd="$TDIR/$1" +[ -f "$cmd" -a -x "$cmd" ] \ + || die 2 "template command ($1) not in template dir ($TDIR)" + +# Generate the PKGBUILD using basic pbfields script plus custom template. +"$TDIR/pbfields" < PKGDATA > PKGBUILD || die 1 "pbfields returned error ${?}." +"$TDIR"/$tcmd < PKGDATA >> PKGBUILD || die 1 "template pipeline ($tcmd) failed" + +# Prepand/append text to the package, check, or build functions. +for func in package check build +do + for op in append prepend + do + editpb $op $func \ + || die 2 "error $? when trying to $op to ${func}()" + done +done + +exit 0 diff --git a/bin/mkpkgdata b/bin/mkpkgdata index ced31db..f330894 100755 --- a/bin/mkpkgdata +++ b/bin/mkpkgdata @@ -60,20 +60,18 @@ tmp="/tmp/$prog.$$" for flav in "$METABIN"/* do [ -f "$flav" -a -x "$flav" ] || continue - PATH="$PATH:$flav.d" "$flav" "$1" > "$tmp" trap 'rm "$tmp"' 1 2 15 + PATH="$PATH:$flav.d" "$flav" "$1" > "$tmp" metaret=$? - if [ "$metaret" -eq 0 ] - then - basicmeta "$1" + case "$metaret" in + 0) basicmeta "$1" lazysource < "$tmp" - rm "$tmp" - exit 0 - fi + esac rm "$tmp" trap '' 1 2 5 - case $metaret in + case "$metaret" in + 0) exit 0 ;; 1) echo "$prog: $flav encountered an error" 1>&2 exit 1 ;; 2) ;; # loop diff --git a/metas/perl b/metas/perl index 4b61175..23f4907 100755 --- a/metas/perl +++ b/metas/perl @@ -100,7 +100,7 @@ END_META my $file = $cpath; $file =~ s{.*/}{}; system 'perl-dist' => $file; - return $?; + return $? >> 8; } exit main(@ARGV); diff --git a/metas/perl.d/perl-dist b/metas/perl.d/perl-dist index 3259fd8..297d052 100755 --- a/metas/perl.d/perl-dist +++ b/metas/perl.d/perl-dist @@ -3,7 +3,7 @@ use warnings 'FATAL' => 'all'; use strict; -my $PROG = 'perl-dist'; +my $PROG = 'metas/perl.d/perl-dist'; package Convert; @@ -312,6 +312,15 @@ sub _nocore my (@mods) = @_; my $path = _vardir() . '/coremods'; + unless(-f $path){ + print STDERR "$PROG: error: $path is missing. +****************************************************************************** + You must generate it with genpkg's metas/perl.d/scrapecore script. Run it + against the source distribution of perl that is currently being packaged. +****************************************************************************** +"; + exit 1; + } open(my $if, '<', $path) or die "$PROG: open $path: $!"; my %mods = map { ($_ => 1) } @mods; -- cgit v1.2.3-24-g4f1b