564
by Michael Vogt
reboot in /var/run/reboot-required.pkgs (LP: #538253) |
1 |
#ifdef HAVE_CONFIG_H
|
2 |
#include "config.h" |
|
3 |
#endif
|
|
4 |
||
5 |
#include <glib.h> |
|
6 |
#include <glib-object.h> |
|
7 |
||
8 |
#include <sys/types.h> |
|
9 |
#include <sys/wait.h> |
|
10 |
#include <time.h> |
|
11 |
||
12 |
#include "update-notifier.h" |
|
13 |
||
569
by Michael Vogt
src/release.c: add --devel-release option |
14 |
extern gboolean DEVEL_RELEASE; |
15 |
||
568
by Michael Vogt
add --debug-new-release-check |
16 |
static inline void |
17 |
g_debug_release(const char *msg, ...) |
|
18 |
{
|
|
19 |
va_list va; |
|
20 |
va_start(va, msg); |
|
21 |
g_logv("release",G_LOG_LEVEL_DEBUG, msg, va); |
|
22 |
va_end(va); |
|
23 |
}
|
|
24 |
||
751
by Brian Murray
Switch from using gksu for apport crashes to pkexec (LP: #1098235) |
25 |
// actually show the notification
|
564
by Michael Vogt
reboot in /var/run/reboot-required.pkgs (LP: #538253) |
26 |
static gboolean |
27 |
check_new_release(gpointer user_data) |
|
28 |
{
|
|
568
by Michael Vogt
add --debug-new-release-check |
29 |
g_debug_release ("check_new_release"); |
564
by Michael Vogt
reboot in /var/run/reboot-required.pkgs (LP: #538253) |
30 |
|
630.1.4
by Michael Terry
convert to gsettings |
31 |
GSettings *settings = (GSettings*)user_data; |
751
by Brian Murray
Switch from using gksu for apport crashes to pkexec (LP: #1098235) |
32 |
|
564
by Michael Vogt
reboot in /var/run/reboot-required.pkgs (LP: #538253) |
33 |
time_t now = time(NULL); |
630.1.4
by Michael Terry
convert to gsettings |
34 |
time_t last_check = (time_t)g_settings_get_uint(settings, |
35 |
SETTINGS_KEY_LAST_RELEASE_CHECK); |
|
564
by Michael Vogt
reboot in /var/run/reboot-required.pkgs (LP: #538253) |
36 |
|
37 |
// test if we need to run
|
|
38 |
if ( (last_check + RELEASE_UPGRADE_CHECK_WAIT) > now ) { |
|
568
by Michael Vogt
add --debug-new-release-check |
39 |
g_debug_release ("release upgrade check not needed (%i > %i)", last_check + RELEASE_UPGRADE_CHECK_WAIT, now); |
564
by Michael Vogt
reboot in /var/run/reboot-required.pkgs (LP: #538253) |
40 |
return TRUE; |
41 |
}
|
|
42 |
||
43 |
// run the checker
|
|
930
by Brian Murray
releasing package update-notifier version 3.192.1 |
44 |
gchar *argv[10] = { "/bin/sh", "-c", RELEASE_UPGRADE_CHECKER, }; |
569
by Michael Vogt
src/release.c: add --devel-release option |
45 |
if (DEVEL_RELEASE) { |
46 |
g_debug_release ("running the release upgrade checker %s in devel mode", RELEASE_UPGRADE_CHECKER); |
|
930
by Brian Murray
releasing package update-notifier version 3.192.1 |
47 |
argv[3] = "--devel-release"; |
48 |
argv[4] = NULL; |
|
569
by Michael Vogt
src/release.c: add --devel-release option |
49 |
} else { |
50 |
g_debug_release ("running the release upgrade checker %s", RELEASE_UPGRADE_CHECKER); |
|
930
by Brian Murray
releasing package update-notifier version 3.192.1 |
51 |
argv[3] = NULL; |
569
by Michael Vogt
src/release.c: add --devel-release option |
52 |
}
|
564
by Michael Vogt
reboot in /var/run/reboot-required.pkgs (LP: #538253) |
53 |
g_spawn_async ("/", argv, NULL, 0, NULL, NULL, NULL, NULL); |
54 |
||
55 |
// and update the timestamp so we don't check again too soon
|
|
630.1.4
by Michael Terry
convert to gsettings |
56 |
g_settings_set_uint(settings, SETTINGS_KEY_LAST_RELEASE_CHECK, (guint)now); |
564
by Michael Vogt
reboot in /var/run/reboot-required.pkgs (LP: #538253) |
57 |
|
58 |
return TRUE; |
|
59 |
}
|
|
60 |
||
61 |
gboolean
|
|
62 |
release_checker_init (UpgradeNotifier *un) |
|
63 |
{
|
|
568
by Michael Vogt
add --debug-new-release-check |
64 |
g_debug_release ("release_checker_init"); |
564
by Michael Vogt
reboot in /var/run/reboot-required.pkgs (LP: #538253) |
65 |
|
570
by Michael Vogt
add --force-release-check |
66 |
// check once at startup
|
750.1.1
by Colin Watson
Only create a single GSettings instance for com.ubuntu.update-notifier, |
67 |
check_new_release (un->settings); |
564
by Michael Vogt
reboot in /var/run/reboot-required.pkgs (LP: #538253) |
68 |
// release upgrades happen not that frequently, we use two timers
|
570
by Michael Vogt
add --force-release-check |
69 |
// check every 10 min if 48h are reached and then run
|
564
by Michael Vogt
reboot in /var/run/reboot-required.pkgs (LP: #538253) |
70 |
// "check-release-upgrade-gtk" again
|
750.1.1
by Colin Watson
Only create a single GSettings instance for com.ubuntu.update-notifier, |
71 |
g_timeout_add_seconds (60*10, check_new_release, un->settings); |
564
by Michael Vogt
reboot in /var/run/reboot-required.pkgs (LP: #538253) |
72 |
|
73 |
return TRUE; |
|
74 |
}
|