3 # Thomas Nagy, 2014-2015
6 A simple file for verifying signatures in signed waf files
7 This script is meant for Python >= 2.6 and the encoding is bytes - latin-1
9 Distributing detached signatures is boring
12 import sys
, os
, re
, subprocess
14 if __name__
== '__main__':
21 outfile1
= sys
.argv
[2]
23 outfile1
= infile
+ '-sig'
26 outfile2
= sys
.argv
[3]
28 outfile2
= outfile1
+ '.asc'
30 f1
= open(outfile1
, 'wb')
31 f2
= open(outfile2
, 'wb')
32 f
= open(infile
, 'rb')
36 lastline
= txt
.decode('latin-1').splitlines()[-1] # just the last line
37 if not lastline
.startswith('#-----BEGIN PGP SIGNATURE-----'):
38 print("ERROR: there is no signature to verify in %r :-/" % infile
)
41 sigtext
= lastline
.replace('\\n', '\n') # convert newlines
42 sigtext
= sigtext
[1:] # omit the '# character'
43 sigtext
= sigtext
.encode('latin-1') # python3
46 f1
.write(txt
[:-len(lastline
) - 1]) # one newline character was eaten from splitlines()
52 cmd
= 'gpg --verify %s' % outfile2
54 ret
= subprocess
.Popen(cmd
, shell
=True).wait()