meta-virtualization/recipes-extended/libvirt/libvirt-python.inc
Tom Hochstein d54989cbee libvirt: Fix missing libvirt-python
The do_rootfs task for an image that includes libvirt-python fails.
```
  - nothing provides libvirt-python needed by packagegroup-fsl-virtualization-1.0-r0.ls1012afrwy from oe-repo
```

The log shows that the do_compile:append() from libvirt-python.inc is
failing but not reporting the failure.
```
174: cd: can't cd to /.../libvirt/v11.8.0+git/sources/libvirt-v11.8.0+git/libvirt-python-11.8.0
```

The root cause is the archive folder format is changed from
libvirt-python-VERSION to libvirt_python-VERSION, but the do_compile
and do_install tasks are hard-coded to the old format.

Fix the root cause by encoding the archive folder name in a common
variable. Also, fix the build and install commands so the cd failure is
not ignored.

Signed-off-by: Tom Hochstein <tom.hochstein@oss.nxp.com>
Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com>
2025-11-19 18:22:50 -05:00

75 lines
2.6 KiB
PHP

inherit python3native python3-dir python3targetconfig
export STAGING_INCDIR
export STAGING_LIBDIR
export BUILD_SYS
export HOST_SYS
RDEPENDS:${PN}-python += "python3"
PACKAGECONFIG_${PN}-python[xen] = ",,,xen-python"
PACKAGES += "${PN}-python-staticdev ${PN}-python-dev ${PN}-python-dbg ${PN}-python"
FILES:${PN}-python-staticdev += "${PYTHON_SITEPACKAGES_DIR}/*.a"
FILES:${PN}-python-dev += "${PYTHON_SITEPACKAGES_DIR}/*.la"
FILES:${PN}-python-dbg += "${PYTHON_SITEPACKAGES_DIR}/.debug/"
FILES:${PN}-python = "${bindir}/* ${libdir}/* ${libdir}/${PYTHON_DIR}/*"
# Currently the libvirt-python debug libraries contain buildpaths
INSANE_SKIP:${PN}-dbg += "buildpaths"
SRC_URI += "http://libvirt.org/sources/python/${LIBVIRT_PYTHON_ARCHIVE_NAME}.tar.gz;name=libvirt_python;subdir=${BP}"
LIBVIRT_PYTHON_ARCHIVE_NAME = "${BPN}_python-${LIBVIRT_VERSION}"
SRC_URI[libvirt_python.sha256sum] = "5d80e13e0cfb96dd254d765ee60e77e5f9b6925172540056cec0aa0e6f0ca83c"
export LIBVIRT_API_PATH = "${S}/docs/libvirt-api.xml"
export LIBVIRT_CFLAGS = "-I${S}/include"
export LIBVIRT_LIBS = "-L${B}/src/.libs -lvirt -ldl"
export LDFLAGS = "-L${B}/src/.libs"
LIBVIRT_INSTALL_ARGS = "--root=${D} \
--prefix=${prefix} \
--install-lib=${PYTHON_SITEPACKAGES_DIR} \
--install-data=${datadir}"
python __anonymous () {
pkgconfig = d.getVar('PACKAGECONFIG')
if ('python') in pkgconfig.split():
d.setVar('LIBVIRT_PYTHON_ENABLE', '1')
else:
d.setVar('LIBVIRT_PYTHON_ENABLE', '0')
}
do_compile:append() {
if [ "${LIBVIRT_PYTHON_ENABLE}" = "1" ]; then
# we need the python bindings to look into our source dir, not
# the syroot staged pkgconfig entries. So we clear the sysroot
# for just this portion.
export PKG_CONFIG_SYSROOT_DIR=
src=${UNPACKDIR}/${BP}/${LIBVIRT_PYTHON_ARCHIVE_NAME}
if [ ! -d $src ]; then
bbfatal "Python source not found at expected location \"$src\". Please check that this task logic and SRC_URI are consistent."
fi
cd $src
${STAGING_BINDIR_NATIVE}/python3-native/python3 setup.py build
cd -
fi
}
do_install:append() {
if [ "${LIBVIRT_PYTHON_ENABLE}" = "1" ]; then
# we need the python bindings to look into our source dir, not
# the syroot staged pkgconfig entries. So we clear the sysroot
# for just this portion.
export PKG_CONFIG_SYSROOT_DIR=
src=${UNPACKDIR}/${BP}/${LIBVIRT_PYTHON_ARCHIVE_NAME}
if [ ! -d $src ]; then
bbfatal "Python source not found at expected location \"$src\". Please check that this task logic and SRC_URI are consistent."
fi
cd $src
${STAGING_BINDIR_NATIVE}/python3-native/python3 setup.py install \
--install-lib=${D}/${PYTHON_SITEPACKAGES_DIR} ${LIBVIRT_INSTALL_ARGS}
cd -
fi
}