From 085ce152bac157835a98cffc19667b95e3630566 Mon Sep 17 00:00:00 2001
From: Jondy Zhao <jondy.zhao@gmail.com>
Date: Fri, 12 Jul 2013 14:38:28 +0800
Subject: [PATCH] mariadb, mysql, wordpress, apache-frontend support cygwin

---
 component/apache-php/buildout.cfg             |  17 ++-
 component/autoconf/buildout.cfg               |   6 +
 component/automake/buildout.cfg               |   5 +
 component/cclient/buildout.cfg                |  23 ++--
 component/freetype/buildout.cfg               |  12 ++
 component/libiconv/buildout.cfg               |   8 ++
 component/libjpeg/buildout.cfg                |  12 ++
 component/libpng/buildout.cfg                 |  12 ++
 component/libtool/buildout.cfg                |   8 ++
 component/mariadb/buildout.cfg                |  36 ++++--
 .../cygwin-mariadb-5.5.25-no-threadpool.patch | 109 ++++++++++++++++++
 component/perl/buildout.cfg                   |   5 +
 software/apache-frontend/software.cfg         |   4 +-
 software/mariadb/software.cfg                 |   4 +-
 software/mysql-5.1/software.cfg               |   2 +-
 stack/lamp/buildout.cfg                       |   7 +-
 16 files changed, 236 insertions(+), 34 deletions(-)
 create mode 100644 component/mariadb/cygwin-mariadb-5.5.25-no-threadpool.patch

diff --git a/component/apache-php/buildout.cfg b/component/apache-php/buildout.cfg
index 28adb19b5..e8baf1801 100644
--- a/component/apache-php/buildout.cfg
+++ b/component/apache-php/buildout.cfg
@@ -17,7 +17,6 @@ extends =
   ../pkgconfig/buildout.cfg
   ../zlib/buildout.cfg
 
-
 [apache-php]
 # Note: Shall react on each build of apache and reinstall itself
 recipe = slapos.recipe.cmmi
@@ -65,8 +64,6 @@ environment =
   TMPDIR=${buildout:parts-directory}/${:_buildout_section_name_}
   HOME=${apache:location}
 
-
-
 [apache-php-postgres]
 # Note: Shall react on each build of apache and reinstall itself
 recipe = slapos.recipe.cmmi
@@ -112,8 +109,6 @@ environment =
   TMPDIR=${buildout:parts-directory}/${:_buildout_section_name_}
   HOME=${apache:location}
 
-
-
 [libmcrypt]
 recipe = slapos.recipe.cmmi
 url = http://sourceforge.net/projects/mcrypt/files/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.bz2/download
@@ -123,3 +118,15 @@ md5sum = c4f491dd411a09e9de3b8702ea6f73eb
 recipe = slapos.recipe.cmmi
 url = http://downloads.sourceforge.net/project/phpxmlrpc/phpxmlrpc/2.2.2/xmlrpc-2.2.2.tar.gz
 md5sum = 59a644c636c6d98267d0c99b406ae9e8
+
+[apache-php:cygwin]
+url = ftp://sourceware.org/pub/cygwinports/release-2/php/php-5.4.16-2-src.tar.bz2
+md5sum = 53e1c17c929322433788cbcb7ced6c8e
+configure-command = cygport
+configure-options =
+  libevent.cygport
+  download
+  prep
+  compile
+  install
+make-binary = true
diff --git a/component/autoconf/buildout.cfg b/component/autoconf/buildout.cfg
index 6bb8ca87a..e809d857e 100644
--- a/component/autoconf/buildout.cfg
+++ b/component/autoconf/buildout.cfg
@@ -12,3 +12,9 @@ md5sum = 82d05e03b93e45f5a39b828dc9c6c29b
 environment =
   M4=${m4:location}/bin/m4
   PATH=${perl:location}/bin:%(PATH)s
