package libvirt-python

In 1.2.0, libvirt separated the python components into a separate package.

Signed-off-by: Amy Fong <amy.fong@windriver.com>
Signed-off-by: Bruce Ashfield <bruce.ashfield@windriver.com>
This commit is contained in:
Amy Fong 2014-02-03 14:36:57 -05:00 committed by Bruce Ashfield
parent 8515475890
commit 43fe4b7d0e
3 changed files with 128 additions and 4 deletions

View File

@ -14,4 +14,39 @@ FILES_${PN}-python-dev += "${PYTHON_SITEPACKAGES_DIR}/*.la"
FILES_${PN}-python-dbg += "${PYTHON_SITEPACKAGES_DIR}/.debug/"
FILES_${PN}-python += "${PYTHON_SITEPACKAGES_DIR}"
EXTRA_OECONF += "TARGET_PYTHON=${bindir}/python"
SRC_URI += "http://libvirt.org/sources/python/libvirt-python-${PV}.tar.gz;name=libvirt_python"
SRC_URI += "file://libvirt_api_xml_path.patch;patchdir=../libvirt-python-${PV}"
SRC_URI[libvirt_python.md5sum] = "38158e5740be65f17eef9f99ffa5dadf"
SRC_URI[libvirt_python.sha256sum] = "2fe7e341cb1b35cff130b7a04d0d58f3607094e63cbca689bc16c7b47da0f52b"
export LIBVIRT_API_PATH = "${S}/docs/libvirt-api.xml"
export LIBVIRT_CFLAGS = "-I${S}/include"
export LIBVIRT_LIBS = "-L${S}/src/.libs -lvirt -ldl"
export LDFLAGS="-L${S}/src/.libs"
python __anonymous () {
pkgconfig = d.getVar('PACKAGECONFIG', True)
if ('python') in pkgconfig.split():
d.setVar('LIBVIRT_PYTHON_ENABLE', '1')
else:
d.setVar('LIBVIRT_PYTHON_ENABLE', '0')
}
do_compile_python() {
if [ "${LIBVIRT_PYTHON_ENABLE}" = "1" ]; then
cd ${WORKDIR}/libvirt-python-${PV} && \
${STAGING_BINDIR_NATIVE}/python-native/python setup.py build
fi
}
addtask do_compile_python before do_install after do_compile
do_install_python() {
if [ "${LIBVIRT_PYTHON_ENABLE}" = "1" ]; then
cd ${WORKDIR}/libvirt-python-${PV} && \
${STAGING_BINDIR_NATIVE}/python-native/python setup.py install \
--install-lib=${PYTHON_SITEPACKAGES_DIR} \
--root=${WORKDIR}/image
fi
}
addtask do_install_python before do_populate_sysroot after do_install

View File

@ -0,0 +1,89 @@
Adding support for LIBVIRT_CFLAGS and LIBVIRT_LIBS
Signed-off-by: Amy Fong <amy.fong@windriver.com>
Adding a support for LIBVIRT_API_PATH evironment variable, which can
control where the script should look for the 'libvirt-api.xml' file.
This allows building libvirt-python against different libvirt than the
one installed in the system. This may be used for example in autotest
or by packagers without the need to install libvirt into the system.
Signed-off-by: Martin Kletzander <mkletzan redhat com>
---
setup.py | 25 ++++++++++++++++++++++---
1 file changed, 22 insertions(+), 3 deletions(-)
Index: libvirt-python-1.2.1/setup.py
===================================================================
--- libvirt-python-1.2.1.orig/setup.py
+++ libvirt-python-1.2.1/setup.py
@@ -30,18 +30,19 @@
if pkgcfg is None:
raise Exception("pkg-config binary is required to compile libvirt-python")
-spawn([pkgcfg,
- "--print-errors",
- "--atleast-version=%s" % MIN_LIBVIRT,
- "libvirt"])
+# spawn([pkgcfg,
+# "--print-errors",
+# "--atleast-version=%s" % MIN_LIBVIRT,
+# "libvirt"])
have_libvirt_lxc=True
-try:
- spawn([pkgcfg,
- "--atleast-version=%s" % MIN_LIBVIRT_LXC,
- "libvirt"])
-except DistutilsExecError:
- have_libvirt_lxc=False
+# try:
+# spawn([pkgcfg,
+# "--atleast-version=%s" % MIN_LIBVIRT_LXC,
+# "libvirt"])
+# except DistutilsExecError:
+# have_libvirt_lxc=False
+have_libvirt_lxc=True
def get_pkgconfig_data(args, mod, required=True):
"""Run pkg-config to and return content associated with it"""
@@ -63,7 +64,17 @@
"""Check with pkg-config that libvirt is present and extract
the API XML file paths we need from it"""
- libvirt_api = get_pkgconfig_data(["--variable", "libvirt_api"], "libvirt")
+ libvirt_api = os.getenv("LIBVIRT_API_PATH")
+
+ if libvirt_api:
+ if not libvirt_api.endswith("-api.xml"):
+ raise ValueError("Invalid path '%s' for API XML" % libvirt_api)
+ if not os.path.exists(libvirt_api):
+ raise ValueError("API XML '%s' does not exist, "
+ "have you built libvirt?" % libvirt_api)
+ else:
+ libvirt_api = get_pkgconfig_data(["--variable", "libvirt_api"],
+ "libvirt")
offset = libvirt_api.index("-api.xml")
libvirt_qemu_api = libvirt_api[0:offset] + "-qemu-api.xml"
@@ -73,8 +84,17 @@
return (libvirt_api, libvirt_qemu_api, libvirt_lxc_api)
-ldflags = get_pkgconfig_data(["--libs-only-L"], "libvirt", False)
-cflags = get_pkgconfig_data(["--cflags"], "libvirt", False)
+libvirt_cflags = os.getenv("LIBVIRT_CFLAGS")
+if libvirt_cflags:
+ cflags = libvirt_cflags
+else:
+ cflags = get_pkgconfig_data(["--cflags"], "libvirt", False)
+
+libvirt_libs = os.getenv("LIBVIRT_LIBS")
+if libvirt_libs:
+ ldflags = libvirt_libs
+else:
+ ldflags = get_pkgconfig_data(["--libs-only-L"], "libvirt", False)
c_modules = []
py_modules = []

View File

@ -19,13 +19,13 @@ RDEPENDS_libvirt-libvirtd_append_x86 = " dmidecode"
#connman blocks the 53 port and libvirtd can't start its DNS service
RCONFLICTS_${PN}_libvirtd = "connman"
SRC_URI = "http://libvirt.org/sources/libvirt-${PV}.tar.gz \
SRC_URI = "http://libvirt.org/sources/libvirt-${PV}.tar.gz;name=libvirt \
file://tools-add-libvirt-net-rpc-to-virt-host-validate-when.patch \
file://libvirtd.sh \
file://libvirtd.conf"
SRC_URI[md5sum] = "cce374220f67895afb6331bd2ddedbfd"
SRC_URI[sha256sum] = "bc29b5751bf36753c17e2fdbb75e70c7b07df3d9527586d3426e90f5f4abb898"
SRC_URI[libvirt.md5sum] = "cce374220f67895afb6331bd2ddedbfd"
SRC_URI[libvirt.sha256sum] = "bc29b5751bf36753c17e2fdbb75e70c7b07df3d9527586d3426e90f5f4abb898"
inherit autotools gettext update-rc.d pkgconfig