Skip to content

Commit

Permalink
* A quick hack to list the contents of various types of files (RPM,
Browse files Browse the repository at this point in the history
  Debs, tars, ...).
  • Loading branch information
edolstra committed Mar 18, 2009
1 parent b39e2c5 commit 9e4b029
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 5 deletions.
6 changes: 4 additions & 2 deletions release.nix
Expand Up @@ -82,8 +82,10 @@ let
''; # */

hydraPath = stdenv.lib.concatStringsSep ":" (map (p: "${p}/bin") [
libxslt sqlite subversion nix coreutils
gzip bzip2 gnused graphviz
libxslt sqlite subversion nix coreutils findutils
gzip bzip2 lzma gnutar unzip
gnused graphviz
rpm dpkg
]);

installPhase = ''
Expand Down
56 changes: 55 additions & 1 deletion src/lib/Hydra/Controller/Build.pm
Expand Up @@ -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});
Expand Down Expand Up @@ -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) = @_;

Expand Down
6 changes: 4 additions & 2 deletions src/root/product-list.tt
Expand Up @@ -10,6 +10,8 @@
_ (product.name ? "/" _ product.name : "")
_ (product.defaultpath ? "/" _ product.defaultpath : "") %]

[% contents = c.uri_for('/build' build.id 'contents' product.productnr) %]

[% SWITCH product.type %]

[% CASE "nix-build" %]
Expand All @@ -20,7 +22,7 @@
<img src="/static/images/nix-build.png" alt="Source" />
One-click install of Nix package <tt>[% build.nixname %]</tt>
</a>
[<a class="productDetailsToggle" href="javascript:">help</a>]
[<a class="productDetailsToggle" href="javascript:">help</a>, <a href="[% contents %]">contents</a>]
<div class="help productDetails">
<p>If you have Nix installed on your machine, you can
install this package and all its dependencies automatically
Expand Down Expand Up @@ -96,7 +98,7 @@
File <tt>[% product.name %]</tt> of type <tt>[% product.subtype %]</tt>
[% END %]
</a>
[<a class="productDetailsToggle" href="javascript:">details</a>]
[<a class="productDetailsToggle" href="javascript:">details</a>, <a href="[% contents %]">contents</a>]
<div class="productDetails">
<table>
<tr>
Expand Down

0 comments on commit 9e4b029

Please sign in to comment.