* A quick hack to list the contents of various types of files (RPM,

Debs, tars, ...).
This commit is contained in:
Eelco Dolstra
2009-03-18 17:40:12 +00:00
parent b39e2c5e32
commit 9e4b029285
3 changed files with 63 additions and 5 deletions

View File

@ -90,7 +90,7 @@ sub showLog {
}
sub download : Chained('build') PathPart('download') {
sub download : Chained('build') PathPart {
my ($self, $c, $productnr, @path) = @_;
my $product = $c->stash->{build}->buildproducts->find({productnr => $productnr});
@ -125,6 +125,60 @@ sub download : Chained('build') PathPart('download') {
}
sub contents : Chained('build') PathPart {
my ($self, $c, $productnr, @path) = @_;
my $product = $c->stash->{build}->buildproducts->find({productnr => $productnr});
notFound($c, "Build doesn't have a product $productnr.") if !defined $product;
my $path = $product->path;
notFound($c, "Product $path has disappeared.") unless -e $path;
my $res;
if ($product->type eq "nix-build") {
$res = `cd $path && find . -print0 | xargs -0 ls -ld --`;
error($c, "`ls -lR' error: $?") if $? != 0;
}
elsif ($path =~ /\.rpm$/) {
$res = `rpm --query --info --package "$path"`;
error($c, "RPM error: $?") if $? != 0;
$res .= "===\n";
$res .= `rpm --query --list --verbose --package "$path"`;
error($c, "RPM error: $?") if $? != 0;
}
elsif ($path =~ /\.deb$/) {
$res = `dpkg-deb --info "$path"`;
error($c, "`dpkg-deb' error: $?") if $? != 0;
$res .= "===\n";
$res .= `dpkg-deb --contents "$path"`;
error($c, "`dpkg-deb' error: $?") if $? != 0;
}
elsif ($path =~ /\.tar(\.gz|\.bz2|\.lzma)?$/ ) {
$res = `tar tvfa "$path"`;
error($c, "`tar' error: $?") if $? != 0;
}
elsif ($path =~ /\.zip$/ ) {
$res = `unzip -v "$path"`;
error($c, "`unzip' error: $?") if $? != 0;
}
else {
error($c, "Unsupported file type.");
}
die unless $res;
$c->stash->{'plain'} = { data => $res };
$c->forward('Hydra::View::Plain');
}
sub runtimedeps : Chained('build') PathPart('runtime-deps') {
my ($self, $c) = @_;