user/dev discussion of public-inbox itself
 help / color / Atom feed
999ddd1cb239cefe57eaaaa70e866f30a311ac32 blob 2151 bytes (raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
 
# Copyright (C) 2018-2019 all contributors <meta@public-inbox.org>
# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
package PublicInbox::Xapcmd;
use strict;
use warnings;
use PublicInbox::Spawn qw(which spawn);
use PublicInbox::Over;
use File::Temp qw(tempdir);
use File::Path qw(remove_tree);

sub commit_changes ($$$) {
	my ($im, $old, $new) = @_;
	my @st = stat($old) or die "failed to stat($old): $!\n";

	my $over = "$old/over.sqlite3";
	if (-f $over) {
		$over = PublicInbox::Over->new($over);
		$over->connect->sqlite_backup_to_file("$new/over.sqlite3");
	}
	rename($old, "$new/old") or die "rename $old => $new/old: $!\n";
	chmod($st[2] & 07777, $new) or die "chmod $old: $!\n";
	rename($new, $old) or die "rename $new => $old: $!\n";
	$im->lock_release;
	remove_tree("$old/old") or die "failed to remove $old/old: $!\n";
}

sub run {
	my ($ibx, $cmd, $env, $opt) = @_;
	$opt ||= {};
	my $dir = $ibx->{mainrepo} or die "no mainrepo in inbox\n";
	which($cmd->[0]) or die "$cmd->[0] not found in PATH\n";
	$ibx->umask_prepare;
	my $old = $ibx->search->xdir(1);
	-d $old or die "$old does not exist\n";
	my $new = tempdir($cmd->[0].'-XXXXXXXX', CLEANUP => 1, DIR => $dir);
	my $v = $ibx->{version} || 1;
	my @cmds;
	if ($v == 1) {
		push @cmds, [@$cmd, $old, $new];
	} else {
		opendir my $dh, $old or die "Failed to opendir $old: $!\n";
		while (defined(my $dn = readdir($dh))) {
			if ($dn =~ /\A\d+\z/) {
				push @cmds, [@$cmd, "$old/$dn", "$new/$dn"];
			} elsif ($dn eq '.' || $dn eq '..') {
			} elsif ($dn =~ /\Aover\.sqlite3/) {
			} else {
				warn "W: skipping unknown dir: $old/$dn\n"
			}
		}
		die "No Xapian parts found in $old\n" unless @cmds;
	}
	my $im = $ibx->importer(0);
	my $max = $opt->{jobs} || scalar(@cmds);
	$ibx->with_umask(sub {
		$im->lock_acquire;
		my %pids;
		while (@cmds) {
			while (scalar(keys(%pids)) < $max && scalar(@cmds)) {
				my $x = shift @cmds;
				$pids{spawn($x, $env, $opt)} = $x;
			}

			while (scalar keys %pids) {
				my $pid = waitpid(-1, 0);
				my $x = delete $pids{$pid};
				die join(' ', @$x)." failed: $?\n" if $?;
			}
		}
		commit_changes($im, $old, $new);
	});
}

1;
debug log:

solving 999ddd1 ...
found 999ddd1 in https://80x24.org/public-inbox.git

user/dev discussion of public-inbox itself

Archives are clonable:
	git clone --mirror http://public-inbox.org/meta
	git clone --mirror http://czquwvybam4bgbro.onion/meta
	git clone --mirror http://hjrcffqmbrq6wope.onion/meta
	git clone --mirror http://ou63pmih66umazou.onion/meta

Example config snippet for mirrors

Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.mail.public-inbox.meta
	nntp://ou63pmih66umazou.onion/inbox.comp.mail.public-inbox.meta
	nntp://czquwvybam4bgbro.onion/inbox.comp.mail.public-inbox.meta
	nntp://hjrcffqmbrq6wope.onion/inbox.comp.mail.public-inbox.meta
	nntp://news.gmane.org/gmane.mail.public-inbox.general

 note: .onion URLs require Tor: https://www.torproject.org/

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git