diff options
| author | Ludovic Courtès <ludo@gnu.org> | 2020-11-12 16:35:24 +0100 |
|---|---|---|
| committer | Ludovic Courtès <ludo@gnu.org> | 2020-11-13 09:13:56 +0100 |
| commit | ae10ec441aa524bf267f9cefd4a319b44d0b8b44 (patch) | |
| tree | 9d32d984c3fcf32266ce13a73ddf83c6c91cf675 | |
| parent | a30e7a72fce5b2357a2ccd4fb49980090425579c (diff) | |
gnu: glib: Graft patch to detect changes to the installed applications.
Fixes <https://bugs.gnu.org/35594>.
Reported by sirgazil <sirgazil@zoho.com> and others.
* gnu/packages/patches/glib-appinfo-watch.patch: New file.
* gnu/local.mk (dist_patch_DATA): Add it.
* gnu/packages/glib.scm (glib)[replacement]: New field.
(glib-with-gio-patch): New variable.
(glib-with-documentation): Use 'package/inherit'.
| -rw-r--r-- | gnu/local.mk | 1 | ||||
| -rw-r--r-- | gnu/packages/glib.scm | 14 | ||||
| -rw-r--r-- | gnu/packages/patches/glib-appinfo-watch.patch | 92 |
3 files changed, 105 insertions, 2 deletions
diff --git a/gnu/local.mk b/gnu/local.mk index d5a13cbdbd9..2301a04d2f8 100644 --- a/gnu/local.mk +++ b/gnu/local.mk | |||
| @@ -1050,6 +1050,7 @@ dist_patch_DATA = \ | |||
| 1050 | %D%/packages/patches/ghostscript-no-header-id.patch \ | 1050 | %D%/packages/patches/ghostscript-no-header-id.patch \ |
| 1051 | %D%/packages/patches/ghostscript-no-header-uuid.patch \ | 1051 | %D%/packages/patches/ghostscript-no-header-uuid.patch \ |
| 1052 | %D%/packages/patches/ghostscript-no-header-creationdate.patch \ | 1052 | %D%/packages/patches/ghostscript-no-header-creationdate.patch \ |
| 1053 | %D%/packages/patches/glib-appinfo-watch.patch \ | ||
| 1053 | %D%/packages/patches/glib-tests-timer.patch \ | 1054 | %D%/packages/patches/glib-tests-timer.patch \ |
| 1054 | %D%/packages/patches/glibc-CVE-2018-11236.patch \ | 1055 | %D%/packages/patches/glibc-CVE-2018-11236.patch \ |
| 1055 | %D%/packages/patches/glibc-CVE-2018-11237.patch \ | 1056 | %D%/packages/patches/glibc-CVE-2018-11237.patch \ |
diff --git a/gnu/packages/glib.scm b/gnu/packages/glib.scm index 901222476ab..43523e516da 100644 --- a/gnu/packages/glib.scm +++ b/gnu/packages/glib.scm | |||
| @@ -181,6 +181,7 @@ shared NFS home directories.") | |||
| 181 | (package | 181 | (package |
| 182 | (name "glib") | 182 | (name "glib") |
| 183 | (version "2.62.6") | 183 | (version "2.62.6") |
| 184 | (replacement glib-with-gio-patch) | ||
| 184 | (source (origin | 185 | (source (origin |
| 185 | (method url-fetch) | 186 | (method url-fetch) |
| 186 | (uri (string-append "mirror://gnome/sources/" | 187 | (uri (string-append "mirror://gnome/sources/" |
| @@ -387,11 +388,20 @@ dynamic loading, and an object system.") | |||
| 387 | (home-page "https://developer.gnome.org/glib/") | 388 | (home-page "https://developer.gnome.org/glib/") |
| 388 | (license license:lgpl2.1+))) | 389 | (license license:lgpl2.1+))) |
| 389 | 390 | ||
| 391 | (define glib-with-gio-patch | ||
| 392 | ;; GLib with a fix for <https://bugs.gnu.org/35594>. | ||
| 393 | ;; TODO: Fold into 'glib' above in the next rebuild cycle. | ||
| 394 | (package | ||
| 395 | (inherit glib) | ||
| 396 | (source (origin | ||
| 397 | (inherit (package-source glib)) | ||
| 398 | (patches (cons (search-patch "glib-appinfo-watch.patch") | ||
| 399 | (origin-patches (package-source glib)))))))) | ||
| 400 | |||
| 390 | (define-public glib-with-documentation | 401 | (define-public glib-with-documentation |
| 391 | ;; glib's doc must be built in a separate package since it requires gtk-doc, | 402 | ;; glib's doc must be built in a separate package since it requires gtk-doc, |
| 392 | ;; which in turn depends on glib. | 403 | ;; which in turn depends on glib. |
| 393 | (package | 404 | (package/inherit glib |
| 394 | (inherit glib) | ||
| 395 | (properties (alist-delete 'hidden? (package-properties glib))) | 405 | (properties (alist-delete 'hidden? (package-properties glib))) |
| 396 | (outputs (cons "doc" (package-outputs glib))) ; 20 MiB of GTK-Doc reference | 406 | (outputs (cons "doc" (package-outputs glib))) ; 20 MiB of GTK-Doc reference |
| 397 | (native-inputs | 407 | (native-inputs |
diff --git a/gnu/packages/patches/glib-appinfo-watch.patch b/gnu/packages/patches/glib-appinfo-watch.patch new file mode 100644 index 00000000000..638a5e09494 --- /dev/null +++ b/gnu/packages/patches/glib-appinfo-watch.patch | |||
| @@ -0,0 +1,92 @@ | |||
| 1 | This patch lets GLib's GDesktopAppInfo API watch and notice changes | ||
| 2 | to the Guix user and system profiles. That way, the list of available | ||
| 3 | applications shown by the desktop environment is immediately updated | ||
| 4 | when the user runs "guix install", "guix remove", or "guix system | ||
| 5 | reconfigure" (see <https://issues.guix.gnu.org/35594>). | ||
| 6 | |||
| 7 | It does so by monitoring /var/guix/profiles (for changes to the system | ||
| 8 | profile) and /var/guix/profiles/per-user/USER (for changes to the user | ||
| 9 | profile) and crawling their share/applications sub-directory when | ||
| 10 | changes happen. | ||
| 11 | |||
| 12 | diff --git a/gio/gdesktopappinfo.c b/gio/gdesktopappinfo.c | ||
| 13 | index f1e2fdd..095c110 100644 | ||
| 14 | --- a/gio/gdesktopappinfo.c | ||
| 15 | +++ b/gio/gdesktopappinfo.c | ||
| 16 | @@ -148,6 +148,7 @@ typedef struct | ||
| 17 | gchar *alternatively_watching; | ||
| 18 | gboolean is_config; | ||
| 19 | gboolean is_setup; | ||
| 20 | + gchar *guix_profile_watch_dir; | ||
| 21 | GFileMonitor *monitor; | ||
| 22 | GHashTable *app_names; | ||
| 23 | GHashTable *mime_tweaks; | ||
| 24 | @@ -180,6 +181,7 @@ desktop_file_dir_unref (DesktopFileDir *dir) | ||
| 25 | { | ||
| 26 | desktop_file_dir_reset (dir); | ||
| 27 | g_free (dir->path); | ||
| 28 | + g_free (dir->guix_profile_watch_dir); | ||
| 29 | g_free (dir); | ||
| 30 | } | ||
| 31 | } | ||
| 32 | @@ -204,6 +206,13 @@ desktop_file_dir_get_alternative_dir (DesktopFileDir *dir) | ||
| 33 | { | ||
| 34 | gchar *parent; | ||
| 35 | |||
| 36 | + /* If DIR is a profile, watch the specified directory--e.g., | ||
| 37 | + * /var/guix/profiles/per-user/$USER/ for the user profile. Do not watch | ||
| 38 | + * ~/.guix-profile or /run/current-system/profile because GFileMonitor does | ||
| 39 | + * not pass IN_DONT_FOLLOW and thus cannot notice any change. */ | ||
| 40 | + if (dir->guix_profile_watch_dir != NULL) | ||
| 41 | + return g_strdup (dir->guix_profile_watch_dir); | ||
| 42 | + | ||
| 43 | /* If the directory itself exists then we need no alternative. */ | ||
| 44 | if (g_access (dir->path, R_OK | X_OK) == 0) | ||
| 45 | return NULL; | ||
| 46 | @@ -249,11 +258,11 @@ desktop_file_dir_changed (GFileMonitor *monitor, | ||
| 47 | * | ||
| 48 | * If this is a notification for a parent directory (because the | ||
| 49 | * desktop directory didn't exist) then we shouldn't fire the signal | ||
| 50 | - * unless something actually changed. | ||
| 51 | + * unless something actually changed or it's in /var/guix/profiles. | ||
| 52 | */ | ||
| 53 | g_mutex_lock (&desktop_file_dir_lock); | ||
| 54 | |||
| 55 | - if (dir->alternatively_watching) | ||
| 56 | + if (dir->alternatively_watching && dir->guix_profile_watch_dir == NULL) | ||
| 57 | { | ||
| 58 | gchar *alternative_dir; | ||
| 59 | |||
| 60 | @@ -1555,6 +1564,32 @@ desktop_file_dirs_lock (void) | ||
| 61 | for (i = 0; dirs[i]; i++) | ||
| 62 | g_ptr_array_add (desktop_file_dirs, desktop_file_dir_new (dirs[i])); | ||
| 63 | |||
| 64 | + { | ||
| 65 | + /* Monitor the system and user profile under /var/guix/profiles and | ||
| 66 | + * treat modifications to them as if they were modifications to their | ||
| 67 | + * /share sub-directory. */ | ||
| 68 | + const gchar *user; | ||
| 69 | + DesktopFileDir *system_profile_dir, *user_profile_dir; | ||
| 70 | + | ||
| 71 | + system_profile_dir = | ||
| 72 | + desktop_file_dir_new ("/var/guix/profiles/system/profile/share"); | ||
| 73 | + system_profile_dir->guix_profile_watch_dir = g_strdup ("/var/guix/profiles"); | ||
| 74 | + g_ptr_array_add (desktop_file_dirs, desktop_file_dir_ref (system_profile_dir)); | ||
| 75 | + | ||
| 76 | + user = g_get_user_name (); | ||
| 77 | + if (user != NULL) | ||
| 78 | + { | ||
| 79 | + gchar *profile_dir, *user_data_dir; | ||
| 80 | + | ||
| 81 | + profile_dir = g_build_filename ("/var/guix/profiles/per-user", user, NULL); | ||
| 82 | + user_data_dir = g_build_filename (profile_dir, "guix-profile", "share", NULL); | ||
| 83 | + user_profile_dir = desktop_file_dir_new (user_data_dir); | ||
| 84 | + user_profile_dir->guix_profile_watch_dir = profile_dir; | ||
| 85 | + g_ptr_array_add (desktop_file_dirs, desktop_file_dir_ref (user_profile_dir)); | ||
| 86 | + g_free (user_data_dir); | ||
| 87 | + } | ||
| 88 | + } | ||
| 89 | + | ||
| 90 | /* The list of directories will never change after this, unless | ||
| 91 | * g_get_user_config_dir() changes due to %G_TEST_OPTION_ISOLATE_DIRS. */ | ||
| 92 | desktop_file_dirs_config_dir = user_config_dir; | ||
