ports/182547: [PATCH] databases/mariadb55-server: Respect hier(7) (also affects databases/mariadb55-client)
Michael Gmelin
freebsd at grem.de
Tue Oct 15 20:30:03 UTC 2013
The following reply was made to PR ports/182547; it has been noted by GNATS.
From: Michael Gmelin <freebsd at grem.de>
To: Miroslav Lachman <000.fbsd at quip.cz>
Cc: "bug-followup at FreeBSD.org" <bug-followup at FreeBSD.org>, Alexandr
Kovalenko <never at nevermind.kiev.ua>
Subject: Re: ports/182547: [PATCH] databases/mariadb55-server: Respect
hier(7) (also affects databases/mariadb55-client)
Date: Tue, 15 Oct 2013 22:20:56 +0200
--MP_/bOIrcDKmCGchhlbSQhwXR+G
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
On Sat, 12 Oct 2013 13:19:34 +0200
Miroslav Lachman <000.fbsd at quip.cz> wrote:
> Michael Gmelin wrote:
> >
> >
> >> On 11 Oct 2013, at 18:41, Miroslav Lachman<000.fbsd at quip.cz>
> >> wrote:
> >>
> >> Michael Gmelin wrote:
> >>>
> >>>
> >>>> On 11 Oct 2013, at 16:56, Miroslav Lachman<000.fbsd at quip.cz>
> >>>> wrote:
> >>>>
> >>>> Michael Gmelin wrote:
> >>>>> On Wed, 02 Oct 2013 21:55:29 +0200
> >>>>> Miroslav Lachman<000.fbsd at quip.cz> wrote:
> >>>>>>
> >>>>>> I will test your patch in a few days. I am too busy with my
> >>>>>> $WORK now.
> >>>>>>
> >>>>>> Miroslav Lachman
> >>>>>
> >>>>> Did you have a chance to test the patch yet?
> >>>>>
> >>>>> Michael
> >>>>
> >>>> I tried it right now, but I have a problem. mariadb55-server
> >>>> cannot be built on my test machine FreeBSD 9.2-RC4 amd64 GENERIC.
> >>>>
> >>>> I always get this error even with original (not patched) version:
> >>>>
> >>>> Creating bzip'd tar ball in
> >>>> '/usr/ports/databases/mariadb55-server/work/mariadb55-server-5.5.33a.tbz'
> >>>> tar: lib/mysql/plugin/auth_pam.so: Cannot stat: No such file or
> >>>> directory tar: Error exit delayed from previous errors.
> >>>> pkg_create: make_dist: tar command failed with code 256
> >>>>
> >>>> I'll investigate it later. I have mariadb55-server-5.5.33a built
> >>>> on 8.4 production server, so I don't know why it failed on
> >>>> 9.2-RC4.
> >>
> >> I am not able to find a proper fix of the problem with
> >> auth_pam.so, so I just delete it from pkg-plist. MariaDB works
> >> without it.
> >>
> >> Tests I did:
> >>
> >> 1) start MariaDB with /usr/local/etc/my.cnf
> >> works
> >> 2) start MariaDB with /etc/my.cnf
> >> failed to start [intended]
> >> 3) check my_print_defaults --help
> >> it still prints /etc/ and /etc/mysql/ as right locations for
> >> my.cnf [wrong]
> >>
> >> And I have a comment to (2). It prints the error message to a
> >> logfile, but user is not informed about any error with 'service'
> >> command. I think it should be printed to the users console.
> >>
> >> I did:
> >>
> >> root at sm-reserve ~/# service mysql-server onestart
> >> Starting mysql.
> >>
> >> As you can see, 'service' command said "Starting mysql." and no
> >> error was shown, which is really bad. I thought it started
> >> with /etc/my.cnf and later found in a logfile, that MariaDB start
> >> failed:
> >>
> >> root at sm-reserve ~/# tail -f /var/db/mysql/sm-reserve.codelab.cz.err
> >>
> >> 131011 18:18:23 mysqld_safe Starting mysqld daemon with databases
> >> from /var/db/mysql error: Config file /etc/my.cnf in invalid
> >> location, please move to or merge with /usr/local/etc/my.cnf Fatal
> >> error in defaults handling. Program aborted 131011 18:18:23
> >> mysqld_safe mysqld from pid
> >> file /var/db/mysql/sm-reserve.codelab.cz.pid ended
> >>
> >> Maybe it is not related to your patch but why 'service' (rc script
> >> mysql-server) is silent in the case of a failed start?
> >>
> >> Miroslav Lachman
> >
> > Afaik service mysql always has been silent about errors (eg innodb
> > log file sizes don't match etc) due to the way the daemon is
> > started, this should be the same with mysql55. I remember missing a
> > warning about innodb not working many years ago since it was buried
> > in MySQL error log
> >
> > So improving this - also for the MySQL port - would be great, but
> > might be outside of the scope of this PR.
>
> So how about this patch to rc.d/mysql-server:
>
> --- /usr/local/etc/rc.d/mysql-server.orig 2013-10-11
> 18:09:34.000000000 +0200
> +++ /usr/local/etc/rc.d/mysql-server 2013-10-12 13:12:59.000000000
> +0200 @@ -52,6 +52,11 @@
>
> mysql_prestart()
> {
> + if [ -f "/etc/my.cnf" -o -f "/etc/mysql/my.cnf" ]; then
> + echo "Please move existing my.cnf file from /etc
> to /usr/local/etc"
> + return 1
> + fi
> +
>
> And are you able to fix my_print_defaults --help to not print /etc/
> and /etc/mysql/ as default options directories?
>
> Miroslav
Hi,
Please find attached a patch that fixes my_print_defaults as well as
incorporates a modified version of what you suggested for
rc.d/mysql-server.
The patch is against the latest SVN version and incorporates
the fix Alexandr's posted about an hour ago
as PR 183001: http://www.freebsd.org/cgi/query-pr.cgi?pr=183001
Cheers,
Michael
--
Michael Gmelin
--MP_/bOIrcDKmCGchhlbSQhwXR+G
Content-Type: text/x-patch
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename=mariadb55-mycnf-20131015.patch
diff -ruN databases.orig/mariadb55-client/Makefile databases/mariadb55-client/Makefile
--- databases.orig/mariadb55-client/Makefile 2013-10-15 21:41:31.980319265 +0200
+++ databases/mariadb55-client/Makefile 2013-10-15 21:48:25.970349842 +0200
@@ -7,7 +7,7 @@
MASTERDIR= ${.CURDIR}/../mariadb55-server
-PKGMESSAGE= mustnotexist
+FILESDIR= ${.CURDIR}/files
PATCHDIR= ${.CURDIR}/files
PLIST= ${.CURDIR}/pkg-plist
diff -ruN databases.orig/mariadb55-client/files/patch-mysys_default.c databases/mariadb55-client/files/patch-mysys_default.c
--- databases.orig/mariadb55-client/files/patch-mysys_default.c 2013-10-15 21:41:31.970323302 +0200
+++ databases/mariadb55-client/files/patch-mysys_default.c 2013-10-15 20:34:56.000000000 +0200
@@ -1,5 +1,5 @@
---- mysys/default.c.orig 2012-12-17 03:57:40.000000000 +0200
-+++ mysys/default.c 2012-12-17 04:00:28.000000000 +0200
+--- mysys/default.c.orig 2013-10-01 21:15:03.544135869 +0200
++++ mysys/default.c 2013-10-01 21:15:38.871375504 +0200
@@ -89,7 +89,7 @@
/* Which directories are searched for options (and in which order) */
@@ -18,11 +18,41 @@
/*
Ignore world-writable regular files.
This is mainly done to protect us to not read a file created by
-@@ -1229,6 +1229,7 @@
- #if defined(DEFAULT_SYSCONFDIR)
- if (DEFAULT_SYSCONFDIR[0])
- errors += add_directory(alloc, DEFAULT_SYSCONFDIR, dirs);
-+ errors += add_directory(alloc, DEFAULT_SYSCONFDIR "/mysql", dirs);
- #endif /* DEFAULT_SYSCONFDIR */
+@@ -803,6 +803,14 @@
+ if (!(fp= mysql_file_fopen(key_file_cnf, name, O_RDONLY, MYF(0))))
+ return 1; /* Ignore wrong files */
+
++ if (strstr(name, "/etc") == name)
++ {
++ fprintf(stderr,
++ "error: Config file %s in invalid location, please move to or merge with %%PREFIX%%%s\n",
++ name,name);
++ goto err;
++ }
++
+ while (mysql_file_fgets(buff, sizeof(buff) - 1, fp))
+ {
+ line++;
+@@ -1067,7 +1067,8 @@
+ if (name[0] == FN_HOMELIB) /* Add . to filenames in home */
+ *end++= '.';
+ strxmov(end, conf_file, *ext, " ", NullS);
+- fputs(name, stdout);
++ if (strstr(name, "/etc") != name)
++ fputs(name, stdout);
+ }
+ }
+ }
+@@ -1226,10 +1226,8 @@
+ errors += add_directory(alloc, "/etc/", dirs);
+ errors += add_directory(alloc, "/etc/mysql/", dirs);
+
+-#if defined(DEFAULT_SYSCONFDIR)
+- if (DEFAULT_SYSCONFDIR[0])
+- errors += add_directory(alloc, DEFAULT_SYSCONFDIR, dirs);
+-#endif /* DEFAULT_SYSCONFDIR */
++ errors += add_directory(alloc, "%%PREFIX%%/etc/", dirs);
++ errors += add_directory(alloc, "%%PREFIX%%/etc/mysql/", dirs);
#endif
+
diff -ruN databases.orig/mariadb55-client/files/patch-scripts_mysql_config.sh databases/mariadb55-client/files/patch-scripts_mysql_config.sh
--- databases.orig/mariadb55-client/files/patch-scripts_mysql_config.sh 1970-01-01 01:00:00.000000000 +0100
+++ databases/mariadb55-client/files/patch-scripts_mysql_config.sh 2013-10-15 21:59:57.920529823 +0200
@@ -0,0 +1,14 @@
+--- scripts/mysql_config.sh.orig 2013-09-20 01:34:23.000000000 +0300
++++ scripts/mysql_config.sh 2013-10-15 21:23:34.000000000 +0300
+@@ -108,8 +108,11 @@
+ # We intentionally add a space to the beginning and end of lib strings, simplifies replace later
+ libs=" $ldflags -L$pkglibdir -lmysqlclient @ZLIB_DEPS@ @NON_THREADED_LIBS@"
+ libs="$libs @openssl_libs@ @STATIC_NSS_FLAGS@ "
++libs="$libs -L%%LOCALBASE%%/lib "
+ libs_r=" $ldflags -L$pkglibdir -lmysqlclient_r @ZLIB_DEPS@ @CLIENT_LIBS@ @openssl_libs@ "
++libs_r="$libs_r -L%%LOCALBASE%%/lib "
+ embedded_libs=" $ldflags -L$pkglibdir -lmysqld @LIBDL@ @ZLIB_DEPS@ @LIBS@ @WRAPLIBS@ @openssl_libs@ "
++embedded_libs="$embedded_libs -L%%LOCALBASE%%/lib "
+
+ if [ -r "$pkglibdir/libmygcc.a" ]; then
+ # When linking against the static library with a different version of GCC
diff -ruN databases.orig/mariadb55-client/files/pkg-message.in databases/mariadb55-client/files/pkg-message.in
--- databases.orig/mariadb55-client/files/pkg-message.in 1970-01-01 01:00:00.000000000 +0100
+++ databases/mariadb55-client/files/pkg-message.in 2013-10-01 23:50:26.000000000 +0200
@@ -0,0 +1,7 @@
+************************************************************************
+
+MariaDB respects hier(7) and doesn't check /etc and /etc/mysql for
+my.cnf. Please move existing my.cnf files from those paths to
+%%PREFIX%%/etc and %%PREFIX%%/etc/mysql.
+
+************************************************************************
diff -ruN databases.orig/mariadb55-server/Makefile databases/mariadb55-server/Makefile
--- databases.orig/mariadb55-server/Makefile 2013-10-15 21:41:32.510255891 +0200
+++ databases/mariadb55-server/Makefile 2013-10-15 21:58:19.670709245 +0200
@@ -2,7 +2,7 @@
PORTNAME?= mariadb
PORTVERSION= 5.5.33a
-PORTREVISION?= 0
+PORTREVISION?= 1
CATEGORIES= databases ipv6
MASTER_SITES= http://ftp.osuosl.org/pub/mariadb/${PORTNAME}-${PORTVERSION}/kvm-tarbake-jaunty-x86/ \
http://mirrors.supportex.net/mariadb/${PORTNAME}-${PORTVERSION}/kvm-tarbake-jaunty-x86/ \
@@ -18,6 +18,9 @@
MAINTAINER= never at nevermind.kiev.ua
COMMENT?= Multithreaded SQL database (server)
+SUB_FILES= pkg-message
+PKGMESSAGE= ${WRKDIR}/pkg-message
+
SLAVEDIRS= databases/mariadb55-client
USES= cmake gmake
NO_OPTIONS_SORT=yes
@@ -133,6 +136,8 @@
post-patch:
@${REINPLACE_CMD} 's/*.1/${MAN1}/' ${WRKSRC}/man/CMakeLists.txt
+ @${REINPLACE_CMD} 's|%%PREFIX%%|${PREFIX}|g' ${WRKSRC}/mysys/default.c
+ @${REINPLACE_CMD} 's|%%LOCALBASE%%|${LOCALBASE}|g' ${WRKSRC}/scripts/mysql_config.sh
.include <bsd.port.pre.mk>
diff -ruN databases.orig/mariadb55-server/files/mysql-server.in databases/mariadb55-server/files/mysql-server.in
--- databases.orig/mariadb55-server/files/mysql-server.in 2013-10-15 21:41:32.500822849 +0200
+++ databases/mariadb55-server/files/mysql-server.in 2013-10-15 21:49:53.186289856 +0200
@@ -52,6 +52,13 @@
mysql_prestart()
{
+ local dir
+ for dir in /etc /etc/mysql; do
+ if [ -f "${dir}/my.cnf" ]; then
+ echo "Please move existing my.cnf file from ${dir} to %%PREFIX%%${dir}"
+ return 1
+ fi
+ done
if [ ! -d "${mysql_dbdir}/mysql/." ]; then
mysql_create_auth_tables || return 1
fi
diff -ruN databases.orig/mariadb55-server/files/patch-mysys_default.c databases/mariadb55-server/files/patch-mysys_default.c
--- databases.orig/mariadb55-server/files/patch-mysys_default.c 2013-10-15 21:41:32.510255891 +0200
+++ databases/mariadb55-server/files/patch-mysys_default.c 2013-10-15 20:26:48.000000000 +0200
@@ -1,6 +1,6 @@
---- mysys/default.c.orig 2010-11-02 23:01:13.000000000 +0100
-+++ mysys/default.c 2010-11-10 16:39:51.000000000 +0100
-@@ -70,7 +70,7 @@
+--- mysys/default.c.orig 2013-10-01 21:15:03.544135869 +0200
++++ mysys/default.c 2013-10-01 21:15:38.871375504 +0200
+@@ -89,7 +89,7 @@
/* Which directories are searched for options (and in which order) */
@@ -9,7 +9,7 @@
#define DEFAULT_DIRS_SIZE (MAX_DEFAULT_DIRS + 1) /* Terminate with NULL */
static const char **default_directories = NULL;
-@@ -711,7 +711,7 @@
+@@ -785,7 +785,7 @@
{
MY_STAT stat_info;
if (!my_stat(name,&stat_info,MYF(0)))
@@ -18,14 +18,41 @@
/*
Ignore world-writable regular files.
This is mainly done to protect us to not read a file created by
-@@ -1153,7 +1153,10 @@
+@@ -803,6 +803,14 @@
+ if (!(fp= mysql_file_fopen(key_file_cnf, name, O_RDONLY, MYF(0))))
+ return 1; /* Ignore wrong files */
- #if defined(DEFAULT_SYSCONFDIR)
- if (DEFAULT_SYSCONFDIR[0])
++ if (strstr(name, "/etc") == name)
+ {
- errors += add_directory(alloc, DEFAULT_SYSCONFDIR, dirs);
-+ errors += add_directory(alloc, DEFAULT_SYSCONFDIR "/mysql", dirs);
++ fprintf(stderr,
++ "error: Config file %s in invalid location, please move to or merge with %%PREFIX%%%s\n",
++ name,name);
++ goto err;
+ }
- #endif /* DEFAULT_SYSCONFDIR */
++
+ while (mysql_file_fgets(buff, sizeof(buff) - 1, fp))
+ {
+ line++;
+@@ -1067,7 +1067,8 @@
+ if (name[0] == FN_HOMELIB) /* Add . to filenames in home */
+ *end++= '.';
+ strxmov(end, conf_file, *ext, " ", NullS);
+- fputs(name, stdout);
++ if (strstr(name, "/etc") != name)
++ fputs(name, stdout);
+ }
+ }
+ }
+@@ -1226,10 +1226,8 @@
+ errors += add_directory(alloc, "/etc/", dirs);
+ errors += add_directory(alloc, "/etc/mysql/", dirs);
+
+-#if defined(DEFAULT_SYSCONFDIR)
+- if (DEFAULT_SYSCONFDIR[0])
+- errors += add_directory(alloc, DEFAULT_SYSCONFDIR, dirs);
+-#endif /* DEFAULT_SYSCONFDIR */
++ errors += add_directory(alloc, "%%PREFIX%%/etc/", dirs);
++ errors += add_directory(alloc, "%%PREFIX%%/etc/mysql/", dirs);
#endif
+
diff -ruN databases.orig/mariadb55-server/files/patch-scripts_mysql_config.sh databases/mariadb55-server/files/patch-scripts_mysql_config.sh
--- databases.orig/mariadb55-server/files/patch-scripts_mysql_config.sh 1970-01-01 01:00:00.000000000 +0100
+++ databases/mariadb55-server/files/patch-scripts_mysql_config.sh 2013-10-15 22:01:24.530302853 +0200
@@ -0,0 +1,14 @@
+--- scripts/mysql_config.sh.orig 2013-09-20 01:34:23.000000000 +0300
++++ scripts/mysql_config.sh 2013-10-15 21:23:34.000000000 +0300
+@@ -108,8 +108,11 @@
+ # We intentionally add a space to the beginning and end of lib strings, simplifies replace later
+ libs=" $ldflags -L$pkglibdir -lmysqlclient @ZLIB_DEPS@ @NON_THREADED_LIBS@"
+ libs="$libs @openssl_libs@ @STATIC_NSS_FLAGS@ "
++libs="$libs -L%%LOCALBASE%%/lib "
+ libs_r=" $ldflags -L$pkglibdir -lmysqlclient_r @ZLIB_DEPS@ @CLIENT_LIBS@ @openssl_libs@ "
++libs_r="$libs_r -L%%LOCALBASE%%/lib "
+ embedded_libs=" $ldflags -L$pkglibdir -lmysqld @LIBDL@ @ZLIB_DEPS@ @LIBS@ @WRAPLIBS@ @openssl_libs@ "
++embedded_libs="$embedded_libs -L%%LOCALBASE%%/lib "
+
+ if [ -r "$pkglibdir/libmygcc.a" ]; then
+ # When linking against the static library with a different version of GCC
diff -ruN databases.orig/mariadb55-server/files/pkg-message.in databases/mariadb55-server/files/pkg-message.in
--- databases.orig/mariadb55-server/files/pkg-message.in 1970-01-01 01:00:00.000000000 +0100
+++ databases/mariadb55-server/files/pkg-message.in 2013-10-01 23:50:41.000000000 +0200
@@ -0,0 +1,11 @@
+************************************************************************
+
+Remember to run mysql_upgrade (with the optional --datadir=<dbdir> flag)
+the first time you start the MySQL server after an upgrade from an
+earlier version.
+
+MariaDB respects hier(7) and doesn't check /etc and /etc/mysql for
+my.cnf. Please move existing my.cnf files from those paths to
+%%PREFIX%%/etc and %%PREFIX%%/etc/mysql.
+
+************************************************************************
diff -ruN databases.orig/mariadb55-server/pkg-message databases/mariadb55-server/pkg-message
--- databases.orig/mariadb55-server/pkg-message 2013-10-15 21:41:32.510255891 +0200
+++ databases/mariadb55-server/pkg-message 1970-01-01 01:00:00.000000000 +0100
@@ -1,7 +0,0 @@
-************************************************************************
-
-Remember to run mysql_upgrade (with the optional --datadir=<dbdir> flag)
-the first time you start the MySQL server after an upgrade from an
-earlier version.
-
-************************************************************************
--MP_/bOIrcDKmCGchhlbSQhwXR+G--
More information about the freebsd-ports-bugs
mailing list