summary refs log tree commit diff
path: root/gnu/packages/freedesktop.scm
diff options
context:
space:
mode:
Diffstat (limited to 'gnu/packages/freedesktop.scm')
-rw-r--r--gnu/packages/freedesktop.scm108
1 files changed, 108 insertions, 0 deletions
diff --git a/gnu/packages/freedesktop.scm b/gnu/packages/freedesktop.scm
index 3bfc8b33ae..6408918c2a 100644
--- a/gnu/packages/freedesktop.scm
+++ b/gnu/packages/freedesktop.scm
@@ -33,6 +33,7 @@
 ;;; Copyright © 2022 Petr Hodina <phodina@protonmail.com>
 ;;; Copyright © 2022 muradm <mail@muradm.net>
 ;;; Copyright © 2023 Alex Devaure <ajadevaure@gmail.com>
+;;; Copyright © 2023 Bruno Victal <mirai@makinata.eu>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -465,6 +466,113 @@ method framework.")
 display servers.  It supports many different languages and emoji.")
     (license license:gpl3+)))
 
+;; 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")
+      (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"))))
+      (build-system gnu-build-system)
+      (arguments
+       (list
+        #:tests? #f  ; no tests
+        #:make-flags #~(list (string-append "DESTDIR=" #$output)
+                             #$(string-append "CC=" (cc-for-target)))
+        #:imported-modules `((guix build copy-build-system)
+                             ,@%gnu-build-system-modules)
+        #:modules `((guix build gnu-build-system)
+                    ((guix build copy-build-system) #:prefix copy:)
+                    (guix build utils))
+        #:phases
+        #~(modify-phases %standard-phases
+            ;; Package uses a hand-crafted Makefile.
+            (delete 'configure)
+            (replace 'install
+              (lambda args
+                (apply (assoc-ref copy:%standard-phases 'install)
+                       #:install-plan
+                       '(("src" "bin/" #:include ("print-mime-data"
+                                                  "test-mime-data"
+                                                  "test-mime")))
+                       args))))))
+      (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)))))
+
+;; Note: when updating shared-mime-info, don't forget to update xdgmime's commit
+;; to the one used in the release.
+(define-public shared-mime-info
+  (package
+    (name "shared-mime-info")
+    (version "2.2")
+    (source (origin
+             (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
+               "04dfnnflspprxg7qia3whz1754lfvgi4ihvmihg379936zy5xd22"))
+             (patches (search-patches "shared-mime-info-xdgmime-path.patch"))))
+    (build-system meson-build-system)
+    (arguments
+     (list
+      #:configure-flags
+      #~(list #$(format #f "-Dxdgmime-path=~a/bin"
+                        (this-package-native-input "xdgmime"))
+              "-Dupdate-mimedb=true")
+      #:phases
+      #~(modify-phases %standard-phases
+          ;; Don't patch shebangs for the test files.
+          (replace 'patch-source-shebangs
+            (lambda _
+              (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)))))
+          ;; The docs have no install rule.
+          (add-after 'install 'install-doc
+            (lambda* (#:key source #:allow-other-keys)
+              (let ((dest (string-append #$output:doc "/share/doc")))
+                (with-directory-excursion "data/shared-mime-info-spec-html"
+                  (install-file "shared-mime-info-spec.html"
+                                (string-append dest "/html")))
+                (install-file (string-append source
+                                             "/data/shared-mime-info-spec.xml")
+                              dest)))))))
+    (inputs
+     (list glib libxml2))
+    (native-inputs
+     (list gettext-minimal pkg-config python xdgmime
+           ;; For 'doc' output.
+           docbook-xml-4.1.2 docbook-xsl xmlto))
+    (outputs (list "out" "doc"))
+    (home-page "https://www.freedesktop.org/wiki/Software/shared-mime-info")
+    (synopsis "Database of common MIME types")
+    (description
+     "The shared-mime-info package contains the core database of common types
+and the update-mime-database command used to extend it.  It requires glib2 to
+be installed for building the update command.  Additionally, it uses intltool
+for translations, though this is only a dependency for the maintainers.  This
+database is translated at Transifex.")
+    (license license:gpl2+)))
+
 (define-public xdg-utils
   (package
     (name "xdg-utils")