2 # -*- coding: utf-8 -*-
4 # Copyright (C) 2013 Team-XBMC
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
23 from lib
.common
import log
, dialog_yesno
24 from lib
.common
import upgrade_message
as _upgrademessage
25 from lib
.common
import upgrade_message2
as _upgrademessage2
27 __addon__
= lib
.common
.__addon
__
28 __addonversion__
= lib
.common
.__addonversion
__
29 __addonname__
= lib
.common
.__addonname
__
30 __addonpath__
= lib
.common
.__addonpath
__
31 __icon__
= lib
.common
.__icon
__
39 if xbmc
.getCondVisibility('System.Platform.Linux') and __addon__
.getSetting("upgrade_apt") == 'true':
41 _versionchecklinux(packages
)
43 oldversion
, version_installed
, version_available
, version_stable
= _versioncheck()
45 _upgrademessage2( version_installed
, version_available
, version_stable
, oldversion
, False)
49 from lib
.jsoninterface
import get_installedversion
, get_versionfilelist
50 from lib
.versions
import compare_version
51 # retrieve versionlists from supplied version file
52 versionlist
= get_versionfilelist()
53 # retrieve version installed
54 version_installed
= get_installedversion()
55 # copmpare installed and available
56 oldversion
, version_installed
, version_available
, version_stable
= compare_version(version_installed
, versionlist
)
57 return oldversion
, version_installed
, version_available
, version_stable
60 def _versionchecklinux(packages
):
61 if platform
.dist()[0].lower() in ['ubuntu', 'debian', 'linuxmint']:
66 from lib
.aptdeamonhandler
import AptdeamonHandler
67 handler
= AptdeamonHandler()
70 # since we need the user password, ask to check for new version first
71 from lib
.shellhandlerapt
import ShellHandlerApt
73 handler
= ShellHandlerApt(sudo
)
74 if dialog_yesno(32015):
76 elif dialog_yesno(32009, 32010):
77 log("disabling addon by user request")
78 __addon__
.setSetting("versioncheck_enable", 'false')
82 if handler
.check_upgrade_available(packages
[0]):
83 if _upgrademessage(32012, oldversion
, True):
84 if __addon__
.getSetting("upgrade_system") == "false":
85 result
= handler
.upgrade_package(packages
[0])
87 result
= handler
.upgrade_system()
89 from lib
.common
import message_upgrade_success
, message_restart
90 message_upgrade_success()
93 log("Error during upgrade")
95 log("Error: no handler found")
97 log("Unsupported platform %s" %platform
.dist()[0])
102 if (__name__
== "__main__"):
103 log('Version %s started' % __addonversion__
)