diff options
author | Ross Burton <ross.burton@arm.com> | 2024-11-22 14:21:58 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2024-11-23 14:44:54 +0000 |
commit | b2e64adf18e05177858322e3eb21b79ffc73af5e (patch) | |
tree | 6d556400015720af1a8219880a29d1179a461730 | |
parent | f7116bd84acc8c6571d66570722d16a4726d52b1 (diff) | |
download | poky-b2e64adf18e05177858322e3eb21b79ffc73af5e.tar.gz |
xserver-xorg: rewrite ABI dependency generation
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.
(From OE-Core rev: f40b36fb089f6ccd4fb25373ed4cb57fae78a79f)
Signed-off-by: Ross Burton <ross.burton@arm.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
5 files changed, 58 insertions, 44 deletions
diff --git a/meta/recipes-graphics/xorg-driver/xorg-driver-common.inc b/meta/recipes-graphics/xorg-driver/xorg-driver-common.inc index 38848676f4..dd964d466d 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} | |||
20 | # depends on virtual/xserver | 20 | # depends on virtual/xserver |
21 | REQUIRED_DISTRO_FEATURES = "x11" | 21 | REQUIRED_DISTRO_FEATURES = "x11" |
22 | 22 | ||
23 | # Function to add the relevant ABI dependency to drivers, which should be called | ||
24 | # from a PACKAGEFUNC. | ||
25 | def _add_xorg_abi_depends(d, name): | ||
26 | # Map of ABI names exposed in the dependencies to pkg-config variables | ||
27 | abis = { | ||
28 | "video": "abi_videodrv", | ||
29 | "input": "abi_xinput" | ||
30 | } | ||
31 | |||
32 | output = os.popen("pkg-config xorg-server --variable=%s" % abis[name]).read() | ||
33 | mlprefix = d.getVar('MLPREFIX') or '' | ||
34 | abi = "%sxorg-abi-%s-%s" % (mlprefix, name, output.split(".")[0]) | ||
35 | |||
36 | pn = d.getVar("PN") | ||
37 | d.appendVar('RDEPENDS:' + pn, ' ' + abi) | ||
38 | |||
39 | SECURITY_LDFLAGS = "${SECURITY_X_LDFLAGS}" | 23 | SECURITY_LDFLAGS = "${SECURITY_X_LDFLAGS}" |
24 | |||
25 | 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 4efb90278c..269a78931e 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 @@ | |||
1 | require xorg-driver-common.inc | 1 | require xorg-driver-common.inc |
2 | 2 | ||
3 | python add_xorg_abi_depends() { | 3 | python add_xorg_abi_depends() { |
4 | _add_xorg_abi_depends(d, "input") | 4 | _add_xorg_abi_depends(d, "xinput") |
5 | } | 5 | } |
6 | PACKAGEFUNCS =+ "add_xorg_abi_depends" | 6 | PACKAGEFUNCS =+ "add_xorg_abi_depends" |
7 | 7 | ||
diff --git a/meta/recipes-graphics/xorg-driver/xorg-driver-video.inc b/meta/recipes-graphics/xorg-driver/xorg-driver-video.inc index c9365d8954..18441210c2 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 @@ | |||
1 | require xorg-driver-common.inc | 1 | require xorg-driver-common.inc |
2 | 2 | ||
3 | python add_xorg_abi_depends() { | 3 | python add_xorg_abi_depends() { |
4 | _add_xorg_abi_depends(d, "video") | 4 | _add_xorg_abi_depends(d, "videodrv") |
5 | } | 5 | } |
6 | PACKAGEFUNCS =+ "add_xorg_abi_depends" | 6 | 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 0000000000..9731185649 --- /dev/null +++ b/meta/recipes-graphics/xorg-xserver/xserver-abi.inc | |||
@@ -0,0 +1,48 @@ | |||
1 | # Add runtime provides for the ABI versions, so that drivers can depend on the | ||
2 | # relevant version. This should be called from PACKAGEFUNCS. | ||
3 | python add_xorg_abi_provides() { | ||
4 | import subprocess | ||
5 | |||
6 | pn = d.getVar("PN") | ||
7 | mlprefix = d.getVar("MLPREFIX") or "" | ||
8 | |||
9 | # Set PKG_CONFIG_PATH so pkg-config looks at the .pc files that are going | ||
10 | # into the new package, not the staged ones. | ||
11 | newenv = dict(os.environ) | ||
12 | newenv["PKG_CONFIG_PATH"] = d.expand("${PKGD}${libdir}/pkgconfig/:") + newenv["PKG_CONFIG_PATH"] | ||
13 | |||
14 | # Get the list of ABIs that the pc file declares | ||
15 | cmd = ("pkg-config", "--print-variables", "xorg-server") | ||
16 | output = subprocess.run(cmd, check=True, capture_output=True, text=True, env=newenv).stdout | ||
17 | abis = [var for var in output.splitlines() if var.startswith("abi_")] | ||
18 | |||
19 | # Set RPROVIDES for those ABIs with the major version | ||
20 | for abi in abis: | ||
21 | cmd = ("pkg-config", "--variable", abi, "xorg-server") | ||
22 | version = subprocess.run(cmd, check=True, capture_output=True, text=True, env=newenv).stdout | ||
23 | major = version.split(".")[0] | ||
24 | |||
25 | provides = " %sxorg-%s-%s" % (mlprefix, abi.replace("_", "-"), major) | ||
26 | d.appendVar("RPROVIDES:" + pn, provides) | ||
27 | } | ||
28 | |||
29 | # Add the specified ABI dependency to the specified package. | ||
30 | # If package is not set then PN is used. | ||
31 | # This should be called via a shim function in PACKAGEFUNCS. | ||
32 | def _add_xorg_abi_depends(d, abi, package=None): | ||
33 | import subprocess | ||
34 | |||
35 | if not package: | ||
36 | package = d.getVar("PN") | ||
37 | |||
38 | # Set PKG_CONFIG_PATH to cater for the case where xserver is | ||
39 | # itself providing drivers. | ||
40 | newenv = dict(os.environ) | ||
41 | newenv["PKG_CONFIG_PATH"] = d.expand("${PKGD}${libdir}/pkgconfig/:") + newenv["PKG_CONFIG_PATH"] | ||
42 | |||
43 | mlprefix = d.getVar("MLPREFIX") or "" | ||
44 | cmd = ("pkg-config", "xorg-server", "--variable=abi_%s" % abi) | ||
45 | output = subprocess.run(cmd, text=True, capture_output=True, check=True, env=newenv).stdout | ||
46 | abi = "%sxorg-abi-%s-%s" % (mlprefix, abi, output.split(".")[0]) | ||
47 | |||
48 | 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 e2754426cf..3eb0de7b35 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 \ | |||
79 | xf86-video-modesetting" | 79 | xf86-video-modesetting" |
80 | 80 | ||
81 | SUMMARY:xf86-video-modesetting = "X.Org X server -- modesetting display driver" | 81 | SUMMARY:xf86-video-modesetting = "X.Org X server -- modesetting display driver" |
82 | INSANE_SKIP:${MLPREFIX}xf86-video-modesetting = "xorg-driver-abi" | ||
83 | 82 | ||
84 | XSERVER_RDEPENDS = "xkeyboard-config rgb xserver-xf86-config xkbcomp xf86-input-libinput" | 83 | XSERVER_RDEPENDS = "xkeyboard-config rgb xserver-xf86-config xkbcomp xf86-input-libinput" |
85 | RDEPENDS:${PN} += "${XSERVER_RDEPENDS}" | 84 | RDEPENDS:${PN} += "${XSERVER_RDEPENDS}" |
@@ -149,31 +148,12 @@ do_install:append () { | |||
149 | sed -i -e 's,${libdir}/xorg/modules,${prefix}/lib*/xorg/modules,' ${D}${mandir}/man5/xorg.conf.5 | 148 | sed -i -e 's,${libdir}/xorg/modules,${prefix}/lib*/xorg/modules,' ${D}${mandir}/man5/xorg.conf.5 |
150 | } | 149 | } |
151 | 150 | ||
152 | # Add runtime provides for the ABI versions of the video and input subsystems, | 151 | require xserver-abi.inc |
153 | # so that drivers can depend on the relevant version. | 152 | |
154 | python populate_packages:prepend() { | 153 | python add_xorg_abi_depends() { |
155 | import subprocess | 154 | _add_xorg_abi_depends(d, "videodrv", d.expand("${MLPREFIX}xf86-video-modesetting")) |
156 | |||
157 | # Set PKG_CONFIG_PATH so pkg-config looks at the .pc files that are going | ||
158 | # into the new package, not the staged ones. | ||
159 | newenv = dict(os.environ) | ||
160 | newenv["PKG_CONFIG_PATH"] = d.expand("${PKGD}${libdir}/pkgconfig/") | ||
161 | |||
162 | def get_abi(name): | ||
163 | abis = { | ||
164 | "video": "abi_videodrv", | ||
165 | "input": "abi_xinput" | ||
166 | } | ||
167 | p = subprocess.Popen(args="pkg-config --variable=%s xorg-server" % abis[name], | ||
168 | shell=True, env=newenv, stdout=subprocess.PIPE) | ||
169 | stdout, stderr = p.communicate() | ||
170 | output = stdout.decode("utf-8").split(".")[0] | ||
171 | mlprefix = d.getVar('MLPREFIX') or '' | ||
172 | return "%sxorg-abi-%s-%s" % (mlprefix, name, output) | ||
173 | |||
174 | pn = d.getVar("PN") | ||
175 | d.appendVar("RPROVIDES:" + pn, " " + get_abi("input")) | ||
176 | d.appendVar("RPROVIDES:" + pn, " " + get_abi("video")) | ||
177 | } | 155 | } |
178 | 156 | ||
157 | PACKAGEFUNCS =+ "add_xorg_abi_provides add_xorg_abi_depends" | ||
158 | |||
179 | CVE_STATUS[CVE-2023-5574] = "${@bb.utils.contains('PACKAGECONFIG', 'xvfb', 'unpatched', 'not-applicable-config: specific to Xvfb', d)}" | 159 | CVE_STATUS[CVE-2023-5574] = "${@bb.utils.contains('PACKAGECONFIG', 'xvfb', 'unpatched', 'not-applicable-config: specific to Xvfb', d)}" |