Merge branch 'uu_test' into 'backend_uu'
Uu test See merge request kylin-desktop/update-manager-group/kylin-system-updater!446
This commit is contained in:
commit
64f1cd1390
|
@ -533,10 +533,19 @@ class KylinBackupManager:
|
|||
|
||||
def ConnectToSignals(self):
|
||||
def backup_start_handler(result):
|
||||
logging.debug("backup start result:%d"%result)
|
||||
if result == 31 or result == 30:
|
||||
logging.debug("backup start success")
|
||||
else:
|
||||
logging.error("backup start failed")
|
||||
UpdateInfos = {}
|
||||
UpdateInfos.update({"packageName":""})
|
||||
UpdateInfos.update({"source":"kylin unattended upgrade"})
|
||||
UpdateInfos.update({"status":0})
|
||||
UpdateInfos.update({"errorCode":"backup start failed"})
|
||||
json_file = json.dumps(UpdateInfos.copy())
|
||||
UpdateInfos.clear()
|
||||
kylin_system_updater.DataBackendCollect("UpdateInfos",json_file)
|
||||
WriteValueToFile(UNATTENDED_UPGRADE_CONFIG_FILE_PATH,"UNATTENDED_UPGRADE","autoupdate_run_status","idle")
|
||||
os._exit(1)
|
||||
|
||||
|
@ -546,6 +555,14 @@ class KylinBackupManager:
|
|||
self.loop.quit()
|
||||
else:
|
||||
logging.error("backup failed")
|
||||
UpdateInfos = {}
|
||||
UpdateInfos.update({"packageName":""})
|
||||
UpdateInfos.update({"source":"kylin unattended upgrade"})
|
||||
UpdateInfos.update({"status":0})
|
||||
UpdateInfos.update({"errorCode":"backup failed"})
|
||||
json_file = json.dumps(UpdateInfos.copy())
|
||||
UpdateInfos.clear()
|
||||
kylin_system_updater.DataBackendCollect("UpdateInfos",json_file)
|
||||
WriteValueToFile(UNATTENDED_UPGRADE_CONFIG_FILE_PATH,"UNATTENDED_UPGRADE","autoupdate_run_status","idle")
|
||||
subprocess.Popen('dbus-send --system --type=signal / com.kylin.install.notification.BackupFailure',shell=True)
|
||||
os._exit(1)
|
||||
|
@ -2657,6 +2674,7 @@ def main(options, rootdir="/"):
|
|||
config_to_result.set("OTA","upgrade","1")
|
||||
if not os.path.exists(OTA_RESULT_FILE_PATH):
|
||||
os.makedirs(OTA_RESULT_FILE_PATH)
|
||||
|
||||
if not os.path.exists(OTA_RESULT_FILE):
|
||||
f = open(OTA_RESULT_FILE,'w')
|
||||
f.close()
|
||||
|
@ -3038,7 +3056,7 @@ def run(options, # type: Options
|
|||
insmod = ReadValueFromFile("/var/lib/unattended-upgrades/unattended-upgrades-policy.conf","autoUpgradePolicy","installmode")
|
||||
if fetcher_statistics.incomplete_pkg_amount == 0 and len(pkgs_to_upgrade) > 0:
|
||||
if os_release_info['PROJECT_CODENAME'] == 'V10SP1-edu' and os_release_info['SUB_PROJECT_CODENAME']=='mavis':
|
||||
docker_image_fetch_result = None
|
||||
docker_image_fetch_result = 0
|
||||
#docker image fetch for mavis and laika
|
||||
if os.path.exists("/usr/bin/service_runtime_ota.sh"):
|
||||
docker_image_fetch_result = subprocess.run(["/usr/bin/service_runtime_ota.sh"], shell=True)
|
||||
|
@ -3046,13 +3064,13 @@ def run(options, # type: Options
|
|||
logging.info("all pkgs downloaded")
|
||||
else:
|
||||
return UnattendedUpgradesResult(False,_("docker fetch failed"))
|
||||
# logging.info("pkg number:%d,shutdown delay time:%d s"%(len(pkgs),30*len(pkgs)))
|
||||
logging.info("pkg number:%d"%(len(pkgs)))
|
||||
login_manager.SetExtraInhibitShutdownDelaySec(1800)
|
||||
configfilemanager.AddFileName("OTA_PKGS_TO_INSTALL")
|
||||
subprocess.Popen('dbus-send --system --type=signal / com.kylin.update.notification.DownloadFinish', shell=True)
|
||||
kylin_system_updater.SetConfigValue('InstallMode','auto_install','True')
|
||||
elif insmod == 'bshutdown':
|
||||
# logging.info("pkg number:%d,shutdown delay time:%d s"%(len(pkgs),30*len(pkgs)))
|
||||
logging.info("pkg number:%d"%(len(pkgs)))
|
||||
login_manager.SetExtraInhibitShutdownDelaySec(1800)
|
||||
configfilemanager.AddFileName("OTA_PKGS_TO_INSTALL")
|
||||
kylin_system_updater.SetConfigValue('InstallMode','auto_install','True')
|
||||
|
|
|
@ -244,7 +244,7 @@ def log_progress():
|
|||
"please don't turn off the computer")
|
||||
'''
|
||||
# progress info
|
||||
progress_file = "/var/run/kylin-unattended-upgrades.progress"
|
||||
progress_file = PROGRESS_LOG
|
||||
if os.path.exists(progress_file):
|
||||
progress_text = open(progress_file).read()
|
||||
logging.debug("progress text content %s"%progress_text)
|
||||
|
@ -338,10 +338,11 @@ class UnattendedUpgradesShutdown():
|
|||
self.download_mode = ReadValueFromFile(UNATTENDED_UPGRADE_POLICY_FILE_PATH, POLICY_CONF_SECTION_AUTO_UPGRADE_POLICY, AUTO_UPGRADE_POLICY_OPTION_DOWNLOAD_MODE)
|
||||
self.install_mode = ReadValueFromFile(UNATTENDED_UPGRADE_POLICY_FILE_PATH, POLICY_CONF_SECTION_AUTO_UPGRADE_POLICY, AUTO_UPGRADE_POLICY_OPTION_INSTALL_MODE)
|
||||
download_time = ReadValueFromFile(UNATTENDED_UPGRADE_POLICY_FILE_PATH, POLICY_CONF_SECTION_AUTO_UPGRADE_POLICY, AUTO_UPGRADE_POLICY_OPTION_DOWNLOAD_TIME)
|
||||
self.download_random = int(kylin_system_updater.GetConfigValue('InstallMode','downloadRandom')[1])
|
||||
self.upgrade_interval = int(kylin_system_updater.GetConfigValue('InstallMode','upgradeInterval')[1])
|
||||
self.download_random = int(kylin_system_updater.GetConfigValue('AutoUpgradeConfig','downloadRandom')[1])
|
||||
self.upgrade_interval = int(kylin_system_updater.GetConfigValue('AutoUpgradeConfig','upgradeInterval')[1])
|
||||
logging.info("download random:%s,upgrade interval:%s"%(self.download_random,self.upgrade_interval))
|
||||
# upgradeInterval = int(ReadValueFromFile(UNATTENDED_UPGRADE_POLICY_FILE_PATH, POLICY_CONF_SECTION_AUTO_UPGRADE_POLICY, 'upgradeInverval'))
|
||||
'''
|
||||
if os_release_info['PROJECT_CODENAME'] == 'V10SP1-edu' and os_release_info['SUB_PROJECT_CODENAME']=='mavis':
|
||||
self.download_time['h'] = 10
|
||||
self.download_time['m'] = 0
|
||||
|
@ -350,7 +351,7 @@ class UnattendedUpgradesShutdown():
|
|||
self.download_time_r['h'], self.download_time_r['m'],self.preDownload, self.autoUpgrade, \
|
||||
self.download_mode, self.install_mode)
|
||||
return
|
||||
|
||||
'''
|
||||
timelist = download_time.strip().split(':')
|
||||
if len(timelist) != TimeElement.TIME_NUM:
|
||||
logging.debug("unattended-upgrades-policy.conf time err %s",download_time)
|
||||
|
@ -618,22 +619,33 @@ class UnattendedUpgradesShutdown():
|
|||
self.install_mode = ReadValueFromFile(UNATTENDED_UPGRADE_POLICY_FILE_PATH, POLICY_CONF_SECTION_AUTO_UPGRADE_POLICY, AUTO_UPGRADE_POLICY_OPTION_INSTALL_MODE)
|
||||
self.preDownload = ReadValueFromFile(UNATTENDED_UPGRADE_POLICY_FILE_PATH, POLICY_CONF_SECTION_AUTO_UPGRADE_POLICY, AUTO_UPGRADE_POLICY_OPTION_PREDOWNLOAD)
|
||||
self.autoUpgrade = ReadValueFromFile(UNATTENDED_UPGRADE_POLICY_FILE_PATH, POLICY_CONF_SECTION_AUTO_UPGRADE_POLICY, AUTO_UPGRADE_POLICY_OPTION_AUTOUPGRADE)
|
||||
self.download_random = int(kylin_system_updater.GetConfigValue('InstallMode','downloadRandom')[1])
|
||||
self.upgrade_interval = int(kylin_system_updater.GetConfigValue('InstallMode','upgradeInterval')[1])
|
||||
self.download_random = int(kylin_system_updater.GetConfigValue('AutoUpgradeConfig','downloadRandom')[1])
|
||||
self.upgrade_interval = int(kylin_system_updater.GetConfigValue('AutoUpgradeConfig','upgradeInterval')[1])
|
||||
download_time = ReadValueFromFile(UNATTENDED_UPGRADE_POLICY_FILE_PATH, POLICY_CONF_SECTION_AUTO_UPGRADE_POLICY, AUTO_UPGRADE_POLICY_OPTION_DOWNLOAD_TIME)
|
||||
timelist = download_time.strip().split(':')
|
||||
if len(timelist) != TimeElement.TIME_NUM:
|
||||
logging.debug("unattended-upgrades-policy.conf time err %s",download_time)
|
||||
return
|
||||
# 检查 传入时间 安全性
|
||||
try:
|
||||
tmphour = int(timelist[TimeElement.TIME_HOUR])
|
||||
except ValueError:
|
||||
logging.debug("unattended-upgrades-policy.conf download_time h error")
|
||||
return
|
||||
try:
|
||||
tmpminute = int(timelist[TimeElement.TIME_MINUTE])
|
||||
except ValueError:
|
||||
logging.debug("unattended-upgrades-policy.conf download_time m error")
|
||||
return
|
||||
|
||||
self.download_time['h'] = tmphour
|
||||
self.download_time['m'] = tmpminute
|
||||
self.download_time_r = convert_time_by_random(self.download_time, self.download_random)
|
||||
self.install_time['h'] = self.download_time_r['h']
|
||||
self.install_time['m'] = self.download_time_r['m'] + INTERVAL_DOWN_INSTALL
|
||||
self.install_time_r = convert_time_by_random(self.install_time, INSTALL_RANDOM)
|
||||
'''
|
||||
logging.info("download random:%d,upgrade interval:%d"%(self.download_random,self.upgrade_interval))
|
||||
if self.autoUpgrade == FeatureSwitch.OFF.value:
|
||||
logging.info("auto upgrade turned off,removing download and instal jobs...")
|
||||
try:
|
||||
if self.download_job is not None:
|
||||
self.download_job.remove()
|
||||
except Exception as e:
|
||||
logging.error(e)
|
||||
try:
|
||||
if self.install_job is not None:
|
||||
self.install_job.remove()
|
||||
except Exception as e:
|
||||
logging.error(e)
|
||||
return
|
||||
|
||||
if self.preDownload == FeatureSwitch.ON.value: #open download timing
|
||||
download_time_tmp = ReadValueFromFile(UNATTENDED_UPGRADE_POLICY_FILE_PATH, POLICY_CONF_SECTION_AUTO_UPGRADE_POLICY, AUTO_UPGRADE_POLICY_OPTION_DOWNLOAD_TIME)
|
||||
|
@ -662,41 +674,79 @@ class UnattendedUpgradesShutdown():
|
|||
logging.error(e)
|
||||
logging.info("pre-download time:%d:%d"%(self.download_time_r['h'], self.download_time_r['m']))
|
||||
self.download_job = self.scheduler.add_job(self.timing_download, 'cron', hour=self.download_time_r['h'], minute=self.download_time_r['m'])
|
||||
elif self.preDownload == FeatureSwitch.OFF.value:
|
||||
pass
|
||||
|
||||
else: #close download timing
|
||||
try:
|
||||
self.download_job.pause()
|
||||
except Exception as e:
|
||||
logging.error(e)
|
||||
'''
|
||||
|
||||
if self.autoUpgrade == FeatureSwitch.OFF.value:
|
||||
logging.info("auto upgrade turned off,removing download and instal jobs...")
|
||||
try:
|
||||
if self.download_job.pending:
|
||||
self.download_job.remove()
|
||||
except Exception as e:
|
||||
pass
|
||||
# logging.error(e)
|
||||
try:
|
||||
if self.install_job.pending:
|
||||
self.install_job.remove()
|
||||
except Exception as e:
|
||||
pass
|
||||
# logging.error(e)
|
||||
return
|
||||
else:
|
||||
if self.download_mode == DownloadMode.TIMING_DOWNLOAD.value:
|
||||
try:
|
||||
if self.download_job.pending:
|
||||
self.download_job.remove()
|
||||
except Exception as e:
|
||||
pass
|
||||
# logging.error(e)
|
||||
logging.info("download time:%d:%d"%(self.download_time_r['h'], self.download_time_r['m']))
|
||||
self.download_job = self.scheduler.add_job(self.timing_download, 'cron', hour=self.download_time_r['h'], minute=self.download_time_r['m'])
|
||||
else:
|
||||
try:
|
||||
if self.download_job.pending:
|
||||
self.download_job.remove()
|
||||
except Exception as e:
|
||||
pass
|
||||
# logging.error(e)
|
||||
|
||||
if self.install_mode == InstallMode.TIMING_INSTALL.value: #open install timing
|
||||
self.install_time['h'] = self.download_time_r['h']
|
||||
self.install_time['m'] = self.download_time_r['m'] + INTERVAL_DOWN_INSTALL
|
||||
self.install_time_r = convert_time_by_random(self.install_time, INSTALL_RANDOM)
|
||||
try:
|
||||
if self.install_job is not None:
|
||||
self.install_job.remove()
|
||||
except Exception as e:
|
||||
logging.error(e)
|
||||
logging.info("install time:%d:%d"%(self.install_time_r['h'], self.install_time_r['m']))
|
||||
self.install_job = self.scheduler.add_job(self.timing_install, 'cron', hour=self.install_time_r['h'], minute=self.install_time_r['m'])
|
||||
elif self.install_mode == InstallMode.BEFORE_SHUTDOWN_INSTALL.value:
|
||||
try:
|
||||
if self.install_job is not None:
|
||||
self.install_job.remove()
|
||||
except Exception as e:
|
||||
logging.error(e)
|
||||
if self.install_mode == InstallMode.TIMING_INSTALL.value:
|
||||
try:
|
||||
if self.install_job.pending:
|
||||
self.install_job.remove()
|
||||
except Exception as e:
|
||||
pass
|
||||
# logging.error(e)
|
||||
logging.info("install time:%d:%d"%(self.install_time_r['h'], self.install_time_r['m']))
|
||||
self.install_job = self.scheduler.add_job(self.timing_install, 'cron', hour=self.install_time_r['h'], minute=self.install_time_r['m'])
|
||||
elif self.install_mode == InstallMode.BEFORE_SHUTDOWN_INSTALL.value:
|
||||
try:
|
||||
if self.install_job.pending:
|
||||
self.install_job.remove()
|
||||
except Exception as e:
|
||||
pass
|
||||
# logging.error(e)
|
||||
logging.debug("install job removed,installation will conduct before shutdown")
|
||||
else: #close install timing
|
||||
try:
|
||||
self.install_job.pause()
|
||||
except Exception as e:
|
||||
logging.error(e)
|
||||
|
||||
|
||||
else: #close install timing
|
||||
try:
|
||||
if self.download_job.pending:
|
||||
self.install_job.remove()
|
||||
except Exception as e:
|
||||
pass
|
||||
# logging.error(e)
|
||||
|
||||
'''
|
||||
logging.info("upgrade time: [%d:%d] [%d:%d] predown[%s] autoupgrade[%s] d-mode[%s] i-mode[%s]",
|
||||
self.download_time_r['h'], self.download_time_r['m'],self.install_time_r['h'],self.install_time_r['m'],
|
||||
self.preDownload, self.autoUpgrade, self.download_mode, self.install_mode)
|
||||
|
||||
'''
|
||||
else:
|
||||
logging.debug("unattended-upgrades-policy.conf not exist")
|
||||
|
||||
|
@ -732,7 +782,7 @@ class UnattendedUpgradesShutdown():
|
|||
self.start_iterations()
|
||||
logging.info("finished iteration")
|
||||
elif autoUpgrade == FeatureSwitch.ON.value and self.install_mode == InstallMode.BEFORE_SHUTDOWN_INSTALL.value:
|
||||
if self.update_interface.GetConfigValue('InstallMode','shutdown_install'):
|
||||
if self.update_interface.GetConfigValue('AutoUpgradeConfig','shutdown_install'):
|
||||
#show plymouth splash if bsshutdown is set
|
||||
if os.path.exists(PKGS_TO_INSTALL_FLAG_FILE):
|
||||
do_plymouth_splash()
|
||||
|
@ -772,7 +822,7 @@ class UnattendedUpgradesShutdown():
|
|||
# starting final iterations immediately
|
||||
logging.debug("Skip waiting for signals, starting operation "
|
||||
"now")
|
||||
self.start_iterations()
|
||||
# self.start_iterations()
|
||||
|
||||
if os_release_info['PROJECT_CODENAME'] == 'V10SP1-edu' and os_release_info['SUB_PROJECT_CODENAME']=='mavis':
|
||||
logging.info("setting startup download timer")
|
||||
|
|
Loading…
Reference in New Issue