Merge lp:~azzar1/update-notifier/livepatch-notification into lp:update-notifier/ubuntu

Proposed by Andrea Azzarone
Status: Merged
Merged at revision: 910
Proposed branch: lp:~azzar1/update-notifier/livepatch-notification
Merge into: lp:update-notifier/ubuntu
Diff against target: 181 lines (+115/-1)
6 files modified
debian/systemd/update-notifier-livepatch.path (+6/-0)
debian/systemd/update-notifier-livepatch.service (+6/-0)
debian/update-notifier.install (+3/-0)
po/POTFILES.in (+1/-0)
src/Makefile.am (+6/-1)
src/livepatch.c (+93/-0)
To merge this branch: bzr merge lp:~azzar1/update-notifier/livepatch-notification
Reviewer Review Type Date Requested Status
Brian Murray Needs Fixing
Sebastien Bacher Needs Information
Review via email: mp+329322@code.launchpad.net

Commit message

Show livepatch notifications using update-notifier.

To post a comment you must log in.
917. By Andrea Azzarone

Fix debian/update-notifier.install

918. By Andrea Azzarone

Trigger the notification on EVENT=create too.

Revision history for this message
Sebastien Bacher (seb128) wrote :

Thank you for your work, it looks good, one minor comment though
_("A LivePatch update
and
_("Canonical Livepatch"

shouldn't the spelling of Live(pP)atch be consistent between those strings?

review: Needs Information
919. By Andrea Azzarone

LivePatch -> Livepatch

Revision history for this message
Andrea Azzarone (azzar1) wrote :

> Thank you for your work, it looks good, one minor comment though
> _("A LivePatch update
> and
> _("Canonical Livepatch"
>
> shouldn't the spelling of Live(pP)atch be consistent between those strings?

Fixed

920. By Andrea Azzarone

Add "usr/bin/livepatch-notification usr/lib/update-notifier/" to update-notifier.install

921. By Andrea Azzarone

Fix path to status file in systemd and upstart file.

Revision history for this message
Brian Murray (brian-murray) wrote :

I've only taken a brief look at this but did not some inconsistencies between LivePatch and Livepatch.

review: Needs Fixing
922. By Andrea Azzarone

LivePatch -> livepatch in sysmted and upstart files too.

Revision history for this message
Andrea Azzarone (azzar1) wrote :

> I've only taken a brief look at this but did not some inconsistencies between
> LivePatch and Livepatch.

Fixed.

Revision history for this message
Brian Murray (brian-murray) wrote :

In Artful we are working on removing upstart jobs from packages and given that this merge proposal is against trunk / artful I don't think the upstart job should included.

If there is a desire to get livepatch support in update-notifier into Ubuntu 16.04 the upstart job doesn't also need to exist in Artful (I say this as an SRU team member).

review: Needs Fixing
923. By Andrea Azzarone

Remove upstart jobs conf files.

Revision history for this message
Andrea Azzarone (azzar1) wrote :

> In Artful we are working on removing upstart jobs from packages and given that
> this merge proposal is against trunk / artful I don't think the upstart job
> should included.
>
> If there is a desire to get livepatch support in update-notifier into Ubuntu
> 16.04 the upstart job doesn't also need to exist in Artful (I say this as an
> SRU team member).

Fixed.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'debian/systemd/update-notifier-livepatch.path'
2--- debian/systemd/update-notifier-livepatch.path 1970-01-01 00:00:00 +0000
3+++ debian/systemd/update-notifier-livepatch.path 2017-08-24 10:15:37 +0000
4@@ -0,0 +1,6 @@
5+[Unit]
6+Description=Path trigger for Livepatch status notifications
7+PartOf=graphical-session.target
8+
9+[Path]
10+PathChanged=/var/snap/canonical-livepatch/current/status
11
12=== added file 'debian/systemd/update-notifier-livepatch.service'
13--- debian/systemd/update-notifier-livepatch.service 1970-01-01 00:00:00 +0000
14+++ debian/systemd/update-notifier-livepatch.service 2017-08-24 10:15:37 +0000
15@@ -0,0 +1,6 @@
16+[Unit]
17+Description=Livepatch status notification
18+
19+[Service]
20+ExecStart=/usr/lib/update-notifier/livepatch-notification
21+Type=oneshot
22
23=== modified file 'debian/update-notifier.install'
24--- debian/update-notifier.install 2016-07-20 15:49:04 +0000
25+++ debian/update-notifier.install 2017-08-24 10:15:37 +0000
26@@ -8,6 +8,7 @@
27 usr/share/GConf/gsettings/update-notifier.convert
28 usr/bin/update-notifier
29 usr/bin/distro-cd-updater usr/lib/update-notifier/
30+usr/bin/livepatch-notification usr/lib/update-notifier/
31 usr/bin/local-avahi-notification usr/lib/update-notifier/
32 usr/bin/system-crash-notification usr/lib/update-notifier/
33 # upstart jobs
34@@ -24,6 +25,8 @@
35 debian/systemd/unicast-local-avahi.service usr/lib/systemd/user
36 debian/systemd/update-notifier-release.path usr/lib/systemd/user
37 debian/systemd/update-notifier-release.service usr/lib/systemd/user
38+debian/systemd/update-notifier-livepatch.path usr/lib/systemd/user
39+debian/systemd/update-notifier-livepatch.service usr/lib/systemd/user
40 # disable upstart job under systemd sessions
41 debian/systemd/unicast-local-avahi.override usr/share/upstart/systemd-session/upstart/
42 debian/systemd/update-notifier-crash.override usr/share/upstart/systemd-session/upstart/
43
44=== modified file 'po/POTFILES.in'
45--- po/POTFILES.in 2013-06-04 17:06:19 +0000
46+++ po/POTFILES.in 2017-08-24 10:15:37 +0000
47@@ -10,6 +10,7 @@
48 src/avahi.c
49 src/cdroms.c
50 src/hooks.c
51+src/livepatch.c
52 src/update.c
53 src/update-notifier.c
54 [type: gettext/glade]ui/hooks-dialog.ui
55
56=== modified file 'src/Makefile.am'
57--- src/Makefile.am 2013-06-03 22:40:21 +0000
58+++ src/Makefile.am 2017-08-24 10:15:37 +0000
59@@ -10,7 +10,8 @@
60 bin_PROGRAMS = update-notifier \
61 distro-cd-updater \
62 local-avahi-notification \
63- system-crash-notification
64+ system-crash-notification \
65+ livepatch-notification
66
67
68
69@@ -39,6 +40,8 @@
70 system_crash_notification_SOURCES = system-crash.c\
71 system-crash.h
72
73+livepatch_notification_SOURCES = livepatch.c
74+
75 update_notifier_LDADD = $(PACKAGE_LIBS) $(INTLLIBS) $(APP_INDICATOR_LIBS)
76 update_notifier_LDFLAGS = -export-dynamic
77
78@@ -47,3 +50,5 @@
79 local_avahi_notification_LDADD = $(PACKAGE_LIBS) $(INTLLIBS)
80
81 system_crash_notification_LDADD = $(PACKAGE_LIBS) $(INTLLIBS)
82+
83+livepatch_notification_LDADD = $(PACKAGE_LIBS) $(INTLLIBS)
84
85=== added file 'src/livepatch.c'
86--- src/livepatch.c 1970-01-01 00:00:00 +0000
87+++ src/livepatch.c 2017-08-24 10:15:37 +0000
88@@ -0,0 +1,93 @@
89+#ifdef HAVE_CONFIG_H
90+#include "config.h"
91+#endif
92+
93+#include <glib.h>
94+#include <libnotify/notify.h>
95+#include <stdlib.h>
96+
97+#include "update-notifier.h"
98+
99+#define STATUS_PATH "/var/snap/canonical-livepatch/current/status"
100+
101+static void
102+init_notification ()
103+{
104+ notify_init ("update-notifier");
105+}
106+
107+static void
108+init_gettext ()
109+{
110+ setlocale (LC_ALL, "");
111+ bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
112+ bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
113+ textdomain (GETTEXT_PACKAGE);
114+}
115+
116+static void
117+show_notification (const char *summary, const char *body, const char *icon)
118+{
119+ NotifyNotification *n = notify_notification_new (summary, body, icon);
120+ notify_notification_set_timeout (n, 60000);
121+ notify_notification_show (n, NULL);
122+ g_object_unref (n);
123+}
124+
125+static void
126+get_event_from_file (const char* filename, char **event, char **description)
127+{
128+ g_autofree gchar *content = NULL;
129+
130+ g_return_if_fail (filename != NULL);
131+ g_return_if_fail (event != NULL);
132+ g_return_if_fail (description != NULL);
133+
134+ *event = *description = NULL;
135+
136+ g_file_get_contents (filename, &content, NULL, NULL);
137+
138+ if (content) {
139+ gchar **strings = g_strsplit (content, " ", 2);
140+
141+ if (g_strv_length (strings) > 0)
142+ *event = g_strdup (g_strstrip (strings[0]));
143+ if (g_strv_length (strings) > 1)
144+ *description = g_strdup (g_strstrip (strings[1]));
145+
146+ g_strfreev (strings);
147+ }
148+}
149+
150+static void
151+show_status_notification ()
152+{
153+ if (g_file_test (STATUS_PATH, G_FILE_TEST_EXISTS))
154+ {
155+ g_autofree gchar *event, *description;
156+ get_event_from_file (STATUS_PATH, &event, &description);
157+
158+ if (!g_strcmp0 (event, "applied")) {
159+ g_autofree gchar *body = NULL;
160+
161+ if (!g_strcmp0 (description, "1")) {
162+ body = g_strdup_printf (_("A Livepatch update has been sucessfully applied"));
163+ } else {
164+ body = g_strdup_printf (_("%s Livepatch updates have been sucessfully applied"), description);
165+ }
166+
167+ show_notification (_("Canonical Livepatch"), body, NULL);
168+ }
169+ }
170+}
171+
172+int
173+main (int argc, char **argv)
174+{
175+ init_notification ();
176+ init_gettext ();
177+
178+ show_status_notification ();
179+
180+ return EXIT_SUCCESS;
181+}

Subscribers

People subscribed via source and target branches

to all changes: