Source: vpnc
Version: 0.5.3r550-2
Tags: patch
User: [email protected]
Usertags: rebootstrap

vpnc fails to cross build from source, because it uses build
architecture tools, which is finally noticed by dh_strip. Prefixing the
c compiler is a simple matter of exporting CC. Substituting pkg-config
requires patching the Makefile though. The hardest part is makeman.pl,
which tries to execute the just built vpnc. I opted for adding a
self-dependency to provide a build architecture vpnc binary, which is
used to generate the manual page. Alternative approaches include
building vpnc twice and shipping a pregenerated manual page. I hope you
find the self-dependency acceptable and can apply the attached patch.
With it applied, cross building vpnc works.

Helmut
diff --minimal -Nru vpnc-0.5.3r550/debian/changelog 
vpnc-0.5.3r550/debian/changelog
--- vpnc-0.5.3r550/debian/changelog     2014-10-05 22:56:57.000000000 +0200
+++ vpnc-0.5.3r550/debian/changelog     2016-09-27 20:49:53.000000000 +0200
@@ -1,3 +1,10 @@
+vpnc (0.5.3r550-2.1) UNRELEASED; urgency=medium
+
+  * Non-maintainer upload.
+  * Fix FTCBFS: Use triplet-prefixed build tools (closes: #-1)
+
+ -- Helmut Grohne <[email protected]>  Tue, 27 Sep 2016 20:49:31 +0200
+
 vpnc (0.5.3r550-2) unstable; urgency=medium
 
   * Enable PIE and BINDNOW hardening as suggested by Markus
diff --minimal -Nru vpnc-0.5.3r550/debian/control vpnc-0.5.3r550/debian/control
--- vpnc-0.5.3r550/debian/control       2014-10-05 22:56:57.000000000 +0200
+++ vpnc-0.5.3r550/debian/control       2016-09-27 20:52:54.000000000 +0200
@@ -3,7 +3,7 @@
 Priority: extra
 Maintainer: Florian Schlichting <[email protected]>
 Build-Depends: debhelper (>= 9), libgnutls28-dev, libgcrypt20-dev,
- pkg-config
+ pkg-config, vpnc:native <cross>
 Standards-Version: 3.9.6
 Vcs-Browser: http://anonscm.debian.org/gitweb/?p=collab-maint/vpnc.git
 Vcs-Git: git://anonscm.debian.org/collab-maint/vpnc.git
diff --minimal -Nru vpnc-0.5.3r550/debian/patches/cross.patch 
vpnc-0.5.3r550/debian/patches/cross.patch
--- vpnc-0.5.3r550/debian/patches/cross.patch   1970-01-01 01:00:00.000000000 
+0100
+++ vpnc-0.5.3r550/debian/patches/cross.patch   2016-09-27 20:56:10.000000000 
+0200
@@ -0,0 +1,52 @@
+From: Helmut Grohne <[email protected]>
+Subject: cross compilation support
+
+* Make pkg-config substitutable to provision it as <triplet>-pkg-config.
+* Make the vpnc used by makeman.pl substitutable to use the build arch tool.
+
+Index: vpnc-0.5.3r550/Makefile
+===================================================================
+--- vpnc-0.5.3r550.orig/Makefile
++++ vpnc-0.5.3r550/Makefile
+@@ -41,8 +41,9 @@
+ # GPL incompliant though.
+ #OPENSSL_GPL_VIOLATION=yes
+ 
+-CRYPTO_LDADD = $(shell pkg-config --libs gnutls)
+-CRYPTO_CFLAGS = $(shell pkg-config --cflags gnutls) -DCRYPTO_GNUTLS
++PKG_CONFIG ?= pkg-config
++CRYPTO_LDADD = $(shell $(PKG_CONFIG) --libs gnutls)
++CRYPTO_CFLAGS = $(shell $(PKG_CONFIG) --cflags gnutls) -DCRYPTO_GNUTLS
+ CRYPTO_SRCS = crypto-gnutls.c
+ 
+ ifeq ($(OPENSSL_GPL_VIOLATION), yes)
+@@ -67,6 +68,7 @@
+ CPPFLAGS += -DVERSION=\"$(VERSION)\"
+ LDFLAGS ?= -g
+ LIBS += $(shell libgcrypt-config --libs) $(CRYPTO_LDADD)
++VPNC ?= ./vpnc
+ 
+ ifeq ($(shell uname -s), SunOS)
+ LIBS += -lnsl -lresolv -lsocket
+@@ -82,7 +84,7 @@
+       $(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
+ 
+ vpnc.8 : vpnc.8.template makeman.pl vpnc
+-      ./makeman.pl
++      ./makeman.pl $(VPNC)
+ 
+ cisco-decrypt : cisco-decrypt.o decrypt-utils.o
+       $(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
+Index: vpnc-0.5.3r550/makeman.pl
+===================================================================
+--- vpnc-0.5.3r550.orig/makeman.pl
++++ vpnc-0.5.3r550/makeman.pl
+@@ -21,7 +21,7 @@
+ use filetest qw(access);      # to always get errno-values on filetests
+ use POSIX    qw(strftime setlocale LC_ALL);
+ 
+-my $vpnc = './vpnc';
++my $vpnc = $ARGV[0];
+ -e $vpnc or die "$0: Can't find $vpnc. Did you compile it?\n";
+ -x $vpnc or die "$0: Can't execute $vpnc. Please check permissions.\n";
+ 
diff --minimal -Nru vpnc-0.5.3r550/debian/patches/series 
vpnc-0.5.3r550/debian/patches/series
--- vpnc-0.5.3r550/debian/patches/series        2014-10-05 22:53:15.000000000 
+0200
+++ vpnc-0.5.3r550/debian/patches/series        2016-09-27 20:47:49.000000000 
+0200
@@ -1,3 +1,4 @@
 use-separate-vpnc-script.patch
 fix_makefile_VERSION.patch
 vpnc_typo.patch
+cross.patch
diff --minimal -Nru vpnc-0.5.3r550/debian/rules vpnc-0.5.3r550/debian/rules
--- vpnc-0.5.3r550/debian/rules 2014-09-08 22:07:59.000000000 +0200
+++ vpnc-0.5.3r550/debian/rules 2016-09-27 20:59:54.000000000 +0200
@@ -1,5 +1,14 @@
 #!/usr/bin/make -f
 
+include /usr/share/dpkg/architecture.mk
+ifeq ($(origin CC),default)
+CC = $(DEB_HOST_GNU_TYPE)-gcc
+endif
+export CC
+export PKG_CONFIG=$(DEB_HOST_GNU_TYPE)-pkg-config
+ifneq ($(filter cross,$(DEB_BUILD_PROFILES)),)
+export VPNC = /usr/sbin/vpnc
+endif
 VERSION=$(shell dpkg-parsechangelog | sed -rne 's,^Version: ([^-]+).*,\1,p')
 SVN_REV=$(shell dpkg-parsechangelog | sed -rne 's,^Version: .*r([^-]+).*,\1,p')
 SVN_URL=http://svn.unix-ag.uni-kl.de/vpnc/trunk/

Reply via email to