Source: zip
Version: 3.0-11
Tags: patch
User: helm...@debian.org
Usertags: rebootstrap

zip fails to cross build from source, because it uses the build
architecture compiler (and later fails dh_strip). Simply passing a
triplet-prefixed CC to configure makes the build pass already. Doing
that produces a zip without large file support though, because configure
determines large file support using a compile and run check. Thus I
replaced that check with an equivalent compile-only check. Please
consider applying the attached patch.

Helmut
diff --minimal -Nru zip-3.0/debian/changelog zip-3.0/debian/changelog
--- zip-3.0/debian/changelog    2015-08-16 23:38:20.000000000 +0200
+++ zip-3.0/debian/changelog    2016-09-05 21:37:00.000000000 +0200
@@ -1,3 +1,12 @@
+zip (3.0-11.1) UNRELEASED; urgency=medium
+
+  * Non-maintainer upload.
+  * Fix FTCBFS: Closes: #-1
+    + Pass triplet prefixed CC to configure.
+    + Add d/patches/11-cross-large-file.
+
+ -- Helmut Grohne <hel...@subdivi.de>  Mon, 05 Sep 2016 21:23:18 +0200
+
 zip (3.0-11) unstable; urgency=medium
 
   * Ship a debian/copyright file in source package instead of generating
diff --minimal -Nru zip-3.0/debian/patches/11-cross-large-file 
zip-3.0/debian/patches/11-cross-large-file
--- zip-3.0/debian/patches/11-cross-large-file  1970-01-01 01:00:00.000000000 
+0100
+++ zip-3.0/debian/patches/11-cross-large-file  2016-09-05 21:36:18.000000000 
+0200
@@ -0,0 +1,66 @@
+From: Helmut Grohne <hel...@subdivi.de>
+Subject: make the large file support check work under cross compilation
+
+Index: zip-3.0/unix/configure
+===================================================================
+--- zip-3.0.orig/unix/configure
++++ zip-3.0/unix/configure
+@@ -434,18 +434,48 @@
+ if [ $? -ne 0 ]; then
+   echo -- no Large File Support
+ else
+-# run it
+-  ./conftest
+-  r=$?
+-  if [ $r -eq 1 ]; then
++  cat > conftest.c << _EOF_
++# define _LARGEFILE_SOURCE       /* some OSes need this for fseeko */
++# define _LARGEFILE64_SOURCE
++# define _FILE_OFFSET_BITS 64       /* select default interface as 64 bit */
++# define _LARGE_FILES        /* some OSes need this for 64-bit off_t */
++#include <sys/types.h>
++#include <sys/stat.h>
++#include <unistd.h>
++#include <stdio.h>
++int main()
++{
++  int check[1 - 2 * (sizeof(off_t) < 8)] = {};
++  return check[0];
++}
++_EOF_
++  $CC -o conftest conftest.c >/dev/null 2>/dev/null
++  if [ $? -ne 0 ]; then
+     echo -- no Large File Support - no 64-bit off_t
+-  elif [ $r -eq 2 ]; then
+-    echo -- no Large File Support - no 64-bit stat
+-  elif [ $r -eq 3 ]; then
+-    echo -- yes we have Large File Support!
+-    CFLAGS="${CFLAGS} -DLARGE_FILE_SUPPORT"
+   else
+-    echo -- no Large File Support - conftest returned $r
++    cat > conftest.c << _EOF_
++# define _LARGEFILE_SOURCE       /* some OSes need this for fseeko */
++# define _LARGEFILE64_SOURCE
++# define _FILE_OFFSET_BITS 64       /* select default interface as 64 bit */
++# define _LARGE_FILES        /* some OSes need this for 64-bit off_t */
++#include <sys/types.h>
++#include <sys/stat.h>
++#include <unistd.h>
++#include <stdio.h>
++int main()
++{
++  struct stat s;
++  int check[1 - 2 * (sizeof(s.st_size) < 8)] = {};
++  return check[0];
++}
++_EOF_
++    $CC -o conftest conftest.c >/dev/null 2>/dev/null
++    if [ $? -ne 0 ]; then
++      echo -- no Large File Support - no 64-bit stat
++    else
++      echo -- yes we have Large File Support!
++      CFLAGS="${CFLAGS} -DLARGE_FILE_SUPPORT"
++    fi
+   fi
+ fi
+ 
diff --minimal -Nru zip-3.0/debian/patches/series zip-3.0/debian/patches/series
--- zip-3.0/debian/patches/series       2015-05-17 12:30:00.000000000 +0200
+++ zip-3.0/debian/patches/series       2016-09-05 21:26:18.000000000 +0200
@@ -8,3 +8,4 @@
 08-hardening-build-fix-1
 09-hardening-build-fix-2
 10-remove-build-date
+11-cross-large-file
diff --minimal -Nru zip-3.0/debian/rules zip-3.0/debian/rules
--- zip-3.0/debian/rules        2015-08-16 23:25:10.000000000 +0200
+++ zip-3.0/debian/rules        2016-09-05 21:23:17.000000000 +0200
@@ -1,6 +1,9 @@
 #!/usr/bin/make -f
 
-CC = gcc
+include /usr/share/dpkg/architecture.mk
+ifeq ($(origin CC),default)
+CC = $(DEB_HOST_GNU_TYPE)-gcc
+endif
 CFLAGS := `dpkg-buildflags --get CFLAGS` -Wall -I. -DUNIX
 LDFLAGS := `dpkg-buildflags --get LDFLAGS`
 CPPFLAGS := `dpkg-buildflags --get CPPFLAGS`

Reply via email to