Source: npth
Version: 1.2-2
Severity: normal
Tags: patch

It's useful to be able to build Windows artifacts on debian systems.
In particular, we want to be able to build things like win32-loader,
and the things inside it.

The attached series of patches creates a new arch-independent package,
libnpth-mingw-w64-dev, which facilitates that kind of work.

The choice of location and naming for the libraries comes from Stephen
Kitt, see:

  
https://lists.alioth.debian.org/pipermail/pkg-gnupg-maint/2016-February/003286.html

       --dkg

-- System Information:
Debian Release: stretch/sid
  APT prefers unstable-debug
  APT policy: (500, 'unstable-debug'), (500, 'testing'), (200, 'unstable'), (1, 
'experimental-debug'), (1, 'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 4.3.0-1-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
>From d40c2d6596ba38243a6689ac9099398725ff7deb Mon Sep 17 00:00:00 2001
From: Daniel Kahn Gillmor <d...@fifthhorseman.net>
Date: Mon, 15 Feb 2016 23:45:49 -0500
Subject: [PATCH 1/3] build out-of-tree for cleanliness

---
 debian/clean | 1 +
 debian/rules | 8 +++++++-
 2 files changed, 8 insertions(+), 1 deletion(-)
 create mode 100644 debian/clean

diff --git a/debian/clean b/debian/clean
new file mode 100644
index 0000000..567609b
--- /dev/null
+++ b/debian/clean
@@ -0,0 +1 @@
+build/
diff --git a/debian/rules b/debian/rules
index 3d3a750..af33f17 100755
--- a/debian/rules
+++ b/debian/rules
@@ -4,7 +4,13 @@
 	dh $@ --parallel --with autoreconf
 
 override_dh_auto_configure:
-	dh_auto_configure -- --enable-static
+	dh_auto_configure --builddirectory=build -- --enable-static
+
+override_dh_auto_build-arch:
+	dh_auto_build --builddirectory=build
+
+override_dh_auto_install-arch:
+	dh_auto_install --builddirectory=build
 
 override_dh_makeshlibs:
 	dh_makeshlibs -V
-- 
2.7.0

>From 0717d5a96aff8fa7dbffb8061d3b631f3e0385ed Mon Sep 17 00:00:00 2001
From: Daniel Kahn Gillmor <d...@fifthhorseman.net>
Date: Mon, 15 Feb 2016 23:51:14 -0500
Subject: [PATCH 2/3] Enable cross-building environment for Windows

We have some packages in debian that would like to build for the
Windows platform, in particular, for contributing to win32-loader.

This set of changes enables the creation of an arch-indep package for
use cross-building Windows artifacts that depend on libnpth.
---
 debian/clean                                   |  2 ++
 debian/control                                 | 18 ++++++++++++++++++
 debian/libnpth-mingw-w64-dev.install           |  6 ++++++
 debian/libnpth-mingw-w64-dev.lintian-overrides | 13 +++++++++++++
 debian/rules                                   | 26 ++++++++++++++++++++++++++
 5 files changed, 65 insertions(+)
 create mode 100644 debian/libnpth-mingw-w64-dev.install
 create mode 100644 debian/libnpth-mingw-w64-dev.lintian-overrides

diff --git a/debian/clean b/debian/clean
index 567609b..b388f56 100644
--- a/debian/clean
+++ b/debian/clean
@@ -1 +1,3 @@
 build/
+build-i686-w64-mingw32/
+build-x86_64-w64-mingw32/
diff --git a/debian/control b/debian/control
index a8718e5..27892d2 100644
--- a/debian/control
+++ b/debian/control
@@ -3,6 +3,7 @@ Section: libdevel
 Priority: optional
 Maintainer: Eric Dorland <e...@debian.org>
 Build-Depends: debhelper (>= 9.20151219), dh-autoreconf
+Build-Depends-Indep: mingw-w64
 Standards-Version: 3.9.6.1
 Homepage: http://www.gnupg.org/
 Vcs-Git: git://anonscm.debian.org/users/eric/npth.git
@@ -37,3 +38,20 @@ Description: replacement for GNU Pth using system threads
  implementation. Thus nPth allows the use of libraries which are not
  compatible to GNU Pth.
 
+Package: libnpth-mingw-w64-dev
+Architecture: all
+Priority: extra
+Section: libdevel
+Suggests: mingw-w64
+Depends: ${misc:Depends}, ${shlibs:Depends}
+Description: replacement for GNU Pth using system threads (Windows dev)
+ nPth is a non-preemptive threads implementation using an API very
+ similar to the one known from GNU Pth. It has been designed as a
+ replacement of GNU Pth for non-ancient operating systems. In
+ contrast to GNU Pth it is based on the system's standard threads
+ implementation. Thus nPth allows the use of libraries which are not
+ compatible to GNU Pth.
+ .
+ This is a Windows version of nPth.  It's meant to be used when
+ cross-building software that targets the Windows platform, e.g. the
+ win32-loader component of Debian-Installer.
diff --git a/debian/libnpth-mingw-w64-dev.install b/debian/libnpth-mingw-w64-dev.install
new file mode 100644
index 0000000..ab6e93e
--- /dev/null
+++ b/debian/libnpth-mingw-w64-dev.install
@@ -0,0 +1,6 @@
+usr/i686-w64-mingw32/bin/*
+usr/i686-w64-mingw32/lib/*
+usr/i686-w64-mingw32/include/*
+usr/x86_64-w64-mingw32/bin/*
+usr/x86_64-w64-mingw32/lib/*
+usr/x86_64-w64-mingw32/include/*
diff --git a/debian/libnpth-mingw-w64-dev.lintian-overrides b/debian/libnpth-mingw-w64-dev.lintian-overrides
new file mode 100644
index 0000000..73213e6
--- /dev/null
+++ b/debian/libnpth-mingw-w64-dev.lintian-overrides
@@ -0,0 +1,13 @@
+# libnpth-mingw-w64-dev is "arch-independent" from debian's perspective,
+# since it ships binaries that are only used during cross-building
+# windows software.
+libnpth-mingw-w64-dev: arch-independent-package-contains-binary-or-object
+
+# The location of these cross-building tools is the result of
+# discussion with mingw maintainers:
+# https://lists.alioth.debian.org/pipermail/pkg-gnupg-maint/2016-February/003281.html
+libnpth-mingw-w64-dev: file-in-unusual-dir
+libnpth-mingw-w64-dev: non-standard-dir-in-usr
+
+# DLLs exported via Samba need to be executable (see #796224)
+libnpth-mingw-w64-dev: executable-not-elf-or-script
diff --git a/debian/rules b/debian/rules
index af33f17..62dc7b8 100755
--- a/debian/rules
+++ b/debian/rules
@@ -17,3 +17,29 @@ override_dh_makeshlibs:
 
 override_dh_strip:
 	dh_strip --ddeb-migration='libnpth0-dbg (<< 1.2-2~)'
+
+### "arch-independent" Windows builds: ###
+
+WIN_FLAGS=LDFLAGS="-Xlinker --no-insert-timestamp" CFLAGS="-g -Os" CPPFLAGS=
+
+override_dh_auto_build-indep:
+	for cpu in i686 x86_64; do \
+	 mkdir -p build-$$cpu-w64-mingw32 && \
+	 cd build-$$cpu-w64-mingw32 && $(WIN_FLAGS) ../configure \
+	    --prefix=/usr/$$cpu-w64-mingw32 \
+	    --with-prefix=/usr/$$cpu-w64-mingw32 \
+	    --with-libgpg-error-prefix=/usr/$$cpu-w64-mingw32 \
+	    --enable-static \
+	    --host $$cpu-w64-mingw32 && \
+	  $(WIN_FLAGS) $(MAKE) \
+	  || exit 1 ; \
+	  cd .. ; \
+	done
+
+override_dh_auto_install-indep:
+	for cpu in i686 x86_64; do \
+	  cd build-$$cpu-w64-mingw32 && \
+	  $(MAKE) install DESTDIR=$(shell pwd)/debian/tmp \
+	  || exit 1 ; \
+	  cd .. ; \
+	done
-- 
2.7.0

>From 318aa948adad6efab03f2fd3bac6b8da7f9adecf Mon Sep 17 00:00:00 2001
From: Daniel Kahn Gillmor <d...@fifthhorseman.net>
Date: Mon, 15 Feb 2016 23:45:01 -0500
Subject: [PATCH 3/3] update changelog as an NMU

---
 debian/changelog | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/debian/changelog b/debian/changelog
index 4098093..703c5e5 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+npth (1.2-2.1) unstable; urgency=medium
+
+  * add libnpth-mingw-w64-dev for cross-building Windows artifacts.
+
+ -- Daniel Kahn Gillmor <d...@fifthhorseman.net>  Tue, 16 Feb 2016 01:19:03 -0500
+
 npth (1.2-2) unstable; urgency=medium
 
   * debian/control: Fix grammer mistake in description. Thanks Marius
-- 
2.7.0

Reply via email to