From patchwork Fri Nov 22 14:21:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ross Burton X-Patchwork-Id: 52994 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 49BB9D75E57 for ; Fri, 22 Nov 2024 14:22:06 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web11.25533.1732285323757329912 for ; Fri, 22 Nov 2024 06:22:04 -0800 Authentication-Results: mx.groups.io; dkim=none (message not signed); spf=pass (domain: arm.com, ip: 217.140.110.172, mailfrom: ross.burton@arm.com) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 42AC4113E for ; Fri, 22 Nov 2024 06:22:33 -0800 (PST) Received: from cesw-amp-gbt-1s-m12830-04.oss.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id CDFEB3F5A1 for ; Fri, 22 Nov 2024 06:22:02 -0800 (PST) From: Ross Burton To: openembedded-core@lists.openembedded.org Subject: [PATCH 1/2] xorg-driver: remove redundant DEPENDS on xorgproto Date: Fri, 22 Nov 2024 14:21:57 +0000 Message-Id: <20241122142158.2256406-1-ross.burton@arm.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Fri, 22 Nov 2024 14:22:06 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/207619 xorg-driver-common already has this dependency. Signed-off-by: Ross Burton --- meta/recipes-graphics/xorg-driver/xorg-driver-input.inc | 2 -- meta/recipes-graphics/xorg-driver/xorg-driver-video.inc | 2 -- 2 files changed, 4 deletions(-) diff --git a/meta/recipes-graphics/xorg-driver/xorg-driver-input.inc b/meta/recipes-graphics/xorg-driver/xorg-driver-input.inc index 934c3d75c12..4efb90278c5 100644 --- a/meta/recipes-graphics/xorg-driver/xorg-driver-input.inc +++ b/meta/recipes-graphics/xorg-driver/xorg-driver-input.inc @@ -1,7 +1,5 @@ require xorg-driver-common.inc -DEPENDS += "xorgproto" - python add_xorg_abi_depends() { _add_xorg_abi_depends(d, "input") } diff --git a/meta/recipes-graphics/xorg-driver/xorg-driver-video.inc b/meta/recipes-graphics/xorg-driver/xorg-driver-video.inc index 2938ef11616..c9365d8954a 100644 --- a/meta/recipes-graphics/xorg-driver/xorg-driver-video.inc +++ b/meta/recipes-graphics/xorg-driver/xorg-driver-video.inc @@ -1,7 +1,5 @@ require xorg-driver-common.inc -DEPENDS =+ "xorgproto" - python add_xorg_abi_depends() { _add_xorg_abi_depends(d, "video") } From patchwork Fri Nov 22 14:21:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ross Burton X-Patchwork-Id: 52995 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5D339D75E59 for ; Fri, 22 Nov 2024 14:22:06 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web11.25534.1732285324374443463 for ; Fri, 22 Nov 2024 06:22:04 -0800 Authentication-Results: mx.groups.io; dkim=none (message not signed); spf=pass (domain: arm.com, ip: 217.140.110.172, mailfrom: ross.burton@arm.com) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id E04FB1477 for ; Fri, 22 Nov 2024 06:22:33 -0800 (PST) Received: from cesw-amp-gbt-1s-m12830-04.oss.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 8319E3F5A1 for ; Fri, 22 Nov 2024 06:22:03 -0800 (PST) From: Ross Burton To: openembedded-core@lists.openembedded.org Subject: [PATCH 2/2] xserver-xorg: rewrite ABI dependency generation Date: Fri, 22 Nov 2024 14:21:58 +0000 Message-Id: <20241122142158.2256406-2-ross.burton@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241122142158.2256406-1-ross.burton@arm.com> References: <20241122142158.2256406-1-ross.burton@arm.com> MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Fri, 22 Nov 2024 14:22:06 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/207620 This was motivated by remembering that both xserver-xorg and xorgxrdp need to ignore the xorg-driver-abi test in do_package_qa because the logic to generate the required dependencies is contained in xorg-driver-common.inc, so can't be reused easily by the xserver (which ships the modesetting driver) or xorgxrdp (which ships drivers and more). Merge both the RPROVIDES (xserver) and RDEPENDS (driver) functions into a single xserver-abi.inc to ensure that their logic remains in sync. Generalise the names: instead of hardcoding 'input' and 'video' extract the ABI names from the pkg-config file directly. This means 'input' is now 'xinput' and 'video' is now 'videodrv', also 'ansic' and 'extension' are new ABIs exposed. Rewrite the RDEPENDS generation so that it is more flexible, and can be used from inside the xserver-xorg recipe to generate RDEPENDS for the modesetting driver. This means that recipe can remove the INSANE_SKIP. There's an argument that this new .inc file could be a bbclass, I'm undecided on this myself right now and this patch is essentially a rationalisation of the existing code. Signed-off-by: Ross Burton --- .../xorg-driver/xorg-driver-common.inc | 18 +------ .../xorg-driver/xorg-driver-input.inc | 2 +- .../xorg-driver/xorg-driver-video.inc | 2 +- .../xorg-xserver/xserver-abi.inc | 48 +++++++++++++++++++ .../xorg-xserver/xserver-xorg.inc | 32 +++---------- 5 files changed, 58 insertions(+), 44 deletions(-) create mode 100644 meta/recipes-graphics/xorg-xserver/xserver-abi.inc diff --git a/meta/recipes-graphics/xorg-driver/xorg-driver-common.inc b/meta/recipes-graphics/xorg-driver/xorg-driver-common.inc index 38848676f41..dd964d466d0 100644 --- a/meta/recipes-graphics/xorg-driver/xorg-driver-common.inc +++ b/meta/recipes-graphics/xorg-driver/xorg-driver-common.inc @@ -20,20 +20,6 @@ inherit_defer ${XORGBUILDCLASS} # depends on virtual/xserver REQUIRED_DISTRO_FEATURES = "x11" -# Function to add the relevant ABI dependency to drivers, which should be called -# from a PACKAGEFUNC. -def _add_xorg_abi_depends(d, name): - # Map of ABI names exposed in the dependencies to pkg-config variables - abis = { - "video": "abi_videodrv", - "input": "abi_xinput" - } - - output = os.popen("pkg-config xorg-server --variable=%s" % abis[name]).read() - mlprefix = d.getVar('MLPREFIX') or '' - abi = "%sxorg-abi-%s-%s" % (mlprefix, name, output.split(".")[0]) - - pn = d.getVar("PN") - d.appendVar('RDEPENDS:' + pn, ' ' + abi) - SECURITY_LDFLAGS = "${SECURITY_X_LDFLAGS}" + +require recipes-graphics/xorg-xserver/xserver-abi.inc diff --git a/meta/recipes-graphics/xorg-driver/xorg-driver-input.inc b/meta/recipes-graphics/xorg-driver/xorg-driver-input.inc index 4efb90278c5..269a78931e3 100644 --- a/meta/recipes-graphics/xorg-driver/xorg-driver-input.inc +++ b/meta/recipes-graphics/xorg-driver/xorg-driver-input.inc @@ -1,7 +1,7 @@ require xorg-driver-common.inc python add_xorg_abi_depends() { - _add_xorg_abi_depends(d, "input") + _add_xorg_abi_depends(d, "xinput") } PACKAGEFUNCS =+ "add_xorg_abi_depends" diff --git a/meta/recipes-graphics/xorg-driver/xorg-driver-video.inc b/meta/recipes-graphics/xorg-driver/xorg-driver-video.inc index c9365d8954a..18441210c2e 100644 --- a/meta/recipes-graphics/xorg-driver/xorg-driver-video.inc +++ b/meta/recipes-graphics/xorg-driver/xorg-driver-video.inc @@ -1,6 +1,6 @@ require xorg-driver-common.inc python add_xorg_abi_depends() { - _add_xorg_abi_depends(d, "video") + _add_xorg_abi_depends(d, "videodrv") } PACKAGEFUNCS =+ "add_xorg_abi_depends" diff --git a/meta/recipes-graphics/xorg-xserver/xserver-abi.inc b/meta/recipes-graphics/xorg-xserver/xserver-abi.inc new file mode 100644 index 00000000000..9731185649a --- /dev/null +++ b/meta/recipes-graphics/xorg-xserver/xserver-abi.inc @@ -0,0 +1,48 @@ +# Add runtime provides for the ABI versions, so that drivers can depend on the +# relevant version. This should be called from PACKAGEFUNCS. +python add_xorg_abi_provides() { + import subprocess + + pn = d.getVar("PN") + mlprefix = d.getVar("MLPREFIX") or "" + + # Set PKG_CONFIG_PATH so pkg-config looks at the .pc files that are going + # into the new package, not the staged ones. + newenv = dict(os.environ) + newenv["PKG_CONFIG_PATH"] = d.expand("${PKGD}${libdir}/pkgconfig/:") + newenv["PKG_CONFIG_PATH"] + + # Get the list of ABIs that the pc file declares + cmd = ("pkg-config", "--print-variables", "xorg-server") + output = subprocess.run(cmd, check=True, capture_output=True, text=True, env=newenv).stdout + abis = [var for var in output.splitlines() if var.startswith("abi_")] + + # Set RPROVIDES for those ABIs with the major version + for abi in abis: + cmd = ("pkg-config", "--variable", abi, "xorg-server") + version = subprocess.run(cmd, check=True, capture_output=True, text=True, env=newenv).stdout + major = version.split(".")[0] + + provides = " %sxorg-%s-%s" % (mlprefix, abi.replace("_", "-"), major) + d.appendVar("RPROVIDES:" + pn, provides) +} + +# Add the specified ABI dependency to the specified package. +# If package is not set then PN is used. +# This should be called via a shim function in PACKAGEFUNCS. +def _add_xorg_abi_depends(d, abi, package=None): + import subprocess + + if not package: + package = d.getVar("PN") + + # Set PKG_CONFIG_PATH to cater for the case where xserver is + # itself providing drivers. + newenv = dict(os.environ) + newenv["PKG_CONFIG_PATH"] = d.expand("${PKGD}${libdir}/pkgconfig/:") + newenv["PKG_CONFIG_PATH"] + + mlprefix = d.getVar("MLPREFIX") or "" + cmd = ("pkg-config", "xorg-server", "--variable=abi_%s" % abi) + output = subprocess.run(cmd, text=True, capture_output=True, check=True, env=newenv).stdout + abi = "%sxorg-abi-%s-%s" % (mlprefix, abi, output.split(".")[0]) + + d.appendVar('RDEPENDS:' + package, ' ' + abi) diff --git a/meta/recipes-graphics/xorg-xserver/xserver-xorg.inc b/meta/recipes-graphics/xorg-xserver/xserver-xorg.inc index e2754426cf1..3eb0de7b353 100644 --- a/meta/recipes-graphics/xorg-xserver/xserver-xorg.inc +++ b/meta/recipes-graphics/xorg-xserver/xserver-xorg.inc @@ -79,7 +79,6 @@ PACKAGES =+ "${PN}-sdl \ xf86-video-modesetting" SUMMARY:xf86-video-modesetting = "X.Org X server -- modesetting display driver" -INSANE_SKIP:${MLPREFIX}xf86-video-modesetting = "xorg-driver-abi" XSERVER_RDEPENDS = "xkeyboard-config rgb xserver-xf86-config xkbcomp xf86-input-libinput" RDEPENDS:${PN} += "${XSERVER_RDEPENDS}" @@ -149,31 +148,12 @@ do_install:append () { sed -i -e 's,${libdir}/xorg/modules,${prefix}/lib*/xorg/modules,' ${D}${mandir}/man5/xorg.conf.5 } -# Add runtime provides for the ABI versions of the video and input subsystems, -# so that drivers can depend on the relevant version. -python populate_packages:prepend() { - import subprocess - - # Set PKG_CONFIG_PATH so pkg-config looks at the .pc files that are going - # into the new package, not the staged ones. - newenv = dict(os.environ) - newenv["PKG_CONFIG_PATH"] = d.expand("${PKGD}${libdir}/pkgconfig/") - - def get_abi(name): - abis = { - "video": "abi_videodrv", - "input": "abi_xinput" - } - p = subprocess.Popen(args="pkg-config --variable=%s xorg-server" % abis[name], - shell=True, env=newenv, stdout=subprocess.PIPE) - stdout, stderr = p.communicate() - output = stdout.decode("utf-8").split(".")[0] - mlprefix = d.getVar('MLPREFIX') or '' - return "%sxorg-abi-%s-%s" % (mlprefix, name, output) - - pn = d.getVar("PN") - d.appendVar("RPROVIDES:" + pn, " " + get_abi("input")) - d.appendVar("RPROVIDES:" + pn, " " + get_abi("video")) +require xserver-abi.inc + +python add_xorg_abi_depends() { + _add_xorg_abi_depends(d, "videodrv", d.expand("${MLPREFIX}xf86-video-modesetting")) } +PACKAGEFUNCS =+ "add_xorg_abi_provides add_xorg_abi_depends" + CVE_STATUS[CVE-2023-5574] = "${@bb.utils.contains('PACKAGECONFIG', 'xvfb', 'unpatched', 'not-applicable-config: specific to Xvfb', d)}"