Source: lirc
Version: 0.10.1-6.3
Tags: patch
User: debian-cr...@lists.debian.org
Usertags: cross-satisfiability ftcbfs
lirc fails to cross build from source for a number of reasons. I've
understood a pile and am presenting solutions here:

1. Its Build-Depends are not satisfiable. python3-dev asks (among other
   things), for the host architecture Python interpreter, which fails to
   install. A python(.*)-dev dependency should usually be written as
   python$1-dev:any, libpython$1-dev. Beyond this, python3-yaml also
   requests the host architecture Python interpreter. It is meant to be
   run during build though, so it should be annotated :native.

   Once fixing these, a cross build can be attempted.

2. configure uses AC_RUN_IFELSE to check for existence of /dev/input. In
   principle, this is correct. For file existence however, there is a
   better check: AC_CHECK_FILE. During a cross build, this check also
   fails and consults the cache variable ac_cv__dev_input. A builder may
   supply this variable to make the check pass. It also gets a lot
   simpler by using AC_CHECK_FILE.

3. debian/rules also confuses the build architecture with the host
   architecture in two occasions. Please refer to man dpkg-architecture
   for a precise definition.

4. In order to make setup.py perform a cross build, one is supposed to
   export _PYTHON_SYSCONFIGDATA_NAME. When using the pybuild
   buildsystem, debhelper takes care of that, but here setup.py is run
   from inside autoconf+make and debhelper cannot know. Thus it needs to
   be exported explicitly.

5. When fixing all of the above, what remains is this error:

       /usr/bin/install: cannot stat './python-pkg/dist/lirc-0.10.1.tar.gz': No 
such file or directory

   I have no clue why this file is created during a regular build but
   missing during a cross build. Unfortunately, the build hides compiler
   invocations and such, so we cannot see the relevant commands. I don't
   have a solution for this issue.

In the mean time, I recommend dropping --enable-silent-rules from the
configure invocation. debhelper will automatically pass this flag when
you add "terse" to DEB_BUILD_OPTIONS and --disable-silent-rules
otherwise. Building verbosely by default is recommended by the Debian
policy. By dropping the flag, you implement recommended policy behaviour
and retain the ability to issue a terse log via the standard mechanism.

I ask you to apply the attached patch to fix 1-4. Please close this bug
when addressing 1-4 only. Of course finding a solution to 5 would be
welcome as well.

Helmut
--- lirc-0.10.1/debian/changelog
+++ lirc-0.10.1/debian/changelog
@@ -1,3 +1,14 @@
+lirc (0.10.1-6.4) UNRELEASED; urgency=medium
+
+  * Non-maintainer upload.
+  * Improve cross building. (Closes: #-1)
+    + Multiarchify python Build-Depends.
+    + cross.patch: Check for /dev/input using AC_CHECK_FILE.
+    + Fix two build vs host confusions.
+    + Export _PYTHON_SYSCONFIGDATA_NAME for setup.py.
+
+ -- Helmut Grohne <hel...@subdivi.de>  Thu, 20 May 2021 17:27:08 +0200
+
 lirc (0.10.1-6.3) unstable; urgency=medium
 
   * Non-maintainer upload.
--- lirc-0.10.1/debian/control
+++ lirc-0.10.1/debian/control
@@ -18,6 +18,7 @@
  kmod [linux-any],
  libasound2-dev [linux-any kfreebsd-any],
  libftdi1-dev,
+ libpython3-dev (>= 3.5),
  libsystemd-dev [linux-any],
  libudev-dev [linux-any],
  libusb-1.0-0-dev [!kfreebsd-any],
@@ -26,9 +27,9 @@
  man2html-base,
  pkg-config,
  portaudio19-dev,
- python3-dev (>= 3.5),
+ python3-dev:any (>= 3.5),
  python3-setuptools,
- python3-yaml,
+ python3-yaml:native,
  socat [!hurd-any],
  systemd [linux-any],
  xsltproc
--- lirc-0.10.1/debian/patches/cross.patch
+++ lirc-0.10.1/debian/patches/cross.patch
@@ -0,0 +1,33 @@
+--- a/configure.ac
++++ b/configure.ac
+@@ -291,29 +291,12 @@
+ fi
+ 
+ AC_MSG_CHECKING(for devinput)
+-AC_RUN_IFELSE([AC_LANG_PROGRAM([[
+-  #include <unistd.h>
+-]],[[
+-  return access("/dev/input", R_OK) == 0 ? 0 : 1;
+-]])],[
++AC_CHECK_FILE([/dev/input],[
+   have_devinput="yes"
+   AC_MSG_RESULT(yes)
+ ],[
+   AC_MSG_RESULT(no)
+   have_devinput="no"
+-],[
+-  AS_IF([test x$DEVINPUT_HEADER = x -a x$enable_devinput = xyes], [
+-    AC_MSG_ERROR([
+-      cannot cross-compile with devinput without DEVINPUT_HEADER
+-      defined, giving up
+-    ])
+-  ])
+-  if test -n "$DEVINPUT_HEADER" ; then
+-    have_devinput="yes"
+-  else
+-    have_devinput="no"
+-  fi
+-  AC_MSG_RESULT(yes)
+ ])
+ 
+ 
--- lirc-0.10.1/debian/patches/series
+++ lirc-0.10.1/debian/patches/series
@@ -5,3 +5,4 @@
 0005-systemd-support-Notify-systemd-on-successful-startup.patch
 lirc-gpio-ir-0.10.patch
 python3.8.diff
+cross.patch
--- lirc-0.10.1/debian/rules
+++ lirc-0.10.1/debian/rules
@@ -4,6 +4,7 @@
 
 export DEB_BUILD_MAINT_OPTIONS      = hardening=+all
 export DEB_LDFLAGS_MAINT_APPEND     = -Wl,--as-needed
+export 
_PYTHON_SYSCONFIGDATA_NAME=_sysconfigdata__$(DEB_HOST_ARCH_OS)_$(DEB_HOST_MULTIARCH)
 
 %:
        dh $@ --with python3
@@ -40,7 +41,7 @@
        find debian/tmp -name *.la -delete
        rm -f debian/tmp/usr/share/doc/lirc/lirc.org/api-docs/api-docs
        chmod 755 debian/tmp/usr/share/lirc/python-pkg/lirc/lirctool
-ifeq ($(DEB_BUILD_ARCH_OS), linux)
+ifeq ($(DEB_HOST_ARCH_OS), linux)
        mkdir -p debian/tmp/usr/lib/tmpfiles.d
        echo "d /run/lirc  0755  root  root  10d" \
            > debian/tmp/usr/lib/tmpfiles.d/lirc.conf
@@ -63,7 +64,7 @@
 endif
 
 override_dh_installsystemd:
-ifeq ($(DEB_BUILD_ARCH_OS), linux)
+ifeq ($(DEB_HOST_ARCH_OS), linux)
        dh_installsystemd -p lirc lircd.socket
        dh_installsystemd -p lirc --no-enable --no-start lircd.service
        dh_installsystemd -p lirc --no-enable --no-start irexec.service

Reply via email to