From 3a4178af7e906137bee59d6a51f0edfcce8b6990 Mon Sep 17 00:00:00 2001
From: Iain Lane <iain.lane@canonical.com>
Date: Mon, 2 Jul 2012 13:01:50 +0100
Subject: [PATCH 1/3] Update for multiarch.

---
 debian/changelog           |    6 ++++++
 debian/control             |    6 +++++-
 debian/libcrack2-dev.links |    1 -
 debian/rules               |   18 +++++++++++++-----
 4 files changed, 24 insertions(+), 7 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 63beeb7..c4993c2 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+cracklib2 (2.8.19-2) UNRELEASED; urgency=low
+
+  * Update for multiarch.
+
+ -- Iain Lane <iain.lane@canonical.com>  Mon, 02 Jul 2012 12:45:00 +0100
+
 cracklib2 (2.8.19-1) unstable; urgency=low
 
   * New upstream version
diff --git a/debian/control b/debian/control
index 741ad83..b1df4a2 100644
--- a/debian/control
+++ b/debian/control
@@ -4,7 +4,7 @@ Priority: optional
 Maintainer: Jan Dittberner <jandd@debian.org>
 Uploaders: Martin Pitt <mpitt@debian.org>
 Standards-Version: 3.9.3
-Build-Depends: debhelper (>= 7.0.50), python-all-dev (>= 2.6.6-3~),
+Build-Depends: debhelper (>= 9), python-all-dev (>= 2.6.6-3~),
  python3-all-dev (>= 3.1.3-2~), chrpath, xmlto, automake (>= 1.10),
  autoconf (>=2.61), libtool, python-setuptools, python3-setuptools,
  dpkg-dev (>= 1.16.1~), autotools-dev
@@ -14,6 +14,8 @@ Vcs-Browser: http://git.debian.org/?p=pkg-cracklib/pkg-cracklib.git
 
 Package: libcrack2
 Architecture: any
+Multi-Arch: same
+Pre-Depends: ${misc:Pre-Depends}
 Depends: ${shlibs:Depends}, ${misc:Depends}
 Recommends: cracklib-runtime
 Description: pro-active password checker library
@@ -40,6 +42,8 @@ Description: pro-active password checker library - development files
 Package: cracklib-runtime
 Section: admin
 Architecture: any
+Multi-Arch: foreign
+Pre-Depends: ${misc:Pre-Depends}
 Depends: ${shlibs:Depends}, libcrack2 (>=${binary:Version}), file,
  ${misc:Depends}
 Recommends: wamerican | wordlist
diff --git a/debian/libcrack2-dev.links b/debian/libcrack2-dev.links
index 2bde974..4b01ff6 100644
--- a/debian/libcrack2-dev.links
+++ b/debian/libcrack2-dev.links
@@ -1,2 +1 @@
-/usr/lib/libcrack.so.2 /usr/lib/libcrack.so
 /usr/share/man/man3/FascistCheck.3 /usr/share/man/man3/cracklib.3
diff --git a/debian/rules b/debian/rules
index f3abdd9..36b2940 100755
--- a/debian/rules
+++ b/debian/rules
@@ -8,6 +8,7 @@ include /usr/share/python/python.mk
 
 DEB_HOST_GNU_TYPE  ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
 DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
+DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)
 
 PYVERS := $(shell pyversions -vs)
 PY3VERS := $(shell py3versions -vs)
@@ -19,6 +20,7 @@ override_dh_auto_configure:
 	$(CURDIR)/configure \
 		--host=$(DEB_HOST_GNU_TYPE) --build=$(DEB_BUILD_GNU_TYPE) \
 		--prefix=/usr --disable-rpath --without-python \
+		--libdir=\$${prefix}/lib/$(DEB_HOST_MULTIARCH) \
 		--with-default-dict=/var/cache/cracklib/cracklib_dict \
 		CFLAGS="$(CFLAGS)" CPPFLAGS="$(CPPFLAGS)" LDFLAGS="$(LDFLAGS)"
 	for i in $(PYVERS) $(PY3VERS); do \
@@ -27,6 +29,7 @@ override_dh_auto_configure:
 		$(CURDIR)/configure \
 			--host=$(DEB_HOST_GNU_TYPE) --build=$(DEB_BUILD_GNU_TYPE) \
 			--prefix=/usr --disable-rpath \
+			--libdir=\$${prefix}/lib/$(DEB_HOST_MULTIARCH) \
 			--with-default-dict=/var/cache/cracklib/cracklib_dict \
 			PYTHON_PREFIX=$(call py_builddir_sh,$$i) \
 			PYTHON=/usr/bin/python$$i \
@@ -75,11 +78,11 @@ override_dh_auto_clean:
 override_dh_auto_install:
 	$(MAKE) -C $(CURDIR)/debian/buildtmp/base DESTDIR=$(CURDIR)/debian/libcrack2 install
 	# move files to libcrack2-dev
-	mkdir -p $(CURDIR)/debian/libcrack2-dev/usr/lib
+	mkdir -p $(CURDIR)/debian/libcrack2-dev/usr/lib/$(DEB_HOST_MULTIARCH)
 	mv $(CURDIR)/debian/libcrack2/usr/include \
 	   $(CURDIR)/debian/libcrack2-dev/usr
-	mv $(CURDIR)/debian/libcrack2/usr/lib/*.a \
-	   $(CURDIR)/debian/libcrack2-dev/usr/lib
+	mv $(CURDIR)/debian/libcrack2/usr/lib/$(DEB_HOST_MULTIARCH)/*.a \
+	   $(CURDIR)/debian/libcrack2-dev/usr/lib/$(DEB_HOST_MULTIARCH)
 	# move files to cracklib-runtime
 	mkdir -p $(CURDIR)/debian/cracklib-runtime/usr/share/dict
 	mv $(CURDIR)/debian/libcrack2/usr/sbin \
@@ -87,8 +90,8 @@ override_dh_auto_install:
 	mv $(CURDIR)/debian/libcrack2/usr/share/cracklib/cracklib-small \
 	   $(CURDIR)/debian/cracklib-runtime/usr/share/dict
 	# remove unused files
-	rm -f $(CURDIR)/debian/libcrack2/usr/lib/*.la \
-	      $(CURDIR)/debian/libcrack2/usr/lib/libcrack.so
+	rm -f $(CURDIR)/debian/libcrack2/usr/lib/$(DEB_HOST_MULTIARCH)/*.la \
+	      $(CURDIR)/debian/libcrack2/usr/lib/$(DEB_HOST_MULTIARCH)/libcrack.so
 	rm -rf $(CURDIR)/debian/libcrack2/usr/share/cracklib
 	chrpath -d \
 	  $(CURDIR)/debian/cracklib-runtime/usr/sbin/cracklib-check \
@@ -103,6 +106,11 @@ override_dh_auto_install:
 		python$$i setup.py install --install-layout=deb --root $(CURDIR)/debian/python3-cracklib; \
 	done
 
+override_dh_link:
+	dh_link -plibcrack2-dev usr/lib/$(DEB_HOST_MULTIARCH)/libcrack.so.2 \
+		usr/lib/$(DEB_HOST_MULTIARCH)/libcrack.so
+	dh_link
+
 override_dh_installchangelogs:
 	dh_installchangelogs NEWS
 
-- 
1.7.10.4

