Browse Source

Merge pull request #15 from TheBlueMatt/master

Fix cx_Freeze and add option to specify gpg path
pull/16/merge
Dev Random 10 years ago
parent
commit
f665f3629b
  1. 30
      share/gitian-updater

30
share/gitian-updater

@ -98,7 +98,7 @@ def extract(dir_name, zip_path): @@ -98,7 +98,7 @@ def extract(dir_name, zip_path):
files.append(path.normpath(name))
return files
def get_assertions(temp_dir, unpack_dir, file_names):
def get_assertions(gpg_path, temp_dir, unpack_dir, file_names):
assertions = {"build" : {}}
sums = {}
name = None
@ -116,7 +116,7 @@ def get_assertions(temp_dir, unpack_dir, file_names): @@ -116,7 +116,7 @@ def get_assertions(temp_dir, unpack_dir, file_names):
if file_name.startswith("gitian"):
del to_check[file_name]
if file_name.endswith(".assert"):
popen = subprocess.Popen(["gpg", '--status-fd', '1', '--homedir', path.join(temp_dir, 'gpg'), '--verify', os.path.join(unpack_dir, file_name + '.sig'), os.path.join(unpack_dir, file_name)], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
popen = subprocess.Popen([gpg_path, '--status-fd', '1', '--homedir', path.join(temp_dir, 'gpg'), '--verify', os.path.join(unpack_dir, file_name + '.sig'), os.path.join(unpack_dir, file_name)], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
gpgout = popen.communicate()[0]
retcode = popen.wait()
if retcode != 0:
@ -165,13 +165,13 @@ def get_assertions(temp_dir, unpack_dir, file_names): @@ -165,13 +165,13 @@ def get_assertions(temp_dir, unpack_dir, file_names):
manifest = { 'sums' : sums, 'release' : release, 'name': name, 'optionals': optionals }
return (not error, assertions, manifest)
def import_keys(temp_dir, config):
def import_keys(gpg_path, temp_dir, config):
gpg_dir = path.join(temp_dir, 'gpg')
os.mkdir(gpg_dir, 0700)
signers = config['signers']
for keyid in signers:
key_path = path.join('gitian', signers[keyid]['key'] + '-key.pgp')
popen = subprocess.Popen(['gpg', '--status-fd', '1', '--homedir', gpg_dir, '--import', path.join(temp_dir, 'unpack', key_path)], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
popen = subprocess.Popen([gpg_path, '--status-fd', '1', '--homedir', gpg_dir, '--import', path.join(temp_dir, 'unpack', key_path)], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
gpgout = popen.communicate(signers[keyid]['key'])[0]
if popen.wait() != 0:
print>>sys.stderr, 'Key %s failed to import'%(keyid)
@ -236,6 +236,7 @@ parser.add_argument('-d', '--dest', metavar='DEST', type=str, required=False, @@ -236,6 +236,7 @@ parser.add_argument('-d', '--dest', metavar='DEST', type=str, required=False,
parser.add_argument('-q', '--quiet', action='append_const', const=1, default=[], help='be quiet')
parser.add_argument('-f', '--force', action='store_true', help='force downgrades and such')
parser.add_argument('-m', '--customize', metavar='OUTPUT', type=str, help='generate a customized version of the script with the given config')
parser.add_argument('-g', '--gpg', metavar='GPG', type=str, help='path to GnuPG')
args = parser.parse_args()
@ -253,7 +254,7 @@ if args.config: @@ -253,7 +254,7 @@ if args.config:
s.write(script)
s.close()
os.chmod(args.customize, 0750)
exit(0)
sys.exit(0)
config = yaml.safe_load(f)
f.close()
@ -265,6 +266,11 @@ dest_path = args.dest @@ -265,6 +266,11 @@ dest_path = args.dest
if not dest_path:
parser.error('argument -d/--dest is required unless -m is specified')
gpg_path = args.gpg
if not gpg_path:
gpg_path = 'gpg'
rsses = []
if args.url:
@ -287,7 +293,7 @@ if path.exists(dest_path): @@ -287,7 +293,7 @@ if path.exists(dest_path):
if not files.count('.gitian-manifest') and len(files) > 0:
print>>sys.stderr, "destination already exists, no .gitian-manifest and directory not empty. Please empty destination."
exit(1)
sys.exit(1)
f = file(os.path.join(dest_path,'.gitian-manifest'), 'r')
old_manifest = yaml.load(f, OrderedDictYAMLLoader)
f.close()
@ -331,22 +337,22 @@ if not downloaded: @@ -331,22 +337,22 @@ if not downloaded:
if not downloaded:
print>>sys.stderr, "out of places to download from, try later"
exit(1)
sys.exit(1)
unpack_dir = path.join(temp_dir, 'unpack')
files = extract(unpack_dir, package_file)
import_keys(temp_dir, config)
import_keys(gpg_path, temp_dir, config)
(success, assertions, out_manifest) = get_assertions(temp_dir, unpack_dir, files)
(success, assertions, out_manifest) = get_assertions(gpg_path, temp_dir, unpack_dir, files)
if old_manifest:
if out_manifest['name'] != old_manifest['name']:
print>>sys.stderr, "The old directory has a manifest for a different package"
exit(1)
sys.exit(1)
if LooseVersion(out_manifest['release']) < LooseVersion(old_manifest['release']) and not args.force:
print>>sys.stderr, "This would downgrade from version %s to %s"%(old_manifest['release'],out_manifest['release'])
exit(1)
sys.exit(1)
elif LooseVersion(out_manifest['release']) == LooseVersion(old_manifest['release']):
if quiet <= 1:
print>>sys.stderr, "This is a reinstall of version %s"%(old_manifest['release'])
@ -360,7 +366,7 @@ if not success and quiet <= 1: @@ -360,7 +366,7 @@ if not success and quiet <= 1:
total_weight = check_assertions(config, assertions)
if not total_weight:
print>>sys.stderr, "There were errors checking assertions, build is untrusted, aborting"
exit(1)
sys.exit(1)
if quiet == 0:
print>>sys.stderr, "Successful with signature weight %d"%(total_weight)

Loading…
Cancel
Save