Browse Source

Support stage build (without python). Closes: #709558

Thanks to Daniel Schepler and Eleanor Chen
Christoph Biedl 10 years ago
parent
commit
8b141a001c
2 changed files with 31 additions and 1 deletions
  1. 3 1
      debian/control
  2. 28 0
      debian/rules

+ 3 - 1
debian/control

@@ -2,7 +2,7 @@ Source: file
 Section: utils
 Priority: standard
 Maintainer: Christoph Biedl <debian.axhn@manchmal.in-ulm.de>
-Build-Depends: debhelper (>= 9),
+Build-Depends: debhelper (>= 9.20140227~),
     autotools-dev,
     python-all,
     python3-all,
@@ -67,6 +67,7 @@ Package: python-magic
 Section: python
 Priority: optional
 Architecture: all
+Build-Profiles: !stage1
 Depends: ${misc:Depends}, ${shlibs:Depends}, ${python:Depends},
     libmagic1 (>= ${binary:Version}),
     libmagic1 (<< ${binary:Version}.1~),
@@ -82,6 +83,7 @@ Package: python3-magic
 Section: python
 Priority: optional
 Architecture: all
+Build-Profiles: !stage1
 Depends: ${misc:Depends}, ${python3:Depends},
     libmagic1 (>= ${binary:Version}),
     libmagic1 (<< ${binary:Version}.1~),

+ 28 - 0
debian/rules

@@ -2,7 +2,9 @@
 
 SHELL := sh -e
 
+ifeq (,$(filter stage1,$(DEB_BUILD_PROFILES)))
 -include /usr/share/python/python.mk
+endif
 
 DEB_HOST_GNU_TYPE	?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
 DEB_BUILD_GNU_TYPE	?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
@@ -17,11 +19,17 @@ endif
 # HOWMANY is the number of bytes looked at by file
 CFLAGS += -DHOWMANY=0x18000
 
+ifeq (,$(filter stage1,$(DEB_BUILD_PROFILES)))
 PYTHON_VERSIONS=$(shell pyversions -r debian/control)
 PYTHON3_VERSIONS=$(shell py3versions -r debian/control)
+endif
 
 %:
+ifeq (,$(filter stage1,$(DEB_BUILD_PROFILES)))
 	dh ${@} --with autotools_dev,python2,python3
+else
+	dh ${@} --with autotools_dev
+endif
 
 override_dh_auto_clean:
 	dh_auto_clean
@@ -33,6 +41,7 @@ override_dh_auto_clean:
 override_dh_auto_build:
 	dh_auto_build
 
+ifeq (,$(filter stage1,$(DEB_BUILD_PROFILES)))
 	for python in $(PYTHON_VERSIONS); \
 	do \
 		(cd python && $$python setup.py build_ext \
@@ -44,6 +53,7 @@ override_dh_auto_build:
 		(cd python && $$python setup.py build_ext \
 			-L$(CURDIR)/src/.libs); \
 	done
+endif
 
 override_dh_auto_configure:
 	dh_auto_configure -- $(CROSS) --prefix=/usr --datadir=\$${prefix}/share --libdir=\$${prefix}/lib/$(DEB_HOST_MULTIARCH) --mandir=\$${prefix}/share/man --enable-fsect-man5 --enable-static --disable-silent-rules CFLAGS="$(CFLAGS)"
@@ -56,6 +66,7 @@ override_dh_auto_install:
 	install -D -m 0644 magic/magic.local debian/tmp/etc/magic
 	install -D -m 0644 magic/magic.local debian/tmp/etc/magic.mime
 
+ifeq (,$(filter stage1,$(DEB_BUILD_PROFILES)))
 	for python in $(PYTHON_VERSIONS); \
 	do \
 		(cd python && $$python setup.py install --no-compile \
@@ -67,6 +78,7 @@ override_dh_auto_install:
 		(cd python && $$python setup.py install --no-compile \
 			--root=$(CURDIR)/debian/python3-magic $(py_setup_install_args)); \
 	done
+endif
 
 	# Installing additional headers
 	mkdir -p debian/libmagic-dev/usr/include/file
@@ -82,7 +94,23 @@ override_dh_install:
 	dh_install --fail-missing
 
 override_dh_shlibdeps:
+ifeq ($(DEB_BUILD_ARCH),$(DEB_HOST_ARCH))
+	# use just built file in dh_shlibdeps
+	PATH=$(CURDIR)/debian/file/usr/bin:$$PATH \
+		LD_LIBRARY_PATH=$(CURDIR)/debian/libmagic1/usr/lib/$(DEB_HOST_MULTIARCH)$${LD_LIBRARY_PATH+:$${LD_LIBRARY_PATH}} \
+		MAGIC=$(CURDIR)/debian/libmagic1/usr/share/file/magic.mgc \
+		dh_shlibdeps -Llibmagic1 -ldebian/libmagic1/usr/lib
+else
 	dh_shlibdeps -Llibmagic1 -ldebian/libmagic1/usr/lib
+endif
 
 override_dh_strip:
+ifeq ($(DEB_BUILD_ARCH),$(DEB_HOST_ARCH))
+	# use just built file in dh_strip
+	PATH=$(CURDIR)/debian/file/usr/bin:$$PATH \
+		LD_LIBRARY_PATH=$(CURDIR)/debian/libmagic1/usr/lib/$(DEB_HOST_MULTIARCH)$${LD_LIBRARY_PATH+:$${LD_LIBRARY_PATH}} \
+		MAGIC=$(CURDIR)/debian/libmagic1/usr/share/file/magic.mgc \
+		dh_strip --dbg-package=file-dbg
+else
 	dh_strip --dbg-package=file-dbg
+endif