Source: libksba
Version: 1.3.3-1
Severity: normal
Tags: patch

We should be able to build Windows executables from debian, including
GnuPG (for gpgv-win32 for win32-loader).  Having a cross-building
toolchain will make that possible.

The attached set of patches (also in the debian-windows branch of
https://anonscm.debian.org/users/dkg/libksba.git) provides this for
libksba.

I'm happy to NMU, or to push these to to the pkg-gnutls repo directly
if you'd rather i did that.  let me know!

 For background:
 
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)

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 b9d741ad8afa4c032ca8259c17bf748e1abecd70 Mon Sep 17 00:00:00 2001
From: Daniel Kahn Gillmor <d...@fifthhorseman.net>
Date: Sun, 14 Feb 2016 12:15:32 -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 2e81a33..f492aba 100755
--- a/debian/rules
+++ b/debian/rules
@@ -4,9 +4,15 @@ export DEB_CFLAGS_MAINT_APPEND := -Wall
 export DEB_CXXFLAGS_MAINT_APPEND := -Wall
 
 override_dh_auto_configure:
-	dh_auto_configure --verbose -- \
+	dh_auto_configure --builddirectory=build --verbose -- \
 		--enable-ld-version-script --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 "libksba8 (>= 1.2.0)"
 
-- 
2.7.0

>From d764f32774f1f0ddbfc0bf74b82cfc0746c667e6 Mon Sep 17 00:00:00 2001
From: Daniel Kahn Gillmor <d...@fifthhorseman.net>
Date: Sun, 14 Feb 2016 12:41:06 -0500
Subject: [PATCH 2/3] fix win32 linker

---
 debian/patches/0001-fix-win32-linker.patch | 24 ++++++++++++++++++++++++
 debian/patches/series                      |  1 +
 2 files changed, 25 insertions(+)
 create mode 100644 debian/patches/0001-fix-win32-linker.patch
 create mode 100644 debian/patches/series

diff --git a/debian/patches/0001-fix-win32-linker.patch b/debian/patches/0001-fix-win32-linker.patch
new file mode 100644
index 0000000..fc0d13a
--- /dev/null
+++ b/debian/patches/0001-fix-win32-linker.patch
@@ -0,0 +1,24 @@
+Description: fix mingw32 linker error
+ without this patch, we get a problem cross-building for mingw32, where the linker script is not recognized.
+ .
+ This is a similar issue to the one the libgpg-error had in
+ https://lists.gnupg.org/pipermail/gnupg-devel/2016-February/030798.html
+Author: Daniel Kahn Gillmor <d...@fifthhorseman.net>
+Last-Update: 2016-02-14
+
+
+--- a/src/libksba.def
++++ b/src/libksba.def
+@@ -1,3 +1,4 @@
++EXPORTS
+ ;; libksba.def - Exported symbols for W32
+ ;;      Copyright (C) 2007 g10 Code GmbH
+ ;;
+@@ -28,7 +29,6 @@
+ ;; if not, see <http://www.gnu.org/licenses/>.
+ 
+ 
+-EXPORTS
+       ksba_check_version  @1
+ 
+       ksba_set_hash_buffer_function @2
diff --git a/debian/patches/series b/debian/patches/series
new file mode 100644
index 0000000..67c229c
--- /dev/null
+++ b/debian/patches/series
@@ -0,0 +1 @@
+0001-fix-win32-linker.patch
-- 
2.7.0

>From d27f7da5b372a7ce6615a16fe0e560f747963408 Mon Sep 17 00:00:00 2001
From: Daniel Kahn Gillmor <d...@fifthhorseman.net>
Date: Sun, 14 Feb 2016 12:29:42 -0500
Subject: [PATCH 3/3] Build windows cross-building packages for libksba

---
 debian/clean                                   |  2 ++
 debian/control                                 | 21 +++++++++++++++++++++
 debian/libksba-mingw-w64-dev.install           |  6 ++++++
 debian/libksba-mingw-w64-dev.lintian-overrides | 13 +++++++++++++
 debian/rules                                   | 26 ++++++++++++++++++++++++++
 5 files changed, 68 insertions(+)
 create mode 100644 debian/libksba-mingw-w64-dev.install
 create mode 100644 debian/libksba-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 7222f80..432ce00 100644
--- a/debian/control
+++ b/debian/control
@@ -7,6 +7,7 @@ Uploaders: Andreas Metzler <ametz...@debian.org>,
  Peter Eisentraut <pet...@debian.org>
 Build-Depends: debhelper (>= 9), libgpg-error-dev (>= 1.8),
   dh-autoreconf
+Build-Depends-Indep: libgpg-error-mingw-w64-dev, mingw-w64
 Standards-Version: 3.9.6
 Vcs-Git: https://anonscm.debian.org/git/pkg-gnutls/libksba.git
 Vcs-Browser: https://anonscm.debian.org/cgit/pkg-gnutls/libksba.git
@@ -41,3 +42,23 @@ Description: X.509 and CMS support library
  Encoder, Certificate Handling and CMS Handling.
  .
  This package contains the runtime library files.
+
+Package: libksba-mingw-w64-dev
+Architecture: all
+Priority: extra
+Section: libdevel
+Depends: ${misc:Depends}
+Suggests: mingw-w64
+Description: X.509 and CMS support library (Windows development)
+ KSBA (pronounced Kasbah) is a library to make X.509 certificates as
+ well as the CMS easily accessible by other applications.  Both
+ specifications are building blocks of S/MIME and TLS.
+ .
+ KSBA provides these subsystems: ASN.1 Parser, BER Decoder, BER
+ Encoder, Certificate Handling and CMS Handling.
+ .
+ This package contains the runtime library files.
+ .
+ This is a Windows version of KSBA.  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/libksba-mingw-w64-dev.install b/debian/libksba-mingw-w64-dev.install
new file mode 100644
index 0000000..ab6e93e
--- /dev/null
+++ b/debian/libksba-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/libksba-mingw-w64-dev.lintian-overrides b/debian/libksba-mingw-w64-dev.lintian-overrides
new file mode 100644
index 0000000..2806ca1
--- /dev/null
+++ b/debian/libksba-mingw-w64-dev.lintian-overrides
@@ -0,0 +1,13 @@
+# libksba-mingw-w64-dev is "arch-independent" from debian's perspective,
+# since it ships binaries that are only used during cross-building
+# windows software.
+libksba-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
+libksba-mingw-w64-dev: file-in-unusual-dir
+libksba-mingw-w64-dev: non-standard-dir-in-usr
+
+# DLLs exported via Samba need to be executable (see #796224)
+libksba-mingw-w64-dev: executable-not-elf-or-script
diff --git a/debian/rules b/debian/rules
index f492aba..d6578ce 100755
--- a/debian/rules
+++ b/debian/rules
@@ -18,3 +18,29 @@ override_dh_makeshlibs:
 
 %:
 	dh $@ --parallel --with autoreconf
+
+### "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

Reply via email to