- 5FC781391183934125154CE25C932B651B9B49F1A6BED879E124F6F9A2AD7C16543B0763731147634A224832206E94D1FCD3119C074B4D4FC225C4252257032D
+ C97446D52E0E61E4453130BF0C3E3DFCEB4C03AB336718629BE96BA1E364313DD3F8D1787F40AC235DF4DEDAD50D6E64C1C78709D4545A73C0217450591AD750
v/v.pl
(1 . 6)(1 . 6)
5 #!/usr/bin/perl
6
7 # (C) 2014 - 2017 The Bitcoin Foundation. You do not have, nor can you ever
8 # (C) 2014 - 2018 The Bitcoin Foundation. You do not have, nor can you ever
9 # acquire the right to use, copy or distribute this software ; Should you use
10 # this software for any purpose, or copy and distribute it to anyone or in any
11 # manner, you are breaking the laws of whatever soi-disant jurisdiction, and
(10 . 24)(10 . 32)
13
14 use strict;
15
16 my $version = "99994 K ";
17 my $version = "99993 K ";
18
19 my $tdir = get_homedir() . "/.gnupgtmp";
20 my $tdir = "";
21
22 my $graph;
23 my %wot = ();
24 my %map = ();
25 my %tmp_map = ();
26 my %banners = ();
27 my %ante_map = ();
28 my %desc_map = ();
29 my %vp_map = ();
30
31 my ($pdir, $sdir, $wdir) = "";
32 my (@pfiles, @sfiles, @wfiles) = ();
33
34 sub get_homedir {
35 my $home = `echo \$HOME`; chomp($home);
36 return $home;
37 my @dep_bins = ("cat", "echo", "gpg", "ls", "mkdir", "patch", "pwd",
38 "rm", "sha512sum", "sort", "wget", "which", "mktemp");
39
40 sub check_required_bins {
41 my (@bins) = @_;
42
43 foreach my $bin (@bins) {
44 my $res = `command -v $bin >&1`; chomp($res);
45 death("Dependent program not found! : $bin\n") if $res eq "";
46 }
47 }
48
49 sub get_pwd {
(271 . 7)(279 . 28)
51 }
52 @flow = toposort(%desc_map);
53 %map = scrub_map(@flow);
54 return @flow;
55 return reverse @flow;
56 }
57
58 sub calc_press_path {
59 my ($head) = @_;
60 traverse_press_path($head);
61 return toposort(%ante_map);
62 }
63
64 sub traverse_press_path {
65 my ($vp) = @_;
66
67 my %ante = antecedents($vp);
68
69 if(%ante) {
70 $ante_map{$vp} = [keys %ante];
71 foreach my $a (keys %ante) {
72 traverse_press_path($a);
73 }
74 } else {
75 $ante_map{$vp} = [];
76 }
77 }
78
79 sub scrub_map {
(387 . 7)(416 . 7)
81 death("Cyclic Graph!\n");
82 }
83 }
84 return reverse @flow;
85 return @flow;
86 }
87
88 sub press_vpatches {
(395 . 9)(424 . 10)
90 my @press = @{$p};
91 my $v = 1 and shift @press if $press[0] =~ /^v$|^verbose$/i;
92 death("HEAD: $press[1] not found in flow\n") if !grep /^$press[1]$/, @flow;
93 `rm -rf $press[0]` if -d $press[0];
94 my @pp = calc_press_path($press[1]);
95 death("Directory $press[0] already exists! Halting press.\n") if -d $press[0];
96 `mkdir -p $press[0]`;
97 foreach my $vp (@flow) {
98 foreach my $vp (@pp) {
99 if($v) {
100 my @out = `patch -F 0 -E --dir $press[0] -p1 < $pdir/$vp 2>&1`;
101 print "$vp\n";
(553 . 8)(583 . 9)
103 }
104
105 sub make_tmpdir {
106 my ($dir) = @_;
107 `mkdir -p $dir && chmod 0700 $dir` if !-d $dir or die "$dir exists! $!";
108 if(-d "/tmp") { $tdir = `mktemp -d`; } else { $tdir = `mktemp -d -p .`; }
109 chomp($tdir);
110 death("Failed to create tempdir!\n") if $tdir eq "";
111 }
112
113 sub death {
(694 . 6)(725 . 12)
115 foreach(@flow) { print "$_ " . get_signatories($_) . "\n"; }
116 }
117
118 sub print_press_path {
119 my ($head) = @_;
120 my @pp = calc_press_path($head);
121 foreach(@pp) { print "$_ " . get_signatories($_) . "\n"; }
122 }
123
124 sub get_version {
125 my $version_text = << "END_VERSION_TEXT";
126 ################################################################################
(729 . 6)(766 . 7)
128 # (l | leafs) #
129 # (f | flow) #
130 # (p | press) (<press_dir> <head>) #
131 # (pp | press-path) (<head>) #
132 # (ss | sync-seals) (<mirror_url> <sdir>) #
133 # (sv | sync-vpatches) (<mirror_url> <pdir> <vpatches>... ) #
134 # (sa | sync-all-vpatches) (<mirror_url> <pdir>) #
(738 . 7)(776 . 7)
136 # (o | origin) (<sha512_hash>) #
137 # (g | graph) (<output_dotfile> [<output_svg_html_file>]) #
138 # (v | version) #
139 # (h | ? | help) #
140 # (h | help) #
141 # #
142 END_SHORT_HELP
143 my $l = "########################################" .
(753 . 8)(791 . 9)
145 # Commands: #
146 # m, mirrors (<output_dir>) #
147 # Will attempt to retrieve, cryptographically verify and print entries #
148 # in this list for usage in other commands. Mirrors command my only be #
149 # invoked by itself. [See: sync-seals, sync-vpatches, sync-everything] #
150 # in this list for usage in other commands. Mirrors command may only #
151 # be invoked by itself. [See: sync-seals, sync-vpatches, #
152 # sync-everything] #
153 # #
154 # i, init (<mirror_url>) [(<pdir> <sdir>)] #
155 # init should be run as the first command executed with V. init only #
(803 . 6)(842 . 10)
157 # is supplied immediately after ( p | press ) option. #
158 # See: ( f | flow ) to view the topological ordering. #
159 # #
160 # pp, press-path (<head>) #
161 # Print the actual path to be pressed, given a <head> found in the #
162 # flow. #
163 # #
164 # ss, sync-seals (<mirror_url> <sdir>) #
165 # Given required options of <mirror_url> and output directory <sdir> #
166 # will pull all of the available seal files from the given mirror into #
(845 . 7)(888 . 7)
168 # v, version #
169 # Prints the version message. #
170 # #
171 # h, ?, help #
172 # h, help #
173 # Prints this full help message. #
174 # #
175 ################################################################################
(854 . 11)(897 . 12)
177 }
178
179 sub main {
180 check_required_bins(@dep_bins);
181
182 my $cmd;
183 if(@ARGV > 0) { $cmd = shift @ARGV; }
184 else { print "Unknown or missing option!\n"; print short_help("t"); return; }
185
186 my $home = get_homedir();
187 my $pwd = get_pwd();
188 $wdir = "$pwd/.wot";
189 $pdir = "$pwd/patches";
(900 . 7)(944 . 7)
191 @wfiles = set_files($wdir);
192 build_wot();
193
194 if($cmd =~ /^h$|^help$|^\?$/) { print long_help(); return; }
195 if($cmd =~ /^h$|^help$/) { print long_help(); return; }
196 if($cmd =~ /^i$|^init$/) {
197 if(@ARGV == 1) {
198 init(@ARGV, $pdir, $sdir); return;
(927 . 6)(971 . 7)
200 if ($cmd =~ /^r$|^roots$/) { print_roots(); }
201 elsif($cmd =~ /^l$|^leafs$/) { print_leafs(); }
202 elsif($cmd =~ /^f$|^flow$/) { print_flow(@flow); }
203 elsif($cmd =~ /^pp$|^press-path$/) { print_press_path(@ARGV); }
204 elsif($cmd =~ /^p$|^press$/) {
205 if(@ARGV < 2) {
206 print "$cmd requires two arguments: (<press_dir> <head>)\n\n";
(964 . 6)(1009 . 6)
208 else { print "Unknown option: \"$cmd\"\n"; print short_help("t"); }
209 }
210
211 make_tmpdir($tdir);
212 make_tmpdir();
213 main();
214 remove_tmpdir($tdir);