diff -Nru libnotify-0.7.6/debian/changelog libnotify-0.7.6/debian/changelog --- libnotify-0.7.6/debian/changelog 2015-02-16 04:03:37.000000000 -0600 +++ libnotify-0.7.6/debian/changelog 2018-11-09 04:16:09.000000000 -0600 @@ -1,3 +1,10 @@ +libnotify (0.7.6-2svn1~ubuntu16.04.1) UNRELEASED; urgency=medium + + * d/p/ubuntu/notification-use-snap-namespace-and-prefix-when-launched.patch: + - Update paths when running inside a snap environment (LP: #1802483) + + -- Marco Trevisan (TreviƱo) Fri, 09 Nov 2018 04:16:09 -0600 + libnotify (0.7.6-2svn1) vivid; urgency=medium [ Dmitry Shachnev ] diff -Nru libnotify-0.7.6/debian/control libnotify-0.7.6/debian/control --- libnotify-0.7.6/debian/control 2014-02-21 17:52:36.000000000 -0600 +++ libnotify-0.7.6/debian/control 2018-11-09 04:16:09.000000000 -0600 @@ -1,10 +1,11 @@ # This file is autogenerated. DO NOT EDIT! -# +# # Modifications should be made to debian/control.in instead. # This file is regenerated automatically in the clean target. Source: libnotify Priority: optional -Maintainer: Debian GNOME Maintainers +Maintainer: Ubuntu Developers +XSBC-Original-Maintainer: Debian GNOME Maintainers Build-Depends: gnome-pkg-tools (>= 0.7), cdbs (>= 0.4.93~), debhelper (>= 8.1.3~), @@ -16,7 +17,7 @@ libgirepository1.0-dev (>= 0.9.12), gtk-doc-tools (>= 1.14), dh-autoreconf -Uploaders: Emilio Pozuelo Monfort , Laurent Bigonville , Martin Pitt , Michael Biebl +Uploaders: Debian GNOME Maintainers , Laurent Bigonville , Martin Pitt , Michael Biebl XS-Testsuite: autopkgtest Standards-Version: 3.9.5 Section: libs diff -Nru libnotify-0.7.6/debian/control.in libnotify-0.7.6/debian/control.in --- libnotify-0.7.6/debian/control.in 2014-02-21 17:52:36.000000000 -0600 +++ libnotify-0.7.6/debian/control.in 2018-11-09 04:16:09.000000000 -0600 @@ -1,6 +1,7 @@ Source: libnotify Priority: optional -Maintainer: Debian GNOME Maintainers +Maintainer: Ubuntu Developers +XSBC-Original-Maintainer: Debian GNOME Maintainers Build-Depends: gnome-pkg-tools (>= 0.7), cdbs (>= 0.4.93~), debhelper (>= 8.1.3~), diff -Nru libnotify-0.7.6/debian/patches/series libnotify-0.7.6/debian/patches/series --- libnotify-0.7.6/debian/patches/series 2012-03-27 14:17:45.000000000 -0600 +++ libnotify-0.7.6/debian/patches/series 2018-11-09 04:15:58.000000000 -0600 @@ -0,0 +1 @@ +ubuntu/notification-use-snap-namespace-and-prefix-when-launched.patch diff -Nru libnotify-0.7.6/debian/patches/ubuntu/notification-use-snap-namespace-and-prefix-when-launched.patch libnotify-0.7.6/debian/patches/ubuntu/notification-use-snap-namespace-and-prefix-when-launched.patch --- libnotify-0.7.6/debian/patches/ubuntu/notification-use-snap-namespace-and-prefix-when-launched.patch 1969-12-31 18:00:00.000000000 -0600 +++ libnotify-0.7.6/debian/patches/ubuntu/notification-use-snap-namespace-and-prefix-when-launched.patch 2018-11-09 04:15:58.000000000 -0600 @@ -0,0 +1,198 @@ +From: =?utf-8?b?Ik1hcmNvIFRyZXZpc2FuIChUcmV2acOxbyki?= +Date: Fri, 9 Nov 2018 01:16:41 -0600 +Subject: notification: use snap namespace and prefix when launched inside + snap + +When running inside a SNAP environment, icon, sound and desktop file paths +should be updated so that the notification daemon will be able to read them +by their full path. Normally an snapped application would instead use the +paths relative to the snap itself. + +Desktop IDs instead should be prefixed with the SNAP_NAME, so that the shell +will be able to find them. + +The patch can be ubuntu-only, since this is relevant only when libnotify is +included inside a snap file, and by default ubuntu is used as source. + +Forwarded: not-needed +Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/libnotify/+bug/1802483 +--- + libnotify/notification.c | 141 +++++++++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 141 insertions(+) + +diff --git a/libnotify/notification.c b/libnotify/notification.c +index 88bbf2a..f31d6fe 100644 +--- a/libnotify/notification.c ++++ b/libnotify/notification.c +@@ -425,6 +425,99 @@ notify_notification_new (const char *summary, + NULL); + } + ++static gchar * ++append_snap_prefix (const gchar *path) ++{ ++ gint i; ++ gchar real_path[PATH_MAX]; ++ const gchar *snap; ++ gchar *path_filename; ++ gchar *snapped_path; ++ ++ if (path == NULL || strchr (path, '/') == NULL) { ++ return NULL; ++ } ++ ++ snap = g_getenv ("SNAP"); ++ snapped_path = NULL; ++ path_filename = g_filename_from_uri (path, NULL, NULL); ++ ++ if (path_filename != NULL) { ++ path = path_filename; ++ } ++ ++ if (realpath (path, real_path) != NULL) { ++ path = real_path; ++ } ++ ++ if (g_str_has_prefix (path, "/tmp/")) { ++ g_warning ("Using '/tmp' paths in SNAP environment will " ++ "lead to unreadable resources: '%s'", path); ++ path = NULL; ++ } ++ ++ if (path != NULL && ++ (g_str_has_prefix (path, snap) || ++ g_str_has_prefix (path, g_get_home_dir ()) || ++ g_str_has_prefix (path, g_get_user_cache_dir ()) || ++ g_str_has_prefix (path, g_get_user_config_dir ()) || ++ g_str_has_prefix (path, g_get_user_data_dir ()) || ++ g_str_has_prefix (path, g_get_user_runtime_dir ()))) { ++ path = NULL; ++ } ++ ++ for (i = 0; path != NULL && i < G_USER_N_DIRECTORIES; ++i) { ++ const gchar *dir = g_get_user_special_dir (i); ++ if (dir && g_str_has_prefix (path, dir)) { ++ path = NULL; ++ } ++ } ++ ++ if (path != NULL && ++ !g_file_test (path, G_FILE_TEST_IS_REGULAR)) { ++ snapped_path = g_build_filename (snap, path, NULL); ++ if (path_filename != NULL) { ++ gchar *snapped_path_tmp = snapped_path; ++ snapped_path = g_filename_to_uri (snapped_path, ++ NULL, NULL); ++ g_free (snapped_path_tmp); ++ } ++ g_debug ("Impossible to read file %s, trying with snap " ++ "namepsace: '%s'", path, snapped_path); ++ } ++ ++ g_free (path_filename); ++ ++ return snapped_path; ++} ++ ++static gchar * ++get_snap_desktop_name (const gchar *desktop) ++{ ++ const gchar *snap_name = g_getenv ("SNAP_NAME"); ++ gchar *real_snap_desktop = NULL; ++ ++ if (snap_name == NULL || *snap_name == '\0') { ++ return NULL; ++ } ++ ++ if (strchr (desktop, '/') != NULL) { ++ real_snap_desktop = append_snap_prefix (desktop); ++ } ++ else { ++ gchar *snap_app_prefix = g_strdup_printf ("%s_", snap_name); ++ if (!g_str_has_prefix (desktop, snap_app_prefix)) { ++ real_snap_desktop = g_strconcat (snap_app_prefix, ++ desktop, NULL); ++ g_debug ("Desktop file does not contain the snap prefix, " ++ "fixed: '%s'", real_snap_desktop); ++ } ++ g_free (snap_app_prefix); ++ } ++ ++ return real_snap_desktop; ++} ++ + static void + notify_notification_update_internal (NotifyNotification *notification, + const char *app_name, +@@ -452,9 +545,17 @@ notify_notification_update_internal (NotifyNotification *notification, + } + + if (notification->priv->icon_name != icon) { ++ gchar *snapped_icon; + g_free (notification->priv->icon_name); + notification->priv->icon_name = (icon != NULL + && *icon != '\0' ? g_strdup (icon) : NULL); ++ snapped_icon = append_snap_prefix (notification->priv->icon_name); ++ if (snapped_icon != NULL) { ++ g_debug ("Icon updated in snap environment: '%s' -> '%s'\n", ++ notification->priv->icon_name, snapped_icon); ++ g_free (notification->priv->icon_name); ++ notification->priv->icon_name = snapped_icon; ++ } + g_object_notify (G_OBJECT (notification), "icon-name"); + } + +@@ -779,6 +880,45 @@ notify_notification_set_image_from_pixbuf (NotifyNotification *notification, + notify_notification_set_hint (notification, hint_name, value); + } + ++static GVariant * ++get_parsed_variant (GVariant *variant, ++ gchar *(*str_parser)(const gchar *)) ++{ ++ gchar *parsed = str_parser (g_variant_get_string (variant, NULL)); ++ ++ if (parsed != NULL) { ++ g_variant_unref (variant); ++ variant = g_variant_new_take_string (parsed); ++ } ++ ++ return variant; ++} ++ ++static GVariant * ++maybe_parse_snap_hint_value (const gchar *key, ++ GVariant *value) ++{ ++ const gchar *snap_path = g_getenv ("SNAP"); ++ if (!snap_path || *snap_path == '\0' || ++ !g_variant_is_of_type (value, G_VARIANT_TYPE_STRING)) { ++ return value; ++ } ++ ++ if (g_strcmp0 (key, "desktop-entry") == 0) { ++ value = get_parsed_variant (value, get_snap_desktop_name); ++ } ++ else if (g_strcmp0 (key, "image-path") == 0 || ++ g_strcmp0 (key, "image_path") == 0 || ++ g_strcmp0 (key, "sound-file") == 0) { ++ value = get_parsed_variant (value, append_snap_prefix); ++ } ++ ++ g_debug ("Setting hint '%s' under snap environment: '%s'", key, ++ g_variant_get_string (value, NULL)); ++ ++ return value; ++} ++ + /** + * notify_notification_set_hint: + * @notification: a #NotifyNotification +@@ -801,6 +941,7 @@ notify_notification_set_hint (NotifyNotification *notification, + g_return_if_fail (key != NULL && *key != '\0'); + + if (value != NULL) { ++ value = maybe_parse_snap_hint_value (key, value); + g_hash_table_insert (notification->priv->hints, + g_strdup (key), + g_variant_ref_sink (value));