From: Christopher Baines <mail@cbaines.net>
To: 28399@debbugs.gnu.org
Subject: [bug#28399] [PATCH 1/2] services: mysql: Fix missing modules on activation.
Date: Sat, 9 Sep 2017 15:53:42 +0100 [thread overview]
Message-ID: <20170909145343.14851-1-mail@cbaines.net> (raw)
In-Reply-To: <20170909153905.087c013f@cbaines.net>
Some systems using the MySQL service would fail to boot, giving the error:
ERROR: no code for module (ice-9 popen)
* gnu/services/databases.scm (%mysql-activation): Wrap the gexp using
with-imported-modules, to ensure that the required modules are available.
---
gnu/services/databases.scm | 92 +++++++++++++++++++++++-----------------------
1 file changed, 47 insertions(+), 45 deletions(-)
diff --git a/gnu/services/databases.scm b/gnu/services/databases.scm
index de1f6b841..6b4e6e706 100644
--- a/gnu/services/databases.scm
+++ b/gnu/services/databases.scm
@@ -297,56 +297,58 @@ port=" (number->string port) "
"Return an activation gexp for the MySQL or MariaDB database server."
(let ((mysql (mysql-configuration-mysql config))
(my.cnf (mysql-configuration-file config)))
- #~(begin
- (use-modules (ice-9 popen)
- (guix build utils))
- (let* ((mysqld (string-append #$mysql "/bin/mysqld"))
- (user (getpwnam "mysql"))
- (uid (passwd:uid user))
- (gid (passwd:gid user))
- (datadir "/var/lib/mysql")
- (rundir "/run/mysqld"))
- (mkdir-p datadir)
- (chown datadir uid gid)
- (mkdir-p rundir)
- (chown rundir uid gid)
- ;; Initialize the database when it doesn't exist.
- (when (not (file-exists? (string-append datadir "/mysql")))
- (if (string-prefix? "mysql-" (strip-store-file-name #$mysql))
- ;; For MySQL.
- (system* mysqld
- (string-append "--defaults-file=" #$my.cnf)
- "--initialize"
- "--user=mysql")
- ;; For MariaDB.
- ;; XXX: The 'mysql_install_db' script doesn't work directly
- ;; due to missing 'mkdir' in PATH.
- (let ((p (open-pipe* OPEN_WRITE mysqld
- (string-append
- "--defaults-file=" #$my.cnf)
- "--bootstrap"
- "--user=mysql")))
- ;; Create the system database, as does by 'mysql_install_db'.
- (display "create database mysql;\n" p)
- (display "use mysql;\n" p)
- (for-each
- (lambda (sql)
- (call-with-input-file
- (string-append #$mysql "/share/mysql/" sql)
- (lambda (in) (dump-port in p))))
- '("mysql_system_tables.sql"
- "mysql_performance_tables.sql"
- "mysql_system_tables_data.sql"
- "fill_help_tables.sql"))
- ;; Remove the anonymous user and disable root access from
- ;; remote machines, as does by 'mysql_secure_installation'.
- (display "
+ (with-imported-modules '((ice-9 popen)
+ (guix build utils))
+ #~(begin
+ (use-modules (ice-9 popen)
+ (guix build utils))
+ (let* ((mysqld (string-append #$mysql "/bin/mysqld"))
+ (user (getpwnam "mysql"))
+ (uid (passwd:uid user))
+ (gid (passwd:gid user))
+ (datadir "/var/lib/mysql")
+ (rundir "/run/mysqld"))
+ (mkdir-p datadir)
+ (chown datadir uid gid)
+ (mkdir-p rundir)
+ (chown rundir uid gid)
+ ;; Initialize the database when it doesn't exist.
+ (when (not (file-exists? (string-append datadir "/mysql")))
+ (if (string-prefix? "mysql-" (strip-store-file-name #$mysql))
+ ;; For MySQL.
+ (system* mysqld
+ (string-append "--defaults-file=" #$my.cnf)
+ "--initialize"
+ "--user=mysql")
+ ;; For MariaDB.
+ ;; XXX: The 'mysql_install_db' script doesn't work directly
+ ;; due to missing 'mkdir' in PATH.
+ (let ((p (open-pipe* OPEN_WRITE mysqld
+ (string-append
+ "--defaults-file=" #$my.cnf)
+ "--bootstrap"
+ "--user=mysql")))
+ ;; Create the system database, as does by 'mysql_install_db'.
+ (display "create database mysql;\n" p)
+ (display "use mysql;\n" p)
+ (for-each
+ (lambda (sql)
+ (call-with-input-file
+ (string-append #$mysql "/share/mysql/" sql)
+ (lambda (in) (dump-port in p))))
+ '("mysql_system_tables.sql"
+ "mysql_performance_tables.sql"
+ "mysql_system_tables_data.sql"
+ "fill_help_tables.sql"))
+ ;; Remove the anonymous user and disable root access from
+ ;; remote machines, as does by 'mysql_secure_installation'.
+ (display "
DELETE FROM user WHERE User='';
DELETE FROM user WHERE User='root' AND
Host NOT IN ('localhost', '127.0.0.1', '::1');
FLUSH PRIVILEGES;
" p)
- (close-pipe p))))))))
+ (close-pipe p)))))))))
(define (mysql-shepherd-service config)
(list (shepherd-service
--
2.14.1
next prev parent reply other threads:[~2017-09-09 14:54 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-09 14:39 [bug#28399] [PATCH]: Fix mysql activation, and add a basic test Christopher Baines
2017-09-09 14:53 ` Christopher Baines [this message]
2017-09-09 14:53 ` [bug#28399] [PATCH 2/2] tests: databases: Add a simple test for MySQL Christopher Baines
2017-09-11 7:50 ` [bug#28399] [PATCH 1/2] services: mysql: Fix missing modules on activation Ludovic Courtès
2017-09-12 18:48 ` Christopher Baines
2017-09-15 22:02 ` Ludovic Courtès
2017-09-16 10:38 ` Christopher Baines
2017-09-20 9:21 ` Ludovic Courtès
2017-10-08 9:06 ` Christopher Baines
2017-10-08 15:26 ` Ludovic Courtès
2017-10-08 16:34 ` bug#28399: " Christopher Baines
2017-10-08 19:19 ` [bug#28399] " Ludovic Courtès
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170909145343.14851-1-mail@cbaines.net \
--to=mail@cbaines.net \
--cc=28399@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.