Commit 9daa2f701db26fbef59fbd9c4e76dd0f046dd379
Merge pull request #16 into master
TheCharlatan committed on 9/9/2019, 7:29:36 AMParent: 9767ce1efc3eae02e7a8e5931e95b98b238a36bd
Parent: 28268ea75cff61d18273da351b058dcdd7dd88b2
Files changed
verify-merge.py | changed |
verify-merge.py | ||
---|---|---|
@@ -2,43 +2,56 @@ | ||
2 | 2 | import argparse |
3 | 3 | import os |
4 | 4 | import subprocess |
5 | 5 | import glob |
6 | +import sys | |
6 | 7 | |
7 | 8 | GIT = os.getenv('GIT','git') |
8 | 9 | GPG = os.getenv('GPG','gpg') |
9 | 10 | |
10 | 11 | def verify(): |
11 | 12 | global args, workdir |
12 | - os.chdir('gitian-pubkeys') | |
13 | - print('Importing pubkeys...') | |
14 | - keys = [f for f in glob.glob("*.asc", recursive=True)] | |
15 | - for key in keys: | |
16 | - subprocess.check_call([GPG, '--import', key]) | |
17 | - print('Refreshing pubkeys...') | |
18 | - subprocess.check_call([GPG, '--refresh']) | |
19 | - os.chdir('../../gitian-builder') | |
20 | - print('\nVerifying '+args.version+' Linux\n') | |
21 | - subprocess.check_call(['bin/gverify', '-v', '-d', '../gitian.sigs/', '-r', args.version+'-linux', '../monero/contrib/gitian/gitian-linux.yml']) | |
22 | - print('\nVerifying '+args.version+' Windows\n') | |
23 | - subprocess.check_call(['bin/gverify', '-v', '-d', '../gitian.sigs/', '-r', args.version+'-win', '../monero/contrib/gitian/gitian-win.yml']) | |
24 | - print('\nVerifying '+args.version+' MacOS\n') | |
25 | - subprocess.check_call(['bin/gverify', '-v', '-d', '../gitian.sigs/', '-r', args.version+'-osx', '../monero/contrib/gitian/gitian-osx.yml']) | |
13 | + if args.import_keys: | |
14 | + os.chdir('gitian-pubkeys') | |
15 | + print('Importing pubkeys...') | |
16 | + keys = [f for f in glob.glob("*.asc", recursive=True)] | |
17 | + for key in keys: | |
18 | + subprocess.check_call([GPG, '--import', key]) | |
19 | + os.chdir('../') | |
20 | + if args.refresh_keys: | |
21 | + print('Refreshing pubkeys...') | |
22 | + 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")]: | |
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']) | |
26 | 34 | os.chdir(workdir) |
27 | 35 | |
28 | 36 | def main(): |
29 | 37 | host_repo = "git@github.com/monero-project/gitian.sigs" |
30 | 38 | global args, workdir |
31 | 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') |
32 | 40 | 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('--gitiian-builder-dir', dest='gitian_builder_dir', default='../gitian-builder', help='System Path to the gitian-builder repository, e.g. /home/user/gitian-builder') | |
33 | 43 | parser.add_argument('-r', '--remote', dest='remote', default='upstream', help='git remote repository') |
34 | - parser.add_argument('-t', '--target_branch', dest='target_branch', default='master', help='Remote repository merge into branch') | |
44 | + parser.add_argument('-t', '--target-branch', dest='target_branch', default='master', help='Remote repository merge into branch') | |
35 | 45 | parser.add_argument('-m', '--merge', action='store_true', dest='merge', help='Merge the given pull request id') |
46 | + 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.') | |
47 | + 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.') | |
36 | 48 | parser.add_argument('-o', '--no-verify', action='store_true', dest='no_verify', help='Do not run any signature verification') |
37 | 49 | parser.add_argument('-n', '--name', dest='name', help='username for pgp key verification') |
38 | 50 | parser.add_argument('version', help='Version number, commit, or branch to build.') |
39 | 51 | |
40 | 52 | args = parser.parse_args() |
53 | + | |
41 | 54 | workdir = os.getcwd() |
42 | 55 | if args.pull_id != None: |
43 | 56 | # Get branch from remote pull request and compare |
44 | 57 | head_branch = args.pull_id+'_head' |
Built with git-ssb-web