* gnu/packages/version-control.scm (postgresql-libversion): New variable.
---
gnu/packages/version-control.scm | 85 ++++++++++++++++++++++++++++++++
1 file changed, 85 insertions(+)
Toggle diff (98 lines)
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