]> Sergey Matveev's repositories - public-inbox.git/blobdiff - script/public-inbox-init
fetch: support --exit-code switch
[public-inbox.git] / script / public-inbox-init
index e22a0564c4e4b9673e77b65200ed88cdd0f8000b..78a4d3bd75748f65110bb3e8af18c7d4fc976df8 100755 (executable)
@@ -93,8 +93,7 @@ $ng =~ m![^A-Za-z0-9/_\.\-\~\@\+\=:]! and
 
 require PublicInbox::Config;
 my $pi_config = PublicInbox::Config->default_file;
-require File::Basename;
-my $dir = File::Basename::dirname($pi_config);
+my ($dir) = ($pi_config =~ m!(.*?/)[^/]+\z!);
 require File::Path;
 File::Path::mkpath($dir); # will croak on fatal errors
 
@@ -231,8 +230,11 @@ run_die([@x, "$pfx.newsgroup", $ng]) if $ng ne '';
 
 for my $kv (@c_extra) {
        my ($k, $v) = split(/=/, $kv, 2);
-       # --fixed-value for idempotent invocations
-       run_die([@x, qw(--replace-all --fixed-value), "$pfx.$k", $v, $v]);
+       # git 2.30+ has --fixed-value for idempotent invocations,
+       # but that's too new to depend on in 2021.  Perl quotemeta
+       # seems compatible enough for POSIX ERE which git uses
+       my $re = '^'.quotemeta($v).'$';
+       run_die([@x, qw(--replace-all), "$pfx.$k", $v, $re]);
 }
 
 # needed for git prior to v2.1.0
@@ -244,3 +246,9 @@ if (defined $perm) {
 rename $pi_config_tmp, $pi_config or
        die "failed to rename `$pi_config_tmp' to `$pi_config': $!\n";
 undef $auto_unlink; # trigger ->DESTROY
+
+my $f = "$inboxdir/description";
+if (sysopen $fh, $f, O_CREAT|O_EXCL|O_WRONLY) {
+       print $fh "public inbox for $address[0]\n" or die "print($f): $!";
+       close $fh or die "close($f): $!";
+}