misc: small fix or general refactoring i did not bother commenting
This commit is contained in:
parent
63568f1725
commit
4018071bba
@ -84,6 +84,7 @@ def install(display, update):
|
|||||||
|
|
||||||
os.system('unzip "%s" -d "%s"' % (target_path, path))
|
os.system('unzip "%s" -d "%s"' % (target_path, path))
|
||||||
|
|
||||||
|
source_path = os.path.join(path, name)
|
||||||
checksums = glob.glob("%s/*.sha256")
|
checksums = glob.glob("%s/*.sha256")
|
||||||
if len(checksums) == 0:
|
if len(checksums) == 0:
|
||||||
if update['native']:
|
if update['native']:
|
||||||
@ -92,28 +93,27 @@ def install(display, update):
|
|||||||
else:
|
else:
|
||||||
display.update(force=True, new_data={'status': 'Verifying %s ...' % name})
|
display.update(force=True, new_data={'status': 'Verifying %s ...' % name})
|
||||||
|
|
||||||
binary_path = os.path.join(path, name)
|
|
||||||
checksum = checksums[0]
|
checksum = checksums[0]
|
||||||
|
|
||||||
logging.info("[update] verifying %s for %s ..." % (checksum, binary_path))
|
logging.info("[update] verifying %s for %s ..." % (checksum, source_path))
|
||||||
|
|
||||||
with open(checksums) as fp:
|
with open(checksums) as fp:
|
||||||
expected = fp.read().strip().lower()
|
expected = fp.read().strip().lower()
|
||||||
|
|
||||||
real = subprocess.getoutput('sha256sum "%s"' % binary_path).split(' ')[0].strip().lower()
|
real = subprocess.getoutput('sha256sum "%s"' % source_path).split(' ')[0].strip().lower()
|
||||||
|
|
||||||
if real != expected:
|
if real != expected:
|
||||||
logging.warning("[update] checksum mismatch for %s: expected=%s got=%s" % (binary_path, expected, real))
|
logging.warning("[update] checksum mismatch for %s: expected=%s got=%s" % (source_path, expected, real))
|
||||||
return
|
return
|
||||||
|
|
||||||
display.update(force=True, new_data={'status': 'Installing %s ...' % name})
|
display.update(force=True, new_data={'status': 'Installing %s ...' % name})
|
||||||
|
|
||||||
if update['native']:
|
if update['native']:
|
||||||
dest_path = subprocess.getoutput("which %s" % name)
|
dest_path = subprocess.getoutput("which %s" % name)
|
||||||
logging.info("[update] installing %s to %s ... TODO" % (binary_path, dest_path))
|
logging.info("[update] installing %s to %s ... TODO" % (source_path, dest_path))
|
||||||
|
|
||||||
else:
|
else:
|
||||||
logging.info("[update] installing %s ... TODO" % binary_path)
|
logging.info("[update] installing %s ... TODO" % source_path)
|
||||||
|
|
||||||
|
|
||||||
def on_internet_available(agent):
|
def on_internet_available(agent):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user