diff mbox series

[bug#60826,v2] gnu: shared-mime-info: Update to 2.2.

Message ID 3e142d3b4f560ec3dc55d3356d6ede44a727916b.1686964927.git.mirai@makinata.eu
State New
Headers show
Series [bug#60826,v2] gnu: shared-mime-info: Update to 2.2. | expand

Commit Message

Bruno Victal June 17, 2023, 1:26 a.m. UTC
* gnu/packages/gnome.scm (shared-mime-info): Update to 2.2.
[source]: Switch to git source. Patch xdgmime location.
[build-system]: Switch to meson.
[arguments]: Enable parallel builds. Do not patch test files.
[native-inputs]: Switch to new style. Add python, xmlto,
docbook-xml-4.1.2 and docbook-xsl.
(xdgmime): New variable.
---
Notable changes since v1:
* Rebased against gnome-team.
  (this package should probably be relocated to freedesktop.scm instead)
* Refactored package definition. (the testsuite now works!)
* Removed nonsense comments present in v1. (leftovers from squashing?)

 gnu/packages/gnome.scm | 92 ++++++++++++++++++++++++++++++++++++------
 1 file changed, 79 insertions(+), 13 deletions(-)


base-commit: 909788c0aebd8098084c009afa98d1209c9ec869

Comments

Liliana Marie Prikler June 17, 2023, 4:40 a.m. UTC | #1
Am Samstag, dem 17.06.2023 um 02:26 +0100 schrieb Bruno Victal:
> * gnu/packages/gnome.scm (shared-mime-info): Update to 2.2.
> [source]: Switch to git source. Patch xdgmime location.
> [build-system]: Switch to meson.
> [arguments]: Enable parallel builds. Do not patch test files.
> [native-inputs]: Switch to new style. Add python, xmlto,
> docbook-xml-4.1.2 and docbook-xsl.
> (xdgmime): New variable.
This variable should be added in a patch 1/3.

> ---
> Notable changes since v1:
> * Rebased against gnome-team.
>   (this package should probably be relocated to freedesktop.scm
> instead)
Can you do this relocation in a patch 3/3?  We ought to have the
resources to do this change on the gnome-team branch.

> * Refactored package definition. (the testsuite now works!)
> * Removed nonsense comments present in v1. (leftovers from
> squashing?)
> 
>  gnu/packages/gnome.scm | 92 ++++++++++++++++++++++++++++++++++++----
> --
>  1 file changed, 79 insertions(+), 13 deletions(-)
> 
> diff --git a/gnu/packages/gnome.scm b/gnu/packages/gnome.scm
> index 6db2d6569e..58d0e25c1d 100644
> --- a/gnu/packages/gnome.scm
> +++ b/gnu/packages/gnome.scm
> @@ -73,6 +73,7 @@
>  ;;; Copyright © 2022 Rene Saavedra <nanuui@protonmail.com>
>  ;;; Copyright © 2022 Alexandros Theodotou <alex@zrythm.org>
>  ;;; Copyright © 2022 Arjan Adriaanse <arjan@adriaan.se>
> +;;; Copyright © 2023 Bruno Victal <mirai@makinata.eu>
>  ;;; Copyright © 2023 Kaelyn Takata <kaelyn.alexi@protonmail.com>
>  ;;; Copyright © 2023 Juliana Sims <juli@incana.org>
>  ;;; Copyright © 2023 Dominik Delgado Steuter <d@delgado.nrw>
> @@ -2913,29 +2914,94 @@ (define-public tango-icon-theme
>  guidelines.")
>      (license license:public-domain)))
>  
> +;; Private package used by shared-mime-info.
> +(define xdgmime
> +  ;; No public release, match commit to the one used in the
> +  ;; shared-mime-info release.
> +  (let ((commit "de283fc430460b9b3a7e61432a6d273cd64cb102")
> +        (revision "1"))
> +    (package
> +      (name "xdgmime")
> +      ;; set version to 0.0 and change commit instead
> +      (version (git-version "0.0" revision commit))
> +      (source (origin
> +                (method git-fetch)
> +                (uri (git-reference
> +                      (url
> "https://gitlab.freedesktop.org/xdg/xdgmime.git")
> +                      (commit commit)))
> +                (file-name (git-file-name name version))
> +                (sha256
> +                 (base32
> +                 
> "0m9k7nfxgchb9j0xh9cwsldz6564qisqdkvlhgkcgc0grd4nfbn9"))
> +                (modules '((guix build utils)))
> +                (snippet
> +                 #~(substitute* "src/Makefile"
> +                     (("all: (.+)$" all targets)
> +                      (format #f "~a
> +install: ~a
> +~/install -Dm755 -t $(DESTDIR)/bin $^~%" all targets))))))
Why not just use a custom install phase?
> +      (arguments
> +       (list
> +        #:tests? #f  ; no tests
> +        #:make-flags #~(list (string-append "DESTDIR=" #$output)
> +                             #$(string-append "CC=" (cc-for-
> target)))
> +        #:phases
> +        #~(modify-phases %standard-phases
> +            ;; Package uses a hand-crafted Makefile.
> +            (delete 'configure)
> +            ;; Use the patched install rule in src/Makefile.
> +            (add-before 'install 'change-directory
> +              (lambda _
> +                (chdir "src"))))))
> +      (build-system gnu-build-system)
> +      (home-page "https://gitlab.freedesktop.org/xdg/xdgmime/")
> +      (synopsis "Module that parses the freedesktop.org MIME spec")
> +      (description "This module is used for shared-mime-info package
> tests.")
> +      (license (list license:lgpl2.1+ license:artistic2.0)))))
> +
>  (define-public shared-mime-info
>    (package
>      (name "shared-mime-info")
> -    (version "1.15")
> +    (version "2.2")
>      (source (origin
> -             (method url-fetch)
> -             (uri (string-append
> -                  
> "https://gitlab.freedesktop.org/xdg/shared-mime-info/uploads/"
> -                   "b27eb88e4155d8fccb8bb3cd12025d5b/shared-mime-
> info-" version
> -                   ".tar.xz"))
> +             (method git-fetch)
> +             (uri (git-reference
> +                   (url
> "https://gitlab.freedesktop.org/xdg/shared-mime-info.git")
> +                   (commit version)))
> +             (file-name (git-file-name name version))
>               (sha256
>                (base32
> -              
> "146vynj78wcwdq0ms52jzm1r4m6dzi1rhyh3h4xyb6bw8ckv10pl"))))
> -    (build-system gnu-build-system)
> +              
> "04dfnnflspprxg7qia3whz1754lfvgi4ihvmihg379936zy5xd22"))
> +             (modules '((guix build utils)))
> +             ;; Override the suffix assumed by meson.build.
> +             (snippet
> +              #~(substitute* "meson.build"
> +                  (("^(xdgmime = get_option\\('xdgmime-path'\\)) /
> 'src'"
> +                    _ stem)
> +                   stem)))))
Given that you also have to fix stuff in a phase, I think it'd be
better to use a patch that allows users to specify an xdgmime-bin. 
WDYT?
>      (arguments
> -     ;; The build system appears not to be parallel-safe.
> -     '(#:parallel-build? #f))
> +     (list
> +      #:configure-flags
> +      #~(list (string-append "-Dxdgmime-path="
> +                             #$(this-package-native-input "xdgmime")
> +                             "/bin"))
> +      #:phases
> +      #~(modify-phases %standard-phases
> +          ;; Don't patch shebangs for the test files.
> +          (replace 'patch-source-shebangs
> +            (lambda* (#:key source #:allow-other-keys)
> +              (let ((pred (lambda (file stat)
> +                            (and (eq? 'regular (stat:type stat))
> +                                 (not (string-prefix? "./tests/mime-
> detection"
> +                                                      file))))))
> +                (for-each patch-shebang
> +                          (find-files "." pred #:stat lstat))))))))
> +    (build-system meson-build-system)
Build-system normally goes before arguments.
>      (inputs
>       (list glib libxml2))
>      (native-inputs
> -     `(("gettext" ,gettext-minimal)
> -       ("itstool" ,itstool)
> -       ("pkg-config" ,pkg-config)))
> +     (list gettext-minimal itstool pkg-config python xmlto
> +           docbook-xml-4.1.2 docbook-xsl xdgmime))
>      (home-page
> "https://www.freedesktop.org/wiki/Software/shared-mime-info")
>      (synopsis "Database of common MIME types")
>      (description
> 
> base-commit: 909788c0aebd8098084c009afa98d1209c9ec869
Cheers
diff mbox series

Patch

diff --git a/gnu/packages/gnome.scm b/gnu/packages/gnome.scm
index 6db2d6569e..58d0e25c1d 100644
--- a/gnu/packages/gnome.scm
+++ b/gnu/packages/gnome.scm
@@ -73,6 +73,7 @@ 
 ;;; Copyright © 2022 Rene Saavedra <nanuui@protonmail.com>
 ;;; Copyright © 2022 Alexandros Theodotou <alex@zrythm.org>
 ;;; Copyright © 2022 Arjan Adriaanse <arjan@adriaan.se>
+;;; Copyright © 2023 Bruno Victal <mirai@makinata.eu>
 ;;; Copyright © 2023 Kaelyn Takata <kaelyn.alexi@protonmail.com>
 ;;; Copyright © 2023 Juliana Sims <juli@incana.org>
 ;;; Copyright © 2023 Dominik Delgado Steuter <d@delgado.nrw>
@@ -2913,29 +2914,94 @@  (define-public tango-icon-theme
 guidelines.")
     (license license:public-domain)))
 
+;; Private package used by shared-mime-info.
+(define xdgmime
+  ;; No public release, match commit to the one used in the
+  ;; shared-mime-info release.
+  (let ((commit "de283fc430460b9b3a7e61432a6d273cd64cb102")
+        (revision "1"))
+    (package
+      (name "xdgmime")
+      ;; set version to 0.0 and change commit instead
+      (version (git-version "0.0" revision commit))
+      (source (origin
+                (method git-fetch)
+                (uri (git-reference
+                      (url "https://gitlab.freedesktop.org/xdg/xdgmime.git")
+                      (commit commit)))
+                (file-name (git-file-name name version))
+                (sha256
+                 (base32
+                  "0m9k7nfxgchb9j0xh9cwsldz6564qisqdkvlhgkcgc0grd4nfbn9"))
+                (modules '((guix build utils)))
+                (snippet
+                 #~(substitute* "src/Makefile"
+                     (("all: (.+)$" all targets)
+                      (format #f "~a
+install: ~a
+~/install -Dm755 -t $(DESTDIR)/bin $^~%" all targets))))))
+      (arguments
+       (list
+        #:tests? #f  ; no tests
+        #:make-flags #~(list (string-append "DESTDIR=" #$output)
+                             #$(string-append "CC=" (cc-for-target)))
+        #:phases
+        #~(modify-phases %standard-phases
+            ;; Package uses a hand-crafted Makefile.
+            (delete 'configure)
+            ;; Use the patched install rule in src/Makefile.
+            (add-before 'install 'change-directory
+              (lambda _
+                (chdir "src"))))))
+      (build-system gnu-build-system)
+      (home-page "https://gitlab.freedesktop.org/xdg/xdgmime/")
+      (synopsis "Module that parses the freedesktop.org MIME spec")
+      (description "This module is used for shared-mime-info package tests.")
+      (license (list license:lgpl2.1+ license:artistic2.0)))))
+
 (define-public shared-mime-info
   (package
     (name "shared-mime-info")
-    (version "1.15")
+    (version "2.2")
     (source (origin
-             (method url-fetch)
-             (uri (string-append
-                   "https://gitlab.freedesktop.org/xdg/shared-mime-info/uploads/"
-                   "b27eb88e4155d8fccb8bb3cd12025d5b/shared-mime-info-" version
-                   ".tar.xz"))
+             (method git-fetch)
+             (uri (git-reference
+                   (url "https://gitlab.freedesktop.org/xdg/shared-mime-info.git")
+                   (commit version)))
+             (file-name (git-file-name name version))
              (sha256
               (base32
-               "146vynj78wcwdq0ms52jzm1r4m6dzi1rhyh3h4xyb6bw8ckv10pl"))))
-    (build-system gnu-build-system)
+               "04dfnnflspprxg7qia3whz1754lfvgi4ihvmihg379936zy5xd22"))
+             (modules '((guix build utils)))
+             ;; Override the suffix assumed by meson.build.
+             (snippet
+              #~(substitute* "meson.build"
+                  (("^(xdgmime = get_option\\('xdgmime-path'\\)) / 'src'"
+                    _ stem)
+                   stem)))))
     (arguments
-     ;; The build system appears not to be parallel-safe.
-     '(#:parallel-build? #f))
+     (list
+      #:configure-flags
+      #~(list (string-append "-Dxdgmime-path="
+                             #$(this-package-native-input "xdgmime")
+                             "/bin"))
+      #:phases
+      #~(modify-phases %standard-phases
+          ;; Don't patch shebangs for the test files.
+          (replace 'patch-source-shebangs
+            (lambda* (#:key source #:allow-other-keys)
+              (let ((pred (lambda (file stat)
+                            (and (eq? 'regular (stat:type stat))
+                                 (not (string-prefix? "./tests/mime-detection"
+                                                      file))))))
+                (for-each patch-shebang
+                          (find-files "." pred #:stat lstat))))))))
+    (build-system meson-build-system)
     (inputs
      (list glib libxml2))
     (native-inputs
-     `(("gettext" ,gettext-minimal)
-       ("itstool" ,itstool)
-       ("pkg-config" ,pkg-config)))
+     (list gettext-minimal itstool pkg-config python xmlto
+           docbook-xml-4.1.2 docbook-xsl xdgmime))
     (home-page "https://www.freedesktop.org/wiki/Software/shared-mime-info")
     (synopsis "Database of common MIME types")
     (description