Subject: [PATCH] gnu: mariadb: Split into out, lib and dev.
From: Julien Lepiller <[email-masked]>
To: [email-masked]
Date: Fri, 30 Aug 2019 23:12:39 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

Hi guix!

This patch splits mariadb into three parts: out (150 MB), lib (38 MB)
and dev (5 MB). This means that dependents now have a lighter closure.

For instance, python-mysqlclient lost its references to gcc, perl,
jemalloc and one zlib reference. It went from 537.2 MiB to only 230.4
MiB. qtbase went from ~1.3 GB to ~1.0 GB.

I've rebuilt most of these direct dependents without issues, so I don't
expect any issue with this patch. However, since qtbase is in the
dependency graph, there are ~500 packages that need to be rebuilt, so
this patch qualifies for staging.
From 6e8caab7729e3e0fc207d7f713237895e855a638 Mon Sep 17 00:00:00 2001
From: Julien Lepiller <[email-masked]>
Date: Fri, 30 Aug 2019 22:52:06 +0200
Subject: [PATCH] gnu: mariadb: Split into out, lib and dev.

* gnu/packages/databases.scm (mariadb): Split into out, lib and dev.
(perl-dbd-mysql, python-mysqlclient): Adjust dependencies.
* gnu/packages/bioinformatics.scm (kentutils): Adjust dependencies.
* gnu/packages/cran.scm (r-rmysql): Adjust dependencies.
* gnu/packages/emacs-xyz.scm (emacs-emacsql): Adjust dependencies.
* gnu/packages/kodi.scm (kodi): Adjust dependencies.
* gnu/packages/qt.scm (qt, qtbase): Adjust dependencies.
* gnu/packages/ruby.scm (ruby-mysql2): Adjust dependencies.
---
 gnu/packages/bioinformatics.scm |  3 +-
 gnu/packages/cran.scm           |  3 +-
 gnu/packages/databases.scm      | 57 ++++++++++++++++++++++++---------
 gnu/packages/emacs-xyz.scm      |  3 +-
 gnu/packages/kodi.scm           |  3 +-
 gnu/packages/qt.scm             |  6 ++--
 gnu/packages/ruby.scm           |  3 +-
 7 files changed, 55 insertions(+), 23 deletions(-)

diff --git a/gnu/packages/bioinformatics.scm b/gnu/packages/bioinformatics.scm
index 62f368c139..e8859eb144 100644
--- a/gnu/packages/bioinformatics.scm
+++ b/gnu/packages/bioinformatics.scm
@@ -11269,7 +11269,8 @@ models.  TADbit is complemented by TADkit for visualizing 3D models.")
        ("tcsh" ,tcsh)
        ("perl" ,perl)
        ("libpng" ,libpng)
-       ("mariadb" ,mariadb)
+       ("mariadb" ,mariadb "lib")
+       ("mariadb-dev" ,mariadb "dev")
        ("openssl" ,openssl)))
     (home-page "http://genome.cse.ucsc.edu/index.html")
     (synopsis "Assorted bioinformatics utilities")
diff --git a/gnu/packages/cran.scm b/gnu/packages/cran.scm
index 458b141f91..b4c7d4dc56 100644
--- a/gnu/packages/cran.scm
+++ b/gnu/packages/cran.scm
@@ -2601,7 +2601,8 @@ dimensioned arrays.")
     (properties `((upstream-name . "RMySQL")))
     (build-system r-build-system)
     (inputs
-     `(("mariadb" ,mariadb)
+     `(("mariadb" ,mariadb "lib")
+       ("mariadb-dev" ,mariadb "dev")
        ("zlib" ,zlib)))
     (propagated-inputs
      `(("r-dbi" ,r-dbi)))
diff --git a/gnu/packages/databases.scm b/gnu/packages/databases.scm
index 066bcb6962..697df81966 100644
--- a/gnu/packages/databases.scm
+++ b/gnu/packages/databases.scm
@@ -642,9 +642,11 @@ Language.")
                                     (find-files "pcre") (find-files "zlib")))
                   #t))))
     (build-system cmake-build-system)
