Subject: [bug#50586] [PATCH v3] gnu: mysql: Add wrapper around mysql_config.

From: zimoun <[email-masked]>
Date: Tue, 21 Sep 2021 08:35:56 +0200

Fixes <https://bugs.gnu.org/23045>.

* gnu/packages/databases.scm (mysql): Add phase to wrap 'mysql_config'.
[inputs]: Add 'coreutils', 'gawk', 'procps' and 'sed'
---
 gnu/packages/databases.scm | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/gnu/packages/databases.scm b/gnu/packages/databases.scm
index c75e1421d5..58e3d7175b 100644
--- a/gnu/packages/databases.scm
+++ b/gnu/packages/databases.scm
@@ -53,6 +53,7 @@
 ;;; Copyright © 2021 Bonface Munyoki Kilyungi <[email-masked]>
 ;;; Copyright © 2021 Simon Streit <[email-masked]>
 ;;; Copyright © 2021 Alexandre Hannud Abdo <[email-masked]>
+;;; Copyright © 2021 Simon Tournier <[email-masked]>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -90,6 +91,7 @@
   #:use-module (gnu packages emacs)
   #:use-module (gnu packages flex)
   #:use-module (gnu packages freedesktop)
+  #:use-module (gnu packages gawk)
   #:use-module (gnu packages gcc)
   #:use-module (gnu packages gettext)
   #:use-module (gnu packages glib)
@@ -695,6 +697,29 @@ auto-completion and syntax highlighting.")
                        (for-each delete-file
                                  (find-files (string-append out "/bin")
                                              "_embedded$"))
+                       #t)))
+                  (add-after
+                   'install 'wrap-mysql_helpers
+                   (lambda* (#:key inputs outputs #:allow-other-keys)
+                     (let* ((out (assoc-ref outputs "out"))
+                            (bin (string-append out "/bin"))
+                            (awk (assoc-ref inputs "gawk"))
+                            (coreutils (assoc-ref inputs "coreutils"))
+                            (grep (assoc-ref inputs "grep"))
+                            (ps (assoc-ref inputs "procps"))
+                            (sed (assoc-ref inputs "sed")))
+                       (wrap-program (string-append bin "/mysql_config")
+                         `("PATH" ":" suffix
+                           (,(string-append awk "/bin")
+                            ,(string-append coreutils "/bin")
+                            ,(string-append sed "/bin"))))
+                       (wrap-program (string-append bin "/mysqld_safe")
+                         `("PATH" ":" suffix
+                           (,(string-append awk "/bin")
+                            ,(string-append coreutils "/bin")
+                            ,(string-append grep "/bin")
+                            ,(string-append ps "/bin")
+                            ,(string-append sed "/bin"))))
                        #t))))))
     (native-inputs
      `(("bison" ,bison)
@@ -702,11 +727,16 @@ auto-completion and syntax highlighting.")
        ("pkg-config" ,pkg-config)))
     (inputs
      `(("boost" ,boost-for-mysql)
+       ("coreutils" ,coreutils)         ;ls,cat required by mysql_config, mysqld_safe
+       ("gawk" ,gawk)                   ;required by mysql_config, mysqld_safe
+       ("grep" ,grep)                   ;required by mysqld_safe
        ("libaio" ,libaio)
        ("libtirpc" ,libtirpc)
        ("ncurses" ,ncurses)
        ("openssl" ,openssl)
+       ("procps" ,procps)               ;required by mysqld_safe
        ("rpcsvc-proto" ,rpcsvc-proto) ; rpcgen
+       ("sed" ,sed)                     ;required by mysql_config, mysqld_safe
        ("zlib" ,zlib)))
     (home-page "https://www.mysql.com/")
     (synopsis "Fast, easy to use, and popular database")
-- 
2.32.0