Skip to contentSkip to conversation

Make MIME work on desktops

PATCH In review Andreas Müller 3 participants 16 messages Jan 17, 2020 – Jan 18, 2020

lore
Share & tools
lore
#0 lore raw

v2 cover Make MIME work on desktops

On fresh images file-browsers do not know how to open files and usually open a dialog with ALL applications available on the machine. This is not what users are used to when working with linux: For just one application installed per Mime-Type, the application is opened automatically.

To get a working MIME on desktop it needs two 'databases' on target:

1. Mime-Types: This is handled by mime.bbclass and creates database in /usr/share/mime/mime.cache.
2. Mime associations: A simple text-list of pairs Mime-Type <-> application in /usr/share/applications/mimeinfo.cache

This patch series updates/implements/enhances both parts to get images work as expected.

@Khem: This series creates many QA warnings for layers in meta-openembedded and a patch series fixing many was prepared [1]. Once this series get's applied (or you ask for it) I can send them out.

[1] https://github.com/schnitzeltony/meta-openembedded/tree/work-2020-01

V1 -> V2:
* Shelve global path export thingy
* Add me as maintainer of itstool (let's consider 'ü' in my name as test case :)
* Change "to to" to "to" in commit message
* Build shared-mime-info from git to allow automated upgrades
* mime-xdg.bbclass: Be prepared for packages as libreoffice: Desktop files installed are absolut symlinks broken for us. In case other projects do same:
Offer asolution and guide recipe writers how to handle by generating warnings with instructions how to handle.

Andreas Müller (10):
itstool: add from meta-oe
itstool: extend to nativesdk
shared-mime-info: upgrade 1.10 -> 1.15
mime.bbclass: rework
insane.bbclass: introduce a warning for mime missing in inherit
shared-mime-info: add mime to inherit
gcr: add mime to inherit
mime-xdg.bbclass: initial add
insane.bbclass: Spawn warning for missing mime-xdg in inherit
gcr: add mime-xdg to inherit

 meta/classes/insane.bbclass                   | 41 ++++++++++
 meta/classes/mime-xdg.bbclass                 | 74 +++++++++++++++++++
 meta/classes/mime.bbclass                     | 62 ++++++++--------
 meta/conf/distro/include/maintainers.inc      |  1 +
 meta/recipes-gnome/gcr/gcr_3.34.0.bb          |  2 +-
 ...-build-time-hardcoded-python-binary-.patch | 35 +++++++++
 ...ld-time-hardcoded-python-binary-path.patch | 29 ++++++++
 meta/recipes-support/itstool/itstool_2.0.6.bb | 21 ++++++
 .../shared-mime-info/install-data-hook.patch  | 25 -------
 .../shared-mime-info/parallelmake.patch       | 33 ---------
 .../shared-mime-info/shared-mime-info_1.10.bb |  7 --
 ...-mime-info.inc => shared-mime-info_git.bb} |  9 ++-
 .../update_desktop_database                   |  8 ++
 .../postinst-intercepts/update_mime_database  |  9 +++
 14 files changed, 257 insertions(+), 99 deletions(-)
 create mode 100644 meta/classes/mime-xdg.bbclass
 create mode 100644 meta/recipes-support/itstool/itstool/0001-Native-Don-t-use-build-time-hardcoded-python-binary-.patch
 create mode 100644 meta/recipes-support/itstool/itstool/0002-Don-t-use-build-time-hardcoded-python-binary-path.patch
 create mode 100644 meta/recipes-support/itstool/itstool_2.0.6.bb
 delete mode 100644 meta/recipes-support/shared-mime-info/shared-mime-info/install-data-hook.patch
 delete mode 100644 meta/recipes-support/shared-mime-info/shared-mime-info/parallelmake.patch
 delete mode 100644 meta/recipes-support/shared-mime-info/shared-mime-info_1.10.bb
 rename meta/recipes-support/shared-mime-info/{shared-mime-info.inc => shared-mime-info_git.bb} (75%)
 create mode 100644 scripts/postinst-intercepts/update_desktop_database
 create mode 100644 scripts/postinst-intercepts/update_mime_database
Signature · 1 line
2.21.0
#1 lore raw

PATCH v2 1/10 itstool: add from meta-oe

Recent versions of shared-mime-info depend on itstool

---
 meta/conf/distro/include/maintainers.inc      |  1 +
 ...-build-time-hardcoded-python-binary-.patch | 35 +++++++++++++++++++
 ...ld-time-hardcoded-python-binary-path.patch | 29 +++++++++++++++
 meta/recipes-support/itstool/itstool_2.0.6.bb | 20 +++++++++++
 4 files changed, 85 insertions(+)
 create mode 100644 meta/recipes-support/itstool/itstool/0001-Native-Don-t-use-build-time-hardcoded-python-binary-.patch
 create mode 100644 meta/recipes-support/itstool/itstool/0002-Don-t-use-build-time-hardcoded-python-binary-path.patch
 create mode 100644 meta/recipes-support/itstool/itstool_2.0.6.bb
meta/conf/distro/include/maintainers.inc +1 -0
index 7d47677d3b..ffb6da7dae 100644
@@ -281,6 +281,7 @@ RECIPE_MAINTAINER_pn-iproute2 = "Changhyeok Bae <[email protected]>"
 RECIPE_MAINTAINER_pn-iptables = "Changhyeok Bae <[email protected]>"
 RECIPE_MAINTAINER_pn-iputils = "Changhyeok Bae <[email protected]>"
 RECIPE_MAINTAINER_pn-iso-codes = "Alexander Kanavin <[email protected]>"