+    (outputs '("out" "lib" "dev"))
     (arguments
      `(#:configure-flags
-       '("-DBUILD_CONFIG=mysql_release"
+       (list
+         "-DBUILD_CONFIG=mysql_release"
          ;; Linking with libarchive fails, like this:
 
          ;; ld: /gnu/store/...-libarchive-3.2.2/lib/libarchive.a(archive_entry.o):
@@ -668,15 +670,26 @@ Language.")
          "-DDEFAULT_COLLATION=utf8_general_ci"
          "-DMYSQL_DATADIR=/var/lib/mysql"
          "-DMYSQL_UNIX_ADDR=/run/mysqld/mysqld.sock"
-         "-DINSTALL_INFODIR=share/mysql/docs"
-         "-DINSTALL_MANDIR=share/man"
+         (string-append "-DCMAKE_INSTALL_PREFIX=" (assoc-ref %outputs "lib"))
+         (string-append "-DCMAKE_INSTALL_RPATH=" (assoc-ref %outputs "lib")
+                        "/lib")
+         (string-append "-DINSTALL_INFODIR=" (assoc-ref %outputs "out")
+                        "/share/mysql/docs")
+         (string-append "-DINSTALL_MANDIR=" (assoc-ref %outputs "out")
+                        "/share/man")
+         (string-append "-DINSTALL_SCRIPTDIR=" (assoc-ref %outputs "out") "/bin")
+         (string-append "-DINSTALL_BINDIR=" (assoc-ref %outputs "out") "/bin")
+         "-DCMAKE_INSTALL_LIBDIR=lib"
          "-DINSTALL_PLUGINDIR=lib/mysql/plugin"
-         "-DINSTALL_SCRIPTDIR=bin"
-         "-DINSTALL_INCLUDEDIR=include/mysql"
-         "-DINSTALL_DOCREADMEDIR=share/mysql/docs"
-         "-DINSTALL_SUPPORTFILESDIR=share/mysql/support-files"
+         (string-append "-DINSTALL_INCLUDEDIR=" (assoc-ref %outputs "dev")
+                        "/include/mysql")
+         (string-append "-DINSTALL_DOCREADMEDIR=" (assoc-ref %outputs "out")
+                        "/share/mysql/docs")
+         (string-append "-DINSTALL_DOCDIR=" (assoc-ref %outputs "out")
+                        "/share/mysql/docs")
+         (string-append "-DINSTALL_SUPPORTFILESDIR=" (assoc-ref %outputs "out")
+                        "/share/mysql/support-files")
          "-DINSTALL_MYSQLSHAREDIR=share/mysql"
-         "-DINSTALL_DOCDIR=share/mysql/docs"
          "-DINSTALL_SHAREDIR=share")
        #:phases
        (modify-phases %standard-phases
@@ -759,19 +772,29 @@ Language.")
           'install 'post-install
           (lambda* (#:key outputs #:allow-other-keys)
             (let* ((out     (assoc-ref outputs "out"))
-                   (test    (assoc-ref outputs "test")))
+                   (dev     (assoc-ref outputs "dev"))
+                   (lib     (assoc-ref outputs "lib")))
               (substitute* (string-append out "/bin/mysql_install_db")
                 (("basedir=\"\"")
                  (string-append "basedir=\"" out "\"")))
               ;; Remove unneeded files for testing.
-              (with-directory-excursion out
+              (with-directory-excursion lib
                 (for-each delete-file-recursively
-                          '("data" "mysql-test" "sql-bench"
-                            "share/man/man1/mysql-test-run.pl.1"))
-                ;; Delete huge and unnecessary executables.
-                (for-each delete-file (find-files "bin" "(test|embedded)"))
+                          '("data" "mysql-test" "sql-bench"))
                 ;; And static libraries.
                 (for-each delete-file (find-files "lib" "\\.a$")))
+              (with-directory-excursion out
+                (delete-file "share/man/man1/mysql-test-run.pl.1")
+                ;; Delete huge and unnecessary executables.
+                (for-each delete-file (find-files "bin" "(test|embedded)")))
+              (mkdir-p (string-append dev "/share"))
+              (mkdir-p (string-append dev "/bin"))
+              (rename-file (string-append lib "/bin/mysqld")
+                           (string-append out "/bin/mysqld"))
+              (rename-file (string-append lib "/share/pkgconfig")
+                           (string-append dev "/share/pkgconfig"))
+              (rename-file (string-append out "/bin/mysql_config")
+                           (string-append dev "/bin/mysql_config"))
               #t))))))
     (native-inputs
      `(("bison" ,bison)
@@ -1535,7 +1558,8 @@ columns, primary keys, unique constraints and relationships.")
        #:tests? #f))
     (propagated-inputs
      `(("perl-dbi" ,perl-dbi)
-       ("mysql" ,mariadb)))
+       ("mysql" ,mariadb "lib")
+       ("mysql-dev" ,mariadb "dev")))
     (home-page "https://metacpan.org/release/DBD-mysql")
     (synopsis "DBI MySQL interface")
     (description "This package provides a MySQL driver for the Perl5
@@ -2653,7 +2677,8 @@ database).")
        ("mock" ,python-mock)
        ("py.test" ,python-pytest)))
     (inputs
-     `(("mysql" ,mariadb)
+     `(("mysql" ,mariadb "lib")
+       ("mysql-dev" ,mariadb "dev")
        ("libz" ,zlib)
        ("openssl" ,openssl)))
     (home-page "https://github.com/PyMySQL/mysqlclient-python")
diff --git a/gnu/packages/emacs-xyz.scm b/gnu/packages/emacs-xyz.scm
index 9e94d3fc8e..2ef85c5cfe 100644
--- a/gnu/packages/emacs-xyz.scm
+++ b/gnu/packages/emacs-xyz.scm
@@ -10787,7 +10787,8 @@ object has been freed.")
              #t)))))
     (inputs
      `(("emacs-minimal" ,emacs-minimal)
-       ("mariadb" ,mariadb)
+       ("mariadb" ,mariadb "lib")
+       ("mariadb-dev" ,mariadb "dev")
        ("postgresql" ,postgresql)))
     (propagated-inputs
      `(("emacs-finalize" ,emacs-finalize)
diff --git a/gnu/packages/kodi.scm b/gnu/packages/kodi.scm
index a9b5b85a47..fbb153b1f2 100644
--- a/gnu/packages/kodi.scm
+++ b/gnu/packages/kodi.scm
@@ -436,7 +436,8 @@ alternatives. In compilers, this can reduce the cascade of secondary errors.")
        ("libxrender" ,libxrender)
        ("libxslt" ,libxslt)
        ("lzo" ,lzo)
-       ("mariadb" ,mariadb)
+       ("mariadb" ,mariadb "lib")
+       ("mariadb-dev" ,mariadb "dev")
        ("openssl" ,openssl)
        ("pcre" ,pcre)
        ("pulseaudio" ,pulseaudio)
diff --git a/gnu/packages/qt.scm b/gnu/packages/qt.scm
index 52eb46cce0..957cbd151b 100644
--- a/gnu/packages/qt.scm
+++ b/gnu/packages/qt.scm
@@ -218,7 +218,8 @@ system, and the core design of Django is reused in Grantlee.")
        ("libxslt" ,libxslt)
        ("libxtst" ,libxtst)
        ("mtdev" ,mtdev)
-       ("mariadb" ,mariadb)
+       ("mariadb" ,mariadb "lib")
+       ("mariadb-dev" ,mariadb "dev")
        ("nss" ,nss)
        ("openssl" ,openssl)
        ("postgresql" ,postgresql)
@@ -569,7 +570,8 @@ system, and the core design of Django is reused in Grantlee.")
        ("libxslt" ,libxslt)
        ("libxtst" ,libxtst)
        ("mtdev" ,mtdev)
-       ("mariadb" ,mariadb)
+       ("mariadb" ,mariadb "lib")
+       ("mariadb-dev" ,mariadb "dev")
        ("nss" ,nss)
        ("openssl" ,openssl)
        ("pcre2" ,pcre2)
diff --git a/gnu/packages/ruby.scm b/gnu/packages/ruby.scm
index ef9792bc0f..132f254a36 100644
--- a/gnu/packages/ruby.scm
+++ b/gnu/packages/ruby.scm
@@ -2615,7 +2615,8 @@ specs for Ruby implementations in ruby/spec.")
                (invoke "rspec"))
              #t)))))
     (inputs
-     `(("mariadb" ,mariadb)
+     `(("mariadb" ,mariadb "lib")
+       ("mariadb-dev" ,mariadb "dev")
        ("zlib" ,zlib)))
     (native-inputs
      `(("ruby-rspec" ,ruby-rspec)
-- 
2.22.0