chiark / gitweb /
Fix some warnings
[ypp-sc-tools.db-live.git] / yarrg / web / source.tar.gz
1 <%doc>
2
3  This is part of the YARRG website.  YARRG is a tool and website
4  for assisting players of Yohoho Puzzle Pirates.
5
6  Copyright (C) 2009 Ian Jackson <ijackson@chiark.greenend.org.uk>
7  Copyright (C) 2009 Clare Boothby
8
9   YARRG's client code etc. is covered by the ordinary GNU GPL (v3 or later).
10   The YARRG website is covered by the GNU Affero GPL v3 or later, which
11    basically means that every installation of the website will let you
12    download the source.
13
14  This program is free software: you can redistribute it and/or modify
15  it under the terms of the GNU Affero General Public License as
16  published by the Free Software Foundation, either version 3 of the
17  License, or (at your option) any later version.
18
19  This program is distributed in the hope that it will be useful,
20  but WITHOUT ANY WARRANTY; without even the implied warranty of
21  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22  GNU Affero General Public License for more details.
23
24  You should have received a copy of the GNU Affero General Public License
25  along with this program.  If not, see <http://www.gnu.org/licenses/>.
26
27  Yohoho and Puzzle Pirates are probably trademarks of Three Rings and
28  are used without permission.  This program is not endorsed or
29  sponsored by Three Rings.
30
31
32  This Mason component allows visitors to the YARRG website to download
33  the YARRG website's source code.
34
35
36 </%doc><%flags>
37 inherit => undef
38 </%flags><%perl>
39 use IO::Pipe;
40 use CommodsWeb;
41
42 $r->content_type('application/octet-stream');
43 $m->flush_buffer();
44
45 $ENV{'YPPSC_YARRG_SRCBASE'}= $sourcebasedir;
46 my $pipe= new IO::Pipe or die $!;
47 my $pid= fork();  defined $pid or die $!;
48 if (!$pid) {
49         $pipe->writer();
50         exec '/bin/sh','-c','
51                 cd -P "$YPPSC_YARRG_SRCBASE"
52                 (
53                  git-ls-files -z;
54                  git-ls-files -z --others --exclude-from=.gitignore;
55                  if test -d .git; then find .git -print0; fi
56                 ) | (
57                  cpio -Hustar -o --quiet -0 -R 1000:1000 || \
58                  cpio -Hustar -o --quiet -0
59                 ) | gzip
60         ';
61         die $!;
62 }
63 $pipe->reader();
64
65 my ($d, $l);
66 while ($l= read $pipe, $d, 65536) {
67         print $d;
68         $m->flush_buffer();
69 }
70 waitpid $pid,0;
71 defined $l or die "read pipe $!";
72 $pipe->error and die "pipe error $!";
73 close $pipe;
74 # deliberately ignore errors
75
76 </%perl>