From 8c7eb165c945353c3c34ba05964ce94cb14f518d Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 3 Mar 2009 10:44:54 +0000 Subject: [PATCH] * Generate a .tar.bz2 file for the channel Nix expression, since that's what nix-channel expects. --- src/Hydra/lib/Hydra/Base/Controller/Nix.pm | 2 +- src/Hydra/lib/Hydra/View/NixExprs.pm | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/Hydra/lib/Hydra/Base/Controller/Nix.pm b/src/Hydra/lib/Hydra/Base/Controller/Nix.pm index 717769d7..623b0d9d 100644 --- a/src/Hydra/lib/Hydra/Base/Controller/Nix.pm +++ b/src/Hydra/lib/Hydra/Base/Controller/Nix.pm @@ -57,7 +57,7 @@ sub pkg : Chained('nix') PathPart Args(1) { } -sub nixexprs : Chained('nix') PathPart Args(0) { +sub nixexprs : Chained('nix') PathPart('nixexprs.tar.bz2') Args(0) { my ($self, $c) = @_; $c->stash->{current_view} = 'Hydra::View::NixExprs'; } diff --git a/src/Hydra/lib/Hydra/View/NixExprs.pm b/src/Hydra/lib/Hydra/View/NixExprs.pm index b8a0012d..b52bbd6e 100644 --- a/src/Hydra/lib/Hydra/View/NixExprs.pm +++ b/src/Hydra/lib/Hydra/View/NixExprs.pm @@ -3,6 +3,8 @@ package Hydra::View::NixExprs; use strict; use base qw/Catalyst::View/; use Hydra::Helper::Nix; +use Archive::Tar; +use IO::Compress::Bzip2 qw(bzip2); sub escape { @@ -38,9 +40,16 @@ sub process { } $res .= "]\n"; - - $c->response->content_type('text/plain'); - $c->response->body($res); + + my $tar = Archive::Tar->new; + $tar->add_data("channel/default.nix", $res); + + my $tardata = $tar->write; + my $bzip2data; + bzip2(\$tardata => \$bzip2data); + + $c->response->content_type('application/x-bzip2'); + $c->response->body($bzip2data); return 1; }