diff --git a/release.nix b/release.nix index 2f69c7d8f..b1c4c64c8 100644 --- a/release.nix +++ b/release.nix @@ -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 = '' diff --git a/src/lib/Hydra/Controller/Build.pm b/src/lib/Hydra/Controller/Build.pm index e6cddeb4a..bcef22a87 100644 --- a/src/lib/Hydra/Controller/Build.pm +++ b/src/lib/Hydra/Controller/Build.pm @@ -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) = @_; diff --git a/src/root/product-list.tt b/src/root/product-list.tt index 5076a8b5e..6b90c54a1 100644 --- a/src/root/product-list.tt +++ b/src/root/product-list.tt @@ -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" %] @@ -20,7 +22,7 @@ Source One-click install of Nix package [% build.nixname %] - [help] + [help, contents]

If you have Nix installed on your machine, you can install this package and all its dependencies automatically @@ -96,7 +98,7 @@ File [% product.name %] of type [% product.subtype %] [% END %] - [details] + [details, contents]