From fc389a7c402e8fead2b7cd7c10f8bfbfb1bb340f Mon Sep 17 00:00:00 2001 From: Justin Davis Date: Sat, 12 Nov 2011 17:05:20 -0500 Subject: Remove profiling/timing code. --- lib/metas/perl.d/perl-dist | 3 --- 1 file changed, 3 deletions(-) diff --git a/lib/metas/perl.d/perl-dist b/lib/metas/perl.d/perl-dist index 57b468b..5f6bd4c 100755 --- a/lib/metas/perl.d/perl-dist +++ b/lib/metas/perl.d/perl-dist @@ -269,9 +269,6 @@ sub _distsofmods return () if(@mods == 0); - use Time::HiRes qw(time); - my $beg = time; - my $var = $ENV{'PKGVAR'} or die "$PROG: PKGVAR env variable is unset\n"; open(my $fh, '<', "$var/cpanmods") -- cgit v1.2.3-24-g4f1b From 5479ee241bff33345317e81d8b5917cdb73085e2 Mon Sep 17 00:00:00 2001 From: Justin Davis Date: Sun, 20 Nov 2011 10:07:05 -0500 Subject: Fix error messages and error codes. --- bin/genpkg | 16 +++++++++++----- bin/makepkgmeta | 18 +++++++----------- lib/metas/perl | 4 ++-- 3 files changed, 20 insertions(+), 18 deletions(-) diff --git a/bin/genpkg b/bin/genpkg index b475ac2..c933076 100755 --- a/bin/genpkg +++ b/bin/genpkg @@ -10,25 +10,25 @@ vard=~/var if [ $# -lt 1 ] then echo "usage: $prog [package name]" 1>&2 - exit 1 + exit 2 fi if ! [ -d "$tweakd" ] then echo "$prog: bad package tweaks dir: $tweakd" 1>&2 - exit 2 + exit 1 fi if ! [ -d "$pkgd" ] then echo "$prog: bad package dest dir: $pkgd" 1>&2 - exit 2 + exit 1 fi if ! [ -d "$vard" ] then echo "$prog: bad package var dir: $vard" 1>&2 - exit 2 + exit 1 fi cwd=$(pwd) @@ -40,12 +40,18 @@ do cd "$pkgd/$pkg" METABIN=$libd/metas PKGVAR=$vard makepkgmeta "$pkg" >PKGMETA + case $? in 1) rm PKGMETA ; exit 1 ;; esac + echo "Generated $pkgd/$pkg/PKGMETA" twk=$libd/tweakd/$pkg if [ -f "$twk" -a -r "$twk" ] then - tweakmeta >PKGMETA.new <$twk + if ! tweakmeta >PKGMETA.new <$twk + then + rm PKGMETA.new + exit 1 + fi mv PKGMETA.new PKGMETA echo "Tweaked PKGMETA with $tweakd/$pkg." fi diff --git a/bin/makepkgmeta b/bin/makepkgmeta index 476d576..b6dfcff 100755 --- a/bin/makepkgmeta +++ b/bin/makepkgmeta @@ -17,13 +17,9 @@ $1 == "source" { END { # remember that metas emit no output when they cant match # a package. - if (NR == 0) exit 0 + if (NR == 0 || !ver) exit 2 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) @@ -68,13 +64,13 @@ do case $metaret in 0) basicmeta $1 exit 0 ;; - 1) ;; # loop - 2) echo "error: $flav encountered an error" 1>&2 - exit 2 ;; - *) echo "error: $flav returned error code $metaret" 1>&2 - exit 2 ;; + 1) echo "makepkgmeta: $flav encountered an error" 1>&2 + exit 1 ;; + 2) ;; # loop + *) echo "makepkgmeta: $flav returned error code $metaret" 1>&2 + exit 1 ;; esac done -echo "error: no matching meta generator found for '$1'" 1>&2 +echo "makepkgmeta: no matching meta generator found for '$1'" 1>&2 exit 1 diff --git a/lib/metas/perl b/lib/metas/perl index ba2cfa1..df6fc9c 100755 --- a/lib/metas/perl +++ b/lib/metas/perl @@ -7,7 +7,7 @@ use File::Fetch; use IO::Handle; # for autoflush use Cwd; -my $PROG = 'perl'; +my $PROG = 'metas/perl'; sub err { @@ -73,7 +73,7 @@ sub main my ($realname, $cpath) = matchdist($dist); unless($realname){ print STDERR "$PROG: failed to find perl dist similar to $dist\n"; - exit 1; + return 2; } fetchdist($cpath); -- cgit v1.2.3-24-g4f1b From a36fce5c41553ae705d265813560a0823b9b6249 Mon Sep 17 00:00:00 2001 From: Justin Davis Date: Sun, 20 Nov 2011 10:08:21 -0500 Subject: Add special logic to avoid deps on core-only modules to perl-dist. --- lib/metas/perl.d/perl-dist | 57 +++++++++++++++++++++++++++++++-------------- lib/metas/perl.d/scrapecore | 2 +- 2 files changed, 40 insertions(+), 19 deletions(-) diff --git a/lib/metas/perl.d/perl-dist b/lib/metas/perl.d/perl-dist index 5f6bd4c..ee3f5ee 100755 --- a/lib/metas/perl.d/perl-dist +++ b/lib/metas/perl.d/perl-dist @@ -268,35 +268,33 @@ sub _distsofmods my (@mods) = @_; return () if(@mods == 0); + @mods = _nocore(@mods); - my $var = $ENV{'PKGVAR'} - or die "$PROG: PKGVAR env variable is unset\n"; + my $var = _vardir(); open(my $fh, '<', "$var/cpanmods") or die "$PROG: failed to open $var/cpanmods: $!"; - my (@hunted, %dists) = @mods; + my %mods = map { ($_ => 1) } @mods; + my %dists; local $/ = ''; RECLOOP: while(my $rec = <$fh>) { - my ($dist, @modvers) = split(/\n/, $rec); - for (@modvers) { - my ($m) = split; - - CMPLOOP: - for my $i (0 .. $#hunted) { - next CMPLOOP unless($hunted[$i] eq $m); - $dists{$m} = $dist; - splice @hunted, $i, 1; - last RECLOOP if(@hunted == 0); - last CMPLOOP; - } + last RECLOOP unless(keys %mods > 0); + + my($dist, @mvs) = split(/\n/, $rec); + MODLOOP: + for(@mvs){ + my($m) = split; + my $fnd = delete($mods{$m}) or next; + $dists{$m} = $dist; } } - if (@hunted) { - for my $lost (@hunted) { - print STDERR "$PROG: failed to find module $lost\n"; + my @lost = keys %mods; + if(@lost){ + for my $m (@lost){ + print STDERR "$PROG: failed to find module $m\n"; } exit 2; } @@ -304,6 +302,29 @@ sub _distsofmods return %dists; } +sub _nocore +{ + my (@mods) = @_; + + my $path = _vardir() . '/coremods'; + open(my $if, '<', $path) or die "$PROG: open $path: $!"; + + my %mods = map { ($_ => 1) } @mods; + while(<$if>){ + my ($m) = split; + delete $mods{$m}; + } + + close($if); + return keys %mods; +} + +sub _vardir +{ + return $ENV{'PKGVAR'} + or die "$PROG: PKGVAR env variable is unset\n"; +} + #----------------------------------------------------------------------------- package main; diff --git a/lib/metas/perl.d/scrapecore b/lib/metas/perl.d/scrapecore index eae1b21..19cce80 100644 --- a/lib/metas/perl.d/scrapecore +++ b/lib/metas/perl.d/scrapecore @@ -205,7 +205,7 @@ sub _delmatch sub coreonly { - my (%mods) = map { @$_ } @_; + my %mods = map { @$_ } @_; my $path = "$ENV{'PKGVAR'}/cpanmods"; open(my $if, '<', $path) or die("open $path: $!"); -- cgit v1.2.3-24-g4f1b From 56b249308eba7e641fb84c45b08b290133e1d783 Mon Sep 17 00:00:00 2001 From: Justin Davis Date: Sun, 20 Nov 2011 11:56:08 -0500 Subject: More fine-tuning of errors and messages. Cleanup package dirs when meta building fails, in genpkg. --- bin/genpkg | 8 ++++++-- bin/makepkgmeta | 4 +++- lib/metas/perl | 16 ++++++++++++---- lib/metas/perl.d/perl-dist | 2 +- 4 files changed, 22 insertions(+), 8 deletions(-) diff --git a/bin/genpkg b/bin/genpkg index c933076..afd1f49 100755 --- a/bin/genpkg +++ b/bin/genpkg @@ -32,7 +32,6 @@ then fi cwd=$(pwd) -set -e for pkg do @@ -40,7 +39,12 @@ do cd "$pkgd/$pkg" METABIN=$libd/metas PKGVAR=$vard makepkgmeta "$pkg" >PKGMETA - case $? in 1) rm PKGMETA ; exit 1 ;; esac + case $? in + 1) cd .. + rm -r "$pkgd/$pkg" + echo "$prog: aborting." 1>&2 + exit 1 + esac echo "Generated $pkgd/$pkg/PKGMETA" diff --git a/bin/makepkgmeta b/bin/makepkgmeta index b6dfcff..82a7b1f 100755 --- a/bin/makepkgmeta +++ b/bin/makepkgmeta @@ -59,10 +59,12 @@ esac for flav in "$METABIN"/* do [ -f "$flav" -a -x "$flav" ] || continue - PATH="$PATH:$flav.d" "$flav" $1 | lazysource + PATH="$PATH:$flav.d" "$flav" $1 >PKGMETA.tmp metaret=$? case $metaret in 0) basicmeta $1 + lazysource &2 exit 1 ;; diff --git a/lib/metas/perl b/lib/metas/perl index df6fc9c..4d310a6 100755 --- a/lib/metas/perl +++ b/lib/metas/perl @@ -24,7 +24,7 @@ sub matchdist or err("$PROG: PKGVAR env variable is unset\n"); if(!-f "$var/cpandists" || -M "$var/cpandists" > 1) { - print STDERR "Refreshing local CPAN distribution list..."; + print STDERR "$PROG: Refreshing local CPAN data..."; my $cwd = getcwd(); chdir($var) or die "chdir: $!"; system('fetchcpan'); @@ -36,7 +36,8 @@ sub matchdist open(DISTS, '<', "$var/cpandists") or err("$PROG: open: $!"); while() { my @f = split; - next unless(lc($f[0]) eq lc($dist)); + my $d = lc $f[0]; $d =~ tr/-_/--/s; + next unless($d eq lc($dist)); close(DISTS); return ($f[0], $f[2]); } @@ -67,12 +68,19 @@ sub main my $pkg = shift or die "Usage: $PROG [package name]\n"; my $dist = $pkg; - $dist = "app-$dist" if($dist =~ s/^perl-// == 0); + my $forcechk; + if($dist =~ s/^perl-// == 0){ + $forcechk = 1; + $dist = "app-$dist"; + } STDERR->autoflush(1); my ($realname, $cpath) = matchdist($dist); unless($realname){ - print STDERR "$PROG: failed to find perl dist similar to $dist\n"; + unless($forcechk){ + ## Don't print errors unless perl- package was requested. + print STDERR qq{$PROG: failed to find perl dist similar to '$dist'\n}; + } return 2; } fetchdist($cpath); diff --git a/lib/metas/perl.d/perl-dist b/lib/metas/perl.d/perl-dist index ee3f5ee..36a7b60 100755 --- a/lib/metas/perl.d/perl-dist +++ b/lib/metas/perl.d/perl-dist @@ -296,7 +296,7 @@ sub _distsofmods for my $m (@lost){ print STDERR "$PROG: failed to find module $m\n"; } - exit 2; + exit 1; } return %dists; -- cgit v1.2.3-24-g4f1b From 65f503976340ea03c030b26af8691e2f373f1377 Mon Sep 17 00:00:00 2001 From: Justin Davis Date: Sun, 20 Nov 2011 11:56:53 -0500 Subject: Default to ~/var for var path. Always print Config mod which has no .pm file. --- lib/metas/perl.d/scrapecore | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) mode change 100644 => 100755 lib/metas/perl.d/scrapecore diff --git a/lib/metas/perl.d/scrapecore b/lib/metas/perl.d/scrapecore old mode 100644 new mode 100755 index 19cce80..2e1aba3 --- a/lib/metas/perl.d/scrapecore +++ b/lib/metas/perl.d/scrapecore @@ -206,7 +206,8 @@ sub _delmatch sub coreonly { my %mods = map { @$_ } @_; - my $path = "$ENV{'PKGVAR'}/cpanmods"; + my $var = $ENV{'PKGVAR'} || "$ENV{'HOME'}/var"; + my $path = "$var/cpanmods"; open(my $if, '<', $path) or die("open $path: $!"); my @dists; @@ -233,5 +234,8 @@ my @mods = (CoreDist::findmods($perldir), CoreLib::findmods($perldir)); +## Embedded modules without any files... +push @mods, [qw/ Config 1/]; + @mods = coreonly(@mods); for my $mv (@mods){ print "@$mv\n"; } -- cgit v1.2.3-24-g4f1b