#!/usr/bin/env perl use strict; use warnings; my $keysfile = "include/keys.txt"; my $wmifile = 'include/keys.wmi'; my $forcekeyupdates = 0; my $skipkeyupdates = 0; # First we load the keys, then we create a wmi file which is included by # https://www.torproject.org/docs/signing-keys.html.en # Determine the base directory in case we are called from somewhere else. # We assume to sit in docs/en. Update $root path if this file has moved: $0 =~ /^(.+)\/[^\/]+$/; my $root = "$1/../.."; chdir $root or die "Could not enter $root: $! (script path: $0)\n"; open my $kf, '<', "$keysfile" # read keys or die "Could not open $keysfile: $!\n"; my %sections; # project => key owners my %owners; # key owner => string with all keys my @projects; # save sections in order of appearance my $section; foreach (<$kf>) { # filters comment and empty lines next if ($_ eq "\n"); if (/^#/) { # [section] / project } elsif (/^\[(.+)\]$/) { $section = "$1"; $sections{"$section"} = (); push (@projects, $section); # key owner with list of key id(s) } elsif (/^([^:]+):(.+)$/) { my $owner = "$1"; my $keys = "$2"; push( @{$sections{"$section"}}, $owner); $owners{"$owner"} = "$keys"; # tell about unrecognized lines } else { print "Ignored line: $_\n"; } } close $kf; my @owners = keys %owners; print "Loaded $keysfile. Found $#owners key owners in $#projects projects.\n"; # If the keysfile did not change since the last run, we will not update them. # To update all keys anyway, set $forcekeyupdates = 1 above, or comment: if (-f $wmifile && qx/[ $wmifile -nt $keysfile ]/) { $forcekeyupdates or $skipkeyupdates++; } open my $out, '>', "$wmifile" or die "Could not write to $wmifile; $!\n"; print $out "#!/usr/bin/env wml\n

The signing keys we use are:

\n\n

Fingerprints

\n

The fingerprints for the keys are:

\n"; foreach my $project (@projects) { print $out "

$project

\n". $fingerprints{"$project"}; } close $out; print "Wrote $wmifile.\n"; exit 0;