[package] add mysql-server (#7384)
authorFlorian Fainelli <florian@openwrt.org>
Sat, 4 Sep 2010 18:04:02 +0000 (18:04 +0000)
committerFlorian Fainelli <florian@openwrt.org>
Sat, 4 Sep 2010 18:04:02 +0000 (18:04 +0000)
This is a patch to build the mysql server. So far I only have the
kirkwood target to test on, but it works great on that.

There seems to be some contention on whether Openwrt should have a
mysql-server package, but I don't see why it shouldn't at least have
the option. A full LAMP stack is now a reality.

Closes out https://dev.openwrt.org/ticket/7384

Again, I'm still pretty new to this, so any constructive criticism
would be appreciated.

Sorry for the attachment, but I wanted to make sure the whitespace and
lines got preserved.

Signed-off-by: Kyle Anderson <kyle@xkyle.com>
SVN-Revision: 22911

libs/mysql/Makefile
libs/mysql/conf/my.cnf [new file with mode: 0644]
libs/mysql/files/mysqld.init [new file with mode: 0644]
libs/mysql/patches/501-disable-pthread-and-tests.patch [new file with mode: 0644]

index 288b9988ed6ed439db45814a300c72cf0e2f88f9..28ca8077343b08645ed9d01d40658a4c4c3a13dd 100644 (file)
@@ -32,6 +32,19 @@ define Package/libmysqlclient/Default
   URL:=http://dev.mysql.com/
 endef
 
+define Package/mysql-server/Default
+  SECTION:=utils
+  CATEGORY:=Utilities
+  DEPENDS:=+zlib +libmysqlclient +uclibcxx
+  TITLE:=MySQL Server
+  URL:=http://dev.mysql.com/
+  SUBMENU:=database
+endef
+
+define Package/mysql-server
+  $(call Package/mysql-server/Default)
+endef
+
 define Package/libmysqlclient
   $(call Package/libmysqlclient/Default)
 endef
@@ -41,6 +54,14 @@ define Package/libmysqlclient_r
   TITLE += threadsafe
 endef
 
+CONFIGURE_VARS += \
+        CXXFLAGS="$$$$CXXFLAGS -fno-builtin -fno-rtti -nostdinc++"  \
+        CPPFLAGS="$$$$CPPFLAGS -I$(STAGING_DIR)/usr/include/uClibc++" \
+        LDFLAGS="$$$$LDFLAGS" \
+        LIBS="-nodefaultlibs -luClibc++ -lm $(LIBGCC_S)" \
+        CLIENTCLIBS="-nodefaultlibs -luClibc++ -lm $(LIBGCC_S)" \
+
+
 define Build/Configure
        (cd $(PKG_BUILD_DIR); touch \
                configure.in \
@@ -49,26 +70,31 @@ define Build/Configure
                config.h.in \
                configure \
        );
+
        $(call Build/Configure/Default, \
                --enable-shared \
                --enable-static \
                --enable-thread-safe-client \
                --disable-assembler \
                --with-pthread \
+               --with-server \
+               --without-mysqlmanager \
                --without-raid \
+               --with-mysqld-user=root \
                --with-unix-socket-path=/tmp \
                --without-libwrap \
                --without-pstack \
                --with-low-memory \
-               --without-server \
                --without-embedded-server \
                --without-query-cache \
                --without-mysqlfs \
                --without-vio \
                --without-openssl \
                --without-docs \
+               --without-man \
                --without-bench \
                --without-readline \
+               --without-debug \
                --with-named-thread-libs=-lpthread \
                , \
                mysql_cv_compress=yes \
@@ -102,8 +128,12 @@ define Build/Compile
                DESTDIR="$(PKG_INSTALL_DIR)" \
                bin_SCRIPTS="mysql_config" \
                install
+       $(MAKE) -C "$(PKG_BUILD_DIR)" \
+               DESTDIR="$(PKG_INSTALL_DIR)" \
+               install
 endef
 
+
 define Build/InstallDev
        $(INSTALL_DIR) $(2)/bin $(1)/usr/bin $(1)/usr/include $(1)/usr/lib
        $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/mysql_config $(1)/usr/bin/
@@ -124,5 +154,25 @@ define Package/libmysqlclient_r/install
        $(CP) $(PKG_INSTALL_DIR)/usr/lib/mysql/libmysqlclient_r.so.* $(1)/usr/lib/
 endef
 
+define Package/mysql-server/install
+       $(INSTALL_DIR) $(1)/usr/bin
+       $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/mysql $(1)/usr/bin/
+       $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/mysqld $(1)/usr/bin/
+       $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/myisamchk $(1)/usr/bin/
+       $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/mysqladmin $(1)/usr/bin/
+       $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/mysqldump $(1)/usr/bin/
+       $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/mysql_install_db $(1)/usr/bin/
+       $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/mysql_create_system_tables $(1)/usr/bin/
+       $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/my_print_defaults $(1)/usr/bin/
+       $(INSTALL_DIR) $(1)/etc/init.d/
+       $(INSTALL_BIN) files/mysqld.init $(1)/etc/init.d/mysqld
+       $(INSTALL_CONF) conf/my.cnf $(1)/etc/
+       $(INSTALL_DIR) $(1)/usr/share/mysql
+       $(INSTALL_DIR) $(1)/usr/share/mysql/english
+       $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/share/mysql/english/errmsg.sys $(1)/usr/share/mysql/english
+       $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/share/mysql/fill_help_tables.sql $(1)/usr/share/mysql/
+endef
+
+$(eval $(call BuildPackage,mysql-server))
 $(eval $(call BuildPackage,libmysqlclient))
 $(eval $(call BuildPackage,libmysqlclient_r))
diff --git a/libs/mysql/conf/my.cnf b/libs/mysql/conf/my.cnf
new file mode 100644 (file)
index 0000000..ec2ade2
--- /dev/null
@@ -0,0 +1,54 @@
+[client]
+port           = 3306
+socket         = /var/run/mysqld.sock
+
+[mysqld]
+user           = root
+socket         = /var/run/mysqld.sock
+port           = 3306
+basedir                = /usr
+
+############ Don't put this on the NAND #############
+# Figure out where you are going to put the databases
+# And run mysql_install_db --force
+datadir                = /mnt/data/mysql/
+
+######### This should also not go on the NAND #######
+tmpdir         = /mnt/data/tmp/
+
+skip-external-locking
+
+bind-address           = 127.0.0.1
+
+# Fine Tuning
+key_buffer             = 16M
+max_allowed_packet     = 16M
+thread_stack           = 192K
+thread_cache_size       = 8
+
+# Here you can see queries with especially long duration
+#log_slow_queries      = /var/log/mysql/mysql-slow.log
+#long_query_time = 2
+#log-queries-not-using-indexes
+
+# The following can be used as easy to replay backup logs or for replication.
+#server-id             = 1
+#log_bin                       = /var/log/mysql/mysql-bin.log
+#expire_logs_days      = 10
+#max_binlog_size         = 100M
+#binlog_do_db          = include_database_name
+#binlog_ignore_db      = include_database_name
+
+
+[mysqldump]
+quick
+quote-names
+max_allowed_packet     = 16M
+
+[mysql]
+#no-auto-rehash        # faster start of mysql but no tab completition
+
+[isamchk]
+key_buffer             = 16M
+
+
diff --git a/libs/mysql/files/mysqld.init b/libs/mysql/files/mysqld.init
new file mode 100644 (file)
index 0000000..d3edd15
--- /dev/null
@@ -0,0 +1,33 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2010 OpenWrt.org
+START=95
+STOP=10
+
+
+PID=/var/run/mysqld.pid
+CMD=/usr/bin/mysqld
+
+start() {
+    DATADIR=`grep datadir /etc/my.cnf | cut -f 2 -d =`
+    if [ !  -d $DATADIR ]; then
+       echo "Error: datadir in /etc/my.cnf ($DATADIR) doesn't exist"
+       return 1
+    elif [ ! -f $DATADIR/mysql/tables_priv.MYD ]; then
+       echo "Error: I didn't detect a privileges table, you might need to run mysql_install_db --force to initialize the system tables"
+       return 1
+    else
+       start-stop-daemon -x $CMD -p $PID -b -m -S
+    fi
+}
+
+stop() {
+    echo -n "Stopping Mysqld..."
+    start-stop-daemon -x $CMD -p $PID -K
+    ret=$?
+    if [ -f "$PID" ]; then
+        rm "$PID"
+    fi
+    return ${ret}
+}
+
+
diff --git a/libs/mysql/patches/501-disable-pthread-and-tests.patch b/libs/mysql/patches/501-disable-pthread-and-tests.patch
new file mode 100644 (file)
index 0000000..fa92c4a
--- /dev/null
@@ -0,0 +1,112 @@
+--- mysql.old/sql/Makefile.am  2005-12-21 12:39:32.000000000 -0700
++++ mysql.dev/sql/Makefile.am  2010-08-07 15:13:34.399776279 -0600
+@@ -148,8 +148,8 @@
+               @echo "If it fails, re-run configure with --with-low-memory"
+               $(CXXCOMPILE) $(LM_CFLAGS) -c $<
+-lex_hash.h:   gen_lex_hash$(EXEEXT)
+-              ./gen_lex_hash$(EXEEXT) > $@
++#lex_hash.h:  gen_lex_hash$(EXEEXT)
++#             ./gen_lex_hash$(EXEEXT) > $@
+ # For testing of udf_example.so;  Works on platforms with gcc
+ # (This is not part of our build process but only provided as an example)
+
+--- mysql.old/sql/Makefile.in  2005-12-21 12:41:41.000000000 -0700
++++ mysql.dev/sql/Makefile.in  2010-08-07 15:15:39.747273400 -0600
+@@ -1253,8 +1253,8 @@
+               @echo "If it fails, re-run configure with --with-low-memory"
+               $(CXXCOMPILE) $(LM_CFLAGS) -c $<
+-lex_hash.h:   gen_lex_hash$(EXEEXT)
+-              ./gen_lex_hash$(EXEEXT) > $@
++#lex_hash.h:  gen_lex_hash$(EXEEXT)
++#             ./gen_lex_hash$(EXEEXT) > $@
+ # For testing of udf_example.so;  Works on platforms with gcc
+ # (This is not part of our build process but only provided as an example)
+
+
+--- mysql.old/extra/Makefile.am        2005-12-21 12:39:55.000000000 -0700
++++ mysql.dev/extra/Makefile.am        2010-08-07 16:44:45.649771408 -0600
+@@ -29,14 +29,14 @@
+ DIST_SUBDIRS=           yassl
+ # This will build mysqld_error.h and sql_state.h
+-$(top_builddir)/include/mysqld_error.h: comp_err$(EXEEXT)
+-      $(top_builddir)/extra/comp_err$(EXEEXT) \
+-      --charset=$(top_srcdir)/sql/share/charsets \
+-      --out-dir=$(top_builddir)/sql/share/ \
+-      --header_file=$(top_builddir)/include/mysqld_error.h \
+-      --name_file=$(top_builddir)/include/mysqld_ername.h \
+-      --state_file=$(top_builddir)/include/sql_state.h \
+-      --in_file=$(top_srcdir)/sql/share/errmsg.txt
++#$(top_builddir)/include/mysqld_error.h: comp_err$(EXEEXT)
++#     $(top_builddir)/extra/comp_err$(EXEEXT) \
++#     --charset=$(top_srcdir)/sql/share/charsets \
++#     --out-dir=$(top_builddir)/sql/share/ \
++#     --header_file=$(top_builddir)/include/mysqld_error.h \
++#     --name_file=$(top_builddir)/include/mysqld_ername.h \
++#     --state_file=$(top_builddir)/include/sql_state.h \
++#     --in_file=$(top_srcdir)/sql/share/errmsg.txt
+ $(top_builddir)/include/mysqld_ername.h: $(top_builddir)/include/mysqld_error.h
+ $(top_builddir)/include/sql_state.h: $(top_builddir)/include/mysqld_error.h
+--- mysql.old/extra/Makefile.in        2005-12-21 12:41:16.000000000 -0700
++++ mysql.dev/extra/Makefile.in        2010-08-07 16:44:29.537273634 -0600
+@@ -870,14 +870,14 @@
+ # This will build mysqld_error.h and sql_state.h
+-$(top_builddir)/include/mysqld_error.h: comp_err$(EXEEXT)
+-      $(top_builddir)/extra/comp_err$(EXEEXT) \
+-      --charset=$(top_srcdir)/sql/share/charsets \
+-      --out-dir=$(top_builddir)/sql/share/ \
+-      --header_file=$(top_builddir)/include/mysqld_error.h \
+-      --name_file=$(top_builddir)/include/mysqld_ername.h \
+-      --state_file=$(top_builddir)/include/sql_state.h \
+-      --in_file=$(top_srcdir)/sql/share/errmsg.txt
++#$(top_builddir)/include/mysqld_error.h: comp_err$(EXEEXT)
++#     $(top_builddir)/extra/comp_err$(EXEEXT) \
++#     --charset=$(top_srcdir)/sql/share/charsets \
++#     --out-dir=$(top_builddir)/sql/share/ \
++#     --header_file=$(top_builddir)/include/mysqld_error.h \
++#     --name_file=$(top_builddir)/include/mysqld_ername.h \
++#     --state_file=$(top_builddir)/include/sql_state.h \
++#     --in_file=$(top_srcdir)/sql/share/errmsg.txt
+ $(top_builddir)/include/mysqld_ername.h: $(top_builddir)/include/mysqld_error.h
+ $(top_builddir)/include/sql_state.h: $(top_builddir)/include/mysqld_error.h
+
+--- mysql.old/sql/Makefile.am  2010-08-07 16:53:38.047275454 -0600
++++ mysql.dev/sql/Makefile.am  2010-08-07 17:20:05.947271939 -0600
+@@ -40,7 +40,7 @@
+                       $(top_builddir)/strings/libmystrings.a @ZLIB_LIBS@ @NDB_SCI_LIBS@
+ mysqld_LDADD =                @MYSQLD_EXTRA_LDFLAGS@ \
+-                      @bdb_libs@ @innodb_libs@ @pstack_libs@ \
++                      @bdb_libs@ @innodb_libs@ \
+                         @innodb_system_libs@ \
+                       @ndbcluster_libs@ @ndbcluster_system_libs@ \
+                       $(LDADD)  $(CXXLDFLAGS) $(WRAPLIBS) @LIBDL@ \
+
+--- mysql.old/sql/Makefile.in  2010-08-07 16:53:38.047275454 -0600
++++ mysql.dev/sql/Makefile.in  2010-08-07 17:20:23.197362907 -0600
+@@ -483,8 +483,6 @@
+ openssl_libs = @openssl_libs@
+ prefix = @prefix@
+ program_transform_name = @program_transform_name@
+-pstack_dirs = @pstack_dirs@
+-pstack_libs = @pstack_libs@
+ readline_basedir = @readline_basedir@
+ readline_dir = @readline_dir@
+ readline_h_ln_cmd = @readline_h_ln_cmd@
+@@ -533,7 +531,7 @@
+                       $(top_builddir)/strings/libmystrings.a @ZLIB_LIBS@ @NDB_SCI_LIBS@
+ mysqld_LDADD = @MYSQLD_EXTRA_LDFLAGS@ \
+-                      @bdb_libs@ @innodb_libs@ @pstack_libs@ \
++                      @bdb_libs@ @innodb_libs@ \
+                         @innodb_system_libs@ \
+                       @ndbcluster_libs@ @ndbcluster_system_libs@ \
+                       $(LDADD)  $(CXXLDFLAGS) $(WRAPLIBS) @LIBDL@ \
+