GNU bug report logs - #73876
[PATCH 0/3] Add postgresql-libversion

Previous Next

Package: guix-patches;

Reported by: Nicolas Graves <ngraves <at> ngraves.fr>

Date: Sat, 19 Oct 2024 08:56:02 UTC

Severity: normal

Tags: patch

To reply to this bug, email your comments to 73876 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to guix-patches <at> gnu.org:
bug#73876; Package guix-patches. (Sat, 19 Oct 2024 08:56:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Nicolas Graves <ngraves <at> ngraves.fr>:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Sat, 19 Oct 2024 08:56:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Nicolas Graves <ngraves <at> ngraves.fr>
To: guix-patches <at> gnu.org
Cc: Nicolas Graves <ngraves <at> ngraves.fr>
Subject: [PATCH 0/3] Add postgresql-libversion
Date: Sat, 19 Oct 2024 10:49:15 +0200
I was in the process of trying to get more useful information from
repology for Guix using a database dump.  I've just jumped into the
postgresql-extensions rabbithole. Here's a properly constructed
extension.

I also wonder why:
- the postgresql-service is stuck with postgresql-10
- we don't patch postgresql with a native-search-path just like python so that pg_config/psql reads from this native-search-path for extensions and falls back to its current default instead. It seems like the reasonable thing to do instead of the circumvoluted directory-union for extensions.

Nicolas Graves (3):
  gnu: Add libversion.
  gnu: final-postgresql: Move to (gnu packages databases).
  gnu: Add postgresql-libversion.

 gnu/packages/databases.scm       |   9 +++
 gnu/packages/version-control.scm | 118 ++++++++++++++++++++++++++++++-
 gnu/services/databases.scm       |  26 +------
 3 files changed, 128 insertions(+), 25 deletions(-)

-- 
2.46.0





Information forwarded to guix-patches <at> gnu.org:
bug#73876; Package guix-patches. (Sat, 19 Oct 2024 09:10:02 GMT) Full text and rfc822 format available.

Message #8 received at 73876 <at> debbugs.gnu.org (full text, mbox):

From: Nicolas Graves <ngraves <at> ngraves.fr>
To: 73876 <at> debbugs.gnu.org
Cc: Nicolas Graves <ngraves <at> ngraves.fr>
Subject: [PATCH 1/3] gnu: Add libversion.
Date: Sat, 19 Oct 2024 11:09:13 +0200
* gnu/packages/version-control.scm (libversion): New variable.
---
 gnu/packages/version-control.scm | 34 +++++++++++++++++++++++++++++++-
 1 file changed, 33 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/version-control.scm b/gnu/packages/version-control.scm
index 6bd37fee82..b14ec77ff5 100644
--- a/gnu/packages/version-control.scm
+++ b/gnu/packages/version-control.scm
@@ -47,7 +47,7 @@
 ;;; Copyright © 2022 Maxime Devos <maximedevos <at> telenet.be>
 ;;; Copyright © 2022 Dhruvin Gandhi <contact <at> dhruvin.dev>
 ;;; Copyright © 2015, 2022 David Thompson <davet <at> gnu.org>
-;;; Copyright © 2023 Nicolas Graves <ngraves <at> ngraves.fr>
+;;; Copyright © 2023, 2024 Nicolas Graves <ngraves <at> ngraves.fr>
 ;;; Copyright © 2023 Bruno Victal <mirai <at> makinata.eu>
 ;;; Copyright © 2023 Kjartan Oli Agustsson <kjartanoli <at> disroot.org>
 ;;; Copyright © 2023 Steve George <steve <at> futurile.net>