+RECIPE_MAINTAINER_pn-itstool = "Andreas Müller <[email protected]>"
 RECIPE_MAINTAINER_pn-iw = "Changhyeok Bae <[email protected]>"
 RECIPE_MAINTAINER_pn-libjpeg-turbo = "Anuj Mittal <[email protected]>"
 RECIPE_MAINTAINER_pn-json-c = "Yi Zhao <[email protected]>"
meta/recipes-support/itstool/itstool/0001-Native-Don-t-use-build-time-hardcoded-python-binary-.patch new file +35 -0
new file mode 100644
index 0000000000..19a858bd75
@@ -0,0 +1,35 @@
+From 335ef14fc801c9dfbe7e5692dc71cfbe72049d2b Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Andreas=20M=C3=BCller?= <[email protected]>
+Date: Sun, 27 Oct 2019 16:38:52 +0100
+Subject: [PATCH] Native: Don't use build time hardcoded python binary path.
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+This is same patch as used for target build except that we do not use the
+'-S' and '-s' option because '-S' is relatively young [1] and elder build-host
+don't support it [2]
+
+[1] https://github.com/coreutils/coreutils/commit/668306ed86c8c79b0af0db8b9c882654ebb66db2#diff-83d9d52b1f12ac589739ab1334ae4f30
+[2] https://errors.yoctoproject.org/Errors/Details/274743/
+
+Upstream-Status: Inappropriate [OE specific]
+
+Signed-off-by: Andreas Müller <[email protected]>
+---
+ itstool.in | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/itstool.in b/itstool.in
+index e64cd34..05d264f 100755
+--- a/itstool.in
++++ b/itstool.in
+@@ -1,4 +1,4 @@
+-#!@PYTHON@ -s
++#!/usr/bin/env python3
+ #
+ # Copyright (c) 2010-2018 Shaun McCance <[email protected]>
+ #
+-- 
+2.21.0
+
meta/recipes-support/itstool/itstool/0002-Don-t-use-build-time-hardcoded-python-binary-path.patch new file +29 -0
new file mode 100644
index 0000000000..b91105330c
@@ -0,0 +1,29 @@
+From cd9b56224895576125e91cca317ace8a80f3eb77 Mon Sep 17 00:00:00 2001
+From: Piotr Tworek <[email protected]>
+Date: Sat, 27 Jul 2019 10:19:11 +0200
+Subject: [PATCH] Don't use build time hardcoded python binary path.
+
+This path obviously won't work on target since they refer to build
+machine directory structure. Native builds will also fail if local.conf
+has INHERIT+=rm_work. Instread of hardcoding path to python binary use
+whatever is found in PATH first. This should also allow the tool to use
+python3 binary provided in recipe-sysroot-native.
+
+Upstream-Status: Inappropriate [OE specific]
+---
+ itstool.in | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/itstool.in b/itstool.in
+index b3c0033..7df2476 100755
+--- a/itstool.in
++++ b/itstool.in
+@@ -1,4 +1,4 @@
+-#!@PYTHON@ -s
++#!/usr/bin/env -S python3 -s
+ #
+ # Copyright (c) 2010-2018 Shaun McCance <[email protected]>
+ #
+--
+2.21.0
+
meta/recipes-support/itstool/itstool_2.0.6.bb new file +20 -0
new file mode 100644
index 0000000000..8290c5e581
@@ -0,0 +1,20 @@
+SUMMARY = "ITS Tool allows you to translate your XML documents with PO files"
+HOMEPAGE = "http://itstool.org/"
+LICENSE = "GPLv3"
+LIC_FILES_CHKSUM = "file://COPYING;md5=59c57b95fd7d0e9e238ebbc7ad47c5a5"
+
+inherit autotools python3native
+
+DEPENDS = "libxml2-native"
+
+SRC_URI = "http://files.itstool.org/${BPN}/${BPN}-${PV}.tar.bz2"
+SRC_URI_append_class-native = " file://0001-Native-Don-t-use-build-time-hardcoded-python-binary-.patch"
+SRC_URI_append_class-target = " file://0002-Don-t-use-build-time-hardcoded-python-binary-path.patch"
+
+SRC_URI[md5sum] = "4306eeba4f4aee6b393d14f9c3c57ca1"
+SRC_URI[sha256sum] = "6233cc22726a9a5a83664bf67d1af79549a298c23185d926c3677afa917b92a9"
+
+BBCLASSEXTEND = "native"
+
+RDEPENDS_${PN} += "libxml2-python"
+RDEPENDS_${PN}_class-native = ""
Signature · 1 line
2.21.0
#2 lore raw

PATCH v2 2/10 itstool: extend to nativesdk

In reply to Andreas Müller

This was not done in meta-oe but shared-mime-info extends to nativesdk either.

---
 meta/recipes-support/itstool/itstool_2.0.6.bb | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
meta/recipes-support/itstool/itstool_2.0.6.bb +2 -1
index 8290c5e581..5f358f463d 100644
@@ -9,12 +9,13 @@ DEPENDS = "libxml2-native"
 
 SRC_URI = "http://files.itstool.org/${BPN}/${BPN}-${PV}.tar.bz2"
 SRC_URI_append_class-native = " file://0001-Native-Don-t-use-build-time-hardcoded-python-binary-.patch"
+SRC_URI_append_class-nativesdk = " file://0001-Native-Don-t-use-build-time-hardcoded-python-binary-.patch"
 SRC_URI_append_class-target = " file://0002-Don-t-use-build-time-hardcoded-python-binary-path.patch"
 
 SRC_URI[md5sum] = "4306eeba4f4aee6b393d14f9c3c57ca1"
 SRC_URI[sha256sum] = "6233cc22726a9a5a83664bf67d1af79549a298c23185d926c3677afa917b92a9"
 
-BBCLASSEXTEND = "native"
+BBCLASSEXTEND = "native nativesdk"
 
 RDEPENDS_${PN} += "libxml2-python"
 RDEPENDS_${PN}_class-native = ""
