chiark / gitweb /
Allow downloading of database tree source code via dictup CGI scripts
authorIan Jackson <ian@liberator.relativity.greenend.org.uk>
Sat, 31 Oct 2009 13:52:15 +0000 (13:52 +0000)
committerIan Jackson <ian@liberator.relativity.greenend.org.uk>
Sat, 31 Oct 2009 13:52:15 +0000 (13:52 +0000)
yarrg/Commods.pm
yarrg/commod-update-receiver
yarrg/db-idempotent-populate
yarrg/dictionary-update-receiver
yarrg/ocean-topology-graph
yarrg/update-master-info
yarrg/web/devel
yarrg/web/source.tar.gz
yarrg/yppedia-ocean-scraper

index f74571ddd39c6c5093902c51aae03969cb780532..24f2e81ae9eedb49353a925f4a2a06d2aeb1b200 100644 (file)
@@ -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;
index d01b6de1753c3cbfac8b7751d0266c5af36a0116..cbd98f84b2e15c64b64bd4e4d1674d856f95b1b4 100755 (executable)
@@ -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 <ijackson@chiark.greenend.org.uk>
 #
 # 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 <http://www.gnu.org/licenses/>.
 #
 # 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 $!;
index c4bd4a761431ef4968520b0080e894925871f73f..0ecde9e51ab82ee1bdffc4c71471fee19109c568 100755 (executable)
@@ -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 <ijackson@chiark.greenend.org.uk>
 #
 # 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 <http://www.gnu.org/licenses/>.
 #
 # Yohoho and Puzzle Pirates are probably trademarks of Three Rings and
index 352b9bbbfd09d77fb1f405be2a53b199d7627615..8ccea9823be369cb7fbe3221c11304baf3c97aac 100755 (executable)
@@ -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 <ijackson@chiark.greenend.org.uk>
 #
 # 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 <http://www.gnu.org/licenses/>.
 #
 # 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 ----------
index e609e35778188dc147390cd3a451dc315c95da62..2336b43c453a717363049a18e4132cecd14b5293 100755 (executable)
@@ -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 <ijackson@chiark.greenend.org.uk>
+#
+# 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 <http://www.gnu.org/licenses/>.
+#
+# 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;
index e2b0973db453b093e9b6f261b60c5f2969701e8b..f7574555d88069356991fe261f7d675c148f3098 100755 (executable)
 #         ./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 <ijackson@chiark.greenend.org.uk>
 #
 # 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 <http://www.gnu.org/licenses/>.
 #
 # Yohoho and Puzzle Pirates are probably trademarks of Three Rings and
index fed459f5b8e1df457e9de2eaf8456944c76b9c3c..b296d14bec121b950da7f5b275cc498e5942db58 100755 (executable)
@@ -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).
 
 <p>
 
@@ -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.
 
-<h3>YARRG lookup website instances</h3>
+<h3>YARRG website code instances</h3>
+
+<h4>Lookup website</h4>
  <ul>
- <li><a href="http://yarrg.chiark.net/">Main released site</a>
- <li><a href="http://yarrg.chiark.net/test/data">Released code; testing database instance (updated with yarrg --test-servers)</a>
- <li><a href="http://yarrg.chiark.net/test/code">Testing version of the site code</a>
- <li><a href="http://yarrg.chiark.net/test/both">Testing code running against the testing database instance</a>
+ <li><a href="http://yarrg.chiark.net/">Main released site</a>,
+     with <a href="http://yarrg.chiark.net/source.tar.gz">source code</a>
+ <li><a href="http://yarrg.chiark.net/test/data">Released code; testing database instance (updated with yarrg --test-servers)</a> (source code as above)
+ <li><a href="http://yarrg.chiark.net/test/code">Testing version of the site code</a>,
+     with <a href="http://yarrg.chiark.net/test/source.tar.gz">source code</a>
+ <li><a href="http://yarrg.chiark.net/test/both">Testing code running against the testing database instance</a> (source code as above)
  </ul>
 
-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.
-
 <p>
 
 You can add the form parameter <kbd>?debug=1</kbd> 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.
+
+<h4>Database and dictionary update receiver</h4>
+
+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:
+
+ <ul>
+ <li><a href="http://upload.yarrg.chiark.net/commod-update-receiver?get_source=1">Main production instance</a>
+ <li><a href="http://upload.yarrg.chiark.net/test/commod-update-receiver?get_source=1">Testing database instance</a>
+ </ul>
 
 <h3>Data</h3>
 
index 1d92ad8584255028578f7b1cbb2da41f9376f5f5..0e47a83e38d755720427b9c453db6bed6cf33288 100755 (executable)
 </%doc><%flags>
 inherit => undef
 </%flags><%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
+})
 
 </%perl>
index 68efa38f6781980c63308a55b55b4334195873d5..d55f7acab83d7d0a03ae21655059e4277e1e9068 100755 (executable)
@@ -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 <ijackson@chiark.greenend.org.uk>
 #
 # 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 <http://www.gnu.org/licenses/>.
 #
 # Yohoho and Puzzle Pirates are probably trademarks of Three Rings and