Package database: Support multiple outputs
This commit is contained in:
parent
0cd5fe7808
commit
e4b04c877f
1 changed files with 13 additions and 7 deletions
|
@ -4,6 +4,7 @@ use strict;
|
||||||
use DBI;
|
use DBI;
|
||||||
use DBD::SQLite;
|
use DBD::SQLite;
|
||||||
use Nix::Manifest;
|
use Nix::Manifest;
|
||||||
|
use List::Util qw(all);
|
||||||
|
|
||||||
my $nixExprs = $ARGV[0] or die;
|
my $nixExprs = $ARGV[0] or die;
|
||||||
my $dbPath = $ARGV[1] or die;
|
my $dbPath = $ARGV[1] or die;
|
||||||
|
@ -33,7 +34,7 @@ $dbh->begin_work;
|
||||||
sub process_dir {
|
sub process_dir {
|
||||||
my ($system, $pkgname, $dir) = @_;
|
my ($system, $pkgname, $dir) = @_;
|
||||||
return unless -d $dir;
|
return unless -d $dir;
|
||||||
print STDERR "indexing $dir\n";
|
#print STDERR "indexing $dir\n";
|
||||||
opendir DH, "$dir" or die "opening $dir";
|
opendir DH, "$dir" or die "opening $dir";
|
||||||
for my $program (readdir DH) {
|
for my $program (readdir DH) {
|
||||||
next if substr($program, 0, 1) eq ".";
|
next if substr($program, 0, 1) eq ".";
|
||||||
|
@ -53,20 +54,25 @@ for my $system ("x86_64-linux", "i686-linux") {
|
||||||
foreach my $line (split "\n", $out) {
|
foreach my $line (split "\n", $out) {
|
||||||
my ($attrName, $name, $drvPath, $outPath) = split ' ', $line;
|
my ($attrName, $name, $drvPath, $outPath) = split ' ', $line;
|
||||||
die unless $attrName && $name && $outPath;
|
die unless $attrName && $name && $outPath;
|
||||||
next unless defined $narFiles{$outPath};
|
|
||||||
next unless -d $outPath;
|
my @outPaths = map { s/^[a-z]+=//; $_ } (split ";", $outPath);
|
||||||
my $prev = $packages{$drvPath};
|
|
||||||
|
next unless all { defined $narFiles{$_} } @outPaths;
|
||||||
|
next unless all { -d $_ } @outPaths;
|
||||||
|
|
||||||
# Prefer shorter attribute names.
|
# Prefer shorter attribute names.
|
||||||
|
my $prev = $packages{$drvPath};
|
||||||
next if defined $prev &&
|
next if defined $prev &&
|
||||||
(length($prev->{attrName}) < length($attrName) ||
|
(length($prev->{attrName}) < length($attrName) ||
|
||||||
(length($prev->{attrName}) == length($attrName) && $prev->{attrName} le $attrName));
|
(length($prev->{attrName}) == length($attrName) && $prev->{attrName} le $attrName));
|
||||||
$packages{$drvPath} = { attrName => $attrName, outPath => $outPath };
|
|
||||||
|
$packages{$drvPath} = { attrName => $attrName, outPaths => [@outPaths] };
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach my $drvPath (keys %packages) {
|
foreach my $drvPath (keys %packages) {
|
||||||
my $pkg = $packages{$drvPath};
|
my $pkg = $packages{$drvPath};
|
||||||
process_dir($system, $pkg->{attrName}, "$pkg->{outPath}/bin");
|
process_dir($system, $pkg->{attrName}, "$_/bin")
|
||||||
process_dir($system, $pkg->{attrName}, "$pkg->{outPath}/sbin");
|
foreach @{$pkg->{outPaths}};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue