lib/PublicInbox/Fetch.pm | 3 ++- lib/PublicInbox/LeiMirror.pm | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++- t/lei-mirror.t | 2 ++ diff --git a/lib/PublicInbox/Fetch.pm b/lib/PublicInbox/Fetch.pm index 0539fe505e42750de4c6fb483ef936041b6b1fbf..184b4f26319f1f01ddf846a97ae0a3612bffeb3c 100644 --- a/lib/PublicInbox/Fetch.pm +++ b/lib/PublicInbox/Fetch.pm @@ -91,7 +91,7 @@ my $rd = popen_rd([qw(git show-ref)], undef, { -C => $git_dir }); Digest::SHA::sha256(do { local $/; <$rd> }); } -sub do_fetch { +sub do_fetch { # main entry point my ($cls, $lei, $cd) = @_; my $ibx_ver; $lei->{curl} //= PublicInbox::LeiCurl->new($lei) or return; @@ -124,6 +124,7 @@ Unable to infer inbox URL from <$git_url> EOM $ibx_uri = URI->new($inbox_url); } + PublicInbox::LeiMirror::write_makefile($dir, $ibx_ver); $lei->qerr("# inbox URL: $ibx_uri/"); my $res = do_manifest($lei, $dir, $ibx_uri) or return; my ($code, $v1_path, $v2_epochs, $muri, $ft, $mf) = @$res; diff --git a/lib/PublicInbox/LeiMirror.pm b/lib/PublicInbox/LeiMirror.pm index c113c9debf8bfccdc0834e09cd1c56d05f167f3c..23a2156c6f8e2cb7bf077ca1ec9bf1b10a3817bb 100644 --- a/lib/PublicInbox/LeiMirror.pm +++ b/lib/PublicInbox/LeiMirror.pm @@ -9,7 +9,7 @@ use parent qw(PublicInbox::IPC); use IO::Uncompress::Gunzip qw(gunzip $GunzipError); use PublicInbox::Spawn qw(popen_rd spawn run_die); use File::Temp (); -use Fcntl qw(SEEK_SET); +use Fcntl qw(SEEK_SET O_CREAT O_EXCL O_WRONLY); sub do_finish_mirror { # dwaitpid callback my ($arg, $pid) = @_; @@ -201,6 +201,7 @@ $uri->as_string, $self->{dst} ]; my $cerr = run_reap($lei, $cmd, $opt); return $lei->child_error($cerr, "@$cmd failed") if $cerr; _try_config($self); + write_makefile($self->{dst}, 1); index_cloned_inbox($self, 1); } @@ -234,6 +235,7 @@ require PublicInbox::MultiGit; my $mg = PublicInbox::MultiGit->new($dst, 'all.git', 'git'); $mg->fill_alternates; for my $i ($mg->git_epochs) { $mg->epoch_cfg_set($i) } + write_makefile($self->{dst}, 2); undef $on_destroy; # unlock index_cloned_inbox($self, 2); } @@ -354,6 +356,63 @@ my ($self) = @_; $self->{lei}->_lei_atfork_child; $SIG{TERM} = sub { exit(128 + 15) }; # trigger OnDestroy $reap $self->SUPER::ipc_atfork_child; +} + +sub write_makefile { + my ($dir, $ibx_ver) = @_; + my $f = "$dir/Makefile"; + if (sysopen my $fh, $f, O_CREAT|O_EXCL|O_WRONLY) { + print $fh <