git ssb

0+

Monero Pub / gitian.sigs



Commit ff5a941316fa43f0f9857bb8bb66cbb72c1e3eaa

Simplify and improve verify-merge.py

Jonathan Cross committed on 11/19/2019, 4:12:13 PM
Parent: 2a476befbce4cfc976c57bf743ccb711041a5e3f

Files changed

verify-merge.pychanged
verify-merge.pyView
@@ -19,36 +19,38 @@
1919 os.chdir('../')
2020 if args.refresh_keys:
2121 print('Refreshing pubkeys...')
2222 subprocess.check_call([GPG, '--refresh'])
23- if not os.path.isdir(args.gitian_builder_dir):
24- sys.stderr.write('Please clone the gitian-builder repository from github.com/devrandom/gitian-builder to the directory containing the gitian.sigs repository.\nIf you already have the gitian.sigs directory cloned, but under another name or path, use --gitian-builder-dir to pass its absolute directory path to the script.\n')
25- sys.exit(1)
26- if not os.path.isdir(args.monero_dir):
27- sys.stderr.write('Please clone the monero repository from github.com/monero-project/monero to the directory containing the gitian.sigs repository.\nIf you already have the monero repository cloned, but under another name or path, use --monero-dir to pass its absolute directory path to the script.\n')
28- sys.exit(1)
29- os.chdir(args.gitian_builder_dir)
30- for os_label, os_id in [("Linux","linux"), ("Windows","win"), ("MacOS","osx"), ("Android", "android")]:
31- if os.path.isdir(workdir + '/' + args.version + '-' + os_id):
32- print('\nVerifying ' + args.version + ' ' + os_label)
33- subprocess.check_call(['bin/gverify', '-v', '-d', workdir, '-r', args.version + '-' + os_id, args.monero_dir + '/contrib/gitian/gitian-' + os_id + '.yml'])
23+ print('Verifying signatures:')
24+ is_verification_error = False
25+ ver_pattern = args.version if args.version else 'v0*'
26+ for sig_file in sorted(glob.glob(ver_pattern + '-*/*/*.sig', recursive=False)):
27+ print(' - ' + '{message: <{fill}}'.format(message=sig_file, fill='72'), end='')
28+ result = subprocess.run([GPG, '--verify', sig_file], capture_output=True, encoding='utf-8')
29+ if result.returncode != 0:
30+ is_verification_error = True
31+ print('\n')
32+ sys.stderr.write('ERROR:\n' + result.stderr + '-' * 80 + '\n')
33+ else:
34+ print(' [OK]')
35+ if is_verification_error:
36+ sys.stderr.write('ERROR: One or more signatures failed verification.\n')
37+ exit(1)
38+
3439 os.chdir(workdir)
3540
3641 def main():
3742 host_repo = "git@github.com/monero-project/gitian.sigs"
3843 global args, workdir
39- parser = argparse.ArgumentParser(usage='%(prog)s [options] version', description='Use this script before merging a pull request to the gitian.sigs repository and to verify the signature of existing gitian assert files and gitian assert files in specific pull requests')
44+ parser = argparse.ArgumentParser(usage='%(prog)s [options]', description='Use this script to verify the signatures of existing gitian assert files and / or assert files in a specific pull request.')
4045 parser.add_argument('-p', '--pull_id', dest='pull_id', help='Github Pull request id to check')
41- parser.add_argument('--monero-dir', dest='monero_dir', default='../monero', help='System Path to the monero repository, e.g. /home/user/monero')
42- parser.add_argument('--gitian-builder-dir', dest='gitian_builder_dir', default='../gitian-builder', help='System Path to the gitian-builder repository, e.g. /home/user/gitian-builder')
4346 parser.add_argument('-r', '--remote', dest='remote', default='upstream', help='git remote repository')
4447 parser.add_argument('-t', '--target-branch', dest='target_branch', default='master', help='Remote repository merge into branch')
4548 parser.add_argument('-m', '--merge', action='store_true', dest='merge', help='Merge the given pull request id')
4649 parser.add_argument('-k', '--refresh-keys', action='store_true', dest='refresh_keys', help='refresh all pgp public keys that are currently in the gpg keyring.')
4750 parser.add_argument('-i', '--import-keys', action='store_true', dest='import_keys', help='import all public keys in the gitian-pubkeys directory to the gpg keyring.')
4851 parser.add_argument('-o', '--no-verify', action='store_true', dest='no_verify', help='Do not run any signature verification')
49- parser.add_argument('-n', '--name', dest='name', help='username for pgp key verification')
50- parser.add_argument('version', help='Version number, commit, or branch to build.')
52+ parser.add_argument('-v', '--version', dest='version', help='Version number of sigs to be verified (defaults to all versions if not specified).')
5153
5254 args = parser.parse_args()
5355
5456 workdir = os.getcwd()

Built with git-ssb-web