+
+[autoconf:cygwin]
+share = /usr
+promises =
+  /usr/bin/autoconf
+  /usr/bin/autoconf-2.69
diff --git a/component/automake/buildout.cfg b/component/automake/buildout.cfg
index b0e8c1967..7caf6d94d 100644
--- a/component/automake/buildout.cfg
+++ b/component/automake/buildout.cfg
@@ -12,3 +12,8 @@ md5sum = 140e084223bf463a24c1a28427c6aec7
 url = http://ftp.gnu.org/gnu/automake/automake-1.12.6.tar.xz
 environment =
   PATH =${autoconf:location}/bin:${perl:location}/bin:${xz-utils:location}/bin:%(PATH)s
+
+[automake]
+share = /usr
+promises =
+  /usr/bin/automake
\ No newline at end of file
diff --git a/component/cclient/buildout.cfg b/component/cclient/buildout.cfg
index aef676ae8..ebf5efa12 100644
--- a/component/cclient/buildout.cfg
+++ b/component/cclient/buildout.cfg
@@ -6,16 +6,8 @@ extends =
   ../openssl/buildout.cfg
 
 parts =
-  cclient-patch
   cclient
 
-[cclient-patch]
-recipe = hexagonit.recipe.download
-download-only = true
-url = ${:_profile_base_location_}/imap-2007f.patch
-md5sum = 42c77fdd5d7a976fc302b93aadb3da98
-filename = imap-2007f.patch
-
 [cclient]
 recipe = slapos.recipe.cmmi
 url = ftp://ftp.cac.washington.edu/imap/imap-2007f.tar.gz
@@ -33,7 +25,16 @@ make-options =
   CCLIENT=${buildout:parts-directory}
   -j1
 
-patches = 
-  ${cclient-patch:location}/${cclient-patch:filename}
-
 patch-options = -p1
+patches =
+  ${:_profile_base_location_}/imap-2007f.patch#42c77fdd5d7a976fc302b93aadb3da98
+
+[cclient:cygwin]
+make-options = 
+  cyg
+  SSLTYPE=none
+  SSLCRYPTO=-lcrypto
+  IP=6
+  EXTRACFLAGS=-fPIC
+  CCLIENT=%(prefix)s
+  -j1
\ No newline at end of file
diff --git a/component/freetype/buildout.cfg b/component/freetype/buildout.cfg
index 6a51d0bc8..546ad01ff 100644
--- a/component/freetype/buildout.cfg
+++ b/component/freetype/buildout.cfg
@@ -22,3 +22,15 @@ environment =
   CPPFLAGS=-I${bzip2:location}/include -I${zlib:location}/include
   LDFLAGS=-L${bzip2:location}/lib -Wl,-rpath=${bzip2:location}/lib -L${zlib:location}/lib -Wl,-rpath=${zlib:location}/lib
   PATH=${libpng:location}/bin:%(PATH)s
+
+[freetype:cygwin]
+url = http://cygwin.mirrorcatalogs.com/release/X11/freetype2/freetype2-2.4.12-1-src.tar.bz2
+md5sum = 9fabeee8347eff093966543331e066aa
+configure-command = cygport
+configure-options =
+  freetype.cygport
+  download
+  prep
+  compile
+  install
+make-binary = true
diff --git a/component/libiconv/buildout.cfg b/component/libiconv/buildout.cfg
index 9582e45a6..26dd36eb0 100644
--- a/component/libiconv/buildout.cfg
+++ b/component/libiconv/buildout.cfg
@@ -18,3 +18,11 @@ patches =
 recipe = slapos.recipe.cmmi
 url = http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
 md5sum = e34509b1623cec449dfeb73d7ce9c6c6
