MCPcopy Create free account
hub / github.com/apache/solr / check_key_in_keys

Function check_key_in_keys

dev-tools/scripts/buildAndPushRelease.py:322–355  ·  view source on GitHub ↗
(gpgKeyID, local_keys)

Source from the content-addressed store, hash-verified

320 raise RuntimeError('"git --version" returned a non-zero exit code.')
321
322def check_key_in_keys(gpgKeyID, local_keys):
323 if gpgKeyID is not None:
324 print(' Verify your gpg key is in the main KEYS file')
325 if local_keys is not None:
326 print(" Using local KEYS file %s" % local_keys)
327 keysFileText = open(local_keys, encoding='iso-8859-1').read()
328 keysFileLocation = local_keys
329 else:
330 keysFileURL = "https://archive.apache.org/dist/solr/KEYS"
331 keysFileLocation = keysFileURL
332 print(" Using online KEYS file %s" % keysFileURL)
333 keysFileText = load(keysFileURL, encoding='iso-8859-1')
334 if len(gpgKeyID) > 2 and gpgKeyID[0:2] == '0x':
335 gpgKeyID = gpgKeyID[2:]
336 if len(gpgKeyID) > 40:
337 gpgKeyID = gpgKeyID.replace(" ", "")
338 if len(gpgKeyID) == 8:
339 gpgKeyID8Char = "%s %s" % (gpgKeyID[0:4], gpgKeyID[4:8])
340 re_to_match = r"^pub .*\n\s+(\w{4} \w{4} \w{4} \w{4} \w{4} \w{4} \w{4} \w{4} %s|\w{32}%s)" % (gpgKeyID8Char, gpgKeyID)
341 elif len(gpgKeyID) == 40:
342 gpgKeyID40Char = "%s %s %s %s %s %s %s %s %s %s" % \
343 (gpgKeyID[0:4], gpgKeyID[4:8], gpgKeyID[8:12], gpgKeyID[12:16], gpgKeyID[16:20],
344 gpgKeyID[20:24], gpgKeyID[24:28], gpgKeyID[28:32], gpgKeyID[32:36], gpgKeyID[36:])
345 re_to_match = r"^pub .*\n\s+(%s|%s)" % (gpgKeyID40Char, gpgKeyID)
346 else:
347 print('Invalid gpg key id format [%s]. Must be 8 byte short ID or 40 byte fingerprint, with or without 0x prefix, no spaces.' % gpgKeyID)
348 exit(2)
349 if re.search(re_to_match, keysFileText, re.MULTILINE):
350 print(' Found key %s in KEYS file at %s' % (gpgKeyID, keysFileLocation))
351 else:
352 print(' ERROR: Did not find your key %s in KEYS file at %s. Please add it and try again.' % (gpgKeyID, keysFileLocation))
353 if local_keys is not None:
354 print(' You are using a local KEYS file. Make sure it is up to date or validate against the online version')
355 exit(2)
356
357
358def resolve_gpghome():

Callers 1

mainFunction · 0.85

Calls 4

loadFunction · 0.70
readMethod · 0.65
replaceMethod · 0.45
searchMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…