gnu: sqlite: Add locking-mode fix for the Hurd.

* gnu/packages/patches/sqlite-hurd.patch: New file.
* gnu/local.mk (dist_patch_DATA): Add it.
* gnu/packages/sqlite.scm (sqlite)[native-inputs]: Add it when building
for the Hurd.
[arguments]: Apply it when building for the Hurd.
This commit is contained in:
Jan (janneke) Nieuwenhuizen 2020-07-01 12:07:15 +02:00
parent af96b5845e
commit 1649c7d69a
No known key found for this signature in database
GPG key ID: F3C1A0D9C1D65273
3 changed files with 78 additions and 0 deletions

View file

@ -1374,6 +1374,7 @@ dist_patch_DATA = \
%D%/packages/patches/sdl-pango-header-guard.patch \ %D%/packages/patches/sdl-pango-header-guard.patch \
%D%/packages/patches/sdl-pango-matrix_declarations.patch \ %D%/packages/patches/sdl-pango-matrix_declarations.patch \
%D%/packages/patches/sdl-pango-sans-serif.patch \ %D%/packages/patches/sdl-pango-sans-serif.patch \
%D%/packages/patches/sqlite-hurd.patch \
%D%/packages/patches/patchutils-test-perms.patch \ %D%/packages/patches/patchutils-test-perms.patch \
%D%/packages/patches/patch-hurd-path-max.patch \ %D%/packages/patches/patch-hurd-path-max.patch \
%D%/packages/patches/perl-autosplit-default-time.patch \ %D%/packages/patches/perl-autosplit-default-time.patch \

View file

@ -0,0 +1,58 @@
Adapted from Debian: https://sources.debian.org/patches/sqlite3/3.32.3-1/20-hurd-locking-style.patch
Upstream status: Not upstreamed.
This patch is needed to get offloading to work.
Sqlite can use simple file locking mode, but that does not work for the Hurd;
a second sqlite process fails with a "locking protocol" error.
See also: https://bugs.debian.org/529734.
diff -purN sqlite-autoconf-3310100/sqlite3.c sqlite-autoconf-3310100-/sqlite3.c
--- sqlite-autoconf-3310100/sqlite3.c 2020-01-27 21:25:19.000000000 +0100
+++ sqlite-autoconf-3310100-/sqlite3.c 2020-07-01 11:50:13.768333806 +0200
@@ -33189,7 +33189,7 @@ SQLITE_PRIVATE const char *sqlite3Opcode
# include <sys/mman.h>
#endif
-#if SQLITE_ENABLE_LOCKING_STYLE
+#if SQLITE_ENABLE_LOCKING_STYLE || defined(__GNU__)
/* # include <sys/ioctl.h> */
# include <sys/file.h>
# include <sys/param.h>
@@ -35676,7 +35676,7 @@ static int dotlockClose(sqlite3_file *id
**
** Omit this section if SQLITE_ENABLE_LOCKING_STYLE is turned off
*/
-#if SQLITE_ENABLE_LOCKING_STYLE
+#if SQLITE_ENABLE_LOCKING_STYLE || defined(__GNU__)
/*
** Retry flock() calls that fail with EINTR
@@ -38586,7 +38586,7 @@ IOMETHODS(
0 /* xShmMap method */
)
-#if SQLITE_ENABLE_LOCKING_STYLE
+#if SQLITE_ENABLE_LOCKING_STYLE || defined(__GNU__)
IOMETHODS(
flockIoFinder, /* Finder function name */
flockIoMethods, /* sqlite3_io_methods object name */
@@ -41142,6 +41142,8 @@ SQLITE_API int sqlite3_os_init(void){
UNIXVFS("unix", autolockIoFinder ),
#elif OS_VXWORKS
UNIXVFS("unix", vxworksIoFinder ),
+#elif defined(__GNU__)
+ UNIXVFS("unix", flockIoFinder ),
#else
UNIXVFS("unix", posixIoFinder ),
#endif
@@ -41151,7 +41153,7 @@ SQLITE_API int sqlite3_os_init(void){
#if OS_VXWORKS
UNIXVFS("unix-namedsem", semIoFinder ),
#endif
-#if SQLITE_ENABLE_LOCKING_STYLE || OS_VXWORKS
+#if SQLITE_ENABLE_LOCKING_STYLE || OS_VXWORKS || defined(__GNU__)
UNIXVFS("unix-posix", posixIoFinder ),
#endif
#if SQLITE_ENABLE_LOCKING_STYLE

View file

@ -11,6 +11,7 @@
;;; Copyright © 2017 Jelle Licht <jlicht@fsfe.org> ;;; Copyright © 2017 Jelle Licht <jlicht@fsfe.org>
;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr> ;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
;;; Copyright © 2018 Alex Vong <alexvong1995@gmail.com> ;;; Copyright © 2018 Alex Vong <alexvong1995@gmail.com>
;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
;;; ;;;
;;; This file is part of GNU Guix. ;;; This file is part of GNU Guix.
;;; ;;;
@ -29,6 +30,7 @@
(define-module (gnu packages sqlite) (define-module (gnu packages sqlite)
#:use-module (gnu packages) #:use-module (gnu packages)
#:use-module (gnu packages hurd)
#:use-module (gnu packages readline) #:use-module (gnu packages readline)
#:use-module ((guix licenses) #:prefix license:) #:use-module ((guix licenses) #:prefix license:)
#:use-module (guix packages) #:use-module (guix packages)
@ -65,6 +67,11 @@ (define-public sqlite
"1bj936svd8i5g25xd1bj52hj4zca01fgl3sqkj86z9q5pkz4wa32")))) "1bj936svd8i5g25xd1bj52hj4zca01fgl3sqkj86z9q5pkz4wa32"))))
(build-system gnu-build-system) (build-system gnu-build-system)
(inputs `(("readline" ,readline))) (inputs `(("readline" ,readline)))
(native-inputs (if (hurd-target?)
;; TODO move into origin on the next rebuild cycle.
`(("hurd-locking-mode.patch"
,@(search-patches "sqlite-hurd.patch")))
'()))
(outputs '("out" "static")) (outputs '("out" "static"))
(arguments (arguments
`(#:configure-flags `(#:configure-flags
@ -79,6 +86,18 @@ (define-public sqlite
;; Column metadata is required by GNU Jami and Qt, et.al. ;; Column metadata is required by GNU Jami and Qt, et.al.
"-DSQLITE_ENABLE_COLUMN_METADATA")) "-DSQLITE_ENABLE_COLUMN_METADATA"))
#:phases (modify-phases %standard-phases #:phases (modify-phases %standard-phases
;; TODO: remove in the next rebuild cycle
,@(if (hurd-target?)
`((add-after 'unpack 'patch-sqlite/hurd
(lambda* (#:key inputs native-inputs
#:allow-other-keys)
(let ((patch (assoc-ref
(if ,(%current-target-system)
native-inputs
inputs)
"hurd-locking-mode.patch")))
(invoke "patch" "-p1" "--force" "-i" patch)))))
'())
(add-after 'install 'move-static-library (add-after 'install 'move-static-library
(lambda* (#:key outputs #:allow-other-keys) (lambda* (#:key outputs #:allow-other-keys)
(let* ((out (assoc-ref outputs "out")) (let* ((out (assoc-ref outputs "out"))