Subject: bug#49815: Upcoming timekeeping failure in gpsd

From: Leo Famulari <[email-masked]>
Date: Mon, 2 Aug 2021 17:24:34 -0400

I got past the previous build failure by setting the environment
variable "TAR=noop" (found in the Nix package [0])... who knows what
that means? It only appears in the Nix packaging.

So now, using the attached patch, it fails to build because it can't
find limits.h, as shown below. Any ideas?

------
gcc -o gpsd-3.22/drivers/driver_greis_checksum.os -c -O2 -fPIC -I/gnu/store/00bkkmzybyfmbhhv0nw7r49m72339lyf-dbus-1.12.16/include/dbus-1.0 -I/gnu/store/00bkkmzybyfmbhhv0nw7r49m72339lyf-dbus-1.12.16/lib/dbus-1.0/include gpsd-3.22/drivers/driver_greis_checksum.c
In file included from /gnu/store/fa6wj5bxkj5ll1d7292a70knmyl7a0cr-glibc-2.31/include/bits/posix1_lim.h:161:0,
                 from /gnu/store/fa6wj5bxkj5ll1d7292a70knmyl7a0cr-glibc-2.31/include/limits.h:183,
                 from /gnu/store/01b4w3m6mp55y531kyi1g8shh722kwqm-gcc-7.5.0-lib/lib/gcc/x86_64-unknown-linux-gnu/7.5.0/include-fixed/limits.h:194,
                 from /gnu/store/01b4w3m6mp55y531kyi1g8shh722kwqm-gcc-7.5.0-lib/lib/gcc/x86_64-unknown-linux-gnu/7.5.0/include-fixed/syslimits.h:7,
                 from /gnu/store/01b4w3m6mp55y531kyi1g8shh722kwqm-gcc-7.5.0-lib/lib/gcc/x86_64-unknown-linux-gnu/7.5.0/include-fixed/limits.h:34,
                 from gpsd-3.22/drivers/driver_greis_checksum.c:11:
/gnu/store/fa6wj5bxkj5ll1d7292a70knmyl7a0cr-glibc-2.31/include/bits/local_lim.h:38:10: fatal error: linux/limits.h: No such file or directory
 #include <linux/limits.h>
          ^~~~~~~~~~~~~~~~
compilation terminated.
gcc -o gpsd-3.22/drivers/driver_rtcm2.os -c -O2 -fPIC -I/gnu/store/00bkkmzybyfmbhhv0nw7r49m72339lyf-dbus-1.12.16/include/dbus-1.0 -I/gnu/store/00bkkmzybyfmbhhv0nw7r49m72339lyf-dbus-1.12.16/lib/dbus-1.0/include gpsd-3.22/drivers/driver_rtcm2.c
scons: *** [gpsd-3.22/drivers/driver_greis_checksum.os] Error 1
In file included from /gnu/store/fa6wj5bxkj5ll1d7292a70knmyl7a0cr-glibc-2.31/include/bits/posix1_lim.h:161:0,
                 from /gnu/store/fa6wj5bxkj5ll1d7292a70knmyl7a0cr-glibc-2.31/include/limits.h:183,
                 from /gnu/store/01b4w3m6mp55y531kyi1g8shh722kwqm-gcc-7.5.0-lib/lib/gcc/x86_64-unknown-linux-gnu/7.5.0/include-fixed/limits.h:194,
                 from /gnu/store/01b4w3m6mp55y531kyi1g8shh722kwqm-gcc-7.5.0-lib/lib/gcc/x86_64-unknown-linux-gnu/7.5.0/include-fixed/syslimits.h:7,
                 from /gnu/store/01b4w3m6mp55y531kyi1g8shh722kwqm-gcc-7.5.0-lib/lib/gcc/x86_64-unknown-linux-gnu/7.5.0/include-fixed/limits.h:34,
                 from gpsd-3.22/drivers/../include/gps.h:14,
                 from gpsd-3.22/drivers/../include/gpsd.h:29,
                 from gpsd-3.22/drivers/driver_rtcm2.c:65:
/gnu/store/fa6wj5bxkj5ll1d7292a70knmyl7a0cr-glibc-2.31/include/bits/local_lim.h:38:10: fatal error: linux/limits.h: No such file or directory
 #include <linux/limits.h>
          ^~~~~~~~~~~~~~~~
compilation terminated.
scons: *** [gpsd-3.22/drivers/driver_rtcm2.os] Error 1
scons: building terminated because of errors.
------

[0]
https://github.com/NixOS/nixpkgs/blob/b166cc7fddc7c9b3fdd27dd74f177116ee5e2a7b/pkgs/servers/gpsd/default.nix#L54
diff --git a/gnu/packages/gps.scm b/gnu/packages/gps.scm
index 0eb4362858..df4c8ef4f6 100644
--- a/gnu/packages/gps.scm
+++ b/gnu/packages/gps.scm
@@ -222,14 +222,16 @@ such as elevation, speed, heart rate, power, temperature, and gear shifts.")
 (define-public gpsd
   (package
     (name "gpsd")
-    (version "3.21")
+    (version "3.23-rc1")
     (source
      (origin
-       (method url-fetch)
-       (uri (string-append "https://download-mirror.savannah.gnu.org"
-                           "/releases/gpsd/gpsd-" version ".tar.gz"))
+       (method git-fetch)
+       (uri (git-reference
+              (url "https://gitlab.com/gpsd/gpsd")
+              (commit "7f30d88d04dc62b8bd6265ad1d09d72d220f97f6")))
+       (file-name (git-file-name name version))
        (sha256
-        (base32 "14gyqrbrq6jz4y6x59rdpv9d4c3pbn0vh1blq3iwrc6kz0x4ql35"))))
+        (base32 "0n2ba6n2z3qjnjl2lvzqrp71x2rkip17p0r9hflviwkzcfr7ppdk"))))
     (build-system scons-build-system)
     (native-inputs
      `(("bc" ,bc)
@@ -259,6 +261,7 @@ such as elevation, speed, heart rate, power, temperature, and gear shifts.")
        (modify-phases %standard-phases
          (add-after 'unpack 'fix-build
            (lambda* (#:key outputs #:allow-other-keys)
+             (setenv "TAR" "noop")
              (substitute* "SConstruct"
                (("envs = \\{\\}")
                 "envs = os.environ"))