diff mbox series

[bug#68556,gnome-team,v5,3/8] gnu: gnome-shell-extensions: Wrap all the extensions.

Message ID af58ecccdc259a48a5230663d6fdc7e8dd102b08.1706558199.git.vivien@planete-kraus.eu
State New
Headers show
Series Wrap gnome-shell-extensions with gobject-introspection in native-inputs | expand

Commit Message

Vivien Kraus Jan. 20, 2024, 10:38 a.m. UTC
The top-level modules that are wrapped are the /extension.js and /prefs.js of
every extension sub-directory.

* gnu/packages/gnome.scm (gnome-shell-extensions) [#:phase
'wrap-applications-menu]: Rename to 'wrap-extensions. Wrap every top-level
module.
[inputs]: Add glib.
[propagated-imputs]: Remove glib.

Change-Id: I88634970321aa8847857e45b369b4ba285caa87d
---
 gnu/packages/gnome.scm | 45 +++++++++++++++++++++++++-----------------
 1 file changed, 27 insertions(+), 18 deletions(-)

Comments

Liliana Marie Prikler Feb. 3, 2024, 2:58 p.m. UTC | #1
Am Samstag, dem 20.01.2024 um 11:38 +0100 schrieb Vivien Kraus:
> The top-level modules that are wrapped are the /extension.js and
> /prefs.js of every extension sub-directory.
> 
> * gnu/packages/gnome.scm (gnome-shell-extensions) [#:phase
> 'wrap-applications-menu]: Rename to 'wrap-extensions. Wrap every top-
> level module.
> [inputs]: Add glib.
> [propagated-imputs]: Remove glib.
> 
> Change-Id: I88634970321aa8847857e45b369b4ba285caa87d
> ---
IMHO you should squash this and 2/8 into one patch.

>  gnu/packages/gnome.scm | 45 +++++++++++++++++++++++++---------------
> --
>  1 file changed, 27 insertions(+), 18 deletions(-)
> 
> diff --git a/gnu/packages/gnome.scm b/gnu/packages/gnome.scm
> index 04fc0500cd..8bc0491230 100644
> --- a/gnu/packages/gnome.scm
> +++ b/gnu/packages/gnome.scm
> @@ -10729,32 +10729,41 @@ (define-public gnome-shell-extensions
>        #:configure-flags #~'("-Dextension_set=all")
>        #:phases
>        #~(modify-phases %standard-phases
> -          (add-after 'unpack 'wrap-applications-menu
> +          (add-after 'unpack 'wrap-extensions
>              (lambda _
>                (use-modules (ice-9 textual-ports))
> -              (call-with-output-file "extensions/apps-
> menu/extension.js-wrapped"
> -                (lambda (out)
> -                  (format out "'~a'.split(':').forEach("
> -                          (getenv "GI_TYPELIB_PATH"))
> -                  (display
> -                   (string-append "path =>
> imports.gi.GIRepository.Repository"
> -                                  ".prepend_search_path(path));\n")
> -                   out)
> -                  (display
> -                   (call-with-input-file "extensions/apps-
> menu/extension.js"
> -                     get-string-all)
> -                   out)))
> -              (rename-file "extensions/apps-menu/extension.js-
> wrapped"
> -                           "extensions/apps-menu/extension.js"))))))
> +              (let list-extensions ((dir (opendir "extensions")))
> +                (let ((extension (readdir dir)))
> +                  (unless (eof-object? extension)
> +                    (for-each
> +                     (lambda (file-to-wrap)
> +                       (when (file-exists? file-to-wrap)
> +                         (call-with-output-file
> +                             (string-append file-to-wrap "-wrapped")
> +                           (lambda (out)
> +                             (format out "'~a'.split(':').forEach("
> +                                     (getenv "GI_TYPELIB_PATH"))
> +                             (display
> +                              (string-append "path =>
> imports.gi.GIRepository.Repository"
> +                                            
> ".prepend_search_path(path));\n")
> +                              out)
> +                             (display
> +                              (call-with-input-file file-to-wrap
> +                                get-string-all)
> +                              out)))
> +                         (rename-file (string-append file-to-wrap "-
> wrapped")
> +                                      file-to-wrap)))
> +                     (list (string-append "extensions/" extension
> "/extension.js")
> +                           (string-append "extensions/" extension
> "/prefs.js")))
> +                    (list-extensions dir)))))))))
You can use with-atomic-file-replacement to accomplish the same.  Also
try (find-files "extensions" "(extension|prefs)\\.js") 
>      (native-inputs
>       (list `(,glib "bin")
>             gettext-minimal
>             gobject-introspection ;to set GI_TYPELIB_PATH
>             pkg-config))
>      (inputs
> -     (list gnome-menus)) ;for Applications Menu
> -    (propagated-inputs
> -     (list glib))
> +     (list glib
> +           gnome-menus)) ;for Applications Menu
Do you use Emacs?  If so, use M-; to pad inline comments to a suitable
length.
If not, it ought to be
           gobject-introspection        ; to set GI_TYPELIB_PATH
I personally prefer a space after the semicolon, but I've also seen
people prefer the opposite.
>      (synopsis "Extensions for GNOME Shell")
>      (description "GNOME Shell extensions modify and extend GNOME
> Shell
>  functionality and behavior.")
Cheers
diff mbox series

Patch

diff --git a/gnu/packages/gnome.scm b/gnu/packages/gnome.scm
index 04fc0500cd..8bc0491230 100644
--- a/gnu/packages/gnome.scm
+++ b/gnu/packages/gnome.scm
@@ -10729,32 +10729,41 @@  (define-public gnome-shell-extensions
       #:configure-flags #~'("-Dextension_set=all")
       #:phases
       #~(modify-phases %standard-phases
-          (add-after 'unpack 'wrap-applications-menu
+          (add-after 'unpack 'wrap-extensions
             (lambda _
               (use-modules (ice-9 textual-ports))
-              (call-with-output-file "extensions/apps-menu/extension.js-wrapped"
-                (lambda (out)
-                  (format out "'~a'.split(':').forEach("
-                          (getenv "GI_TYPELIB_PATH"))
-                  (display
-                   (string-append "path => imports.gi.GIRepository.Repository"
-                                  ".prepend_search_path(path));\n")
-                   out)
-                  (display
-                   (call-with-input-file "extensions/apps-menu/extension.js"
-                     get-string-all)
-                   out)))
-              (rename-file "extensions/apps-menu/extension.js-wrapped"
-                           "extensions/apps-menu/extension.js"))))))
+              (let list-extensions ((dir (opendir "extensions")))
+                (let ((extension (readdir dir)))
+                  (unless (eof-object? extension)
+                    (for-each
+                     (lambda (file-to-wrap)
+                       (when (file-exists? file-to-wrap)
+                         (call-with-output-file
+                             (string-append file-to-wrap "-wrapped")
+                           (lambda (out)
+                             (format out "'~a'.split(':').forEach("
+                                     (getenv "GI_TYPELIB_PATH"))
+                             (display
+                              (string-append "path => imports.gi.GIRepository.Repository"
+                                             ".prepend_search_path(path));\n")
+                              out)
+                             (display
+                              (call-with-input-file file-to-wrap
+                                get-string-all)
+                              out)))
+                         (rename-file (string-append file-to-wrap "-wrapped")
+                                      file-to-wrap)))
+                     (list (string-append "extensions/" extension "/extension.js")
+                           (string-append "extensions/" extension "/prefs.js")))
+                    (list-extensions dir)))))))))
     (native-inputs
      (list `(,glib "bin")
            gettext-minimal
            gobject-introspection ;to set GI_TYPELIB_PATH
            pkg-config))
     (inputs
-     (list gnome-menus)) ;for Applications Menu
-    (propagated-inputs
-     (list glib))
+     (list glib
+           gnome-menus)) ;for Applications Menu
     (synopsis "Extensions for GNOME Shell")
     (description "GNOME Shell extensions modify and extend GNOME Shell
 functionality and behavior.")