--- v.pl.v99996 91c77f3daba8ab012314e2c21d1f3fa7fc3e0e1de9b9ae1c6e6ebb3c3782a12a8b514dc6d3a5bc10b6bac02f5aab598ff1a353e9fb15e1c0f8424eeab3cb306a +++ v.pl 504281c25e0d826f46ea5e9b1b69f699cd4286f53df3ceb4b2836a151892e8c5e43aa38c544240546fd1d9de873f63e9c673eb709ebe29b67b134f388b2bddee @@ -10,7 +10,7 @@ use strict; -my $version = "99996 K "; +my $version = "99995 K "; my $tdir = get_homedir() . "/.gnupgtmp"; @@ -37,9 +37,9 @@ sub set_files { my ($dir) = @_; if(!-d $dir) { - print "$dir directory does not exist. Refer to help.\n"; - print "See 'init' or 'sync' commands.\n"; - print short_help("t"); remove_tmpdir($tdir); exit -1; + my $msg = "$dir directory does not exist.\n" . + "See 'init' or 'sync' commands in 'help'.\n"; + death($msg); } my @a = `ls $dir | sort`; return wash(@a); @@ -109,13 +109,11 @@ "-----------------------------------------"; print "$border\n"; print "WARNING: $seal is an INVALID seal for $patch!\n"; - my $msg = "Check that this user is in your WoT, and that this key " . - "has not expired.\nOtherwise remove the invalid seal from your " . - "SEALS directory."; + my $msg = "Check that this user is in your WoT.\n" . + "Otherwise remove the invalid seal from your SEALS directory."; print "$msg\n"; print "$border\n"; - remove_tmpdir($tdir); - die; + death(); } $verified = ""; } @@ -133,10 +131,13 @@ $src_file = $1, $ante_hash = $2 if $p =~ /^--- (.*) (.*)/; $desc_hash = $1 if $p =~ /^\+\+\+ .* (.*)/; if($src_file && $ante_hash && $desc_hash) { + death("$pfile is an invalid vpatch!\n") if $ante_hash eq $desc_hash; $vpdata{$src_file} = { a => $ante_hash, b => $desc_hash }; $map{$pfile} = {%vpdata}; + $src_file = "", $ante_hash = "", $desc_hash = ""; } } + death("Error! $pfile is an invalid vpatch file.\n") if !%vpdata; %vpdata = (); } return %map; @@ -173,7 +174,7 @@ $src_file->{a} eq $sf->{b} && $src_file->{a} ne "false") { push @tmp, $sf_name; - $desc{$k} = [@tmp]; + $desc{$k} = [@tmp]; } } } @@ -194,7 +195,7 @@ $src_file->{b} eq $sf->{a} && $src_file->{b} ne "false") { push @tmp, $sf_name; - $ante{$k} = [@tmp]; + $ante{$k} = [@tmp]; } } } @@ -207,8 +208,7 @@ if(exists $map{$search_key}) { return %{$map{$search_key}}; } else { - remove_tmpdir($tdir); - die "Error! Could not find vpatch \"$search_key\" in $pdir\n"; + death("Error! Could not find vpatch \"$search_key\" in $pdir\n"); } } @@ -283,7 +283,7 @@ $flag = ""; } if(!$acyclic eq "true") { - print "Cyclic Graph!\n"; remove_tmpdir($tdir); exit -1; + death("Cyclic Graph!\n"); } } return reverse @flow; @@ -294,6 +294,7 @@ my @press = @{$p}; my $v = 1 and shift @press if $press[0] =~ /^v$|^verbose$/i; `mkdir -p $press[0]`; + death("HEAD: $press[1] not found in flow\n") if !grep /^$press[1]$/, @flow; foreach my $vp (@flow) { if($v) { my @out = `patch -E --dir $press[0] -p1 < $pdir/$vp 2>&1`; @@ -328,12 +329,14 @@ if($file_hash ne "false") { my $fp = $press_dir . "/" . get_filepath($src_file_name); my $hashed = `sha512sum $fp`; - $hashed =~ /(.*) .*/; - my $hash = $1; - print " File: $fp\n" . - "expected: $file_hash\n" . - " actual: $hash\n" - and die if $hash != $hashed; + $hashed =~ /^(.*) .*$/; + my $pressed_hash = $1; + if($file_hash ne $pressed_hash) { + print " File: $fp\n" . + "Expected: $file_hash\n" . + " Actual: $pressed_hash\n"; + death("Pressed file hash did not match expected!\n"); + } } } } @@ -417,14 +420,17 @@ sub add_desc_src_files { my ($node) = @_; - my %desc = descendants($node->name()); - my @suc = $node->successors(); - foreach my $s (@suc) { - my $name = $s->name(); - my @edges = $node->edges_to($s); - foreach my $e (@edges) { - $e->set_attribute("title", "[ " . join('; ', sort @{$desc{$name}}) . " ]"); - add_desc_src_files($s); + if($node != "") { + my %desc = descendants($node->name()); + my @suc = $node->successors(); + foreach my $s (@suc) { + my $name = $s->name(); + my @edges = $node->edges_to($s); + foreach my $e (@edges) { + $e->set_attribute("title", "[ " . + join('; ', sort @{$desc{$name}}) . " ]"); + add_desc_src_files($s); + } } } } @@ -449,6 +455,12 @@ `mkdir -p $dir && chmod 0700 $dir` if !-d $dir or die "$dir exists! $!"; } +sub death { + my ($msg) = @_; + remove_tmpdir($tdir); + die "$msg"; +} + sub remove_tmpdir { my ($dir) = @_; `rm -rf $dir` if -d $dir; @@ -481,7 +493,8 @@ my @mirror_sigs = (); if(!-d $out) { `mkdir -p $out`; } my $wget = "wget -q -r -nd -N --no-parent " . - "--reject \"index.html*\" -A 'mirrors.*' http://thebitcoin.foundation/v/ -P $out"; + "--reject \"index.html*\" -A 'mirrors.*' " . + "http://thebitcoin.foundation/v/ -P $out"; `$wget`; my @sigs = `ls $out | sort`; @@ -560,6 +573,20 @@ } } +sub print_origin { + my ($hash) = @_; + my $found = "f"; + foreach my $k (keys %map) { + foreach my $sf (keys %{$map{$k}}) { + if($map{$k}{$sf}{b} eq $hash) { + $found = "t"; + print "Origin: $k " . get_signatories($k) . "\n"; + } + } + } + print "No Origin Found by Hash: $hash\n" if $found ne "t"; +} + sub print_flow { my (@flow) = @_; foreach(@flow) { print "$_ " . get_signatories($_) . "\n"; } @@ -606,6 +633,7 @@ # (se | sync-everything) ( ) # # (a | ante | antecedents) () # # (d | desc | descendants) () # +# (o | origin) () # # (g | graph) ( []) # # (v | version) # # (h | ? | help) # @@ -701,6 +729,10 @@ # Finds the descendants of a given vpatch and prints the results to # # stdout # # # +# o, origin () # +# Returns the vpatch and signatories where the given hash originated in # +# the source tree. # +# # # g, graph ( []) # # Builds a complete directed GraphViz graph of all vpatches from a # # topological flow and prints the Dot language output to file. If the # @@ -743,6 +775,7 @@ $cmd =~ /^se$|^sync-everything$/i || $cmd =~ /^a$|^ante$|^antecedents$/i || $cmd =~ /^d$|^desc$|^descendants$/i || + $cmd =~ /^o$|^origin$/i || $cmd =~ /^g$|^graph$/i) && !@ARGV) { print "Option \"$cmd\" requires arguments!\n"; print short_help("t"); return; @@ -818,6 +851,7 @@ else { sync_everything(@ARGV); } } elsif($cmd =~ /^a$|^ante$|^antecedents$/) { print_antecedents(@ARGV); } elsif($cmd =~ /^d$|^desc$|^descendants$/) { print_descendants(@ARGV); } + elsif($cmd =~ /^o$|^origin$/) { print_origin(@ARGV); } elsif($cmd =~ /^g$|^graph$/) { my $mod = "Graph::Easy"; (my $req = $mod . ".pm") =~ s{::}{/}g;