|
1 | 1 | use strict; |
2 | | -use FindBin '$Bin'; |
3 | | -use lib $Bin; |
4 | | -use inc::Module::Install 0.92; |
5 | | - |
6 | | -$|++; |
7 | | - |
8 | | -name 'Module-Signature'; |
9 | | -license 'unrestricted'; |
10 | | -all_from 'lib/Module/Signature.pm'; |
11 | | -repository 'http://github.com/audreyt/module-signature'; |
12 | | -install_script 'script/cpansign'; |
13 | | -build_requires 'Test::More', 0, 'IPC::Run', 0; |
14 | | -requires 'File::Temp'; |
15 | | - |
16 | | -# clean generated test files |
17 | | -clean_files(q{"t/test-dat*"}); |
18 | | - |
19 | | -# On Win32 (excluding cygwin) we know that IO::Socket::INET, |
20 | | -# which is needed for keyserver stuff, doesn't work. In fact |
21 | | -# it potentially hangs forever. So bail out with a N/A on |
22 | | -# Win32. |
23 | | -if ( $^O eq 'MSWin32' and 0 ) { |
24 | | - print "Keyserver behaviour is dangerous unreliable on Win32\n"; |
25 | | - print "Not installing on this platform.\n"; |
26 | | - exit(255); |
27 | | -} else { |
28 | | - requires 'IO::Socket::INET' => 0; |
29 | | -} |
30 | | - |
31 | | -# We will need something to handle SHA1/256 |
32 | | -unless ( |
33 | | - can_use('Digest::SHA') or |
34 | | - can_use('Digest::SHA::PurePerl') or |
35 | | - (can_use('Digest::SHA1') and can_use('Digest::SHA256')) |
36 | | -) { |
37 | | - # Nothing installed, we need to install a digest module |
38 | | - if ( can_cc() ) { |
39 | | - requires 'Digest::SHA'; |
40 | | - } else { |
41 | | - requires 'Digest::SHA::PurePerl'; |
42 | | - } |
43 | | -} |
44 | | - |
45 | | -# Is openpgp currently installed |
46 | | -if ( can_use('Crypt::OpenPGP') ) { |
47 | | - # Crypt::OpenPGP installed/available, continue on... |
48 | | -} elsif ( my $gpg = locate_gpg() ) { |
49 | | - # We SHOULD have gpg, double-check formally |
50 | | - requires_external_bin $gpg; |
51 | | -} elsif ( can_cc() and $ENV{AUTOMATED_TESTING} ) { |
52 | | - # Dive headlong into a full Crypt::OpenPGP install. |
53 | | - requires('Crypt::OpenPGP'); |
54 | | -} else { |
55 | | - # Ask the user what to do |
56 | | - ask_user(); |
57 | | -} |
58 | | - |
59 | | -unless ( can_run('diff') ) { |
60 | | - # We know Text::Diff fails on Cygwin (for now) |
61 | | - if ( $^O ne 'Cygwin' ) { |
62 | | - requires 'Algorithm::Diff'; |
63 | | - requires 'Text::Diff'; |
64 | | - } |
| 2 | +use warnings; |
| 3 | + |
| 4 | +use 5.010; |
| 5 | + |
| 6 | +use ExtUtils::MakeMaker; |
| 7 | + |
| 8 | +my %WriteMakefileArgs = ( |
| 9 | + "ABSTRACT" => "Module signature file manipulation", |
| 10 | + "AUTHOR" => "Audrey Tang <cpan\@audreyt.org>", |
| 11 | + "CONFIGURE_REQUIRES" => { |
| 12 | + "ExtUtils::MakeMaker" => 0 |
| 13 | + }, |
| 14 | + "DISTNAME" => "Module-Signature", |
| 15 | + "LICENSE" => "perl", |
| 16 | + "MIN_PERL_VERSION" => "5.010", |
| 17 | + "NAME" => "Module::Signature", |
| 18 | + "PREREQ_PM" => { |
| 19 | + "Crypt::OpenPGP" => 0, |
| 20 | + "Crypt::OpenPGP::KeyServer" => 0, |
| 21 | + "Exporter" => 0, |
| 22 | + "ExtUtils::Manifest" => 0, |
| 23 | + "File::Spec" => 0, |
| 24 | + "File::Temp" => 0, |
| 25 | + "IO::Socket::INET" => 0, |
| 26 | + "Text::Diff" => 0, |
| 27 | + "constant" => 0, |
| 28 | + "strict" => 0, |
| 29 | + "vars" => 0, |
| 30 | + "version" => 0, |
| 31 | + "warnings" => 0 |
| 32 | + }, |
| 33 | + "TEST_REQUIRES" => { |
| 34 | + "Data::Dumper" => 0, |
| 35 | + "File::Basename" => 0, |
| 36 | + "File::Path" => 0, |
| 37 | + "FindBin" => 0, |
| 38 | + "Getopt::Long" => 0, |
| 39 | + "IPC::Run" => 0, |
| 40 | + "Pod::Usage" => 0, |
| 41 | + "Socket" => 0, |
| 42 | + "Test::More" => 0, |
| 43 | + "lib" => 0 |
| 44 | + }, |
| 45 | + "VERSION" => "0.90", |
| 46 | + "test" => { |
| 47 | + "TESTS" => "t/*.t" |
| 48 | + } |
| 49 | +); |
| 50 | + |
| 51 | + |
| 52 | +my %FallbackPrereqs = ( |
| 53 | + "Crypt::OpenPGP" => 0, |
| 54 | + "Crypt::OpenPGP::KeyServer" => 0, |
| 55 | + "Data::Dumper" => 0, |
| 56 | + "Exporter" => 0, |
| 57 | + "ExtUtils::Manifest" => 0, |
| 58 | + "File::Basename" => 0, |
| 59 | + "File::Path" => 0, |
| 60 | + "File::Spec" => 0, |
| 61 | + "File::Temp" => 0, |
| 62 | + "FindBin" => 0, |
| 63 | + "Getopt::Long" => 0, |
| 64 | + "IO::Socket::INET" => 0, |
| 65 | + "IPC::Run" => 0, |
| 66 | + "Pod::Usage" => 0, |
| 67 | + "Socket" => 0, |
| 68 | + "Test::More" => 0, |
| 69 | + "Text::Diff" => 0, |
| 70 | + "constant" => 0, |
| 71 | + "lib" => 0, |
| 72 | + "strict" => 0, |
| 73 | + "vars" => 0, |
| 74 | + "version" => 0, |
| 75 | + "warnings" => 0 |
| 76 | +); |
| 77 | + |
| 78 | + |
| 79 | +unless ( eval { ExtUtils::MakeMaker->VERSION(6.63_03) } ) { |
| 80 | + delete $WriteMakefileArgs{TEST_REQUIRES}; |
| 81 | + delete $WriteMakefileArgs{BUILD_REQUIRES}; |
| 82 | + $WriteMakefileArgs{PREREQ_PM} = \%FallbackPrereqs; |
65 | 83 | } |
66 | 84 |
|
67 | | -sign; WriteAll; |
68 | | - |
69 | | - |
70 | | - |
71 | | - |
72 | | - |
73 | | -##################################################################### |
74 | | -# Support Functions |
75 | | - |
76 | | -sub locate_gpg { |
77 | | - print "Looking for GNU Privacy Guard (gpg), a cryptographic signature tool...\n"; |
78 | | - |
79 | | - my ($gpg, $gpg_path); |
80 | | - for my $gpg_bin ('gpg', 'gpg2', 'gnupg', 'gnupg2') { |
81 | | - $gpg_path = can_run($gpg_bin); |
82 | | - next unless $gpg_path; |
83 | | - next unless `$gpg_bin --version` =~ /GnuPG/; |
84 | | - next unless defined `$gpg_bin --list-public-keys`; |
85 | | - |
86 | | - $gpg = $gpg_bin; |
87 | | - last; |
88 | | - } |
89 | | - unless ( $gpg ) { |
90 | | - print "gpg not found.\n"; |
91 | | - return; |
92 | | - } |
93 | | - |
94 | | - print "GnuPG found ($gpg_path).\n"; |
95 | | - |
96 | | - return 1 if grep { /^--installdeps/} @ARGV; |
97 | | - |
98 | | - if ( prompt("Import PAUSE and author keys to GnuPG?", 'y' ) =~ /^y/i) { |
99 | | - print 'Importing... '; |
100 | | - system $gpg, '--quiet', '--import', qw[ AUDREYT2018.pub ANDK2020.pub PAUSE2022.pub NIKLASHOLM2018.pub TIMLEGGE2024.pub ]; |
101 | | - print "done.\n"; |
102 | | - } |
103 | | - |
104 | | - return $gpg; |
105 | | -} |
106 | | - |
107 | | -sub ask_user { |
108 | | - |
109 | | - # Defined the prompt messages |
110 | | - my $message1 = <<'END_MESSAGE'; |
111 | | -
|
112 | | -Could not auto-detect a signature utility on your system. |
113 | | -
|
114 | | -What do you want me to do? |
115 | | -
|
116 | | -1) Let you install GnuPG manually while I'm waiting for your answer; |
117 | | - it is available at http://www.gnupg.org/download/ or may be available |
118 | | - from your platforms packaging system (for Open Source platforms). |
119 | | -
|
120 | | -END_MESSAGE |
121 | | - |
122 | | - my $message2 = <<'END_MESSAGE'; |
123 | | -
|
124 | | -2) Automatically install Crypt::OpenPGP and the 20 modules it requires |
125 | | - from CPAN, which will give the same functionality as GnuPG. |
126 | | -
|
127 | | -END_MESSAGE |
128 | | - |
129 | | - # Present the options |
130 | | - print $message1; |
131 | | - |
132 | | - my $option3 = 2; |
133 | | - if ( can_cc() ) { |
134 | | - $option3 = 3; |
135 | | - print $message2; |
136 | | - } |
137 | | - |
138 | | - print <<"END_MESSAGE"; |
139 | | -
|
140 | | -$option3) Forget this cryptographic signature stuff for now. |
141 | | -
|
142 | | -END_MESSAGE |
143 | | - |
144 | | - my $choice; |
145 | | - foreach ( 1 .. 3 ) { |
146 | | - $choice = prompt("Your choice:", 3) || 3; |
147 | | - last if $choice =~ /^[123]$/; |
148 | | - print "Sorry, I cannot understand '$choice'.\n" |
149 | | - } |
150 | | - |
151 | | - if ( $choice == 1 ) { |
152 | | - # They claim to have installed gpg |
153 | | - requires_external_bin 'gpg'; |
154 | | - } elsif ( $choice == 2 and $option3 == 3 ) { |
155 | | - # They want to install Crypt::OpenPGP |
156 | | - requires('Crypt::OpenPGP'); |
157 | | - } else { |
158 | | - # Forget about it... |
159 | | - print "Module::Signature is not wanted on this host.\n"; |
160 | | - exit(0); |
161 | | - } |
162 | | -} |
| 85 | +delete $WriteMakefileArgs{CONFIGURE_REQUIRES} |
| 86 | + unless eval { ExtUtils::MakeMaker->VERSION(6.52) }; |
163 | 87 |
|
164 | | -__END__ |
| 88 | +WriteMakefile(%WriteMakefileArgs); |
0 commit comments