@@ -1251,6 +1251,38 @@ (define-public libgit2-1.3
                    ;; Tests may be disabled if cross-compiling.
                    (format #t "Test suite not run.~%"))))))))))
 
+(define-public libversion
+  (package
+    (name "libversion")
+    (version "3.0.3")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/repology/libversion")
+             (commit version)))
+       (file-name (git-file-name name version))
+       (sha256
+        (base32 "186dq3x9w8k5xp4b84ms7f5cm10si3yzs52iscgv0xs58c7rfja4"))))
+    (build-system cmake-build-system)
+    (home-page "https://github.com/repology/libversion")
+    (synopsis "Version string comparison library")
+    (description "This package provides a very advanced string comparison
+library, used by the @url{https://repology.org, Repology} project, and able to
+compare versions with:
+
+@itemize
+@item insignificant components
+@item leading zero
+@item unusual separators
+@item letter suffixes
+@item alphanumeric prerelease components
+@item prerelease keywords
+@item patch, post and pl keywords
+@item customizable handling of ambiguous p keyword
+@end itemize")
+    (license license:expat)))
+
 (define-public git-crypt
   (package
     (name "git-crypt")
-- 
2.46.0





Information forwarded to guix-patches <at> gnu.org:
bug#73876; Package guix-patches. (Sat, 19 Oct 2024 09:10:02 GMT) Full text and rfc822 format available.

Message #11 received at 73876 <at> debbugs.gnu.org (full text, mbox):

From: Nicolas Graves <ngraves <at> ngraves.fr>
To: 73876 <at> debbugs.gnu.org
Cc: Nicolas Graves <ngraves <at> ngraves.fr>
Subject: [PATCH 2/3] gnu: final-postgresql: Move to (gnu packages databases).
Date: Sat, 19 Oct 2024 11:09:14 +0200
* gnu/services/databases.scm (final-postgresql): Move from here...
* gnu/packages/databases.scm (extend-postgresql): ...to here and
switch to directory-union implementation.
---
 gnu/packages/databases.scm |  9 +++++++++
 gnu/services/databases.scm | 26 ++------------------------
 2 files changed, 11 insertions(+), 24 deletions(-)

diff --git a/gnu/packages/databases.scm b/gnu/packages/databases.scm
index f05566becd..d9dc4525aa 100644
--- a/gnu/packages/databases.scm
+++ b/gnu/packages/databases.scm
@@ -63,6 +63,7 @@
 ;;; Copyright © 2023 Munyoki Kilyungi <me <at> bonfacemunyoki.com>
 ;;; Copyright © 2023 Giacomo Leidi <goodoldpaul <at> autistici.org>
 ;;; Copyright © 2024 Troy Figiel <troy <at> troyfigiel.com>
+;;; Copyright © 2024 Nicolas Graves <ngraves <at> ngraves.fr>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -1409,6 +1410,14 @@ (define-public postgresql-10
 
 (define-public postgresql postgresql-14)
 
+(define-public (extend-postgresql postgresql extensions)
+  (if (null? extensions)
+      postgresql
+      (let ((packages (cons* postgresql extensions)))
+        (directory-union
+         (string-join (map package-name packages) "+")
+         packages))))
+
 (define-public timescaledb
   (package
     (name "timescaledb")
diff --git a/gnu/services/databases.scm b/gnu/services/databases.scm
index fa332d7978..dc6c1720ff 100644
--- a/gnu/services/databases.scm
+++ b/gnu/services/databases.scm
@@ -205,27 +205,6 @@ (define (create-postgresql-account config)
                (home-directory "/var/empty")
                (shell (file-append shadow "/sbin/nologin")))))))
 
-(define (final-postgresql postgresql extension-packages)
-  (if (null? extension-packages)
-    postgresql
-    (package
-      (inherit postgresql)
-      (source #f)
-      (build-system trivial-build-system)
-      (arguments
-       `(#:modules ((guix build utils) (guix build union))
-         #:builder
-         (begin
-           (use-modules (guix build utils) (guix build union) (srfi srfi-26))
-           (union-build (assoc-ref %outputs "out")
-                        (map (lambda (input) (cdr input))
-                             %build-inputs))
-           #t)))
-      (inputs
-       `(("postgresql" ,postgresql)
-         ,@(map (lambda (extension) (list "extension" extension))
-                extension-packages))))))
-
 (define postgresql-activation
   (match-lambda
     (($ <postgresql-configuration> postgresql port locale config-file
@@ -250,8 +229,7 @@ (define postgresql-activation
 
            (unless (file-exists? #$data-directory)
              (let ((initdb (string-append
-                            #$(final-postgresql postgresql
-                                                extension-packages)
+                            #$(extend-postgresql postgresql extension-packages)
                             "/bin/initdb"))
                    (initdb-args
                     (append
@@ -297,7 +275,7 @@ (define postgresql-shepherd-service
                     ((_ mode)
                      (let ((user (getpwnam "postgres"))
                            (pg_ctl #$(file-append
-                                      (final-postgresql postgresql
+                                      (extend-postgresql postgresql
                                                         extension-packages)
                                                   "/bin/pg_ctl"))
                            (options (format #f "--config-file=~a -p ~d"
-- 
2.46.0





Information forwarded to guix-patches <at> gnu.org:
bug#73876; Package guix-patches. (Sat, 19 Oct 2024 09:11:02 GMT) Full text and rfc822 format available.

Message #14 received at 73876 <at> debbugs.gnu.org (full text, mbox):

From: Nicolas Graves <ngraves <at> ngraves.fr>
To: 73876 <at> debbugs.gnu.org
Cc: Nicolas Graves <ngraves <at> ngraves.fr>
Subject: [PATCH 3/3] gnu: Add postgresql-libversion.
Date: Sat, 19 Oct 2024 11:09:15 +0200
* gnu/packages/version-control.scm (postgresql-libversion): New variable.
---
 gnu/packages/version-control.scm | 85 ++++++++++++++++++++++++++++++++
 1 file changed, 85 insertions(+)

diff --git a/gnu/packages/version-control.scm b/gnu/packages/version-control.scm
index b14ec77ff5..b70db7a022 100644
--- a/gnu/packages/version-control.scm
+++ b/gnu/packages/version-control.scm
@@ -1570,6 +1570,91 @@ (define-public python-git-multimail
 repository")
     (license license:gpl2)))
 
+(define postgresql-libversion-bootstrap
+  (package
+    (name "postgresql-libversion")
+    (version "2.0.1")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/repology/postgresql-libversion")
+             (commit version)))
+       (file-name (git-file-name name version))
+       (sha256
+        (base32 "0g28dbj0zad62irzv051m4acby974f1ya605xfl48i8g3il9fyny"))))
+    (build-system gnu-build-system)
+    (arguments
+     (list
+      #:tests? #f
+      #:make-flags #~(list (string-append "DESTDIR=" (getcwd) "/tmp-out"))
+      #:phases
+      #~(modify-phases %standard-phases
+          (delete 'configure)
+          (delete 'install)
+          (add-after 'build 'pre-install
+            (lambda args
+              (mkdir "tmp-out")
+              (apply (assoc-ref %standard-phases 'install) args)))
+          (add-after 'pre-install 'install
+            (lambda _
+              (let ((tmp-out (string-append (dirname (getcwd)) "/tmp-out")))
+                (copy-recursively
+                 (dirname
+                  (dirname (car (find-files tmp-out "libversion.so"))))
+                 #$output))))
+          (add-after 'build 'start-postgresql
+            (lambda* (#:key tests? #:allow-other-keys)
+              (when tests?
+                (let ((dbdir (string-append (dirname (getcwd)) "/pgdir")))
+                  (invoke "initdb" "-D" dbdir)
+                  (invoke "pg_ctl" "-D" dbdir
+                          "-o" (string-append "-k " dbdir)
+                          "-l" (string-append dbdir "/db.log")
+                          "start")
+	          (invoke "psql" "-h" dbdir "-d" "postgres"
+                          "-c" "CREATE DATABASE nixbld;")
+                  (setenv "PGHOST" dbdir)))))
+          (replace 'check
+            (lambda* (#:key tests? #:allow-other-keys)
+              (if tests?
+                  (invoke "make" "installcheck")
+                  (format #t "test suite not run~%")))))))
+    (inputs (list libversion postgresql))
+    (native-inputs (list pkg-config))
+    (home-page "https://github.com/repology/postgresql-libversion")
+    (synopsis "PostgreSQL extension for version string comparison")
+    (description "This package provides a PostgreSQL extension with support
+for version string comparison through @code{libversion}.  It is used to
+experiment with @url{https://repology.org, Repology} database dumps.")
+    (license license:expat)))
+
+;; A postgresql extension needs extend-postgresql with itself to test.
+;; This is because CREATE EXTENSION needs the extension to be in the
+;; postgresql package.
+(define-public postgresql-libversion
+  (package
+    (inherit postgresql-libversion-bootstrap)
+    (arguments
+     (substitute-keyword-arguments
+         (package-arguments postgresql-libversion-bootstrap)
+       ((#:tests? _) #t)
+       ((#:phases phases)
+        #~(modify-phases #$phases
+            (delete 'build)
+            (delete 'pre-install)
+            (delete 'install-license-files)
+            (replace 'install
+              (lambda _
+                (copy-recursively
+                 #$(this-package-native-input "postgresql-libversion")
+                 #$output)))))))
+    (native-inputs (list pkg-config
+                         postgresql-libversion-bootstrap
+                         (extend-postgresql
+                          postgresql
+                          (list postgresql-libversion-bootstrap))))))
+
 (define-public python-ghp-import
   (package
     (name "python-ghp-import")
-- 
2.46.0





Added tag(s) moreinfo. Request was from Nicolas Graves <ngraves <at> ngraves.fr> to control <at> debbugs.gnu.org. (Sat, 19 Oct 2024 17:37:02 GMT) Full text and rfc822 format available.

Removed tag(s) moreinfo. Request was from Nicolas Graves <ngraves <at> ngraves.fr> to control <at> debbugs.gnu.org. (Sun, 20 Oct 2024 09:07:01 GMT) Full text and rfc822 format available.

Information forwarded to guix-patches <at> gnu.org:
bug#73876; Package guix-patches. (Sun, 20 Oct 2024 14:23:03 GMT) Full text and rfc822 format available.

Message #21 received at 73876 <at> debbugs.gnu.org (full text, mbox):

From: Nicolas Graves <ngraves <at> ngraves.fr>
To: 73876 <at> debbugs.gnu.org
Cc: Nicolas Graves <ngraves <at> ngraves.fr>
Subject: [PATCH v2 1/3] gnu: Add libversion.
Date: Sun, 20 Oct 2024 16:21:33 +0200
* gnu/packages/version-control.scm (libversion): New variable.
---
 gnu/packages/version-control.scm | 34 +++++++++++++++++++++++++++++++-
 1 file changed, 33 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/version-control.scm b/gnu/packages/version-control.scm
index 6bd37fee82..b14ec77ff5 100644
--- a/gnu/packages/version-control.scm
+++ b/gnu/packages/version-control.scm
@@ -47,7 +47,7 @@
 ;;; Copyright © 2022 Maxime Devos <maximedevos <at> telenet.be>
 ;;; Copyright © 2022 Dhruvin Gandhi <contact <at> dhruvin.dev>
 ;;; Copyright © 2015, 2022 David Thompson <davet <at> gnu.org>
-;;; Copyright © 2023 Nicolas Graves <ngraves <at> ngraves.fr>
+;;; Copyright © 2023, 2024 Nicolas Graves <ngraves <at> ngraves.fr>
 ;;; Copyright © 2023 Bruno Victal <mirai <at> makinata.eu>
 ;;; Copyright © 2023 Kjartan Oli Agustsson <kjartanoli <at> disroot.org>
 ;;; Copyright © 2023 Steve George <steve <at> futurile.net>
@@ -1251,6 +1251,38 @@ (define-public libgit2-1.3
                    ;; Tests may be disabled if cross-compiling.
                    (format #t "Test suite not run.~%"))))))))))
 
+(define-public libversion
+  (package
+    (name "libversion")
+    (version "3.0.3")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/repology/libversion")
+             (commit version)))
+       (file-name (git-file-name name version))
+       (sha256
+        (base32 "186dq3x9w8k5xp4b84ms7f5cm10si3yzs52iscgv0xs58c7rfja4"))))
+    (build-system cmake-build-system)
+    (home-page "https://github.com/repology/libversion")
+    (synopsis "Version string comparison library")
+    (description "This package provides a very advanced string comparison
+library, used by the @url{https://repology.org, Repology} project, and able to
+compare versions with:
+
+@itemize
+@item insignificant components
+@item leading zero
+@item unusual separators
+@item letter suffixes
+@item alphanumeric prerelease components
+@item prerelease keywords
+@item patch, post and pl keywords
+@item customizable handling of ambiguous p keyword
+@end itemize")
+    (license license:expat)))
+
 (define-public git-crypt
   (package
     (name "git-crypt")
-- 
2.46.0





Information forwarded to guix-patches <at> gnu.org:
bug#73876; Package guix-patches. (Sun, 20 Oct 2024 14:23:04 GMT) Full text and rfc822 format available.

Message #24 received at 73876 <at> debbugs.gnu.org (full text, mbox):

From: Nicolas Graves <ngraves <at> ngraves.fr>
To: 73876 <at> debbugs.gnu.org
Cc: Nicolas Graves <ngraves <at> ngraves.fr>
Subject: [PATCH v2 2/3] gnu: Add postgresql-libversion.
Date: Sun, 20 Oct 2024 16:21:34 +0200
* gnu/packages/version-control.scm (postgresql-libversion): New variable.
---
 gnu/packages/version-control.scm | 68 ++++++++++++++++++++++++++++++++
 1 file changed, 68 insertions(+)

diff --git a/gnu/packages/version-control.scm b/gnu/packages/version-control.scm
index b14ec77ff5..00e50a9182 100644
--- a/gnu/packages/version-control.scm
+++ b/gnu/packages/version-control.scm
@@ -1570,6 +1570,74 @@ (define-public python-git-multimail
 repository")
     (license license:gpl2)))
 
+(define-public postgresql-libversion
+  (package
+    (name "postgresql-libversion")
+    (version "2.0.1")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/repology/postgresql-libversion")
+             (commit version)))
+       (file-name (git-file-name name version))
+       (sha256
+        (base32 "0g28dbj0zad62irzv051m4acby974f1ya605xfl48i8g3il9fyny"))))
+    (build-system gnu-build-system)
+    (arguments
+     (list
+      #:make-flags #~(list (string-append "DESTDIR=" (getcwd) "/tmp-out"))
+      #:imported-modules `((guix build union)
+                           ,@%default-gnu-imported-modules)
+      #:modules `(,@%default-gnu-imported-modules
+                   (guix build union)
+                   (ice-9 match))
+      #:phases
+      #~(modify-phases %standard-phases
+          (delete 'configure)
+          (delete 'install)
+          (add-after 'build 'pre-install
+            (lambda args
+              (mkdir "tmp-out")
+              (apply (assoc-ref %standard-phases 'install) args)))
+          (add-after 'pre-install 'install
+            (lambda _
+              (let ((tmp-out (string-append (dirname (getcwd)) "/tmp-out")))
+                (copy-recursively
+                 (dirname
+                  (dirname (car (find-files tmp-out "libversion.so"))))
+                 #$output))))
+          (add-after 'install 'prepare-tests
+            (lambda* (#:key inputs tests? #:allow-other-keys)
+              (if tests?
+                  (let ((pg-data (string-append (getcwd) "/../pg-data"))
+                        (pg-union (string-append (getcwd) "/../pg-union")))
+                    (match inputs
+                      (((names . directories) ...)
+                       (union-build pg-union (cons #$output directories))))
+                    (setenv "PATH" (string-append pg-union "/bin:"
+                                                  (getenv "PATH")))
+                    (invoke "initdb" "-D" pg-data)
+                    (invoke "pg_ctl" "-D" pg-data
+                            "-o" (string-append "-k " pg-data)
+                            "-l" (string-append pg-data "/db.log")
+                            "start")
+                    (setenv "PGHOST" pg-data))
+                  (format #t "prepare-tests phase not run~%"))))
+          (replace 'check
+            (lambda* (#:key tests? #:allow-other-keys)
+              (if tests?
+                  (invoke "make" "installcheck")
+                  (format #t "test suite not run~%")))))))
+    (inputs (list libversion postgresql))
+    (native-inputs (list pkg-config))
+    (home-page "https://github.com/repology/postgresql-libversion")
+    (synopsis "PostgreSQL extension for version string comparison")
+    (description "This package provides a PostgreSQL extension with support
+for version string comparison through @code{libversion}.  It is used to
+experiment with @url{https://repology.org, Repology} database dumps.")
+    (license license:expat)))
+
 (define-public python-ghp-import
   (package
     (name "python-ghp-import")
-- 
2.46.0





Information forwarded to guix-patches <at> gnu.org:
bug#73876; Package guix-patches. (Sun, 20 Oct 2024 14:23:04 GMT) Full text and rfc822 format available.

Message #27 received at 73876 <at> debbugs.gnu.org (full text, mbox):

From: Nicolas Graves <ngraves <at> ngraves.fr>
To: 73876 <at> debbugs.gnu.org
Cc: Nicolas Graves <ngraves <at> ngraves.fr>
Subject: [PATCH v2 3/3] gnu: databases: Rewrite final-postgresql for
 postgresql-service.
Date: Sun, 20 Oct 2024 16:21:35 +0200
* gnu/services/databases.scm (final-postgresql): Rewrite using a
directory-union and rename to extend-postgresql.
---
 gnu/services/databases.scm | 31 +++++++++----------------------
 1 file changed, 9 insertions(+), 22 deletions(-)

diff --git a/gnu/services/databases.scm b/gnu/services/databases.scm
index fa332d7978..aed0f414ab 100644
--- a/gnu/services/databases.scm
+++ b/gnu/services/databases.scm
@@ -205,26 +205,13 @@ (define (create-postgresql-account config)
                (home-directory "/var/empty")
                (shell (file-append shadow "/sbin/nologin")))))))
 
-(define (final-postgresql postgresql extension-packages)
-  (if (null? extension-packages)
-    postgresql
-    (package
-      (inherit postgresql)
-      (source #f)
-      (build-system trivial-build-system)
-      (arguments
-       `(#:modules ((guix build utils) (guix build union))
-         #:builder
-         (begin
-           (use-modules (guix build utils) (guix build union) (srfi srfi-26))
-           (union-build (assoc-ref %outputs "out")
-                        (map (lambda (input) (cdr input))
-                             %build-inputs))
-           #t)))
-      (inputs
-       `(("postgresql" ,postgresql)
-         ,@(map (lambda (extension) (list "extension" extension))
-                extension-packages))))))
+(define-public (extend-postgresql postgresql extensions)
+  (if (null? extensions)
+      postgresql
+      (let ((packages (cons* postgresql extensions)))
+        (directory-union
+         (string-join (map package-name packages) "+")
+         packages))))
 
 (define postgresql-activation
   (match-lambda
@@ -250,7 +237,7 @@ (define postgresql-activation
 
            (unless (file-exists? #$data-directory)
              (let ((initdb (string-append
-                            #$(final-postgresql postgresql
+                            #$(extend-postgresql postgresql
                                                 extension-packages)
                             "/bin/initdb"))
                    (initdb-args
@@ -297,7 +284,7 @@ (define postgresql-shepherd-service
                     ((_ mode)
                      (let ((user (getpwnam "postgres"))
                            (pg_ctl #$(file-append
-                                      (final-postgresql postgresql
+                                      (extend-postgresql postgresql
                                                         extension-packages)
                                                   "/bin/pg_ctl"))
                            (options (format #f "--config-file=~a -p ~d"
-- 
2.46.0





This bug report was last modified 237 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.