summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJustin Davis <jrcd83@gmail.com>2012-01-07 18:58:18 +0100
committerJustin Davis <jrcd83@gmail.com>2012-01-07 18:58:18 +0100
commit0fd17fd113f7e6ac696b574c7929444cfb88b52d (patch)
treeb9c24672f5d7c6dd6cbea236e35c3eee25e40759
parent23b61cc4ac925c0139c3456c4672dc2d306af7fe (diff)
parent65f503976340ea03c030b26af8691e2f373f1377 (diff)
downloadgenpkg-0fd17fd113f7e6ac696b574c7929444cfb88b52d.tar.gz
genpkg-0fd17fd113f7e6ac696b574c7929444cfb88b52d.tar.xz
Merge changed from other puter.
Fix return value snafus, etc.
-rwxr-xr-xbin/genpkg23
-rwxr-xr-xbin/makepkgmeta22
-rwxr-xr-xlib/metas/perl12
-rwxr-xr-xlib/metas/perl.d/perl-dist59
-rwxr-xr-xlib/metas/perl.d/scrapecore8
5 files changed, 77 insertions, 47 deletions
diff --git a/bin/genpkg b/bin/genpkg
index 904de8c..e17b984 100755
--- a/bin/genpkg
+++ b/bin/genpkg
@@ -10,29 +10,28 @@ 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)
-set -e
for pkg
do
@@ -40,15 +39,19 @@ do
cd "$pkgd/$pkg"
METABIN=$libd/metas PKGVAR=$vard makepkgmeta "$pkg" >PKGMETA
- case $? in
- 0) echo "Generated $pkgd/$pkg/PKGMETA" ;;
- *) exit $?
- esac
+ case $? in
+ 0) echo "Generated $pkgd/$pkg/PKGMETA" ;;
+ *) exit $?
+ esac
twk=$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..82a7b1f 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)
@@ -63,18 +59,20 @@ 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 <PKGMETA.tmp
+ rm PKGMETA.tmp
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 adb3b08..961084d 100755
--- a/lib/metas/perl
+++ b/lib/metas/perl
@@ -25,7 +25,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');
@@ -37,7 +37,8 @@ sub matchdist
open(DISTS, '<', "$var/cpandists") or err("$PROG: open: $!");
while(<DISTS>) {
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]);
}
@@ -76,8 +77,11 @@ sub main
STDERR->autoflush(1);
my ($realname, $cpath) = matchdist($dist);
unless($realname){
- print STDERR "$PROG: failed to find perl dist similar to $dist\n";
- exit 1;
+ 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 cefcaf9..3259fd8 100755
--- a/lib/metas/perl.d/perl-dist
+++ b/lib/metas/perl.d/perl-dist
@@ -273,42 +273,63 @@ 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;
+ exit 1;
}
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..2e1aba3 100755
--- a/lib/metas/perl.d/scrapecore
+++ b/lib/metas/perl.d/scrapecore
@@ -205,8 +205,9 @@ sub _delmatch
sub coreonly
{
- my (%mods) = map { @$_ } @_;
- my $path = "$ENV{'PKGVAR'}/cpanmods";
+ my %mods = map { @$_ } @_;
+ 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"; }