Source: qpxtool
Version: 0.8.1-2
Tags: patch
User: debian-cr...@lists.debian.org
Usertags: ftcbfs

qpxtool fails to cross build from source for quite a number of reasons.
The immediate failure is running the build architure qmake. Looking into
the configure script, it seems that one is supposed to pass --target for
cross builds and while that helps with not using the build architecture
compiler, it also messes up CC vs CXX. And then --target doesn't fix the
qmake invocation, so one also gets to pass --qmake. That gets quite a
bit further until strip fails. Stripping during build is a bad as it not
only breaks cross building but also generation of -dbgsym packages as
well as DEB_BUILD_OPTIONS=nostrip. To make matter worse, the upstream
build system offers little options between a full debug build and a
stripped release build, so I opted for supplying a non-stripping strip.
Things don't stop breaking here. Manual pages are still missing. Looking
through the log, I noticed lrelease silently failing. That latter is
caused by missing :native dependencies required for running lrelease,
but that doesn't fix the manual pages. Something is breaking the manual
page location as /usr/man rather than /usr/share/man during cross
builds. Instead of digging further, I just added --mandir. So after this
long journey I offer you this invasive patch. What do you think?

Also consider moving away from a handcrafted configure script towards a
more common build system such as qmake, cmake, meson or autoconf. All of
these tend to just work for cross building.

Helmut
diff --minimal -Nru qpxtool-0.8.1/debian/changelog 
qpxtool-0.8.1/debian/changelog
--- qpxtool-0.8.1/debian/changelog      2020-01-01 01:00:01.000000000 +0100
+++ qpxtool-0.8.1/debian/changelog      2023-03-04 13:56:13.000000000 +0100
@@ -1,3 +1,16 @@
+qpxtool (0.8.1-2.1) UNRELEASED; urgency=medium
+
+  * Non-maintainer upload.
+  * Fix FTCBFS: (Closes: #-1)
+    + Pass --target= for cross builds.
+    + Also pass --qmake= as it isn't derived from --target.
+    + cross.patch: Fix CC vs CXX confusion.
+    + Forcibly disable stripping during build.
+    + Depend on qt5-qmake:native and qtbase-5-dev:native for lrelease.
+    + Force --mandir as it is miscomputed during cross builds.
+
+ -- Helmut Grohne <hel...@subdivi.de>  Sat, 04 Mar 2023 13:56:13 +0100
+
 qpxtool (0.8.1-2) unstable; urgency=high
 
   [ Boris Pek ]
diff --minimal -Nru qpxtool-0.8.1/debian/clean qpxtool-0.8.1/debian/clean
--- qpxtool-0.8.1/debian/clean  1970-01-01 01:00:00.000000000 +0100
+++ qpxtool-0.8.1/debian/clean  2023-03-04 13:56:13.000000000 +0100
@@ -0,0 +1 @@
+debian/nostrip
diff --minimal -Nru qpxtool-0.8.1/debian/control qpxtool-0.8.1/debian/control
--- qpxtool-0.8.1/debian/control        2020-01-01 01:00:01.000000000 +0100
+++ qpxtool-0.8.1/debian/control        2023-03-04 13:56:13.000000000 +0100
@@ -6,7 +6,9 @@
                hurd-dev [hurd-i386],
                libcam-dev [kfreebsd-any],
                libpng-dev,
+               qt5-qmake:native,
                qtbase5-dev,
+               qtbase5-dev:native,
                qtchooser,
                qttools5-dev,
                qttools5-dev-tools
diff --minimal -Nru qpxtool-0.8.1/debian/patches/cross.patch 
qpxtool-0.8.1/debian/patches/cross.patch
--- qpxtool-0.8.1/debian/patches/cross.patch    1970-01-01 01:00:00.000000000 
+0100
+++ qpxtool-0.8.1/debian/patches/cross.patch    2023-03-04 13:56:13.000000000 
+0100
@@ -0,0 +1,13 @@
+--- qpxtool-0.8.1.orig/configure
++++ qpxtool-0.8.1/configure
+@@ -358,8 +358,8 @@
+ 
+       if test "$__cross_compilation" = "yes" ; then
+               echo "# additional cross-compilatio options" >> Makefile
+-              echo "CC=$__cxx" >> Makefile
+-              echo "CXX=$__cc" >> Makefile
++              echo "CC=$__cc" >> Makefile
++              echo "CXX=$__cxx" >> Makefile
+               echo "CXXFLAGS += -fPIC" >> Makefile
+               echo "CFLAGS   += -fPIC" >> Makefile
+               echo "export CXX CC" >> Makefile
diff --minimal -Nru qpxtool-0.8.1/debian/patches/series 
qpxtool-0.8.1/debian/patches/series
--- qpxtool-0.8.1/debian/patches/series 2020-01-01 01:00:01.000000000 +0100
+++ qpxtool-0.8.1/debian/patches/series 2023-03-04 13:56:13.000000000 +0100
@@ -1 +1,2 @@
 Fix-check-whether-Tab-should-be-selected.patch
+cross.patch
diff --minimal -Nru qpxtool-0.8.1/debian/rules qpxtool-0.8.1/debian/rules
--- qpxtool-0.8.1/debian/rules  2020-01-01 01:00:01.000000000 +0100
+++ qpxtool-0.8.1/debian/rules  2023-03-04 13:56:13.000000000 +0100
@@ -2,9 +2,17 @@
 
 export DEB_CXXFLAGS_MAINT_APPEND = $(shell dpkg-buildflags --get CPPFLAGS)
 export DEB_BUILD_MAINT_OPTIONS = hardening=+all
+include /usr/share/dpkg/buildtools.mk
+export PATH:=$(CURDIR)/debian/nostrip:$(PATH)
 
 %:
        dh $@ --no-parallel
 
+ifneq ($(DEB_BUILD_ARCH),$(DEB_HOST_ARCH))
+configure_flags += --target=$(DEB_HOST_GNU_TYPE) --qmake=$(QMAKE)
+endif
+
 override_dh_auto_configure:
-       ./configure --prefix=/usr --libdir=/usr/lib --mandir=/usr/share/man
+       mkdir debian/nostrip
+       ln -s /bin/true debian/nostrip/strip
+       ./configure --prefix=/usr --libdir=/usr/lib --mandir=/usr/share/man 
$(configure_flags)

Reply via email to