Commit a4c0d0ce authored by Alan's avatar Alan

ASP: don't show install notifications on upgrade

Will-fix: #15879
parent 268e3f78
......@@ -483,8 +483,11 @@ def apt_hook_post():
handle_removed_packages(additional_packages_removed)
def install_additional_packages(ignore_old_apt_lists=False):
"""Subcommand which activates and installs all additional packages."""
def install_additional_packages(upgrade_mode=False):
"""Subcommand which activates and installs all additional packages.
If upgrade_mode is True, don't attempt to restore old apt lists and don't
notify the user using desktop notifications."""
logging.info("Starting to install additional software...")
if not has_additional_packages_list():
......@@ -498,7 +501,7 @@ def install_additional_packages(ignore_old_apt_lists=False):
# installation step below in this function will fail. To avoid
# that, we restore the old APT lists: there are greater chances
# that the APT packages cache still has the corresponding packages.
if os.path.isdir(OLD_APT_LISTS_DIR) and not ignore_old_apt_lists:
if os.path.isdir(OLD_APT_LISTS_DIR) and not upgrade_mode:
logging.warn("Found a copy of old APT lists, restoring it.")
try:
restore_old_apt_lists()
......@@ -516,7 +519,8 @@ def install_additional_packages(ignore_old_apt_lists=False):
if not packages:
logging.warn("Warning: no packages to install, exiting")
return True
installing_notification_id = _notify(
if not upgrade_mode:
installing_notification_id = _notify(
_("Installing your additional software from persistent "
"storage..."),
_("This can take several minutes."),
......@@ -528,22 +532,25 @@ def install_additional_packages(ignore_old_apt_lists=False):
"--option", "DPkg::Options::=--force-confold",
"install"] + list(packages))
if apt_get_returncode:
_close_notification(installing_notification_id)
logging.warn("Warning: installation of %s failed" % " ".join(packages))
_notify_failure(_("The installation of your additional software "
"failed"))
if not upgrade_mode:
_close_notification(installing_notification_id)
_notify_failure(_("The installation of your additional software "
"failed"))
return False
else:
logging.info("Installation completed successfully.")
_close_notification(installing_notification_id)
# XXX: there should be a "Configure" button in this notification.
# However, the easy way to implement it makes this process not return
# until the notification is clicked. The notification process could be
# detached, and handle the "configure" action itself.
# if _notify(_("Additional software installed successfully"),
# accept_label=_("Configure")):
# show_configuration_window()
_notify(_("Additional software installed successfully"))
if not upgrade_mode:
_close_notification(installing_notification_id)
# XXX: there should be a "Configure" button in this notification.
# However, the easy way to implement it makes this process not
# return until the notification is clicked. The notification
# process could be detached, and handle the "configure" action
# itself.
# if _notify(_("Additional software installed successfully"),
# accept_label=_("Configure")):
# show_configuration_window()
_notify(_("Additional software installed successfully"))
return True
......@@ -569,7 +576,7 @@ def upgrade_additional_packages():
"restart Tails, or read the system log to "
"understand the problem."))
return False
if install_additional_packages(ignore_old_apt_lists=True):
if install_additional_packages(upgrade_mode=True):
logging.info("The upgrade was successful.")
else:
_notify_failure(_("The upgrade of your additional software failed"),
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment