Subject: [bug#44389] [PATCH] gnu: Add firebird.

From: Christopher Baines <[email-masked]>
Date: Sat, 07 Nov 2020 12:39:44 +0000

Tobias Geerinckx-Rice via Guix-patches via <[email-masked]> writes:

> * gnu/packages/databases.scm (firebird): New public variable.
> ---
>
> Guix,
>
> This adds Firebird to enable LibreOffice Base.
>
> Kind regards,
>
> T G-R
>
>  gnu/packages/databases.scm | 174 +++++++++++++++++++++++++++++++++++++
>  1 file changed, 174 insertions(+)
>
> diff --git a/gnu/packages/databases.scm b/gnu/packages/databases.scm
> index 0d8342b04a..c1a9482b5d 100644
> --- a/gnu/packages/databases.scm
> +++ b/gnu/packages/databases.scm
> @@ -87,13 +87,16 @@
>    #:use-module (gnu packages guile)
>    #:use-module (gnu packages time)
>    #:use-module (gnu packages golang)
> +  #:use-module (gnu packages icu4c)
>    #:use-module (gnu packages jemalloc)
>    #:use-module (gnu packages language)
> +  #:use-module (gnu packages libedit)
>    #:use-module (gnu packages libevent)
>    #:use-module (gnu packages linux)
>    #:use-module (gnu packages logging)
>    #:use-module (gnu packages man)
>    #:use-module (gnu packages maths)
> +  #:use-module (gnu packages multiprecision)
>    #:use-module (gnu packages ncurses)
>    #:use-module (gnu packages onc-rpc)
>    #:use-module (gnu packages parallel)
> @@ -308,6 +311,177 @@ ElasticSearch server")
>      (home-page "https://github.com/patientslikeme/es_dump_restore")
>      (license license:expat)))
>  
> +(define-public firebird
> +  (package
> +    (name "firebird")
> +    (version "3.0.7")
> +    (source
> +     (let ((revision "33374-0"))
> +       (origin
> +         (method url-fetch)
> +         (uri (string-append "https://github.com/FirebirdSQL/"
> +                             "firebird/releases/download/R"
> +                             (string-replace-substring version "." "_") "/"
> +                             "Firebird-" version "." revision ".tar.bz2"))
> +         (sha256
> +          (base32 "0xpy1bncz36c6n28y7kllm1dkrdkn4vb4gw2n43f2351mznmrf5c"))
> +         (modules '((guix build utils)))
> +         (snippet
> +          `(begin
> +             (for-each
> +              delete-file-recursively
> +              (list "extern/btyacc/test" ; TODO: package and remove entirely
> +                    "extern/editline"
> +                    "extern/icu"
> +                    "extern/libtommath"
> +                    "extern/zlib"
> +                    "src/include/firebird/impl/boost"
> +
> +                    ;; Missing licence.
> +                    "builds/install/arch-specific/solaris"
> +                    "extern/SfIO"
> +                    "src/msgs/templates.sql"
> +
> +                    ;; Generated files missing sources.
> +                    "doc/Firebird-3-QuickStart.pdf"
> +                    (string-append "doc/Firebird-" ,version
> +                                   "-ReleaseNotes.pdf")
> +                    "doc/README.SecureRemotePassword.html"))
> +             #t)))))
> +    (build-system gnu-build-system)
> +    (arguments
> +     `(#:configure-flags
> +       (let ((out (assoc-ref %outputs "out")))
> +         (list (string-append "--with-fbsbin=" out "/sbin")
> +               (string-append "--with-fbdoc=" out "/share/doc/"
> +                              ,name "-" ,version)
> +               (string-append "--with-fbconf=" out "/lib/firebird")
> +               (string-append "--with-fbintl=" out "/lib/firebird/intl")
> +               (string-append "--with-fbmisc=" out "/lib/firebird/misc")
> +               (string-append "--with-fbmsg=" out "/lib/firebird")
> +               (string-append "--with-fbplugins=" out "/lib/firebird/plugins")
> +               (string-append "--with-fbudf=" out "/lib/firebird/UDF")
> +               "--with-fbglock=/run/firebird"
> +               "--with-fblog=/var/log/firebird"
> +               "--with-fbhelp=/var/lib/firebird/system"
> +               "--with-fbsecure-db=/var/lib/firebird/secure"
> +               "--without-fbsample"
> +               "--without-fbsample-db"
> +               "--with-system-editline"))
> +       #:make-flags
> +       (list (string-append "CC=" ,(cc-for-target))
> +             ;; The plugins/ can't find libfbclient otherwise.
> +             (string-append "LDFLAGS=-Wl,-rpath="
> +                            (assoc-ref %outputs "out") "/lib"))
> +       #:tests? #f                      ; no test suite
> +       #:modules ((guix build gnu-build-system)
> +                  (guix build utils)
> +                  (srfi srfi-26))
> +       #:phases
> +       (modify-phases %standard-phases
> +         (add-after 'unpack 'use-system-boost
> +           (lambda _
> +             (substitute* "src/include/firebird/Message.h"
> +               (("\"\\./impl/boost/preprocessor/seq/for_each_i\\.hpp\"")
> +                "<boost/preprocessor/seq/for_each_i.hpp>")
> +               (("FB_BOOST_") "BOOST_"))
> +             #t))
> +         (add-after 'unpack 'patch-installation
> +           (lambda _
> +             (substitute*
> +                 "builds/install/arch-specific/linux/makeInstallImage.sh.in"
> +               (("/bin/sh") (which "bash"))
> +               ;; Remove shell script helpers from $PATH.
> +               (("(addLibs|cp) .*\\.sh .*@FB_SBINDIR@") ":")
> +               ;; Put files where Guix users expect them.
> +               (("(License\\.txt.*)@FB_CONFDIR" match)
> +                (string-append match "@FB_DOCDIR@"))
> +               (("@FB_CONFDIR@(.*License\\.txt.*)" match)
> +                (string-append "@FB_DOCDIR@" match))
> +               (("(cp .*/doc/.*)@FB_CONFDIR@(.*)" _ head tail)
> +                (string-append head "@FB_DOCDIR@" tail "\n")))
> +             (substitute*
> +                 (list "builds/install/posix-common/changeServerMode.sh.in"
> +                       "builds/install/posix-common/install.sh.in")
> +               ;; Skip phases that (could) cause problems in Guix.
> +               (("check(InstallUser|IfServerRunning|Libraries)|addFirebirdUser")
> +                ":")
> +               ;; Skip phases that are merely pointless on Guix.
> +               (("buildUninstallFile|installInitdScript|startFirebird") ":")
> +               ;; Omit randomly generated password with bonus timestamp.
> +               (("setDBAPassword") ":"))
> +
> +             ;; These files are not relevant on Guix nor missed by install.sh.
> +             (for-each delete-file-recursively
> +                       (find-files "doc" "README\\.(NT|Win)"))
> +             #t))
> +         (add-after 'configure 'delete-init-scripts
> +           (lambda _
> +             (delete-file-recursively "gen/install/misc")
> +             #t))
> +         (add-before 'build 'set-build-environment-variables
> +           (lambda _
> +             ;; ‘isql’ needs to run & find libfbclient.so during the build.
> +             ;; This doubles as a rudimentary test in lieu of a test suite.
> +             (setenv "LD_LIBRARY_PATH"
> +                     (string-append (assoc-ref %build-inputs "icu4c") "/lib"))
> +             #t))
> +         (add-after 'install 'remove-examples
> +           (lambda* (#:key outputs #:allow-other-keys)
> +             (let ((out (assoc-ref outputs "out")))
> +               (for-each delete-file-recursively
> +                         (find-files out "example"))
> +               #t)))
> +         (add-after 'install 'remove-debug-symbols
> +           (lambda* (#:key outputs #:allow-other-keys)
> +             (let ((out (assoc-ref outputs "out")))
> +               (for-each delete-file-recursively
> +                         (find-files out "^\\.debug$"))
> +               ;; The ordering of lines in this file is not deterministic.
> +               (delete-file
> +                (string-append out "/lib/firebird/misc/manifest_debug.txt"))
> +               #t))))))
> +    (inputs
> +     `(("boost" ,boost)
> +       ("editline" ,editline)
> +       ("icu4c" ,icu4c-67)
> +       ("libtommath" ,libtommath)
> +       ("ncurses" ,ncurses)
> +       ("zlib" ,zlib)))
> +    (home-page "https://www.firebirdsql.org")
> +    (synopsis "Relational database with many ANSI SQL standard features")
> +    (description
> +     "Firebird is an SQL @acronym{RDBMS, relational database management system}
> +with rich support for ANSI SQL (e.g., @code{INSERT...RETURNING}), PSQL stored
> +procedures, cursors, and triggers, @acronym{UDFs, user-defined functions}, and
> +more.  Transactions provide full ACID-compliant referential integrity.

I'm all for listing features in descriptions, but I generally remove
"and more" in favour of something like "... rich suppport for ANSI SQL
including PSQL stored procedures, cursors and triggers". The "and more"
just sounds to promotional. Anyway, the description as is is also fine.

> +The database requires very little manual maintenance once set up, making it
> +ideal for small business or embedded use.
> +
> +When installed as a traditional local or remote (network) database server,
> +Firebird can grow to terabyte scale with proper tuning---although PostgreSQL
> +may be a better choice for such very large environments.
> +
> +Firebird can also be embedded into stand-alone applications that don't want or
> +need a full client & server.  Used in this manner, it offers richer SQL support
> +than SQLite as well as the option to seamlessly migrate to a client/server
> +database later.")
> +    (properties
> +     `((lint-hidden-cve . ("CVE-2017-6369"))))
> +    (license
> +     ;; See doc/license/README.license.usage.txt for rationale & details.
> +     (list license:bsd-3                ; src/common/sha2/
> +           license:bsd-4                ; src/common/enc.cpp
> +           license:gpl2+                ; builds/posix/make.defaults
> +           (license:non-copyleft "file:///builds/install/misc/IPLicense.txt"
> +                                 "InterBase Public License v1.0")
> +           (license:non-copyleft "file:///builds/install/misc/IDPLicense.txt"
> +                                 "Initial Developer's Public License v1.0")
> +           license:lgpl2.1           ; exception for OSI-compatible licences
> +           license:mpl1.1            ; examples/interfaces/0{6,8}*.cpp
> +           license:public-domain)))) ; including files without explicit licence
> +
>  (define-public leveldb
>    (package
>      (name "leveldb")

All looks good to me :)