diff mbox series

[bug#52000,v2,2/2] gnu: Add sqlitebrowser.

Message ID PU1PR01MB21555CCD24D8047DB80EE7288D9E9@PU1PR01MB2155.apcprd01.prod.exchangelabs.com
State New
Headers show
Series None | expand

Commit Message

Foo Chuan Wei Nov. 21, 2021, 10:39 a.m. UTC
* gnu/packages/databases.scm (sqlitebrowser): New variable.
---
Changes relative to PATCH v1:
* Move libraries from native-inputs to inputs.
* Reduce the length of some long string arguments given to substitute*.

 gnu/packages/databases.scm | 92 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 92 insertions(+)
diff mbox series

Patch

diff --git a/gnu/packages/databases.scm b/gnu/packages/databases.scm
index 5edc4e2cce..ab7b31392e 100644
--- a/gnu/packages/databases.scm
+++ b/gnu/packages/databases.scm
@@ -54,6 +54,7 @@ 
 ;;; Copyright © 2021 Alexandre Hannud Abdo <abdo@member.fsf.org>
 ;;; Copyright © 2021 Simon Tournier <zimon.toutoune@gmail.com>
 ;;; Copyright © 2021 jgart <jgart@dismail.de>
+;;; Copyright © 2021 Foo Chuan Wei <chuanwei.foo@hotmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -130,6 +131,7 @@ 
   #:use-module (gnu packages python-science)
   #:use-module (gnu packages python-web)
   #:use-module (gnu packages python-xyz)
+  #:use-module (gnu packages qt)
   #:use-module (gnu packages rdf)
   #:use-module (gnu packages readline)
   #:use-module (gnu packages regex)
@@ -4098,6 +4100,96 @@  PostreSQL, SQLite, ODBC and MySQL.")
 connecting to MS SQL and Sybase servers over TCP/IP.")
     (license license:lgpl2.0+)))
 
+(define-public sqlitebrowser
+  (package
+    (name "sqlitebrowser")
+    (version "3.12.2")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/sqlitebrowser/sqlitebrowser")
+             (commit (string-append "v" version))))
+       (file-name (git-file-name name version))
+       (sha256
+        (base32 "1ljqzcx388mmni8lv9jz5r58alhsjrrqi4nzjnbfki94rn4ray6z"))
+       ;; Remove bundled libraries.
+       (modules '((guix build utils)))
+       (snippet '(delete-file-recursively "libs"))))
+    (build-system cmake-build-system)
+    (arguments
+     `(#:configure-flags '("-DENABLE_TESTING=ON"
+                           ;; Force the use of non-bundled libraries.
+                           "-DFORCE_INTERNAL_QSCINTILLA=OFF"
+                           "-DFORCE_INTERNAL_QHEXEDIT=OFF"
+                           "-DFORCE_INTERNAL_QCUSTOMPLOT=OFF")
+       #:phases
+       (modify-phases %standard-phases
+         (add-after 'unpack 'fix-build
+           (lambda* (#:key inputs #:allow-other-keys)
+             (substitute* "CMakeLists.txt"
+               (("^    find_package\\(QScintilla 2.8.10 QUIET\\)" all)
+                (string-append
+                  all "\n"
+                  "    set(QSCINTILLA_FOUND TRUE)\n"
+                  "    set(QSCINTILLA_INCLUDE_DIR "
+                  (assoc-ref inputs "qscintilla") "/include)"))
+               (("^    find_package\\(QHexEdit\\)" all)
+                (string-append
+                  all "\n"
+                  "    set(QHexEdit_FOUND TRUE)\n"
+                  "    set(QHexEdit_INCLUDE_DIR "
+                  (assoc-ref inputs "qhexedit") "/include)"))
+               (("^set\\(JSON_DIR libs/json\\)")
+                (string-append "set(JSON_DIR "
+                               (assoc-ref inputs "json-modern-cxx") "/include)"))
+               (("^add_subdirectory\\(\\$\\{JSON_DIR\\}\\)")  ; No need to build.
+                ""))
+
+             (substitute* '("src/EditDialog.cpp"
+                            "src/ExportDataDialog.cpp"
+                            "src/RemoteCommitsModel.h"
+                            "src/RemoteDock.cpp"
+                            "src/RemoteLocalFilesModel.h"
+                            "src/RemoteModel.h"
+                            "src/RemoteNetwork.cpp"
+                            "src/RemotePushDialog.cpp"
+                            "src/sqlitedb.cpp"
+                            "src/sqlitetablemodel.cpp")
+               (("^#include <json.hpp>")
+                "#include <nlohmann/json.hpp>"))
+
+             ;; Fix compilation error:
+             ;; "no matching function for call to ‘input_adapter(const QByteArray&)’"
+             (substitute* "src/EditDialog.cpp"
+               (("json::parse\\(cellData, nullptr, false\\)")
+                "json::parse(cellData.toStdString(), nullptr, false)"))
+             (substitute* '("src/RemoteDock.cpp"
+                            "src/RemotePushDialog.cpp")
+               (("json::parse\\(reply, nullptr, false\\)")
+                "json::parse(reply.toStdString(), nullptr, false)"))
+             (substitute* "src/RemoteNetwork.cpp"
+               (("json::parse\\(reply->readAll\\(\\), nullptr, false\\)")
+                "json::parse((reply->readAll()).toStdString(), nullptr, false)")))))))
+    (inputs
+     `(("json-modern-cxx" ,json-modern-cxx)
+       ("qcustomplot" ,qcustomplot)
+       ("qhexedit" ,qhexedit)
+       ("qscintilla" ,qscintilla)
+       ("qtbase" ,qtbase-5)
+       ("sqlite" ,sqlite)))
+    (native-inputs
+     `(("qttools" ,qttools)))
+    (home-page "https://sqlitebrowser.org")
+    (synopsis "GUI editor for SQLite databases")
+    (description
+     "DB Browser for SQLite (DB4S) is a visual tool to create, design, and edit
+database files compatible with SQLite.  DB4S is for users and developers who
+want to create, search, and edit databases using a familiar spreadsheet-like
+interface, without needing to learn complicated SQL commands.")
+    ;; Dual licensing.
+    (license (list license:gpl3+ license:mpl2.0))))
+
 (define-public sequeler
   (package
     (name "sequeler")