Build python-libvirt for all python versions
authorPhilipp Hahn <hahn@univention.de>
Tue, 23 Aug 2011 17:18:11 +0000 (19:18 +0200)
committerGuido Günther <agx@sigxcpu.org>
Tue, 23 Aug 2011 19:17:15 +0000 (21:17 +0200)
Closes: #628828

debian/control
debian/python.mk [new file with mode: 0644]
debian/rules

index a68e370..9385606 100644 (file)
@@ -10,7 +10,7 @@ Build-Depends: cdbs (>= 0.4.90~),
  libreadline-dev,
  zlib1g-dev,
  libgnutls-dev,
- python-dev (>= 2.6.6-3~),
+ python-all-dev (>= 2.6.6-3~),
  libavahi-client-dev,
  libsasl2-dev,
  libxen-dev [i386 amd64],
@@ -35,14 +35,13 @@ Build-Depends: cdbs (>= 0.4.90~),
  dnsmasq-base,
  openssh-client,
  netcat-openbsd,
-XS-Python-Version: current
 Build-Conflicts: dpkg-dev (= 1.15.3)
 Vcs-Git: git://git.debian.org/git/pkg-libvirt/libvirt.git
 Vcs-Browser: http://git.debian.org/?p=pkg-libvirt/libvirt.git
 Homepage: http://libvirt.org
 Standards-Version: 3.9.2
 DM-Upload-Allowed: yes
-X-Python-Version: 2.6
+X-Python-Version: current
 
 Package: libvirt-bin
 Architecture: any
diff --git a/debian/python.mk b/debian/python.mk
new file mode 100644 (file)
index 0000000..bcec1f7
--- /dev/null
@@ -0,0 +1,38 @@
+# Build python modules for all known python versions
+
+include /usr/share/python/python.mk
+ifeq (,$(py_sitename))
+  py_libdir_sh = $$(_py_=$(strip $(1)); python$${_py_\#python*} -c 'from distutils import sysconfig; print(sysconfig.get_python_lib())')
+endif
+
+PY_DIR := $(DEB_BUILDDIR)/python
+PYDEFAULTVER := $(shell pyversions --version --default)
+PYVERSIONS := $(shell pyversions --version --installed)
+
+otherpy = \
+       set -e; for v in $(PYVERSIONS); do \
+               $(RM) $(PY_DIR); \
+               ln -sf $(PY_DIR)$$v $(PY_DIR); \
+               $(MAKE) \
+                       -C $(PY_DIR) \
+                       pyexecdir=$(call py_libdir_sh, $$v) \
+                       PYTHON=python$$v \
+                       PYTHON_VERSION=$$v \
+                       PYTHON_INCLUDES=-I/usr/include/python$$v \
+                       $1; \
+               $(RM) $(PY_DIR); \
+       done; \
+       ln -sf $(PY_DIR)$(PYDEFAULTVER) $(PY_DIR)
+
+configure/python-libvirt::
+       set -e; for v in $(PYVERSIONS); do \
+               cp -la $(PY_DIR) $(PY_DIR)$$v; \
+       done
+       $(RM) -r $(PY_DIR)
+       ln -sf $(PY_DIR)$(PYDEFAULTVER) $(PY_DIR)
+
+build/python-libvirt::
+       $(call otherpy, all)
+
+install/python-libvirt::
+       $(call otherpy, install DESTDIR=$(CURDIR)/debian/tmp)
index e513591..b4fba08 100755 (executable)
@@ -49,7 +49,7 @@ ifneq (,$(findstring ${DEB_BUILD_ARCH}, m68k))
        CFLAGS = -fwrapv -DWRAPV
 endif
 
-
+DEB_BUILDDIR := $(CURDIR)/debian/build
 DEB_CONFIGURE_EXTRA_FLAGS :=     \
        --disable-rpath          \
        $(WITH_QEMU)             \
@@ -83,10 +83,13 @@ DEB_COMPRESS_EXCLUDE = .o event-test hellolibvirt info1 suspend
 DEB_PYTHON_SETUP_CMD = /dev/null
 DEB_DH_MAKESHLIBS_ARGS_libvirt0 += -V 'libvirt0 (>= 0.5.0)'
 DEB_DH_INSTALLINIT_ARGS = --no-restart-on-upgrade -- defaults 28 72
+DEB_PYTHON_MODULE_PACKAGE = python-libvirt
 
 LOGROTATE = $(basename $(basename $(notdir $(wildcard daemon/libvirtd*.logrotate.in))))
 EXAMPLES_DIR = $(CURDIR)/debian/libvirt-doc/usr/share/doc/libvirt-doc/examples/
 
+include debian/python.mk
+
 binary-install/libvirt-bin::
        cp $(CURDIR)/tools/libvirt-guests.init.sh $(CURDIR)/debian/libvirt-bin.libvirt-guests.init
        cp $(CURDIR)/tools/libvirt-guests.sysconf $(CURDIR)/debian/libvirt-bin.libvirt-guests.default
@@ -114,3 +117,4 @@ clean::
        rm -f $(CURDIR)/debian/libvirt-bin.libvirt-guests.init
        rm -f $(CURDIR)/debian/libvirt-bin.libvirt-guests.default
        rm -f $(CURDIR)/debian/libvirt-bin.*.logrotate
+       rm -rf $(DEB_BUILDDIR)