diff mbox series

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

Message ID PU1PR01MB2155EDB08E52C857594B4B768D9D9@PU1PR01MB2155.apcprd01.prod.exchangelabs.com
State Accepted
Headers show
Series gnu: Add sqlitebrowser. | expand

Checks

Context Check Description
cbaines/comparison success View comparision
cbaines/git branch success View Git branch
cbaines/applying patch success View Laminar job
cbaines/issue success View issue

Commit Message

Foo Chuan Wei Nov. 20, 2021, 3:44 p.m. UTC
* gnu/packages/databases.scm (sqlitebrowser): New variable.
---
 gnu/packages/databases.scm | 91 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 91 insertions(+)
diff mbox series

Patch

diff --git a/gnu/packages/databases.scm b/gnu/packages/databases.scm
index 5edc4e2cce..ca801489be 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,95 @@  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"
+               (("auto json_parse_result = json::parse\\(cellData, nullptr, false\\);")
+                "auto json_parse_result = json::parse(cellData.toStdString(), nullptr, false);"))
+             (substitute* '("src/RemoteDock.cpp"
+                            "src/RemotePushDialog.cpp")
+               (("json obj = json::parse\\(reply, nullptr, false\\);")
+                "json obj = json::parse(reply.toStdString(), nullptr, false);"))
+             (substitute* "src/RemoteNetwork.cpp"
+               (("json obj = json::parse\\(reply->readAll\\(\\), nullptr, false\\);")
+                "json obj = json::parse((reply->readAll()).toStdString(), nullptr, false);")))))))
+    (native-inputs
+     `(("json-modern-cxx" ,json-modern-cxx)
+       ("qcustomplot" ,qcustomplot)
+       ("qhexedit" ,qhexedit)
+       ("qscintilla" ,qscintilla)
+       ("qtbase" ,qtbase-5)
+       ("qttools" ,qttools)
+       ("sqlite" ,sqlite)))
+    (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")