InteractiveUpgradeHooks

After certain upgrades (most notably upgrades between Ubuntu releases), there are follow-up actions which should be taken by the user. These are not logically part of the upgrade, but should be dealt with at some point after the upgrade is complete.

A prime example is the UTFEightMigrationTool. During an upgrade from WartyWarthog to HoaryHedgehog, the system will be configured such that UTF-8 encoding is available, and will be expected by applications per default. The user should switch to a UTF-8 locale, and possibly rename or re-encode files in order to achieve the best user experience. These things cannot be done in automated fashion during the upgrade, but must instead be dealt with interactively by the user.

Another example is the reboot notification. Packages like the kernel, glibc, dbus and hal require a reboot. To simplify things update-notifier installs a helper script in

/usr/share/update-notifier/notify-reboot-required

that can be called in the packages postinst script (make sure to check for it first). It is i18n-able via langpacks and it will only be shown once.

Original Proposed design

  • Maintainer scripts invoke a program to register a hook (typically a shell script) to be run by the user
  • update-notifier receives these registrations, and notifies the user that they are pending

  • When the user elects to process pending actions, they are executed in sequence within the context of the desktop (and so can display a GUI, interact with the user, etc.)

Design Spec

  • the directory /var/lib/update-notifier/user.d/ is used to store hooks
  • a hook file looks follows rfc822 rules:
    • a fieldname may have a "-$locale" in it. This is for i18n.
    • each hook must have a unique "Name" key and a "Description" key
    • a optional "Priority" with {critical, high, medium, low} that gives the user a idea how important the hook is
    • a optional "Command" field may be registered with a shell-command that the user can run (e.g. a script like /usr/share/package/do-something) note: the command line must be quoted if it contains spaces
    • a optional "Terminal: True" field if the command should be execute in a terminal
    • a optional "DontShowAfterReboot: True" field if the notification should not be shown after a system reboot

    • a optional "DisplayIf" field that contains a shell-command that is used to figure out if the note should be displayed or not. If the command returns 0 the note will be displayed, otherwise it will be ignored

  • update-notifier will use inotify to scan /var/lib/update-notifier/user.d/ and show a small information icon for hooks it has not seen yet
  • when the user clicks on the icon the name and description is given. If a shell script is registered, it asks if it should run that script.
  • the encoding of the i18n fields is UTF-8

Status

  • Basic support implemented in update-notifier 0.38
  • Missing: mtime check of the hook file

Example

_Name: The great UTF-8 Migration
Priority: Medium
Command: bc
Terminal: True
GettextDomain: hwdb-clinet
DisplayIf: shell-command
Title: Change the default title here
DontShowAfterReboot: False
_Description: 
 This command will convert your stuff into UTF-8.
 Use this command if you want a working gnome desktop and you
 feel the world should be a better place.

This is a notification description file as it should be put into a source package. NB the '_' prefix for fields that should be translated. For getting these strings into the package's PO template, you should add a stanza like this to po/POTFILES.in:

[type: gettext/rfc822deb] debian/utf8-migration.installnote

The file should be shipped in /usr/share/packagename and the package's postinst script should install it if the notification should be displayed. At that time it needs to remove the '_' prefixes:

install -d /var/lib/update-notifier/user.d/
sed 's/^_//' /usr/share/utf8-migration-tool/utf8-migration.installnote > /var/lib/update-notifier/user.d/utf8-migration

There are other use-cases where this is useful. The user can be told that he needs to reboot his system after a kernel upgrade. Or relogin when when certain parts of gnome changes etc.

CategoryArchive

InteractiveUpgradeHooks (last edited 2009-09-30 13:32:36 by 10)