* 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

@ -82,8 +82,10 @@ let
''; # */ ''; # */
hydraPath = stdenv.lib.concatStringsSep ":" (map (p: "${p}/bin") [ hydraPath = stdenv.lib.concatStringsSep ":" (map (p: "${p}/bin") [
libxslt sqlite subversion nix coreutils libxslt sqlite subversion nix coreutils findutils
gzip bzip2 gnused graphviz gzip bzip2 lzma gnutar unzip
gnused graphviz
rpm dpkg
]); ]);
installPhase = '' installPhase = ''

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 ($self, $c, $productnr, @path) = @_;
my $product = $c->stash->{build}->buildproducts->find({productnr => $productnr}); 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') { sub runtimedeps : Chained('build') PathPart('runtime-deps') {
my ($self, $c) = @_; my ($self, $c) = @_;

View file

@ -10,6 +10,8 @@
_ (product.name ? "/" _ product.name : "") _ (product.name ? "/" _ product.name : "")
_ (product.defaultpath ? "/" _ product.defaultpath : "") %] _ (product.defaultpath ? "/" _ product.defaultpath : "") %]
[% contents = c.uri_for('/build' build.id 'contents' product.productnr) %]
[% SWITCH product.type %] [% SWITCH product.type %]
[% CASE "nix-build" %] [% CASE "nix-build" %]
@ -20,7 +22,7 @@
<img src="/static/images/nix-build.png" alt="Source" /> <img src="/static/images/nix-build.png" alt="Source" />
One-click install of Nix package <tt>[% build.nixname %]</tt> One-click install of Nix package <tt>[% build.nixname %]</tt>
</a> </a>
[<a class="productDetailsToggle" href="javascript:">help</a>] [<a class="productDetailsToggle" href="javascript:">help</a>, <a href="[% contents %]">contents</a>]
<div class="help productDetails"> <div class="help productDetails">
<p>If you have Nix installed on your machine, you can <p>If you have Nix installed on your machine, you can
install this package and all its dependencies automatically install this package and all its dependencies automatically
@ -96,7 +98,7 @@
File <tt>[% product.name %]</tt> of type <tt>[% product.subtype %]</tt> File <tt>[% product.name %]</tt> of type <tt>[% product.subtype %]</tt>
[% END %] [% END %]
</a> </a>
[<a class="productDetailsToggle" href="javascript:">details</a>] [<a class="productDetailsToggle" href="javascript:">details</a>, <a href="[% contents %]">contents</a>]
<div class="productDetails"> <div class="productDetails">
<table> <table>
<tr> <tr>