X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~yarrgweb/git?p=ypp-sc-tools.db-live.git;a=blobdiff_plain;f=yarrg%2FCommods.pm;h=c6ed2536399a8e713efce419bf04e3d052678b68;hp=0d45c5ea70367945bb997c8cdc409ef4caf3afcc;hb=e353043ae5bf5a7df54f650c51f00d6c3b862ba9;hpb=219c9b471fb927f2263b0e36669188ca937d5c8b diff --git a/yarrg/Commods.pm b/yarrg/Commods.pm index 0d45c5e..c6ed253 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; @@ -36,7 +37,7 @@ BEGIN { @ISA = qw(Exporter); @EXPORT = qw(&parse_info_clientside &fetch_with_rsync &parse_info_serverside &parse_info_serverside_ocean - %oceans %commods %clients + %oceans %commods %clients %commodclasses %vessels %shotname2damage &parse_pctb_commodmap %pctb_commodmap @pctb_commodmap &get_our_version &check_tsv_line @@ -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(); @@ -268,6 +270,7 @@ sub fetch_with_rsync ($) { sub parse_info_serverside () { parse_info1('source-info.txt','s',0); + parse_info1('tree-info.txt','t',1); } sub parse_info_serverside_ocean ($) { my ($oceanname) = @_; @@ -472,4 +475,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;