[bug#77251] guix: gtk-icon-themes: produce only cache in output

Message ID 10f30ed116239fcdbfe9db9e98b01fd36471c9e7.1742838314.git.rutherther@ditigal.xyz
State New
Headers
Series [bug#77251] guix: gtk-icon-themes: produce only cache in output |

Commit Message

Rutherther March 25, 2025, 2:36 p.m. UTC
This patch changes the behavior of gtk-icon-themes to produce only the
icon-theme.cache cache files, instead of producing the whole union.
The reason for this is that by producing the whole union, the icons are put to
the profile twice. This throws off the union build of the profile and symlinks
all the individual files instead of symlinking folders. This means
unnecessarily high numbers of symlinks are produced.

* guix/profiles.scm (gtk-icon-themes): Produce only caches

Change-Id: Ia452565768753b8a60baf4fc075f6fe5ebb4fa39
---
 guix/profiles.scm | 23 ++++++++++++++++-------
 1 file changed, 16 insertions(+), 7 deletions(-)


base-commit: fbfd2b93831978aadbb96f32cafdab997b04c6c6
--
2.49.0
  

Comments

宋文武 April 27, 2025, 2:40 a.m. UTC | #1
Rutherther <rutherther@ditigal.xyz> writes:

> This patch changes the behavior of gtk-icon-themes to produce only the
> icon-theme.cache cache files, instead of producing the whole union.
> The reason for this is that by producing the whole union, the icons are put to
> the profile twice. This throws off the union build of the profile and symlinks
> all the individual files instead of symlinking folders. This means
> unnecessarily high numbers of symlinks are produced.
>
> * guix/profiles.scm (gtk-icon-themes): Produce only caches

Pushed to master as commit 32575294, with simplified commit message.

Thank you!
  

Patch

diff --git a/guix/profiles.scm b/guix/profiles.scm
index fb4dbc5bd0..2dda574e03 100644
--- a/guix/profiles.scm
+++ b/guix/profiles.scm
@@ -1382,23 +1382,32 @@  (define* (gtk-icon-themes manifest #:optional system)
             (let* ((destdir  (string-append #$output "/share/icons"))
                    (icondirs (filter file-exists?
                                      (map (cut string-append <> "/share/icons")
-                                          '#$(manifest-inputs manifest)))))
+                                          '#$(manifest-inputs manifest))))
+                   (cache-file-name "icon-theme.cache")
+                   (scratchdir (string-append (getcwd) "/icons")))
+
+              (mkdir-p destdir)
 
               ;; Union all the icons.
-              (mkdir-p (string-append #$output "/share"))
-              (union-build destdir icondirs
+              (union-build scratchdir icondirs
                            #:log-port (%make-void-port "w"))
 
               ;; Update the 'icon-theme.cache' file for each icon theme.
               (for-each
                (lambda (theme)
-                 (let ((dir (string-append destdir "/" theme)))
-                   ;; Occasionally DESTDIR contains plain files, such as
+                 (let* ((dir (string-append scratchdir "/" theme))
+                        (cache-file (string-append dir "/" cache-file-name)))
+                   ;; Occasionally SCRATCHDIR contains plain files, such as
                    ;; "abiword_48.png".  Ignore these.
                    (when (file-is-directory? dir)
                      (ensure-writable-directory dir)
-                     (system* #+gtk-update-icon-cache "-t" dir "--quiet"))))
-               (scandir destdir (negate (cut member <> '("." "..")))))))))
+                     (system* #+gtk-update-icon-cache "-t" dir "--quiet")
+                     (when (file-exists? cache-file)
+                       (mkdir-p (string-append destdir "/" theme))
+                       (copy-file
+                        cache-file
+                        (string-append destdir "/" theme "/" cache-file-name))))))
+               (scandir scratchdir (negate (cut member <> '("." "..")))))))))
 
     ;; Don't run the hook when there's nothing to do.
     (if %gtk+