From 6925ed72574cb1d92b4237fa51d3299098d61c36 Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Sat, 16 Apr 2016 12:20:54 +0000 Subject: test for TL_GNUPG, gpg, gpg2 git-svn-id: svn://tug.org/texlive/trunk@40550 c570f23f-e606-0410-a88d-b1316a301751 --- Master/tlpkg/TeXLive/TLUtils.pm | 71 ++++++++++++++++++++++++++--------------- 1 file changed, 46 insertions(+), 25 deletions(-) (limited to 'Master/tlpkg/TeXLive') diff --git a/Master/tlpkg/TeXLive/TLUtils.pm b/Master/tlpkg/TeXLive/TLUtils.pm index 9dd9a42df76..bf4a819cccc 100644 --- a/Master/tlpkg/TeXLive/TLUtils.pm +++ b/Master/tlpkg/TeXLive/TLUtils.pm @@ -3633,41 +3633,62 @@ sub tlchecksum_data { =item C<< setup_gpg() >> Tries to set up gpg command line C<$::gpg> used for -verification of downloads. +verification of downloads. Checks first for the environment variable +C, then for C, and finally for C. +Further adaption of the invocation of C can be done using the +two enviroment variables C, which is passed to +C with C<--homedir>, and C, which replaces the +default arguments C<--no-secmem-warning --no-permission-warning>. Returns 1/0 on success/failure. =cut -sub setup_gpg { - my $master = shift; +sub test_one_gpg { + my $prg = shift; + my $cmdline; + debug("Testing for gpg in $prg\n"); if ($^O =~ /^MSWin(32|64)$/i) { - my $sysgpg = which('gpg'); - my $found = 0; - if ($sysgpg) { - # test whether it actually works - my $ret = system("gpg --version >nul 2>&1"); - if ($ret == 0) { - $found = 1; - $::progs{'gpg'} = $sysgpg; - } - } - if (!$found) { - my $tlgpg = conv_to_w32_path("$master/tlpkg/installer/gpg/gpg.exe"); - my $ret = system("$tlgpg --version >nul 2>&1"); # on windows - if ($ret == 0) { - $::progs{'gpg'} = $tlgpg; - $found = 1; - } - } - return 0 if (!$found); + $prg = conv_to_w32_path($prg) if ($^O =~ /^MSWin(32|64)$/i); + $cmdline = "$prg --version >nul 2>&1"; } else { - # first search for a gpg binary - return 0 if (!setup_unix_one( 'gpg' , '/no/such/path', '--version', 1)); + $cmdline = "$prg --version >/dev/null 2>&1"; } + my $ret = system($cmdline); + if ($ret == 0) { + debug(" ... found!\n"); + return $prg; + } else { + debug(" ... not found!\n"); + return ""; + } +} + +sub setup_gpg { + my $master = shift; + my $found = 0; + my $prg; + if ($ENV{'TL_GNUPG'}) { + $prg = test_one_gpg($ENV{'TL_GNUPG'}); + $found = 1 if ($prg); + } + if (!$found) { + $prg = test_one_gpg('gpg'); + $found = 1 if ($prg); + } + if (!$found) { + $prg = test_one_gpg('gpg2'); + $found = 1 if ($prg); + } + if (!$found && $^O =~ /^MSWin(32|64)$/i) { + # test on windows also a shipped version from texlive.gpg.win32 + $prg = test_one_gpg("$master/tlpkg/installer/gpg/gpg.exe"); + $found = 1 if ($prg); + } + return 0 if (!$found); # ok, we found one # Set up the gpg invocation: - $::gpg = "$::progs{'gpg'} "; + $::gpg = "$prg "; my $gpghome = ($ENV{'TL_GNUPGHOME'} ? $ENV{'TL_GNUPGHOME'} : "$master/tlpkg/gpg" ); $gpghome =~ s!/!\\!g if win32(); -- cgit v1.2.3