Source: sane-backends
Version: 1.0.27-3.2
Tags: patch
User: debian-cr...@lists.debian.org
Usertags: ftcbfs

sane-backends fails to cross build from source, because it fails running
tools/sane-desc. The tool is run by debian/rules directly to generate
udev files. Unfortunately, tools/sane-desc is compiled for the host
architecture and thus fails with an Exec format error. Since sane-desc
is not installed into any package, it should be built for the build
architecture instead. This essentially adds a second build pass. After
fixing that, sane-backends cross builds successfully, but it lacks
gphoto2 integration, because the relevant check hard codes the build
architecture pkg-config rather than using PKG_PROG_PKG_CONFIG. The
attached patch fixes all of that. Please consider applying it.

Helmut
diff --minimal -Nru sane-backends-1.0.27/debian/changelog 
sane-backends-1.0.27/debian/changelog
--- sane-backends-1.0.27/debian/changelog       2019-03-23 17:38:37.000000000 
+0100
+++ sane-backends-1.0.27/debian/changelog       2020-01-12 13:22:38.000000000 
+0100
@@ -1,3 +1,12 @@
+sane-backends (1.0.27-3.3) UNRELEASED; urgency=medium
+
+  * Non-maintainer upload.
+  * Fix FTCBFS: (Closes: #-1)
+    + cross.patch: Make gphoto2 detection use the host architecture pkg-config.
+    + Build tools/sane-desc for the build architecture.
+
+ -- Helmut Grohne <hel...@subdivi.de>  Sun, 12 Jan 2020 13:22:38 +0100
+
 sane-backends (1.0.27-3.2) unstable; urgency=medium
 
   * Non-maintainer upload.
diff --minimal -Nru sane-backends-1.0.27/debian/patches/cross.patch 
sane-backends-1.0.27/debian/patches/cross.patch
--- sane-backends-1.0.27/debian/patches/cross.patch     1970-01-01 
01:00:00.000000000 +0100
+++ sane-backends-1.0.27/debian/patches/cross.patch     2020-01-12 
13:22:38.000000000 +0100
@@ -0,0 +1,44 @@
+--- sane-backends-1.0.27.orig/acinclude.m4
++++ sane-backends-1.0.27/acinclude.m4
+@@ -403,14 +403,19 @@
+   # a program.   And, if that works, then add the -l flags to 
+   # GPHOTO2_LIBS and any other flags to GPHOTO2_LDFLAGS to pass to 
+   # sane-config.
+-  if test "$with_gphoto2" != "no" ; then 
+-    AC_CHECK_TOOL(HAVE_GPHOTO2, pkg-config, false)
++  AS_IF([test "$with_gphoto2" != "no"],[
++    AC_REQUIRE([PKG_PROG_PKG_CONFIG])
++    if test "x$PKG_CONFIG" = x; then
++      HAVE_GPHOTO2=false
++    else
++      HAVE_GPHOTO2=$PKG_CONFIG
++    fi
+ 
+     if test ${HAVE_GPHOTO2} != "false" ; then
+-      if pkg-config --exists libgphoto2 ; then
+-        with_gphoto2="`pkg-config --modversion libgphoto2`"
+-      GPHOTO2_CPPFLAGS="`pkg-config --cflags libgphoto2`"
+-        GPHOTO2_LIBS="`pkg-config --libs libgphoto2`"
++      if $PKG_CONFIG --exists libgphoto2 ; then
++        with_gphoto2="`$PKG_CONFIG --modversion libgphoto2`"
++      GPHOTO2_CPPFLAGS="`$PKG_CONFIG --cflags libgphoto2`"
++        GPHOTO2_LIBS="`$PKG_CONFIG --libs libgphoto2`"
+ 
+         saved_CPPFLAGS="${CPPFLAGS}"
+         CPPFLAGS="${GPHOTO2_CPPFLAGS}"
+@@ -431,13 +436,13 @@
+         GPHOTO2_LIBS="" 
+       else
+         SANE_EXTRACT_LDFLAGS(GPHOTO2_LIBS, GPHOTO2_LDFLAGS)
+-        if pkg-config --atleast-version=2.5.0 libgphoto2; then
++        if $PKG_CONFIG --atleast-version=2.5.0 libgphoto2; then
+           AC_DEFINE([GPLOGFUNC_NO_VARGS], [1],
+                     [Define if GPLogFunc does not take a va_list.])
+         fi
+       fi
+     fi
+-  fi
++  ])
+   AC_SUBST(GPHOTO2_CPPFLAGS)
+   AC_SUBST(GPHOTO2_LIBS)
+   AC_SUBST(GPHOTO2_LDFLAGS)
diff --minimal -Nru sane-backends-1.0.27/debian/patches/series 
sane-backends-1.0.27/debian/patches/series
--- sane-backends-1.0.27/debian/patches/series  2019-03-23 17:36:58.000000000 
+0100
+++ sane-backends-1.0.27/debian/patches/series  2020-01-12 13:22:38.000000000 
+0100
@@ -25,3 +25,4 @@
 #0130-usb-timeout.patch
 0715-20-sane.hwdb_multi-arch.patch
 0720-mustek_usb2-Avoid-stack-smashing.patch
+cross.patch
diff --minimal -Nru sane-backends-1.0.27/debian/rules 
sane-backends-1.0.27/debian/rules
--- sane-backends-1.0.27/debian/rules   2018-11-02 18:13:37.000000000 +0100
+++ sane-backends-1.0.27/debian/rules   2020-01-12 13:22:38.000000000 +0100
@@ -24,10 +24,24 @@
 %:
        dh $@
 
+ifeq ($(DEB_BUILD_ARCH),$(DEB_HOST_ARCH))
+SANE_DESC = $(CURDIR)/tools/sane-desc
+else
+SANE_DESC = $(CURDIR)/debian/sane-desc
+endif
+
 override_dh_auto_configure:
        autoconf
-       dh_auto_configure -- --host=$(DEB_HOST_GNU_TYPE) \
-               --build=$(DEB_BUILD_GNU_TYPE) \
+ifneq ($(DEB_BUILD_ARCH),$(DEB_HOST_ARCH))
+       dpkg-architecture -f "-a$(DEB_BUILD_ARCH)" -c dh_auto_configure
+       $(MAKE) -C $(CURDIR)/lib liblib.la
+       $(MAKE) -C $(CURDIR)/sanei libsanei.la
+       $(MAKE) -C $(CURDIR)/tools sane-desc
+       mv $(CURDIR)/tools/sane-desc $(CURDIR)/debian/sane-desc
+       $(RM) include/byteorder.h include/_stdint.h
+       dh_auto_clean
+endif
+       dh_auto_configure -- \
                --prefix=/usr \
                --libdir=\$${prefix}/lib/$(DEB_HOST_MULTIARCH) \
                --sysconfdir=/etc \
@@ -60,6 +74,7 @@
        [ ! -f Makefile ] || $(MAKE) distclean
        $(RM) debian/libsane.udev
        dh_auto_clean
+       $(RM) $(SANE_DESC)
 
 override_dh_auto_install-arch:
        $(MAKE) install DESTDIR=$(CURDIR)/debian/tmp
@@ -117,8 +132,8 @@
 ifeq (linux,$(DEB_HOST_ARCH_OS))
        # udev support
        # Generate the udev rules file
-       $(CURDIR)/tools/sane-desc -s $(CURDIR)/doc/descriptions -m udev+hwdb > 
$(CURDIR)/debian/libsane.udev
-       $(CURDIR)/tools/sane-desc -s $(CURDIR)/doc/descriptions -m hwdb > 
$(CURDIR)/debian/20-sane.hwdb
+       $(SANE_DESC) -s $(CURDIR)/doc/descriptions -m udev+hwdb > 
$(CURDIR)/debian/libsane.udev
+       $(SANE_DESC) -s $(CURDIR)/doc/descriptions -m hwdb > 
$(CURDIR)/debian/20-sane.hwdb
        cp $(CURDIR)/debian/20-sane.hwdb 
$(CURDIR)/debian/libsane/lib/udev/hwdb.d/
        dh_installudev
 endif

Reply via email to