From 59316f0dcddd4e5d15e47dfde36f513e1685c4ae Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sat, 31 Oct 2009 13:52:15 +0000 Subject: [PATCH] Allow downloading of database tree source code via dictup CGI scripts --- yarrg/Commods.pm | 38 +++++++++++++++++++++++++++++++- yarrg/commod-update-receiver | 24 ++++++++++++-------- yarrg/db-idempotent-populate | 14 ++++++------ yarrg/dictionary-update-receiver | 21 +++++++++++------- yarrg/ocean-topology-graph | 22 ++++++++++++++++++ yarrg/update-master-info | 14 ++++++------ yarrg/web/devel | 38 ++++++++++++++++++++++---------- yarrg/web/source.tar.gz | 34 ++++------------------------ yarrg/yppedia-ocean-scraper | 14 ++++++------ 9 files changed, 138 insertions(+), 81 deletions(-) diff --git a/yarrg/Commods.pm b/yarrg/Commods.pm index f74571d..24f2e81 100644 --- a/yarrg/Commods.pm +++ b/yarrg/Commods.pm @@ -22,6 +22,7 @@ package Commods; use IO::File; +use IO::Pipe; use HTTP::Request::Common (); use POSIX; use LWP::UserAgent; @@ -45,7 +46,8 @@ BEGIN { &pipethrough_run_gzip &http_useragent &version_core &http_useragent_string_map &cgipostform &yarrgpostform &cgi_get_caller - &set_ctype_utf8 $masterinfoversion); + &set_ctype_utf8 $masterinfoversion + &source_tarball); %EXPORT_TAGS = ( ); @EXPORT_OK = qw(); @@ -435,4 +437,38 @@ sub http_useragent ($) { return $ua; } +sub source_tarball ($$) { + my ($sourcebasedir,$spitoutfn) = @_; + + my $pipe= new IO::Pipe or die $!; + my $pid= fork(); defined $pid or die $!; + if (!$pid) { + $ENV{'YPPSC_YARRG_SRCBASE'}= $sourcebasedir; + $pipe->writer(); + exec '/bin/sh','-c',' + cd -P "$YPPSC_YARRG_SRCBASE" + ( + git-ls-files -z; + git-ls-files -z --others --exclude-from=.gitignore; + if test -d .git; then find .git -print0; fi + ) | ( + cpio -Hustar -o --quiet -0 -R 1000:1000 || \ + cpio -Hustar -o --quiet -0 + ) | gzip + '; + die $!; + } + $pipe->reader(); + + my ($d, $l); + while ($l= read $pipe, $d, 65536) { + $spitoutfn->($d); + } + waitpid $pid,0; + defined $l or die "read pipe $!"; + $pipe->error and die "pipe error $!"; + close $pipe; + # deliberately ignore errors +} + 1; diff --git a/yarrg/commod-update-receiver b/yarrg/commod-update-receiver index d01b6de..cbd98f8 100755 --- a/yarrg/commod-update-receiver +++ b/yarrg/commod-update-receiver @@ -3,22 +3,22 @@ # This script is invoked when the yarrg client uploads to # the chiark database. -# This is part of ypp-sc-tools, a set of third-party tools for assisting -# players of Yohoho Puzzle Pirates. +# This is part of the YARRG website. YARRG is a tool and website +# for assisting players of Yohoho Puzzle Pirates. # # Copyright (C) 2009 Ian Jackson # # This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# GNU Affero General Public License for more details. # -# You should have received a copy of the GNU General Public License +# You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # # Yohoho and Puzzle Pirates are probably trademarks of Three Rings and @@ -41,8 +41,6 @@ our $now= time; defined $now or die $!; my $re_any= "^(.*)\$"; -parse_info_serverside(); - sub fail ($) { my ($msg) = @_; addlog("failing $msg"); @@ -63,6 +61,14 @@ sub must_param ($$) { my %o; +if (param('get_source')) { + header('application/octet-stream'); + source_tarball('..', sub { print $_[0] or die $!; }); + exit 0; +} + +parse_info_serverside(); + my $midtmp= "_mid-pid$$.hold"; open MIDTMP, ">$midtmp" or die "$midtmp $!"; stat MIDTMP or die $!; diff --git a/yarrg/db-idempotent-populate b/yarrg/db-idempotent-populate index c4bd4a7..0ecde9e 100755 --- a/yarrg/db-idempotent-populate +++ b/yarrg/db-idempotent-populate @@ -7,22 +7,22 @@ # creates or updates OCEAN-Oceanname.db # from source-info.txt -# This is part of ypp-sc-tools, a set of third-party tools for assisting -# players of Yohoho Puzzle Pirates. +# This is part of the YARRG website. YARRG is a tool and website +# for assisting players of Yohoho Puzzle Pirates. # # Copyright (C) 2009 Ian Jackson # # This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# GNU Affero General Public License for more details. # -# You should have received a copy of the GNU General Public License +# You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # # Yohoho and Puzzle Pirates are probably trademarks of Three Rings and diff --git a/yarrg/dictionary-update-receiver b/yarrg/dictionary-update-receiver index 352b9bb..8ccea98 100755 --- a/yarrg/dictionary-update-receiver +++ b/yarrg/dictionary-update-receiver @@ -3,29 +3,28 @@ # This script is invoked when the yarrg wants to send an update to the # dictionary server. See README.privacy. -# This is part of ypp-sc-tools, a set of third-party tools for assisting -# players of Yohoho Puzzle Pirates. +# This is part of the YARRG website. YARRG is a tool and website +# for assisting players of Yohoho Puzzle Pirates. # # Copyright (C) 2009 Ian Jackson # # This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# GNU Affero General Public License for more details. # -# You should have received a copy of the GNU General Public License +# You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # # Yohoho and Puzzle Pirates are probably trademarks of Three Rings and # are used without permission. This program is not endorsed or # sponsored by Three Rings. - # upload testing runes: # # YPPSC_YARRG_DICT_UPDATE=./ YPPSC_YARRG_DICT_SUBMIT=./ ./yarrg --ocean midnight --pirate aristarchus --find-island --same --raw-tsv >raw.tsv @@ -43,6 +42,12 @@ use IO::Handle; use Commods; +if (param('get_source')) { + header('application/octet-stream'); + source_tarball('..', sub { print $_[0] or die $!; }); + exit 0; +} + my $aadepth=2; #---------- pixmaps ---------- diff --git a/yarrg/ocean-topology-graph b/yarrg/ocean-topology-graph index e609e35..2336b43 100755 --- a/yarrg/ocean-topology-graph +++ b/yarrg/ocean-topology-graph @@ -1,5 +1,27 @@ #!/usr/bin/perl -w +# This is part of the YARRG website. YARRG is a tool and website +# for assisting players of Yohoho Puzzle Pirates. +# +# Copyright (C) 2009 Ian Jackson +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +# Yohoho and Puzzle Pirates are probably trademarks of Three Rings and +# are used without permission. This program is not endorsed or +# sponsored by Three Rings. + use strict (qw(vars)); use CommodsDatabase; diff --git a/yarrg/update-master-info b/yarrg/update-master-info index e2b0973..f757455 100755 --- a/yarrg/update-master-info +++ b/yarrg/update-master-info @@ -30,22 +30,22 @@ # ./update-master-info -b -d ~ftp/users/ijackson/yarrg/ -a # ./update-master-info -b -d ~ftp/users/ijackson/yarrg/ -O ... -# This is part of ypp-sc-tools, a set of third-party tools for assisting -# players of Yohoho Puzzle Pirates. +# This is part of the YARRG website. YARRG is a tool and website +# for assisting players of Yohoho Puzzle Pirates. # # Copyright (C) 2009 Ian Jackson # # This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# GNU Affero General Public License for more details. # -# You should have received a copy of the GNU General Public License +# You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # # Yohoho and Puzzle Pirates are probably trademarks of Three Rings and diff --git a/yarrg/web/devel b/yarrg/web/devel index fed459f..b296d14 100755 --- a/yarrg/web/devel +++ b/yarrg/web/devel @@ -56,9 +56,9 @@ YARRG is Free Software - you may share and modify it. See the licences for details. Not only the client but also the website code -is Free. The yarrg client, support files, and so forth are under -the GNU GPL (v3 or later); the website is under the GNU Affero GPL (v3 -or later). +is Free. The yarrg client, support files, and so forth are under the +GNU GPL (v3 or later); the website and database backend is under the +GNU Affero GPL (v3 or later).

@@ -82,21 +82,35 @@ the source for their version, the website code itself lets you download an up-to-date of its actually-running source code. So this link gives you the source code for the pages you are now looking at. -

YARRG lookup website instances

+

YARRG website code instances

+ +

Lookup website

-Each of these allows you to download its own source code so you -can get both the testing and the main version of the website. -

You can add the form parameter ?debug=1 to each of the -above to get a version of the site with debugging output enabled. +website URLs above to get a version of the site with debugging output enabled. + +

Database and dictionary update receiver

+ +On the live system there are different trees, potentially with +different versions, for receiving updates and managing the database, +to the ones for displaying the website. The database management trees +are normally accessed only via the upload client but you may also +download their source directly: + +

Data

diff --git a/yarrg/web/source.tar.gz b/yarrg/web/source.tar.gz index 1d92ad8..0e47a83 100755 --- a/yarrg/web/source.tar.gz +++ b/yarrg/web/source.tar.gz @@ -36,41 +36,15 @@ <%flags> inherit => undef <%perl> -use IO::Pipe; use CommodsWeb; +use Commods; $r->content_type('application/octet-stream'); $m->flush_buffer(); -$ENV{'YPPSC_YARRG_SRCBASE'}= sourcebasedir(); -my $pipe= new IO::Pipe or die $!; -my $pid= fork(); defined $pid or die $!; -if (!$pid) { - $pipe->writer(); - exec '/bin/sh','-c',' - cd -P "$YPPSC_YARRG_SRCBASE" - ( - git-ls-files -z; - git-ls-files -z --others --exclude-from=.gitignore; - if test -d .git; then find .git -print0; fi - ) | ( - cpio -Hustar -o --quiet -0 -R 1000:1000 || \ - cpio -Hustar -o --quiet -0 - ) | gzip - '; - die $!; -} -$pipe->reader(); - -my ($d, $l); -while ($l= read $pipe, $d, 65536) { - print $d; +source_tarball(sourcebasedir(), sub { + print $_[0]; $m->flush_buffer(); -} -waitpid $pid,0; -defined $l or die "read pipe $!"; -$pipe->error and die "pipe error $!"; -close $pipe; -# deliberately ignore errors +}) diff --git a/yarrg/yppedia-ocean-scraper b/yarrg/yppedia-ocean-scraper index 68efa38..d55f7ac 100755 --- a/yarrg/yppedia-ocean-scraper +++ b/yarrg/yppedia-ocean-scraper @@ -2,22 +2,22 @@ # helper program for getting information from yppedia -# This is part of ypp-sc-tools, a set of third-party tools for assisting -# players of Yohoho Puzzle Pirates. +# This is part of the YARRG website. YARRG is a tool and website +# for assisting players of Yohoho Puzzle Pirates. # # Copyright (C) 2009 Ian Jackson # # This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# GNU Affero General Public License for more details. # -# You should have received a copy of the GNU General Public License +# You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # # Yohoho and Puzzle Pirates are probably trademarks of Three Rings and -- 2.30.2