[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#837936: cups FTCBFS: runs host architecture utilities during build



Source: cups
Version: 2.1.4-4
Tags: patch
User: helmutg@debian.org
Usertags: rebootstrap

cups fails to cross build from source, because it runs host architecture
utilities during build. Otherwise, its cross build support is fairly
complete and cups is not a small or simple package, thus fairly
impressive. The two tools that are being run are genstrings and
mantohtml. For genstrings, I figured that its output is not installed
into any binary package, so we can simply stop running it. I updated
mantohtml to not required any other cups component, which makes it
possible to build it with a different compiler. Please consider applying
the attached patch as it makes cups cross build just fine.

Helmut
diff --minimal -Nru cups-2.1.4/debian/changelog cups-2.1.4/debian/changelog
--- cups-2.1.4/debian/changelog	2016-07-11 13:19:14.000000000 +0200
+++ cups-2.1.4/debian/changelog	2016-09-15 19:18:13.000000000 +0200
@@ -1,3 +1,12 @@
+cups (2.1.4-4.1) UNRELEASED; urgency=medium
+
+  * Non-maintainer upload.
+  * Fix FTCBFS: (Closes: #-1)
+    + cross-skip-genstrings-sample.patch: Don't run genstrings
+    + cross-mantohtml.patch: Build mantohtml with CC_FOR_BUILD
+
+ -- Helmut Grohne <helmut@subdivi.de>  Thu, 15 Sep 2016 07:59:16 +0200
+
 cups (2.1.4-4) unstable; urgency=medium
 
   * Patch a final lpstat call to really make the build reproducible when built
diff --minimal -Nru cups-2.1.4/debian/patches/cross-mantohtml.patch cups-2.1.4/debian/patches/cross-mantohtml.patch
--- cups-2.1.4/debian/patches/cross-mantohtml.patch	1970-01-01 01:00:00.000000000 +0100
+++ cups-2.1.4/debian/patches/cross-mantohtml.patch	2016-09-15 19:17:27.000000000 +0200
@@ -0,0 +1,105 @@
+From: Helmut Grohne <helmut@subdivi.de>
+Subject: build mantohtml with the build architecture compiler
+
+mantohtml is run during build. Thus it needs to be built with the build
+architecture compiler (or execution fails). The obvious part is switching to
+CC_FOR_BUILD. That also depends on it not requiring any other cups components.
+In particular, removing uses of strlcpy and replacing host architecture-
+specific includes is thus needed.
+
+Index: cups-2.1.4/man/mantohtml.c
+===================================================================
+--- cups-2.1.4.orig/man/mantohtml.c
++++ cups-2.1.4/man/mantohtml.c
+@@ -17,8 +17,10 @@
+  * Include necessary headers.
+  */
+ 
+-#include <cups/string-private.h>
+-#include <cups/array-private.h>
++#include <ctype.h>
++#include <stdio.h>
++#include <stdlib.h>
++#include <string.h>
+ #include <unistd.h>
+ 
+ 
+@@ -817,7 +819,8 @@
+         * Anchor for HTML output...
+         */
+ 
+-        strlcpy(anchor, line + 4, sizeof(anchor));
++        strncpy(anchor, line + 4, sizeof(anchor) - 1);
++        anchor[sizeof(anchor) - 1] = '\0';
+       }
+       else if (strncmp(line, ".\\\"", 3))
+       {
+@@ -946,7 +949,8 @@
+ 		manfile[1024],		/* Man page filename */
+ 		manurl[1024];		/* Man page URL */
+ 
+-        strlcpy(name, s, sizeof(name));
++        strncpy(name, s, sizeof(name) - 1);
++        name[sizeof(name) - 1] = '\0';
+         if ((size_t)(end - s) < sizeof(name))
+           name[end - s] = '\0';
+ 
+@@ -1175,7 +1179,8 @@
+       if (end[-1] == ',' || end[-1] == '.' || end[-1] == ')')
+         end --;
+ 
+-      strlcpy(temp, s, sizeof(temp));
++      strncpy(temp, s, sizeof(temp) - 1);
++      temp[sizeof(temp) - 1] = '\0';
+       if ((size_t)(end -s) < sizeof(temp))
+         temp[end - s] = '\0';
+ 
+Index: cups-2.1.4/man/Makefile
+===================================================================
+--- cups-2.1.4.orig/man/Makefile
++++ cups-2.1.4/man/Makefile
+@@ -234,10 +234,8 @@
+ 		./mantohtml `basename $$file .$(MAN8EXT)`.man >../doc/help/man-`basename $$file .$(MAN8EXT)`.html; \
+ 	done
+ 
+-mantohtml:	mantohtml.o ../cups/$(LIBCUPSSTATIC)
+-	$(CC) $(ARCHFLAGS) $(LDFLAGS) -o $@ mantohtml.o \
+-		../cups/$(LIBCUPSSTATIC) $(LIBGSSAPI) $(SSLLIBS) \
+-		$(DNSSDLIBS) $(COMMONLIBS) $(LIBZ)
++mantohtml:	mantohtml.c
++	$(CC_FOR_BUILD) -o $@ $<
+ 
+ 
+ #
+Index: cups-2.1.4/configure.ac
+===================================================================
+--- cups-2.1.4.orig/configure.ac
++++ cups-2.1.4/configure.ac
+@@ -24,6 +24,15 @@
+ sinclude(config-scripts/cups-directories.m4)
+ sinclude(config-scripts/cups-manpages.m4)
+ 
++AC_MSG_CHECKING([for build system compiler])
++if test "$cross_compiling" = yes; then
++	CC_FOR_BUILD=${CC_FOR_BUILD-cc}
++else
++	CC_FOR_BUILD=${CC}
++fi
++AC_MSG_RESULT(${CC_FOR_BUILD})
++AC_SUBST(CC_FOR_BUILD)
++
+ sinclude(config-scripts/cups-sharedlibs.m4)
+ sinclude(config-scripts/cups-libtool.m4)
+ sinclude(config-scripts/cups-compiler.m4)
+Index: cups-2.1.4/Makedefs.in
+===================================================================
+--- cups-2.1.4.orig/Makedefs.in
++++ cups-2.1.4/Makedefs.in
+@@ -20,6 +20,7 @@
+ AR		=	@AR@
+ AWK		=	@AWK@
+ CC		=	@LIBTOOL@ @CC@
++CC_FOR_BUILD    =       @CC_FOR_BUILD@
+ CHMOD		=	@CHMOD@
+ CXX		=	@LIBTOOL@ @CXX@
+ DSO		=	@DSO@
diff --minimal -Nru cups-2.1.4/debian/patches/cross-skip-genstrings-sample.patch cups-2.1.4/debian/patches/cross-skip-genstrings-sample.patch
--- cups-2.1.4/debian/patches/cross-skip-genstrings-sample.patch	1970-01-01 01:00:00.000000000 +0100
+++ cups-2.1.4/debian/patches/cross-skip-genstrings-sample.patch	2016-09-15 07:59:13.000000000 +0200
@@ -0,0 +1,20 @@
+From: Helmut Grohne <helmut@subdivi.de>
+Subject: Do not execute genstrings during build
+
+We cannot run genstrings during build, because it is compiled for the host
+architecture. Fortunately, the generated file sample.c is neither processed any
+further nor installed. Thus skipping it is ok.
+
+Index: cups-2.1.4/ppdc/Makefile
+===================================================================
+--- cups-2.1.4.orig/ppdc/Makefile
++++ cups-2.1.4/ppdc/Makefile
+@@ -242,8 +242,6 @@
+ 	$(CXX) $(ARCHFLAGS) $(LDFLAGS) -o genstrings genstrings.o \
+ 		-lcupsppdc ../cups/$(LIBCUPSSTATIC) $(LIBGSSAPI) $(SSLLIBS) \
+ 		$(DNSSDLIBS) $(COMMONLIBS) $(LIBZ)
+-	echo Generating localization strings...
+-	LD_LIBRARY_PATH=.:../cups/ ./genstrings >sample.c
+ 
+ 
+ #
diff --minimal -Nru cups-2.1.4/debian/patches/series cups-2.1.4/debian/patches/series
--- cups-2.1.4/debian/patches/series	2016-07-07 14:53:11.000000000 +0200
+++ cups-2.1.4/debian/patches/series	2016-09-15 08:18:59.000000000 +0200
@@ -55,3 +55,5 @@
 # po4a might not be appropriate. It also needs to be high on the patch
 # queue to catch all Debian-specific changes
 manpage-translations.patch
+cross-skip-genstrings-sample.patch
+cross-mantohtml.patch

Reply to: