~ubuntu-core-dev/update-notifier/ubuntu

299 by Michael Vogt
* HOOKS: added documentation for the hooks
1
After certain upgrades (most notably upgrades between Ubuntu
2
releases), there are follow-up actions which should be taken by the
3
user. These are not logically part of the upgrade, but should be dealt
4
with at some point after the upgrade is complete.
5
6
A prime example is the UTF8MigrationTool. During an upgrade from
7
WartyWarthog to HoaryHedgehog, the system will be configured such that
8
UTF-8 encoding is available, and will be expected by applications per
9
default. The user should switch to a UTF-8 locale, and possibly rename
10
or re-encode files in order to achieve the best user experience. These
11
things cannot be done in automated fashion during the upgrade, but
12
must instead be dealt with interactively by the user.
13
14
Another example is the reboot notification. Packages like the kernel,
15
glibc, dbus and hal require a reboot. To simplify things
16
update-notifier installs a helper script in
17
18
/usr/share/update-notifier/notify-reboot-required
19
20
that can be called in the packages postinst script (make sure to check
21
for it first). It is i18n-able via langpacks and it will only be shown
22
once.  
23
24
Design:
25
 * Maintainer scripts create/copy a notification to
26
   /var/lib/update-notifier/user.d
27
 * update-notifier checks for those after each apt invocation (when
28
   /var/lib/update-notifier/dpkg-was-run changed) and notifies the user
29
   that they are pending
30
 * When the user selects to process pending actions, they are executed
31
   in sequence within the context of the user and the desktop (and so
32
   can display a GUI, interact with the user, etc.)
33
34
Details:
35
 * the directory /var/lib/update-notifier/user.d/ is used to store hooks
36
 * a hook file looks follows rfc822 rules:
37
   - a fieldname may have a "-$locale" in it. This is for i18n.
38
   - if "GettextDomain" is found, dgettext() will also be tried to get a
39
     i18n string (for langpacks)
40
   - each hook must have a unique "Name" key and a "Description" key
41
   - a optional "Priority" with {crititcal, high, medium, low} that
42
     gives the user a idea how importend the hook is (currently not used) 
43
   - a optional "Command" field may be registered with a shell-command
44
     that the user can run (e.g. a script like /usr/share/package/do-something)
45
   - a optional "Terminal: True" field if the command should be
46
     execute in a terminal
47
   - update-notifier uses inotify to monitor
48
     /var/lib/update-notifier/dpkg-was-run and
49
     /var/lib/update-notifier/user.d/ and show a small information icon for
50
     hooks it has not seen yet
51
   - when the user clicks on the icon the name and description is
52
     given. If a shell script is registered a button is displayed that will
53
     run the script. the description in the hook should explain what the
54
     script will do
55
   - the encoding of the i18n fields is UTF-8
56
   - the optional key "DontShowAfterReboot" will make sure that the 
57
     notification is not shown when the system rebootet since it was 
58
     created/refreshed 
59
   - the optional key "DisplayIf" will run a shell command (system())
60
     to figure out if the note should be displayed or not. If the command
61
     returns 0 the note will be displayed, otherwise it will be ignored
388 by Michael Vogt
* src/hooks.c:
62
   - the optional key "OnlyAdminUsers" controls if the note is shown to all
63
     users or only to the admin users (users in the admin group). the
64
     default is "OnlyAdminsUsers=true".
299 by Michael Vogt
* HOOKS: added documentation for the hooks
65
66
Example
67
68
Name: The great UTF-8 Migration
69
Name-de_DE: Die grosse UTF-8 Migration
70
Priority: Medium
71
Command: utf8-migration-assistant
72
Terminal: True
73
GettextDomain: utf8-migration-assistant
74
DisplayIf: shell-command
388 by Michael Vogt
* src/hooks.c:
75
OnlyAdminUsers: False
299 by Michael Vogt
* HOOKS: added documentation for the hooks
76
Description: This command will convert your stuff into UTF-8.
77
 Use this command if you want a working gnome desktop and you
78
 feel the world should be a better place.
79