1# Add runtime provides for the ABI versions, so that drivers can depend on the 2# relevant version. This should be called from PACKAGEFUNCS. 3python 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. 32def _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) 49