Skip to content

Commit c6b863a

Browse files
committed
updates: switch script to import
Signed-off-by: Ian Leonard <antonlacon@gmail.com>
1 parent 7ee92ec commit c6b863a

1 file changed

Lines changed: 20 additions & 18 deletions

File tree

resources/lib/modules/updates.py

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@
2323
import oeWindows
2424
import os_tools
2525

26+
if os.path.isfile('/usr/bin/update-system'):
27+
from importlib.machinery import SourceFileLoader
28+
checker = SourceFileLoader('add', '/usr/bin/update-system').load_module()
29+
2630

2731
class updates(modules.Module):
2832

@@ -575,28 +579,26 @@ def check_updates_v2(self, force=False):
575579
log.log(f'URL: {url}', log.DEBUG)
576580
update_json = oe.load_url(url)
577581
log.log(f'RESULT: {repr(update_json)}', log.DEBUG)
578-
# use system script if available
582+
# use system module if available
579583
if os.path.isfile('/usr/bin/update-system'):
580584
# Discard server response
581585
update_json = None
582586
self.last_update_check = time.time()
583-
update_result = os_tools.execute('/usr/bin/update-system --settingsonly', get_result=True).strip()
584-
if update_result:
585-
log.log(f'update-system result: {update_result}', log.DEBUG)
586-
# Bugfix update found. Notify and automatic update if enabled.
587-
if update_result.startswith('http://') or update_result.startswith('https://'):
588-
log.log(f'Found update: {update_result}', log.INFO)
589-
self.update_file, self.update_checksum = update_result.split(' ')
590-
if self.struct['update']['settings']['UpdateNotify']['value'] == '1':
591-
oe.notify(oe._(32363), oe._(32364))
592-
if self.struct['update']['settings']['AutoUpdate']['value'] == 'auto' and force == False:
593-
self.update_in_progress = True
594-
self.do_autoupdate(None, True)
595-
# Major update found. Notify if enabled but no automatic update.
596-
elif update_result == 'True':
597-
log.log('Major update found.', log.DEBUG)
598-
if self.struct['update']['settings']['UpdateNotify']['value'] == '1':
599-
oe.notify(oe._(32363), oe._(32364))
587+
update_found, update_major, update_url, update_checksum = checker.check_for_update()
588+
if update_found:
589+
if update_url:
590+
log.log(f'Found update: {update_url}', log.INFO)
591+
self.update_file = update_url
592+
if update_checksum:
593+
log.log(f'JSON Update checksum: {update_checksum}', log.DEBUG)
594+
self.update_checksum = update_checksum
595+
# on screen notification
596+
if self.struct['update']['settings']['UpdateNotify']['value'] == '1':
597+
oe.notify(oe._(32363), oe._(32364))
598+
# automatic update if enabled and not a major release
599+
if not update_major and (self.struct['update']['settings']['AutoUpdate']['value'] == 'auto' and force is False):
600+
self.update_in_progress = True
601+
self.do_autoupdate(None, True)
600602
else:
601603
log.log('No update found.', log.DEBUG)
602604
# fallback to server update check

0 commit comments

Comments
 (0)