|
23 | 23 | import oeWindows |
24 | 24 | import os_tools |
25 | 25 |
|
| 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 | + |
26 | 30 |
|
27 | 31 | class updates(modules.Module): |
28 | 32 |
|
@@ -575,28 +579,26 @@ def check_updates_v2(self, force=False): |
575 | 579 | log.log(f'URL: {url}', log.DEBUG) |
576 | 580 | update_json = oe.load_url(url) |
577 | 581 | log.log(f'RESULT: {repr(update_json)}', log.DEBUG) |
578 | | - # use system script if available |
| 582 | + # use system module if available |
579 | 583 | if os.path.isfile('/usr/bin/update-system'): |
580 | 584 | # Discard server response |
581 | 585 | update_json = None |
582 | 586 | 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) |
600 | 602 | else: |
601 | 603 | log.log('No update found.', log.DEBUG) |
602 | 604 | # fallback to server update check |
|
0 commit comments