projects/guix·blob master · refs

171 lines · 7.7 KiB

1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2013, 2015, 2018, 2020 Ludovic Courtès <[email protected]>
3;;; Copyright © 2014, 2015, 2016, 2018 Mark H Weaver <[email protected]>
4;;; Copyright © 2014 Sree Harsha Totakura <[email protected]>
5;;; Copyright © 2015, 2016 Sou Bunnbu <[email protected]>
6;;; Copyright © 2016 Efraim Flashner <[email protected]>
7;;; Copyright © 2016 Ben Woodcroft <[email protected]>
8;;; Copyright © 2016 David Craven <[email protected]>
9;;; Copyright © 2016, 2017, 2018, 2019, 2020, 2021 Marius Bakke <[email protected]>
10;;; Copyright © 2017 Ricardo Wurmus <[email protected]>
11;;; Copyright © 2017 Jelle Licht <[email protected]>
12;;; Copyright © 2018 Tobias Geerinckx-Rice <[email protected]>
13;;; Copyright © 2018 Alex Vong <[email protected]>
14;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <[email protected]>
15;;; Copyright © 2022 Matthew James Kraai <[email protected]>
16;;; Copyright © 2024 Zhu Zihao <[email protected]>
17;;; Copyright © 2025 Ashish SHUKLA <[email protected]>
18;;;
19;;; This file is part of GNU Guix.
20;;;
21;;; GNU Guix is free software; you can redistribute it and/or modify it
22;;; under the terms of the GNU General Public License as published by
23;;; the Free Software Foundation; either version 3 of the License, or (at
24;;; your option) any later version.
25;;;
26;;; GNU Guix is distributed in the hope that it will be useful, but
27;;; WITHOUT ANY WARRANTY; without even the implied warranty of
28;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29;;; GNU General Public License for more details.
30;;;
31;;; You should have received a copy of the GNU General Public License
32;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
33
34;;; Commentary:
35;;;
36;;; This module has been separated from (gnu packages databases) to reduce the
37;;; number of module references for core packages.
38;;;
39;;; Code:
40
41(define-module (gnu packages sqlite)
42 #:use-module (gnu packages)
43 #:use-module (gnu packages hurd)
44 #:use-module (gnu packages readline)
45 #:use-module ((guix licenses) #:prefix license:)
46 #:use-module (guix packages)
47 #:use-module (guix download)
48 #:use-module (guix build-system gnu)
49 #:use-module (guix gexp)
50 #:use-module (guix utils)
51 #:use-module (guix deprecation)
52 #:use-module (ice-9 match)
53 #:use-module (srfi srfi-26))
54
55(define (sqlite-uri version year)
56 (let ((numeric-version
57 (match (string-split version #\.)
58 ((first-digit other-digits ...)
59 (string-append first-digit
60 (string-pad-right
61 (string-concatenate
62 (map (cut string-pad <> 2 #\0)
63 other-digits))
64 6 #\0))))))
65 (string-append "https://sqlite.org/" (number->string year)
66 "/sqlite-autoconf-" numeric-version ".tar.gz")))
67
68(define-public sqlite
69 (package
70 (name "sqlite")
71 (version "3.39.3")
72 (source (origin
73 (method url-fetch)
74 (uri (sqlite-uri version 2022))
75 (patches (search-patches "sqlite-hurd.patch"))
76 (sha256
77 (base32
78 "1f922kq16g7f4h3gpzim78lvrp5xw9nvlvqw97s2qgxyh8qgns3q"))))
79 (build-system gnu-build-system)
80 (inputs (list readline))
81 (outputs '("out" "static"))
82 (arguments
83 `(#:configure-flags
84 ;; Add -DSQLITE_SECURE_DELETE, -DSQLITE_ENABLE_FTS3,
85 ;; -DSQLITE_ENABLE_UNLOCK_NOTIFY and -DSQLITE_ENABLE_DBSTAT_VTAB
86 ;; to CFLAGS. GNU Icecat will refuse to use the system SQLite
87 ;; unless these options are enabled.
88 (list (string-append "CFLAGS=-O2 -g -DSQLITE_SECURE_DELETE "
89 "-DSQLITE_ENABLE_FTS3 "
90 "-DSQLITE_ENABLE_UNLOCK_NOTIFY "
91 "-DSQLITE_ENABLE_DBSTAT_VTAB "
92 ;; Column metadata is required by GNU Jami and Qt, et.al.
93 "-DSQLITE_ENABLE_COLUMN_METADATA"))
94 #:phases (modify-phases %standard-phases
95 (add-after 'install 'move-static-library
96 (lambda* (#:key outputs #:allow-other-keys)
97 (let* ((out (assoc-ref outputs "out"))
98 (static (assoc-ref outputs "static"))
99 (source (string-append out "/lib/libsqlite3.a")))
100 (mkdir-p (string-append static "/lib"))
101 (link source (string-append static "/lib/libsqlite3.a"))
102 (delete-file source)
103
104 ;; Remove reference to the static library from the .la file
105 ;; so that Libtool looks for it in the usual places.
106 (substitute* (string-append out "/lib/libsqlite3.la")
107 (("^old_library=.*")
108 "old_library=''\n"))
109 #t))))))
110 (home-page "https://www.sqlite.org/")
111 (synopsis "The SQLite database management system")
112 (description
113 "SQLite is a software library that implements a self-contained, serverless,
114zero-configuration, transactional SQL database engine. SQLite is the most
115widely deployed SQL database engine in the world. The source code for SQLite
116is in the public domain.")
117 (license license:public-domain)))
118
119;; Newer version required for e.g. fossil.
120(define-public sqlite-next
121 (package
122 (inherit sqlite)
123 (version "3.53.4")
124 (source (origin
125 (method url-fetch)
126 (uri (sqlite-uri version 2026))
127 (sha256
128 (base32
129 "177b2saql7f8b8m59gnmgwgsci8143wnpla8zpl5vkcj1s88750f"))))
130 (arguments
131 (substitute-keyword-arguments arguments
132 ((#:tests? _ #f)
133 #f)
134 ((#:configure-flags flags #~(list))
135 #~(map (lambda (flag)
136 (if (string-prefix? "CFLAGS=" flag)
137 (string-append flag
138 ;; needed by fossil
139 " -DSQLITE_ENABLE_FTS4"
140 " -DSQLITE_ENABLE_FTS5"
141 ;; Needed by node (see
142 ;; deps/sqlite/sqlite.gyp).
143 " -DSQLITE_ENABLE_FTS3_PARENTHESIS"
144 " -DSQLITE_ENABLE_GEOPOLY"
145 " -DSQLITE_ENABLE_MATH_FUNCTIONS"
146 " -DSQLITE_ENABLE_PERCENTILE"
147 " -DSQLITE_ENABLE_PREUPDATE_HOOK"
148 " -DSQLITE_ENABLE_RBU"
149 " -DSQLITE_ENABLE_RTREE"
150 " -DSQLITE_ENABLE_SESSION")
151 flag))
152 ;; sqlite's configure script does not like
153 ;; --enable-fast-install
154 (cons* "--disable-option-checking"
155 (string-append "--with-readline-header="
156 #$(this-package-input "readline") "/include")
157 #$flags)))
158 ((#:phases phases #~(list))
159 #~(modify-phases #$phases
160 (replace 'move-static-library
161 (lambda* (#:key outputs #:allow-other-keys)
162 (let* ((out (assoc-ref outputs "out"))
163 (static (assoc-ref outputs "static"))
164 (source (string-append out "/lib/libsqlite3.a")))
165 (mkdir-p (string-append static "/lib"))
166 (link source (string-append static "/lib/libsqlite3.a"))
167 (delete-file source)
168 (when (file-exists? (string-append out "/lib/libsqlite3.la"))
169 (substitute* (string-append out "/lib/libsqlite3.la")
170 (("^old_library=.*")
171 "old_library=''\n"))))))))))))