+
+[libiconv:cygwin]
+share = /usr
+promises = 
+  /usr/bin/iconv.exe
+  /usr/include/iconv.h
+  /usr/lib/libcharset.dll.a
+  /usr/lib/libiconv.dll.a
diff --git a/component/libjpeg/buildout.cfg b/component/libjpeg/buildout.cfg
index f5457d6bd..05406f155 100644
--- a/component/libjpeg/buildout.cfg
+++ b/component/libjpeg/buildout.cfg
@@ -8,3 +8,15 @@ url = http://www.ijg.org/files/jpegsrc.v8d.tar.gz
 md5sum = 52654eb3b2e60c35731ea8fc87f1bd29
 configure-options =
   --disable-static
+
+[libjpeg:cygwin]
+url = http://cygwin.mirrorcatalogs.com/release/jpeg/jpeg-8b-1-src.tar.bz2
+md5sum = 93fe46997353a81b021d436625e29a5a
+configure-command = cygport
+configure-options =
+  jpeg.cygport
+  download
+  prep
+  compile
+  install
+make-binary = true
diff --git a/component/libpng/buildout.cfg b/component/libpng/buildout.cfg
index a35df6f1f..84f06f742 100644
--- a/component/libpng/buildout.cfg
+++ b/component/libpng/buildout.cfg
@@ -31,3 +31,15 @@ md5sum = fd85af68f84cbdf549147811006488c1
 url = http://download.sourceforge.net/libpng/libpng-1.6.2.tar.xz
 md5sum = 9d838f6fca9948a9f360a0cc1b516d5f
 so_version = 16
+
+[libpng:cygwin]
+url = http://cygwin.mirrorcatalogs.com/release/libpng/libpng-1.5.12-1-src.tar.bz2
+md5sum = 032c14e3b305779014232c2dd1415321
+configure-command = cygport
+configure-options =
+  libpng.cygport
+  download
+  prep
+  compile
+  install
+make-binary = true
diff --git a/component/libtool/buildout.cfg b/component/libtool/buildout.cfg
index 93db838b2..6e4ce22cd 100644
--- a/component/libtool/buildout.cfg
+++ b/component/libtool/buildout.cfg
@@ -7,3 +7,11 @@ md5sum = d2f3b7d4627e69e13514a40e72a24d50
 url = http://ftp.gnu.org/gnu/libtool/libtool-2.4.2.tar.gz
 configure-options =
   --disable-static
+
+[libtool:cygwin]
+share = /usr
+promises = 
+  /usr/bin/libtool
+  /usr/bin/libtoolize
+  /usr/include/ltdl.h
+  /usr/lib/libltdl.dll.a
diff --git a/component/mariadb/buildout.cfg b/component/mariadb/buildout.cfg
index 59957a6a3..6eb9f2f8e 100644
--- a/component/mariadb/buildout.cfg
+++ b/component/mariadb/buildout.cfg
@@ -16,13 +16,6 @@ extends =
 parts =
   mariadb
 
-[mariadb-5.5-no_test-patch]
-recipe = hexagonit.recipe.download
-url = ${:_profile_base_location_}/${:filename}
-md5sum = 14e6d713c16298a10f40d29f2b799aca
-filename = mariadb_5.5_create_system_tables__no_test.patch
-download-only = true
-
 [mariadb]
 recipe = slapos.recipe.cmmi
 version = 5.5.31
@@ -33,7 +26,8 @@ md5sum = 3fe756bc76f0e7a3af2757e48ce0f3f4
 keep-compile-dir = true
 patch-options = -p0
 patches =
-  ${mariadb-5.5-no_test-patch:location}/${mariadb-5.5-no_test-patch:filename}
+  ${:_profile_base_location_}/mariadb-5.5.25-no-mysql-test.patch
+
 configure-command = ${cmake:location}/bin/cmake
 configure-options =
   -DCMAKE_INSTALL_PREFIX=${buildout:parts-directory}/${:_buildout_section_name_}
@@ -76,3 +70,29 @@ environment =
   CPPFLAGS=-I${groonga:location}/include/groonga
   LDFLAGS=-L${groonga:location}/lib
   PKG_CONFIG_PATH=${groonga:location}/lib/pkgconfig:${groonga-normalizer-mysql:location}/lib/pkgconfig