Signature · 1 line
2.21.0
#3 lore raw

PATCH v2 3/10 shared-mime-info: upgrade 1.10 -> 1.15

In reply to Andreas Müller

* sources/development moved to freedesktop's gitlab
* patches do not apply any more due to major changes in Makefile.am
* give up bb/inc separation

---
 .../shared-mime-info/install-data-hook.patch  | 25 --------------
 .../shared-mime-info/parallelmake.patch       | 33 -------------------
 .../shared-mime-info/shared-mime-info_1.10.bb |  7 ----
 ...-mime-info.inc => shared-mime-info_git.bb} |  9 +++--
 4 files changed, 6 insertions(+), 68 deletions(-)
 delete mode 100644 meta/recipes-support/shared-mime-info/shared-mime-info/install-data-hook.patch
 delete mode 100644 meta/recipes-support/shared-mime-info/shared-mime-info/parallelmake.patch
 delete mode 100644 meta/recipes-support/shared-mime-info/shared-mime-info_1.10.bb
 rename meta/recipes-support/shared-mime-info/{shared-mime-info.inc => shared-mime-info_git.bb} (75%)
meta/recipes-support/shared-mime-info/shared-mime-info/install-data-hook.patch deleted +0 -25
deleted file mode 100644
index 262ff7562c..0000000000
@@ -1,25 +0,0 @@
-fix shared-mime-info build race condition
-
-The definition of install-data-hook in Makefile.am leads
-to multiple, overlapping, executions of install-binPROGRAMS
-target.  We modify the definition to avoid that.
-
-Upstream-Status: Pending
-
-Signed-off-by: Joe Slater <[email protected]>
-
-Index: shared-mime-info-1.9/Makefile.am
-===================================================================
---- shared-mime-info-1.9.orig/Makefile.am
-+++ shared-mime-info-1.9/Makefile.am
-@@ -50,7 +50,9 @@ else
-   update_mime_database="$(top_builddir)/update-mime-database$(EXEEXT)"
- endif
- 
--install-data-hook: install-binPROGRAMS
-+# do NOT make this dependent on anything!
-+#
-+install-data-hook:
- if ENABLE_UPDATE_MIMEDB
- 	$(update_mime_database) -V "$(DESTDIR)$(datadir)/mime"
- endif
meta/recipes-support/shared-mime-info/shared-mime-info/parallelmake.patch deleted +0 -33
deleted file mode 100644
index fea34a55a2..0000000000
@@ -1,33 +0,0 @@
-The Makefile used by shared-mime-info is one big race with the SUBDIRS 
-option and the dependency specifically calling make all combining to
-create multiple make instances all of which may try and build targets
-like update-mime-database.
-
-This patch removes those options meaning make can correctly identify
-dependencies and stop itself racing itself.
-
-RP 10/10/2011
-
-Upstream-Status: Pending
-Signed-off-by: Constantin Musca <[email protected]>
-
-Index: shared-mime-info-1.9/Makefile.am
-===================================================================
---- shared-mime-info-1.9.orig/Makefile.am
-+++ shared-mime-info-1.9/Makefile.am
-@@ -1,5 +1,3 @@
--SUBDIRS=. po
--
- AM_CPPFLAGS = $(ALL_CFLAGS)
- 
- packagesdir = $(datadir)/mime/packages
-@@ -81,8 +79,7 @@ endif
- 
- all: $(defaultmakedeps)
- 
--create-pot:
--	$(AM_V_GEN) $(MAKE) -C po shared-mime-info.pot
-+create-pot: po
- 
- local-test: create-pot freedesktop.org.xml update-mime-database$(EXEEXT)
- if CROSS_COMPILING
meta/recipes-support/shared-mime-info/shared-mime-info_1.10.bb deleted +0 -7
deleted file mode 100644
index 9fc210b718..0000000000
@@ -1,7 +0,0 @@
-require shared-mime-info.inc
-
-SRC_URI += "file://parallelmake.patch \
-	    file://install-data-hook.patch"
-
-SRC_URI[md5sum] = "418c2ced9dc4dd5ca8b06a755e6d64e9"
-SRC_URI[sha256sum] = "c625a83b4838befc8cafcd54e3619946515d9e44d63d61c4adf7f5513ddfbebf"
meta/recipes-support/shared-mime-info/shared-mime-info_git.bb renamed from meta/recipes-support/shared-mime-info/shared-mime-info.inc +6 -3
similarity index 75%
rename from meta/recipes-support/shared-mime-info/shared-mime-info.inc
rename to meta/recipes-support/shared-mime-info/shared-mime-info_git.bb
index 3fe1a445b0..bf48e453a0 100644
@@ -5,11 +5,14 @@ SECTION = "base"
 LICENSE = "GPLv2"
 LIC_FILES_CHKSUM = "file://COPYING;md5=b234ee4d69f5fce4486a80fdaf4a4263"
 
-DEPENDS = "libxml2 intltool-native glib-2.0 shared-mime-info-native"
+DEPENDS = "libxml2 itstool glib-2.0 shared-mime-info-native"
 
-SRC_URI = "http://freedesktop.org/~hadess/shared-mime-info-${PV}.tar.xz"
+SRC_URI = "git://gitlab.freedesktop.org/xdg/shared-mime-info.git;protocol=https"
+SRCREV = "829b26d85e7d89a0caee03046c3bce373f04c80a"
+PV = "1.15"
+S = "${WORKDIR}/git"
 
-inherit autotools pkgconfig gettext
+inherit autotools pkgconfig gettext python3native
 
 EXTRA_OECONF = "--disable-update-mimedb"
 
Signature · 1 line
2.21.0
#4 lore raw

PATCH v2 4/10 mime.bbclass: rework

