2121import oe
2222import os_tools
2323
24- if os .path .isfile ('/usr/bin/update-system ' ):
25- update_system = os_tools .import_from_file ('update_system ' , '/usr/bin/update-system ' )
24+ if os .path .isfile ('/usr/lib/libreelec/update_lib.py ' ):
25+ update_lib = os_tools .import_from_file ('update_lib ' , '/usr/lib/libreelec/update_lib.py ' )
2626else :
27- log .log ('No client side update script found; feature will be disabled' , log .DEBUG )
27+ log .log ('No client side update support found; feature disabled' , log .DEBUG )
2828
2929
3030class updates (modules .Module ):
@@ -265,7 +265,7 @@ def load_values(self):
265265 self .update_in_progress = True
266266
267267 # Client Side Update
268- if not os .path .isfile ('/usr/bin/update-system ' ):
268+ if not os .path .isfile ('/usr/lib/libreelec/update_lib.py ' ):
269269 self .struct ['update' ]['settings' ]['ClientSideUpdate' ]['value' ] = '0'
270270 self .struct ['update' ]['settings' ]['ClientSideUpdate' ]['hidden' ] = 'true'
271271 else :
@@ -329,7 +329,7 @@ def set_release_channel(self, listItem):
329329 if 'hidden' in self .struct ['update' ]['settings' ]['AutoUpdate' ]:
330330 del (self .struct ['update' ]['settings' ]['AutoUpdate' ]['hidden' ])
331331 # Client side update only available on stable channel
332- if 'hidden' in self .struct ['update' ]['settings' ]['ClientSideUpdate' ] and os .path .isfile ('/usr/bin/update-system ' ):
332+ if 'hidden' in self .struct ['update' ]['settings' ]['ClientSideUpdate' ] and os .path .isfile ('/usr/lib/libreelec/update_lib.py ' ):
333333 del (self .struct ['update' ]['settings' ]['ClientSideUpdate' ]['hidden' ])
334334 # Only show manual update options if automatic update disabled
335335 if self .struct ['update' ]['settings' ]['AutoUpdate' ]['value' ] == '0' :
@@ -502,6 +502,7 @@ def build_json(self, notify_error=False):
502502 update_json [channel ] = custom_update_json [channel ]
503503 elif notify_error :
504504 ok_window = xbmcgui .Dialog ()
505+ # FIXME localize
505506 answer = ok_window .ok (oe ._ (32191 ), f'Custom URL is invalid, or currently inaccessible.\n \n { custom_url } ' )
506507 if not answer :
507508 return
@@ -579,6 +580,7 @@ def pretty_filename(s):
579580
580581 return build if build else update_files
581582
583+
582584 @log .log_function ()
583585 def check_updates_v2 (self , force = False ):
584586 if self .update_in_progress :
@@ -597,27 +599,35 @@ def check_updates_v2(self, force=False):
597599 if self .struct ['update' ]['settings' ]['ReleaseChannel' ]['value' ] != 'stable' :
598600 log .log ('Not on stable release channel (exit)' , log .DEBUG )
599601 return
600- if os .path .isfile ('/usr/bin/update-system' ) and \
602+ # Client side update
603+ if os .path .isfile ('/usr/lib/libreelec/update_lib.py' ) and \
601604 self .struct ['update' ]['settings' ]['ClientSideUpdate' ]['value' ] == '1' :
602605 # Discard server response
603- update_json = None
606+ del update_json
604607 self .last_update_check = time .time ()
605- client_update_check = update_system .UpdateSystem ()
606- update_available , update_major , update_url , update_checksum = client_update_check .check_for_update ()
607- if update_available :
608- if update_url :
609- log .log (f'Found update: { update_url } ' , log .INFO )
610- self .update_file = update_url
611- if update_checksum :
612- log .log (f'JSON update checksum: { update_checksum } ' , log .DEBUG )
613- self .update_checksum = update_checksum
608+ client_update = update_lib .UpdateSystem (json_data = self .update_json )
609+ # Check for bugfix updates
610+ client_update .check_for_bugfix ()
611+ if not client_update .update_available :
612+ # Check for majro updates
613+ client_update .check_for_major ()
614+ if client_update .update_available :
615+ log .log (f'Found update: { client_update .update_url } ' , log .INFO )
616+ self .update_file = client_update .update_url
617+ log .log (f'Update file checksum: { client_update .candidate ["sha256" ]} ' , log .DEBUG )
618+ self .update_checksum = client_update .candidate ['sha256' ]
614619 # On screen notification
615620 if self .struct ['update' ]['settings' ]['UpdateNotify' ]['value' ] == '1' :
616- oe .notify (oe ._ (32363 ), oe ._ (32364 ))
617- # Automatic update if enabled and not a major release
618- if not update_major and (self .struct ['update' ]['settings' ]['AutoUpdate' ]['value' ] == '1' and force is False ):
621+ if client_update .update_major :
622+ # FIXME localize
623+ oe .notify (oe ._ (32363 ), f'Update available to { oe .DISTRIBUTION } { client_update .candidate ["version_major" ]} . See https://libreelec.tv for details.' )
624+ else :
625+ oe .notify (oe ._ (32363 ), oe ._ (32364 ))
626+ # Bugfix update and autoupdate enabled
627+ if not client_update .update_major and (self .struct ['update' ]['settings' ]['AutoUpdate' ]['value' ] == '1' and force is False ):
619628 self .update_in_progress = True
620629 self .do_autoupdate (True )
630+ # Server side update check
621631 elif update_json :
622632 update_json = json .loads (update_json )
623633 self .last_update_check = time .time ()
@@ -630,6 +640,7 @@ def check_updates_v2(self, force=False):
630640 self .update_in_progress = True
631641 self .do_autoupdate (True )
632642
643+
633644 @log .log_function ()
634645 def do_autoupdate (self , silent = False ):
635646 if self .update_file :
0 commit comments