+
+[mariadb:cygwin]
+version = 5.5.25
+dependencies = cmake zlib libevent ncurses openssl pkgconfig readline bison
+url = http://downloads.askmonty.org/f/mariadb-${:version}/kvm-tarbake-jaunty-x86/mariadb-${:version}.tar.gz/from/http://ftp.osuosl.org/pub/mariadb
+md5sum = 943f67c267d73a4080ab497e11740daf
+configure-options =
+  -DCMAKE_INSTALL_PREFIX=%(prefix)s
+  -DBUILD_CONFIG=mysql_release
+  -DDEFAULT_CHARSET=utf8
+  -DDEFAULT_COLLATION=utf8_unicode_ci
+  -DWITH_SSL=system
+  -DWITH_ZLIB=system
+  -DWITH_READLINE=0
+  -DWITH_PIC=1
+  -DENABLE_DTRACE=0
+  -DWITH_EXTRA_CHARSETS=complex
+  -DWITH_EMBEDDED_SERVER=0
+  -DWITHOUT_EXAMPLE_STORAGE_ENGINE=1
+  -DWITHOUT_DAEMON_EXAMPLE=1
+patches =
+  ${mariadb:patches}
+  ${:_profile_base_location_}/cygwin-mariadb-5.5.25-no-threadpool.patch
+post-install =
+  ln -fs  %(prefix)s/lib/libmysqlclient.dll.a  %(prefix)s/lib/libmysqlclient_r.dll.a
+  cp --preserve -f %(prefix)s/lib/cygmysqlclient-*.dll %(prefix)s/bin
\ No newline at end of file
diff --git a/component/mariadb/cygwin-mariadb-5.5.25-no-threadpool.patch b/component/mariadb/cygwin-mariadb-5.5.25-no-threadpool.patch
new file mode 100644
index 000000000..35e9ded97
--- /dev/null
+++ b/component/mariadb/cygwin-mariadb-5.5.25-no-threadpool.patch
@@ -0,0 +1,109 @@
+diff --git sql/CMakeLists.txt sql/CMakeLists.txt
+index ecf91fc..adbb7bb 100644
+--- sql/CMakeLists.txt
++++ sql/CMakeLists.txt
+@@ -31,7 +31,7 @@ ${CMAKE_CURRENT_BINARY_DIR}/lex_hash.h
+ 
+ SET_SOURCE_FILES_PROPERTIES(${GEN_SOURCES} PROPERTIES GENERATED 1)
+ 
+-ADD_DEFINITIONS(-DMYSQL_SERVER -DHAVE_EVENT_SCHEDULER -DHAVE_POOL_OF_THREADS) 
++ADD_DEFINITIONS(-DMYSQL_SERVER -DHAVE_EVENT_SCHEDULER) 
+ IF(SSL_DEFINES)
+  ADD_DEFINITIONS(${SSL_DEFINES})
+ ENDIF()
+@@ -83,18 +83,11 @@ SET (SQL_SOURCE
+                opt_index_cond_pushdown.cc opt_subselect.cc
+                opt_table_elimination.cc sql_expression_cache.cc
+                gcalc_slicescan.cc gcalc_tools.cc
+-			   threadpool_common.cc 
+ 			   ../sql-common/mysql_async.c
+                ${GEN_SOURCES}
+                ${MYSYS_LIBWRAP_SOURCE}
+ 			   )
+   
+-IF(WIN32)
+-  SET(SQL_SOURCE ${SQL_SOURCE} threadpool_win.cc)
+-ELSE()
+- SET(SQL_SOURCE ${SQL_SOURCE} threadpool_unix.cc)
+-ENDIF()
+-
+ MYSQL_ADD_PLUGIN(partition ha_partition.cc STORAGE_ENGINE DEFAULT STATIC_ONLY
+ RECOMPILE_FOR_EMBEDDED)
+ 
+diff --git sql/scheduler.h sql/scheduler.h
+index 82bba5a..fa38335 100644
+--- sql/scheduler.h
++++ sql/scheduler.h
+@@ -99,14 +99,7 @@ public:
+   void *data;                  /* scheduler-specific data structure */
+ };
+ 
+-#if !defined(EMBEDDED_LIBRARY)
+-#define HAVE_POOL_OF_THREADS 1
+-void pool_of_threads_scheduler(scheduler_functions* func,
+-   ulong *arg_max_connections,
+-   uint *arg_connection_count);
+-#else
+ #define pool_of_threads_scheduler(A,B,C) \
+   one_thread_per_connection_scheduler(A, B, C)
+-#endif
+ 
+ #endif /* SCHEDULER_INCLUDED */
+diff --git strings/dtoa.c strings/dtoa.c
+index 6b21605..4bb5de9 100644
+--- strings/dtoa.c
++++ strings/dtoa.c
+@@ -51,7 +51,7 @@
+ #define DTOA_OVERFLOW 9999
+ 
+ static double my_strtod_int(const char *, char **, int *, char *, size_t);
+-static char *dtoa(double, int, int, int *, int *, char **, char *, size_t);
++static char *x_dtoa(double, int, int, int *, int *, char **, char *, size_t);
+ static void dtoa_free(char *, char *, size_t);
+ 
+ /**
+@@ -92,7 +92,7 @@ size_t my_fcvt(double x, int precision, char *to, my_bool *error)
+   char buf[DTOA_BUFF_SIZE];
+   DBUG_ASSERT(precision >= 0 && precision < NOT_FIXED_DEC && to != NULL);
+   
+-  res= dtoa(x, 5, precision, &decpt, &sign, &end, buf, sizeof(buf));
++  res= x_dtoa(x, 5, precision, &decpt, &sign, &end, buf, sizeof(buf));
+ 
+   if (decpt == DTOA_OVERFLOW)
+   {
+@@ -221,7 +221,7 @@ size_t my_gcvt(double x, my_gcvt_arg_type type, int width, char *to,
+   if (x < 0.)
+     width--;
+ 
+-  res= dtoa(x, 4, type == MY_GCVT_ARG_DOUBLE ? width : min(width, FLT_DIG),
++  res= x_dtoa(x, 4, type == MY_GCVT_ARG_DOUBLE ? width : min(width, FLT_DIG),
+             &decpt, &sign, &end, buf, sizeof(buf));
+   if (decpt == DTOA_OVERFLOW)
+   {
+@@ -327,7 +327,7 @@ size_t my_gcvt(double x, my_gcvt_arg_type type, int width, char *to,
+         number of significant digits = (len-decpt) - (len-width) = width-decpt
+       */
+       dtoa_free(res, buf, sizeof(buf));
+-      res= dtoa(x, 5, width - decpt, &decpt, &sign, &end, buf, sizeof(buf));
++      res= x_dtoa(x, 5, width - decpt, &decpt, &sign, &end, buf, sizeof(buf));
+       src= res;
+       len= end - res;
+     }
+@@ -393,7 +393,7 @@ size_t my_gcvt(double x, my_gcvt_arg_type type, int width, char *to,
+     {
+       /* Yes, re-convert with a smaller width */
+       dtoa_free(res, buf, sizeof(buf));
+-      res= dtoa(x, 4, width, &decpt, &sign, &end, buf, sizeof(buf));
++      res= x_dtoa(x, 4, width, &decpt, &sign, &end, buf, sizeof(buf));
+       src= res;
+       len= end - res;
+       if (--decpt < 0)
+@@ -2166,7 +2166,7 @@ static int quorem(Bigint *b, Bigint *S)
+            calculation.
+  */
+ 
+-static char *dtoa(double dd, int mode, int ndigits, int *decpt, int *sign,
++static char *x_dtoa(double dd, int mode, int ndigits, int *decpt, int *sign,
+                   char **rve, char *buf, size_t buf_size)
+ {
+   /*
diff --git a/component/perl/buildout.cfg b/component/perl/buildout.cfg
index 1414d935c..68a9cc39f 100644
--- a/component/perl/buildout.cfg
+++ b/component/perl/buildout.cfg
@@ -44,3 +44,8 @@ configure-command =
 environment =
   PATH=${patch:location}/bin:%(PATH)s
 post-make-hook = ${perl-postmakehook-download:location}/${perl-postmakehook-download:filename}:post_make_hook
+
+[perl:cygwin]
+share = /
+promises = 
+  /usr/bin/perl.exe
\ No newline at end of file
diff --git a/software/apache-frontend/software.cfg b/software/apache-frontend/software.cfg
index 5c45564f6..73cdbd31c 100644
--- a/software/apache-frontend/software.cfg
+++ b/software/apache-frontend/software.cfg
@@ -60,9 +60,7 @@ paramiko = 1.10.1
 
 # Required by:
 # slapos.toolbox==0.34.0
-# psutil = 0.7.0
-# Patched for cygwin. And works both in cygwin and linux
-psutil = 0.6.2
+psutil = 0.7.100
 
 # Required by:
 # slapos.core==0.35.1
diff --git a/software/mariadb/software.cfg b/software/mariadb/software.cfg
index 2ba926cae..111b65ff7 100644
--- a/software/mariadb/software.cfg
+++ b/software/mariadb/software.cfg
@@ -100,7 +100,7 @@ Flask = 0.9
 
 # Required by:
 # slapos.cookbook==0.72.0
-inotifyx = 0.2.0
+inotifyx = 0.2.0-1
 
 # Required by:
 # slapos.cookbook==0.72.0
@@ -114,7 +114,7 @@ netaddr = 0.7.10
 
 # Required by:
 # slapos.core==0.35
-netifaces = 0.8
+netifaces = 0.8-1
 
 # Required by:
 # slapos.core==0.35
diff --git a/software/mysql-5.1/software.cfg b/software/mysql-5.1/software.cfg
index 0f5757600..8b2cdb8ee 100644
--- a/software/mysql-5.1/software.cfg
+++ b/software/mysql-5.1/software.cfg
@@ -77,7 +77,7 @@ netaddr = 0.7.6
 
 # Required by:
 # slapos.core==0.21
-netifaces = 0.6
+netifaces = 0.8-1
 
 # Required by:
 # slapos.cookbook==0.13
diff --git a/stack/lamp/buildout.cfg b/stack/lamp/buildout.cfg
index 1c9f433b4..a233ba473 100644
--- a/stack/lamp/buildout.cfg
+++ b/stack/lamp/buildout.cfg
@@ -30,7 +30,6 @@ extends =
   ../../component/apache/buildout.cfg
   ../../component/curl/buildout.cfg
   ../../component/dash/buildout.cfg
-  ../../component/dash/buildout.cfg
   ../../component/dcron/buildout.cfg
   ../../component/dropbear/buildout.cfg
   ../../component/git/buildout.cfg
@@ -319,7 +318,7 @@ async = 0.6.1
 buildout-versions = 1.7
 gitdb = 0.5.4
 hexagonit.recipe.cmmi = 1.6
-inotifyx = 0.2.0
+inotifyx = 0.2.0-1
 lxml = 3.1.1
 meld3 = 0.6.10
 netaddr = 0.7.10
@@ -352,7 +351,7 @@ feedparser = 5.1.3
 
 # Required by:
 # slapos.core==0.35.1
-netifaces = 0.8
+netifaces = 0.8-1
 
 # Required by:
 # slapos.toolbox==0.34.0
@@ -360,7 +359,7 @@ paramiko = 1.10.0
 
 # Required by:
 # slapos.toolbox==0.34.0
-psutil = 0.6.1
+psutil = 0.6.2
 
 # Required by:
 # slapos.core==0.35.1
-- 
2.30.9