In reply to Andreas Müller

* add a short descriptions of class' use case
* remove checks for update-mime-database - it can be considered available:
* at build time by PACKAGE_WRITE_DEPS
* at package upgrade by RDEPENDS chain

    pkg -> shared-mime-info-data -> shared-mime-info

* simplify (accelerate?) xml file extension detection
* run update-mime-database once only at image creation to avoid expensive redundant operations
* allow shared-mime-info to inherit mime.bbclass by avoiding circular dependencies

---
 meta/classes/mime.bbclass                     | 62 ++++++++++---------
 .../postinst-intercepts/update_mime_database  |  9 +++
 2 files changed, 41 insertions(+), 30 deletions(-)
 create mode 100644 scripts/postinst-intercepts/update_mime_database
meta/classes/mime.bbclass +32 -30
index 6c7b868f79..c9072adf3b 100644
@@ -1,46 +1,47 @@
-DEPENDS += "shared-mime-info"
+#
+# This class is used by recipes installing mime types
+#
+
+DEPENDS += "${@bb.utils.contains('BPN', 'shared-mime-info', '', 'shared-mime-info', d)}"
 PACKAGE_WRITE_DEPS += "shared-mime-info-native"
+MIMEDIR = "${datadir}/mime"
 
 mime_postinst() {
-if [ "$1" = configure ]; then
-	UPDATEMIMEDB=`which update-mime-database`
-	if [ -x "$UPDATEMIMEDB" ] ; then
-		echo "Updating MIME database... this may take a while."
-		$UPDATEMIMEDB $D${datadir}/mime
-	else
-		echo "Missing update-mime-database, update of mime database failed!"
-		exit 1
-	fi
+if [ "x$D" != "x" ]; then
+	$INTERCEPT_DIR/postinst_intercept update_mime_database ${PKG} \
+		mlprefix=${MLPREFIX} \
+		mimedir=${MIMEDIR}
+else
+	echo "Updating MIME database... this may take a while."
+	update-mime-database $D${MIMEDIR}
 fi
 }
 
 mime_postrm() {
-if [ "$1" = remove ] || [ "$1" = upgrade ]; then
-	UPDATEMIMEDB=`which update-mime-database`
-	if [ -x "$UPDATEMIMEDB" ] ; then
-		echo "Updating MIME database... this may take a while."
-		$UPDATEMIMEDB $D${datadir}/mime
-	else
-		echo "Missing update-mime-database, update of mime database failed!"
-		exit 1
-	fi
+if [ "x$D" != "x" ]; then
+	$INTERCEPT_DIR/postinst_intercept update_mime_database ${PKG} \
+		mlprefix=${MLPREFIX} \
+		mimedir=${MIMEDIR}
+else
+	echo "Updating MIME database... this may take a while."
+	update-mime-database $D${MIMEDIR}
 fi
 }
 
 python populate_packages_append () {
-    import re
     packages = d.getVar('PACKAGES').split()
     pkgdest =  d.getVar('PKGDEST')
+    mimedir = d.getVar('MIMEDIR')
 
     for pkg in packages:
-        mime_dir = '%s/%s/usr/share/mime/packages' % (pkgdest, pkg)
-        mimes = []
-        mime_re = re.compile(".*\.xml$")
-        if os.path.exists(mime_dir):
-            for f in os.listdir(mime_dir):
-                if mime_re.match(f):
-                    mimes.append(f)
-        if mimes:
+        mime_packages_dir = '%s/%s%s/packages' % (pkgdest, pkg, mimedir)
+        mimes_types_found = False
+        if os.path.exists(mime_packages_dir):
+            for f in os.listdir(mime_packages_dir):
+                if f.endswith('.xml'):
+                    mimes_types_found = True
+                    break
+        if mimes_types_found:
             bb.note("adding mime postinst and postrm scripts to %s" % pkg)
             postinst = d.getVar('pkg_postinst_%s' % pkg)
             if not postinst:
@@ -52,6 +53,7 @@ python populate_packages_append () {
                 postrm = '#!/bin/sh\n'
             postrm += d.getVar('mime_postrm')
             d.setVar('pkg_postrm_%s' % pkg, postrm)
-            bb.note("adding shared-mime-info-data dependency to %s" % pkg)
-            d.appendVar('RDEPENDS_' + pkg, " " + d.getVar('MLPREFIX')+"shared-mime-info-data")
+            if pkg != 'shared-mime-info-data':
+                bb.note("adding shared-mime-info-data dependency to %s" % pkg)
+                d.appendVar('RDEPENDS_' + pkg, " " + d.getVar('MLPREFIX')+"shared-mime-info-data")
 }
scripts/postinst-intercepts/update_mime_database new file +9 -0
new file mode 100644
index 0000000000..582d1e162c
@@ -0,0 +1,9 @@
+#!/bin/sh
+#
+# SPDX-License-Identifier: MIT
+#
+# Post-install intercept for mime.bbclass
+
+echo "Updating MIME database... this may take a while."
+update-mime-database $D${mimedir}
+
Signature · 1 line
2.21.0
#5 lore raw

PATCH v2 5/10 insane.bbclass: introduce a warning for mime missing in inherit

In reply to Andreas Müller

* looking through layers it looks that usage of mime.bbclass is somewhat orphaned
* now that update-mime-database is called once only at image creation time, costs of mime.bbclass are limited

---
 meta/classes/insane.bbclass | 12 ++++++++++++
 1 file changed, 12 insertions(+)
meta/classes/insane.bbclass +12 -0
index 723348fc8e..a2d9318276 100644
@@ -28,6 +28,7 @@ WARN_QA ?= "ldflags useless-rpaths rpaths staticdev libdir xorg-driver-abi \
             pn-overrides infodir build-deps src-uri-bad \
             unknown-configure-option symlink-to-sysroot multilib \
             invalid-packageconfig host-user-contaminated uppercase-pn patch-fuzz \
+            mime \
             "
 ERROR_QA ?= "dev-so debug-deps dev-deps debug-files arch pkgconfig la \
             perms dep-cmp pkgvarcheck perm-config perm-line perm-link \
@@ -185,6 +186,17 @@ def package_qa_check_staticdev(path, name, d, elf, messages):
         package_qa_add_message(messages, "staticdev", "non -staticdev package contains static .a library: %s path '%s'" % \
                  (name, package_qa_clean_path(path,d)))
 
+QAPATHTEST[mime] = "package_qa_check_mime"
+def package_qa_check_mime(path, name, d, elf, messages):
+    """
+    Check if package installs mime types to /usr/share/mime/packages
+    while no inheriting mime.bbclass
+    """
+
+    if d.getVar("datadir") + "/mime/packages" in path and path.endswith('.xml') and not bb.data.inherits_class("mime", d):
+        package_qa_add_message(messages, "mime", "package contains mime types but does not inhert mime: %s path '%s'" % \
+                 (name, package_qa_clean_path(path,d)))
+
 def package_qa_check_libdir(d):
     """
     Check for wrong library installation paths. For instance, catch
Signature · 1 line
2.21.0
#6 lore raw

PATCH v2 6/10 shared-mime-info: add mime to inherit

In reply to Andreas Müller

shared-mime-info-data: is the base for mime database

---
 meta/recipes-support/shared-mime-info/shared-mime-info_git.bb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta/recipes-support/shared-mime-info/shared-mime-info_git.bb +1 -1
index bf48e453a0..b2d562157b 100644
@@ -12,7 +12,7 @@ SRCREV = "829b26d85e7d89a0caee03046c3bce373f04c80a"
 PV = "1.15"
 S = "${WORKDIR}/git"
 
-inherit autotools pkgconfig gettext python3native
+inherit autotools pkgconfig gettext python3native mime
 
 EXTRA_OECONF = "--disable-update-mimedb"
 
Signature · 1 line
2.21.0
#7 lore raw

PATCH v2 7/10 gcr: add mime to inherit

In reply to Andreas Müller

gcr installs mime types we want in our mime-database

---
 meta/recipes-gnome/gcr/gcr_3.34.0.bb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta/recipes-gnome/gcr/gcr_3.34.0.bb +1 -1
index e3e8999635..272112dd12 100644
@@ -11,7 +11,7 @@ LIC_FILES_CHKSUM = "file://COPYING;md5=55ca817ccb7d5b5b66355690e9abc605"
 DEPENDS = "gtk+3 p11-kit glib-2.0 libgcrypt \
            ${@bb.utils.contains('GI_DATA_ENABLED', 'True', 'libxslt-native', '', d)}"
 
-inherit gnomebase gtk-icon-cache gtk-doc features_check upstream-version-is-even vala gobject-introspection gettext
+inherit gnomebase gtk-icon-cache gtk-doc features_check upstream-version-is-even vala gobject-introspection gettext mime
 # depends on gtk+3, but also x11 through gtk+-x11
 REQUIRED_DISTRO_FEATURES = "x11"
 
Signature · 1 line
2.21.0
#8 lore raw

PATCH v2 8/10 mime-xdg.bbclass: initial add

In reply to Andreas Müller

When opening files by file-browsers on fresh images, user has to choose the application to open from the pool af ALL known applications even those not designed to open the file selected. By inheriting this classs in recipes the assosiations in /usr/share/applications/mimeinfo.cache are build by calling update-desktop-database.

---
 meta/classes/mime-xdg.bbclass                 | 74 +++++++++++++++++++
 .../update_desktop_database                   |  8 ++
 2 files changed, 82 insertions(+)
 create mode 100644 meta/classes/mime-xdg.bbclass
 create mode 100644 scripts/postinst-intercepts/update_desktop_database
meta/classes/mime-xdg.bbclass new file +74 -0
new file mode 100644
index 0000000000..63169e990d
@@ -0,0 +1,74 @@
+#
+# This class creates mime <-> application associations based on entry 
+# 'MimeType' in *.desktop files
+#
+
+DEPENDS += "desktop-file-utils"
+PACKAGE_WRITE_DEPS += "desktop-file-utils-native"
+DESKTOPDIR = "${datadir}/applications"
+
+# There are recipes out there installing their .desktop files as absolute
+# symlinks. For us these are dangling and cannot be introspected for "MymeType"
+# easily. By addding package-names to MIME_XDG_PACKAGES, packager can force
+# proper update-desktop-database handling. Note that all introspection is
+# skipped for MIME_XDG_PACKAGES not empty
+MIME_XDG_PACKAGES ?= ""
+
+mime_xdg_postinst() {
+if [ "x$D" != "x" ]; then
+	$INTERCEPT_DIR/postinst_intercept update_desktop_database ${PKG} \
+		mlprefix=${MLPREFIX} \
+		desktop_dir=${DESKTOPDIR}
+else
+	update-desktop-database $D${DESKTOPDIR}
+fi
+}
+
+mime_xdg_postrm() {
+if [ "x$D" != "x" ]; then
+	$INTERCEPT_DIR/postinst_intercept update_desktop_database ${PKG} \
+		mlprefix=${MLPREFIX} \
+		desktop_dir=${DESKTOPDIR}
+else
+	update-desktop-database $D${DESKTOPDIR}
+fi
+}
+
+python populate_packages_append () {
+    packages = d.getVar('PACKAGES').split()
+    pkgdest =  d.getVar('PKGDEST')
+    desktop_base = d.getVar('DESKTOPDIR')
+    forced_mime_xdg_pkgs = (d.getVar('MIME_XDG_PACKAGES') or '').split()
+
+    for pkg in packages:
+        desktops_with_mime_found = pkg in forced_mime_xdg_pkgs
+        if d.getVar('MIME_XDG_PACKAGES') == '':
+            desktop_dir = '%s/%s%s' % (pkgdest, pkg, desktop_base)
+            if os.path.exists(desktop_dir):
+                for df in os.listdir(desktop_dir):
+                    if df.endswith('.desktop'):
+                        try:
+                            with open(desktop_dir + '/'+ df, 'r') as f:
+                                for line in f.read().split('\n'):
+                                    if 'MimeType' in line:
+                                        desktops_with_mime_found = True
+                                        break;
+                        except:
+                            bb.warn('Could not open %s. Set MIME_XDG_PACKAGES in recipe or add mime-xdg to INSANE_SKIP.' % desktop_dir + '/'+ df)
+                    if desktops_with_mime_found:
+                        break
+        if desktops_with_mime_found:
+            bb.note("adding mime-xdg postinst and postrm scripts to %s" % pkg)
+            postinst = d.getVar('pkg_postinst_%s' % pkg)
+            if not postinst:
+                postinst = '#!/bin/sh\n'
+            postinst += d.getVar('mime_xdg_postinst')
+            d.setVar('pkg_postinst_%s' % pkg, postinst)
+            postrm = d.getVar('pkg_postrm_%s' % pkg)
+            if not postrm:
+                postrm = '#!/bin/sh\n'
+            postrm += d.getVar('mime_xdg_postrm')
+            d.setVar('pkg_postrm_%s' % pkg, postrm)
+            bb.note("adding desktop-file-utils dependency to %s" % pkg)
+            d.appendVar('RDEPENDS_' + pkg, " " + d.getVar('MLPREFIX')+"desktop-file-utils")
+}
scripts/postinst-intercepts/update_desktop_database new file +8 -0
new file mode 100644
index 0000000000..8903b496f3
@@ -0,0 +1,8 @@
+#!/bin/sh
+#
+# SPDX-License-Identifier: MIT
+#
+# Post-install intercept for mime-xdg.bbclass
+
+update-desktop-database $D${desktop_dir}
+
Signature · 1 line
2.21.0
#9 lore raw

PATCH v2 9/10 insane.bbclass: Spawn warning for missing mime-xdg in inherit

In reply to Andreas Müller

If a package signals that it can open mime-types but does not inharit mime-xdg, a warning is created.

---
 meta/classes/insane.bbclass | 31 ++++++++++++++++++++++++++++++-
 1 file changed, 30 insertions(+), 1 deletion(-)
meta/classes/insane.bbclass +30 -1
index a2d9318276..d6c60326db 100644
@@ -28,7 +28,7 @@ WARN_QA ?= "ldflags useless-rpaths rpaths staticdev libdir xorg-driver-abi \
             pn-overrides infodir build-deps src-uri-bad \
             unknown-configure-option symlink-to-sysroot multilib \
             invalid-packageconfig host-user-contaminated uppercase-pn patch-fuzz \
-            mime \
+            mime mime-xdg \
             "
 ERROR_QA ?= "dev-so debug-deps dev-deps debug-files arch pkgconfig la \
             perms dep-cmp pkgvarcheck perm-config perm-line perm-link \
@@ -197,6 +197,35 @@ def package_qa_check_mime(path, name, d, elf, messages):
         package_qa_add_message(messages, "mime", "package contains mime types but does not inhert mime: %s path '%s'" % \
                  (name, package_qa_clean_path(path,d)))
 
+QAPATHTEST[mime-xdg] = "package_qa_check_mime_xdg"
+def package_qa_check_mime_xdg(path, name, d, elf, messages):
+    """
+    Check if package installs desktop file containing MimeType and requires
+    mime-types.bbclass to create /usr/share/applications/mimeinfo.cache
+    """
+
+    if d.getVar("datadir") + "/applications" in path and path.endswith('.desktop') and not bb.data.inherits_class("mime-xdg", d):
+        mime_type_found = False
+        try:
+            with open(path, 'r') as f:
+                for line in f.read().split('\n'):
+                    if 'MimeType' in line:
+                        mime_type_found = True
+                        break;
+        except:
+            # At least libreoffice installs symlinks with absolute paths that are dangling here.
+            # We could implement some magic but for few (one) recipes it is not worth the effort so just warn:
+            wstr = "%s cannot open %s - is it a symlink with absolute path?\n" % (name, package_qa_clean_path(path,d))
+            wstr += "Please check if (linked) file contains key 'MimeType'.\n"
+            pkgname = name
+            if name == d.getVar('PN'):
+                pkgname = '${PN}'
+            wstr += "If yes: add \'inhert mime-xdg\' and \'MIME_XDG_PACKAGES += \"%s\"\' / if no add \'INSANE_SKIP_%s += \"mime-xdg\"\' to recipe." % (pkgname, pkgname)
+            package_qa_add_message(messages, "mime-xdg", wstr)
+        if mime_type_found:
+            package_qa_add_message(messages, "mime-xdg", "package contains desktop file with key 'MimeType' but does not inhert mime-xdg: %s path '%s'" % \
+                    (name, package_qa_clean_path(path,d)))
+
 def package_qa_check_libdir(d):
     """
     Check for wrong library installation paths. For instance, catch
Signature · 1 line
2.21.0
#10 lore raw

PATCH v2 10/10 gcr: add mime-xdg to inherit

In reply to Andreas Müller
---
 meta/recipes-gnome/gcr/gcr_3.34.0.bb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta/recipes-gnome/gcr/gcr_3.34.0.bb +1 -1
index 272112dd12..9853b3f416 100644
@@ -11,7 +11,7 @@ LIC_FILES_CHKSUM = "file://COPYING;md5=55ca817ccb7d5b5b66355690e9abc605"
 DEPENDS = "gtk+3 p11-kit glib-2.0 libgcrypt \
            ${@bb.utils.contains('GI_DATA_ENABLED', 'True', 'libxslt-native', '', d)}"
 
-inherit gnomebase gtk-icon-cache gtk-doc features_check upstream-version-is-even vala gobject-introspection gettext mime
+inherit gnomebase gtk-icon-cache gtk-doc features_check upstream-version-is-even vala gobject-introspection gettext mime mime-xdg
 # depends on gtk+3, but also x11 through gtk+-x11
 REQUIRED_DISTRO_FEATURES = "x11"
 
Signature · 1 line
2.21.0
#11 lore raw

✗ patchtest: failure for Make MIME work on desktops (rev2)

In reply to Andreas Müller

== Series Details ==

Series: Make MIME work on desktops (rev2)
Revision: 2
URL : https://patchwork.openembedded.org/series/21945/
State : failure

== Summary ==

Thank you for submitting this patch series to OpenEmbedded Core. This is an automated response. Several tests have been executed on the proposed series by patchtest resulting in the following failures:

* Issue A patch file has been added, but does not have a Signed-off-by tag [test_signed_off_by_presence]
Suggested fix Sign off the added patch file (meta/recipes-support/itstool/itstool/0002-Don-t-use-build-time-hardcoded-python-binary-path.patch)

If you believe any of these test results are incorrect, please reply to the mailing list ([email protected]) raising your concerns. Otherwise we would appreciate you correcting the issues and submitting a new version of the patchset if applicable. Please ensure you add/increment the version number when sending the new version (i.e. [PATCH] -> [PATCH v2] -> [PATCH v3] -> ...).

---

Guidelines:     https://www.openembedded.org/wiki/Commit_Patch_Message_Guidelines
Test framework: http://git.yoctoproject.org/cgit/cgit.cgi/patchtest
Test suite:     http://git.yoctoproject.org/cgit/cgit.cgi/patchtest-oe
#12 lore raw
In reply to Andreas Müller
Quoted 30 lines · Andreas Müller

On fresh images file-browsers do not know how to open files and usually open a
dialog with ALL applications available on the machine. This is not what users
are used to when working with linux: For just one application installed per
Mime-Type, the application is opened automatically.

To get a working MIME on desktop it needs two 'databases' on target:

1. Mime-Types: This is handled by mime.bbclass and creates database in
/usr/share/mime/mime.cache.
2. Mime associations: A simple text-list of pairs Mime-Type <-> application
in /usr/share/applications/mimeinfo.cache

This patch series updates/implements/enhances both parts to get images work as
expected.

@Khem: This series creates many QA warnings for layers in meta- openembedded and
a patch series fixing many was prepared [1]. Once this series get's applied (or
you ask for it) I can send them out.

