Package: libgcrypt20 Version: 1.6.4-5 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 against branch1.6 (also in the debian-windows branch of https://anonscm.debian.org/git/users/dkg/libgcrypt.git) provides this for libgcrypt. 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) Versions of packages libgcrypt20 depends on: ii libc6 2.21-7 ii libgpg-error0 1.21-1 libgcrypt20 recommends no packages. Versions of packages libgcrypt20 suggests: pn rng-tools <none> -- debconf-show failed
>From c58a86b9b3c4c6abc507dcd3fc4df00a63d51493 Mon Sep 17 00:00:00 2001 From: Daniel Kahn Gillmor <d...@fifthhorseman.net> Date: Tue, 9 Feb 2016 01:45:50 -0500 Subject: [PATCH 1/4] build out-of-tree for cleanliness --- debian/clean | 1 + debian/libgcrypt20-doc.install | 4 ++-- debian/rules | 13 ++++++++----- 3 files changed, 11 insertions(+), 7 deletions(-) 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/libgcrypt20-doc.install b/debian/libgcrypt20-doc.install index 0d070ae..af97bd4 100644 --- a/debian/libgcrypt20-doc.install +++ b/debian/libgcrypt20-doc.install @@ -1,3 +1,3 @@ -doc/gcrypt.pdf usr/share/doc/libgcrypt20-doc -doc/gcrypt.html/* usr/share/doc/libgcrypt20-doc/html +build/doc/gcrypt.pdf usr/share/doc/libgcrypt20-doc +build/doc/gcrypt.html/* usr/share/doc/libgcrypt20-doc/html doc/*.png usr/share/doc/libgcrypt20-doc/html diff --git a/debian/rules b/debian/rules index 71dd640..abe8677 100755 --- a/debian/rules +++ b/debian/rules @@ -5,7 +5,7 @@ DEBVERSION := $(shell dpkg-parsechangelog | \ sed -n '/^Version: /s/^Version: //p') override_dh_auto_configure: - dh_auto_configure --verbose -- \ + dh_auto_configure --verbose --builddirectory=build -- \ --enable-noexecstack \ --enable-ld-version-script --enable-static \ --libdir=/lib/$(DEB_HOST_MULTIARCH) @@ -14,14 +14,17 @@ override_dh_makeshlibs: dh_makeshlibs -V 'libgcrypt20 (>=1.6.0-0)' \ --add-udeb=libgcrypt20-udeb -- -c4 +override_dh_auto_build-arch: + dh_auto_build --builddirectory=build + override_dh_auto_build-indep: # use current version in /usr/share/texmf/tex/texinfo/, see #803081 rm -f build-aux/texinfo.tex - cd doc && $(MAKE) stamp-vti - cd doc && $(MAKE) pdf html + cd build/doc && $(MAKE) stamp-vti + cd build/doc && $(MAKE) pdf html -override_dh_auto_install: - dh_auto_install --verbose +override_dh_auto_install-arch: + dh_auto_install --verbose --builddirectory=build mkdir -p -m755 debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH) cd debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH) \ && ln -v -s /lib/$(DEB_HOST_MULTIARCH)/`readlink ../../../lib/*/*.so` libgcrypt.so -- 2.7.0
>From d2274205fce30db0bf20cd1d23885fc1f5b2a0f2 Mon Sep 17 00:00:00 2001 From: Daniel Kahn Gillmor <d...@fifthhorseman.net> Date: Tue, 9 Feb 2016 02:57:54 -0500 Subject: [PATCH 2/4] update gpg-error.m4 --- debian/patches/35_fix_gpg_error_config_prefix.diff | 21 +++++++++++++++++++++ debian/patches/series | 1 + 2 files changed, 22 insertions(+) create mode 100644 debian/patches/35_fix_gpg_error_config_prefix.diff diff --git a/debian/patches/35_fix_gpg_error_config_prefix.diff b/debian/patches/35_fix_gpg_error_config_prefix.diff new file mode 100644 index 0000000..ec1f25f --- /dev/null +++ b/debian/patches/35_fix_gpg_error_config_prefix.diff @@ -0,0 +1,21 @@ +Description: avoid overwriting --with-libgpg-error-prefix with --with-gpg-error-prefix + gpg-error's upstream fixed this problem a few years ago with: + http://git.gnupg.org/cgi-bin/gitweb.cgi?p=libgpg-error.git;a=commitdiff;h=056cc2d0dfef023fda47ce377d3ee544612526a3 + The corrected file is also available on debian in + /usr/share/aclocal/gpg-error.m4 in the libgpg-error-dev package, but + i'm not sure how to swap it in here before the autoreconf. Probably + gcrypt upstream should update to the latest gpg-error.m4. +Author: Daniel Kahn Gillmor <d...@fifthhorseman.net> +Last-Update: 2016-02-09 + +--- libgcrypt20-1.6.4.orig/m4/gpg-error.m4 ++++ libgcrypt20-1.6.4/m4/gpg-error.m4 +@@ -27,7 +27,7 @@ AC_DEFUN([AM_PATH_GPG_ERROR], + dnl --with-libgpg-error-prefix above, for backwards compatibility, + dnl but do not document this old, inconsistently-named option. + AC_ARG_WITH(gpg-error-prefix,, +- gpg_error_config_prefix="$withval", gpg_error_config_prefix="") ++ gpg_error_config_prefix="$withval") + + if test x$gpg_error_config_prefix != x ; then + if test x${GPG_ERROR_CONFIG+set} != xset ; then diff --git a/debian/patches/series b/debian/patches/series index 2f0a91b..f99d8a4 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -2,3 +2,4 @@ 15_multiarchpath_in_-L.diff 20_fedora_libgcrypt-1.6.3-aliasing.patch 30_support_source_date_epoch.diff +35_fix_gpg_error_config_prefix.diff -- 2.7.0
>From ed9f4b5a2a20d32cca1ff483bd9c80e6fb0bd312 Mon Sep 17 00:00:00 2001 From: Daniel Kahn Gillmor <d...@fifthhorseman.net> Date: Tue, 9 Feb 2016 20:19:49 -0500 Subject: [PATCH 3/4] patch linker script --- debian/patches/40_fix_windows_linker_script.patch | 32 +++++++++++++++++++++++ debian/patches/series | 1 + 2 files changed, 33 insertions(+) create mode 100644 debian/patches/40_fix_windows_linker_script.patch diff --git a/debian/patches/40_fix_windows_linker_script.patch b/debian/patches/40_fix_windows_linker_script.patch new file mode 100644 index 0000000..74bb5c5 --- /dev/null +++ b/debian/patches/40_fix_windows_linker_script.patch @@ -0,0 +1,32 @@ +Description: fix mingw32 linker error + without this patch, i see the following problems cross-building for mingw32: + . + libtool: link: /usr/bin/i686-w64-mingw32-nm -B .libs/libgcrypt_la-visibility.o .libs/libgcrypt_la-misc.o .libs/libgcrypt_la-global.o .libs/libgcrypt_la-sexp.o .libs/libgcrypt_la-hwfeatures.o .libs/libgcrypt_la-stdmem.o .libs/libgcrypt_la-secmem.o .libs/libgcrypt_la-missing-string.o .libs/libgcrypt_la-fips.o .libs/libgcrypt_la-hmac256.o .libs/libgcrypt_la-context.o .libs/libgcrypt_la-ath.o .libs/versioninfo.o .libs/hwf-x86.o ../cipher/.libs/libcipher.a ../random/.libs/librandom.a ../mpi/.libs/libmpi.a ../compat/.libs/libcompat.a | sed -n -e 's/^.*[ ]\([ABCDGIRSTW][ABCDGIRSTW]*\)[ ][ ]*_\([_A-Za-z][_A-Za-z0-9]*\)$/\1 _\2 \2/p' | sed '/ __gnu_lto/d' | /bin/sed -e '/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1 DATA/;s/^.*[ ]__nm__\([^ ]*\)[ ][^ ]*/\1 DATA/;/^I[ ]/d;/^[AITW][ ]/s/.* //' | sort | uniq > .libs/libgcrypt.exp + libtool: link: if test "x`/bin/sed 1q .libs/libgcrypt.def`" = xEXPORTS; then cp .libs/libgcrypt.def .libs/libgcrypt-20.dll.def; else echo EXPORTS > .libs/libgcrypt-20.dll.def; cat .libs/libgcrypt.def >> .libs/libgcrypt-20.dll.def; fi + libtool: link: i686-w64-mingw32-gcc -shared .libs/libgcrypt-20.dll.def .libs/libgcrypt_la-visibility.o .libs/libgcrypt_la-misc.o .libs/libgcrypt_la-global.o .libs/libgcrypt_la-sexp.o .libs/libgcrypt_la-hwfeatures.o .libs/libgcrypt_la-stdmem.o .libs/libgcrypt_la-secmem.o .libs/libgcrypt_la-missing-string.o .libs/libgcrypt_la-fips.o .libs/libgcrypt_la-hmac256.o .libs/libgcrypt_la-context.o .libs/libgcrypt_la-ath.o .libs/versioninfo.o .libs/hwf-x86.o -Wl,--whole-archive ../cipher/.libs/libcipher.a ../random/.libs/librandom.a ../mpi/.libs/libmpi.a ../compat/.libs/libcompat.a -Wl,--no-whole-archive -L/usr/share/win32/lib /usr/share/win32/lib/libgpg-error.dll.a -Os -static-libgcc -Wl,--no-insert-timestamp -o .libs/libgcrypt-20.dll -Wl,--enable-auto-image-base -Xlinker --out-implib -Xlinker .libs/libgcrypt.dll.a + /usr/bin/i686-w64-mingw32-ld: .libs/libgcrypt-20.dll.def:6: syntax error + /usr/bin/i686-w64-mingw32-ld:.libs/libgcrypt-20.dll.def: file format not recognized; treating as linker script + /usr/bin/i686-w64-mingw32-ld:.libs/libgcrypt-20.dll.def:2: syntax error + collect2: error: ld returned 1 exit status + Makefile:611: recipe for target 'libgcrypt.la' failed + . + 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-09 + +--- a/src/libgcrypt.def ++++ b/src/libgcrypt.def +@@ -1,3 +1,4 @@ ++EXPORTS + ;; libgcrypt.defs - Exported symbols for W32 + ;; Copyright (C) 2003, 2007 Free Software Foundation, Inc. + ;; +@@ -22,7 +23,6 @@ + ;; never be changed. Also check libgcrypt.vers and visibility.h. + + +-EXPORTS + gcry_check_version @1 + gcry_control @2 + diff --git a/debian/patches/series b/debian/patches/series index f99d8a4..46210f7 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -3,3 +3,4 @@ 20_fedora_libgcrypt-1.6.3-aliasing.patch 30_support_source_date_epoch.diff 35_fix_gpg_error_config_prefix.diff +40_fix_windows_linker_script.patch -- 2.7.0
>From 1a62dff66e170c709cfd3fd2c5fecd907848eb05 Mon Sep 17 00:00:00 2001 From: Daniel Kahn Gillmor <d...@fifthhorseman.net> Date: Tue, 9 Feb 2016 02:20:30 -0500 Subject: [PATCH 4/4] Added libgcrypt-mingw-w64-dev package This prepares us to be able to build a gpgv-win32 package for debian installer's win32-loader. --- debian/clean | 2 ++ debian/control | 21 ++++++++++++++++++++- debian/libgcrypt-mingw-w64-dev.install | 6 ++++++ debian/libgcrypt-mingw-w64-dev.lintian-overrides | 13 +++++++++++++ debian/rules | 22 ++++++++++++++++++++++ 5 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 debian/libgcrypt-mingw-w64-dev.install create mode 100644 debian/libgcrypt-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 d3acdc9..cb7584b 100644 --- a/debian/control +++ b/debian/control @@ -8,7 +8,7 @@ Uploaders: Andreas Metzler <ametz...@debian.org>, Build-Depends: debhelper (>= 9.20150628), libgpg-error-dev (>= 1.11), dh-autoreconf, automake (>= 1:1.12) Build-Depends-Indep: texlive-latex-base, texlive-generic-recommended, - texinfo (>= 4.6-0) + texinfo (>= 4.6-0), mingw-w64, libgpg-error-mingw-w64-dev Standards-Version: 3.9.6 Vcs-Git: https://anonscm.debian.org/git/pkg-gnutls/libgcrypt.git -b branch1.6 Vcs-Browser: https://anonscm.debian.org/cgit/pkg-gnutls/libgcrypt.git/?h=branch1.6 @@ -90,3 +90,22 @@ Breaks: libgnutls-dev (<< 2.12.23-18) Description: transitional libgcrypt11-dev package This is a transitional dummy package to ease the migration from libgcrypt11-dev to libgcrypt20-dev. You can safely remove this package. + +Package: libgcrypt-mingw-w64-dev +Priority: extra +Section: libdevel +Architecture: all +Depends: ${shlibs:Depends}, ${misc:Depends}, libgpg-error-mingw-w64-dev +Suggests: wine +Description: LGPL Crypto library - Windows development + libgcrypt contains cryptographic functions. Many important free + ciphers, hash algorithms and public key signing algorithms have been + implemented: + . + Arcfour, Blowfish, CAST5, DES, AES, Twofish, Serpent, rfc2268 (rc2), SEED, + Camellia, IDEA, Salsa, CRC, MD4, MD5, RIPE-MD160, SHA-1, SHA-256, SHA-512, + Tiger, Whirlpool, DSA, DSA2, ElGamal, RSA, ECC. + . + This is a Windows version of libgcrypt. 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/libgcrypt-mingw-w64-dev.install b/debian/libgcrypt-mingw-w64-dev.install new file mode 100644 index 0000000..ab6e93e --- /dev/null +++ b/debian/libgcrypt-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/libgcrypt-mingw-w64-dev.lintian-overrides b/debian/libgcrypt-mingw-w64-dev.lintian-overrides new file mode 100644 index 0000000..79ca178 --- /dev/null +++ b/debian/libgcrypt-mingw-w64-dev.lintian-overrides @@ -0,0 +1,13 @@ +# libgcrypt-mingw-w64-dev is "arch-independent" from debian's perspective, +# since it ships binaries that are only used during cross-building +# windows software. +libgcrypt-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 +libgcrypt-mingw-w64-dev: file-in-unusual-dir +libgcrypt-mingw-w64-dev: non-standard-dir-in-usr + +# DLLs exported via Samba need to be executable (see #796224) +libgcrypt-mingw-w64-dev: executable-not-elf-or-script diff --git a/debian/rules b/debian/rules index abe8677..5fa3d7d 100755 --- a/debian/rules +++ b/debian/rules @@ -4,6 +4,8 @@ DEBVERSION := $(shell dpkg-parsechangelog | \ sed -n '/^Version: /s/^Version: //p') +WIN_FLAGS=LDFLAGS="-Xlinker --no-insert-timestamp" CFLAGS="-g -Os" CPPFLAGS= + override_dh_auto_configure: dh_auto_configure --verbose --builddirectory=build -- \ --enable-noexecstack \ @@ -22,6 +24,26 @@ override_dh_auto_build-indep: rm -f build-aux/texinfo.tex cd build/doc && $(MAKE) stamp-vti cd build/doc && $(MAKE) pdf html + 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-libgpg-error-prefix=/usr/$$cpu-w64-mingw32 \ + --disable-padlock-support --disable-asm \ + --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 override_dh_auto_install-arch: dh_auto_install --verbose --builddirectory=build -- 2.7.0