[1]
https://github.com/schnitzeltony/meta-openembedded/tree/work-2020-01

Quoted 13 lines

V1 -> V2:
* Shelve global path export thingy
* Add me as maintainer of itstool (let's consider 'ü' in my name as test case :)
* Change "to to" to "to" in commit message
* Build shared-mime-info from git to allow automated upgrades
* mime-xdg.bbclass: Be prepared for packages as libreoffice: Desktop files
installed are absolut symlinks broken for us. In case other
projects do same:
Offer asolution and guide recipe writers how to handle by
generating warnings
with instructions how to handle.

Thanks, this looks good to me. It did generate a warning on master-next builds in many places:

WARNING: libfm-1.3.1-r0 do_package_qa: QA Issue: package contains desktop file with key 'MimeType' but does not inhert mime-xdg: libfm-gtk path '/work/armv7vet2hf-neon-oe-linux-gnueabi/libfm/1.3.1-r0/packages-split/libfm-gtk/usr/share/applications/lxshortcut.desktop' [mime-xdg]
WARNING: libfm-1.3.1-r0 do_package_qa: QA Issue: package contains mime types but does not inhert mime: libfm-mime path '/work/armv7vet2hf-neon-oe-linux-gnueabi/libfm/1.3.1-r0/packages-split/libfm-mime/usr/share/mime/packages/libfm.xml' [mime]

It also generated:

https://autobuilder.yoctoproject.org/typhoon/#/builders/75/builds/1458

which partly is the python2 removal that was in with the test and partly this series since itstool is GPLv3 :(.

I have to admit I'm not sure how reasonable it is to keep hacking the gplv2 layer to work...

Cheers,

Richard

#13 lore raw
Quoted 15 lines · Richard Purdie
Quoted 14 lines

V1 -> V2:
* Shelve global path export thingy
* Add me as maintainer of itstool (let's consider 'ü' in my name as test case :)
* Change "to to" to "to" in commit message
* Build shared-mime-info from git to allow automated upgrades
* mime-xdg.bbclass: Be prepared for packages as libreoffice: Desktop files
installed are absolut symlinks broken for us. In case other
projects do same:
Offer asolution and guide recipe writers how to handle by
generating warnings
with instructions how to handle.

Quoted 5 lines

Thanks, this looks good to me. It did generate a warning on master-next builds in many places:

WARNING: libfm-1.3.1-r0 do_package_qa: QA Issue: package contains desktop file with key 'MimeType' but does not inhert mime-xdg: libfm-gtk path '/work/armv7vet2hf-neon-oe-linux-gnueabi/libfm/1.3.1-r0/packages-split/libfm-gtk/usr/share/applications/lxshortcut.desktop' [mime-xdg]
WARNING: libfm-1.3.1-r0 do_package_qa: QA Issue: package contains mime types but does not inhert mime: libfm-mime path '/work/armv7vet2hf-neon-oe-linux-gnueabi/libfm/1.3.1-r0/packages-split/libfm-mime/usr/share/mime/packages/libfm.xml' [mime]

Slipped through - will send a follow up

Quoted 7 lines

It also generated:

https://autobuilder.yoctoproject.org/typhoon/#/builders/75/builds/1458

which partly is the python2 removal that was in with the test and partly this series since itstool is GPLv3 :(.

Is there any activity required from my side?

Quoted 8 lines

I have to admit I'm not sure how reasonable it is to keep hacking the gplv2 layer to work...

Cheers,

Richard

Andreas

#14 lore raw
Quoted 18 lines · Andreas Müller
Quoted 16 lines · Richard Purdie
Quoted 15 lines

V1 -> V2:
* Shelve global path export thingy
* Add me as maintainer of itstool (let's consider 'ü' in my name as
test case :)
* Change "to to" to "to" in commit message
* Build shared-mime-info from git to allow automated upgrades
* mime-xdg.bbclass: Be prepared for packages as libreoffice:
Desktop
files
installed are absolut symlinks broken for us. In case other
projects do same:
Offer asolution and guide recipe writers how to handle by
generating warnings
with instructions how to handle.

Quoted 7 lines
Quoted 6 lines

Thanks, this looks good to me. It did generate a warning on master- next
builds in many places:

WARNING: libfm-1.3.1-r0 do_package_qa: QA Issue: package contains desktop file with key 'MimeType' but does not inhert mime-xdg: libfm-gtk path '/work/armv7vet2hf-neon-oe-linux-gnueabi/libfm/1.3.1-r0/packages-split/libfm-gtk/usr/share/applications/lxshortcut.desktop' [mime-xdg]
WARNING: libfm-1.3.1-r0 do_package_qa: QA Issue: package contains mime types but does not inhert mime: libfm-mime path '/work/armv7vet2hf-neon-oe-linux-gnueabi/libfm/1.3.1-r0/packages-split/libfm-mime/usr/share/mime/packages/libfm.xml' [mime]

Slipped through - will send a follow up

Thanks, should be simple at least! :)

Quoted 7 lines
Quoted 6 lines

It also generated:

https://autobuilder.yoctoproject.org/typhoon/#/builders/75/builds/1458

which partly is the python2 removal that was in with the test and partly this series since itstool is GPLv3 :(.

Is there any activity required from my side?

Well, as things stand this series breaks meta-gplv2. This is currently tested on the autobuilder and turns it red. I'm therefore blocked on merging.

Quoted 2 lines
Quoted 2 lines

I have to admit I'm not sure how reasonable it is to keep hacking the gplv2 layer to work...

The question now is really whether we want to continue supporting meta- gplv2 with master?

I don't like the layer, I think there are other approaches we're going to need to take going forward and the project may need to send that message.

If someone steps up and fixes it, great, we can move forward and I'll defer that discussion.

If nobody does, quickly, then I will need to start a discussion about dropping it from the core YP testing. This patch is blocked until something changes though :(

Cheers,

Richard

#15 lore raw
Quoted 34 lines · Richard Purdie
Quoted 33 lines · Andreas Müller
Quoted 31 lines · Richard Purdie
Quoted 8 lines

V1 -> V2:
* Shelve global path export thingy
* Add me as maintainer of itstool (let's consider 'ü' in my name
as
test case :)
* Change "to to" to "to" in commit message
* Build shared-mime-info from git to allow automated upgrades

Quoted 8 lines

* mime-xdg.bbclass: Be prepared for packages as libreoffice:
Desktop
files
installed are absolut symlinks broken for us. In case other
projects do same:
Offer asolution and guide recipe writers how to handle by
generating warnings
with instructions how to handle.

Thanks, this looks good to me. It did generate a warning on master-
next
builds in many places:

WARNING: libfm-1.3.1-r0 do_package_qa: QA Issue: package contains desktop file with key 'MimeType' but does not inhert mime-xdg:
libfm-gtk path '/work/armv7vet2hf-neon-oe-linux- gnueabi/libfm/1.3.1-r0/packages-split/libfm- gtk/usr/share/applications/lxshortcut.desktop' [mime-xdg]
WARNING: libfm-1.3.1-r0 do_package_qa: QA Issue: package contains mime types but does not inhert mime: libfm-mime path '/work/armv7vet2hf-neon-oe-linux-gnueabi/libfm/1.3.1-r0/packages- split/libfm-mime/usr/share/mime/packages/libfm.xml' [mime]

Quoted 3 lines
Quoted 1 line

Slipped through - will send a follow up

Thanks, should be simple at least! :)

I've sent a fix out which I think is right...

Quoted 27 lines
Quoted 8 lines
Quoted 7 lines

It also generated:

https://autobuilder.yoctoproject.org/typhoon/#/builders/75/builds/1458

which partly is the python2 removal that was in with the test and partly this series since itstool is GPLv3 :(.

Is there any activity required from my side?

Well, as things stand this series breaks meta-gplv2. This is currently
tested on the autobuilder and turns it red. I'm therefore blocked on merging.

Quoted 3 lines
Quoted 3 lines

I have to admit I'm not sure how reasonable it is to keep hacking the
gplv2 layer to work...

The question now is really whether we want to continue supporting meta-
gplv2 with master?

I don't like the layer, I think there are other approaches we're going
to need to take going forward and the project may need to send that message.

Quoted 6 lines

If someone steps up and fixes it, great, we can move forward and I'll defer that discussion.

If nobody does, quickly, then I will need to start a discussion about dropping it from the core YP testing. This patch is blocked until something changes though :(

I figured out how to fix the issues so I've sent patches as well and am rerunning the autobuilder tests.

Cheers,

Richard