summaryrefslogtreecommitdiff
path: root/scripts/make_win_bin_dist
blob: 7387dc2c1a6e4bd7ffd4be1a0ff59346ac0918e2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
#!/bin/sh
# Copyright (c) 2006, 2011, Oracle and/or its affiliates.
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1335  USA

# Exit if failing to copy, we want exact specifications, not
# just "what happen to be built".
set -e

# ----------------------------------------------------------------------
# Read first argument that is the base name of the resulting TAR file.
# See usage() function below for a description on the arguments.
#
# NOTE: We will read the rest of the command line later on.
# NOTE: Pattern matching with "{..,..}" can't be used, not portable.
# ----------------------------------------------------------------------

# FIXME why "libmysql.dll" installed both in "bin" and "lib/opt"?

usage()
{
  echo <<EOF
Usage: make_win_bin_dist [ options ] package-base-name [ copy-defs... ]

This is a script to run from the top of a source tree built on Windows.
The "package-base-name" argument should be something like

  mysql-noinstall-5.0.25-win32  (or winx64)

and will become the name of the directory of the unpacked ZIP (stripping
away the "noinstall" part of the ZIP file name if any) and the base
for the resulting package name.

Options are

  --embedded       Pack the embedded server and give error if not built.
                   The default is to pack it if it is built.

  --no-embedded    Don't pack the embedded server even if built

  --debug          Pack the debug binaries and give error if not built.
                   The default is to pack them if they are built.

  --no-debug       Don't pack the debug binaries even if built

  --only-debug     The target for this build was "Debug", and we just
                   want to replace the normal binaries with debug
                   versions, i.e. no separate "debug" directories.

  --exe-suffix=SUF Add a suffix to the filename part of the "mysqld" binary.

As you might want to include files of directories from other builds
(like a "mysqld-max.exe" server), you can instruct this script to copy
them in for you. This is the "copy-def" arguments, and they are of the
form

  relative-dest-name=source-name .....

i.e. can be something like

  bin/mysqld-max.exe=../my-max-build/sql/release/mysqld.exe

If you specify a directory the whole directory will be copied.

EOF
  exit 1
}

# ----------------------------------------------------------------------
# We need to be at the top of a source tree, check that we are
# ----------------------------------------------------------------------

if [ ! -d "sql" ] ; then
  echo "You need to run this script from inside the source tree"
  usage
fi

# ----------------------------------------------------------------------
# Actual argument processing, first part
# ----------------------------------------------------------------------

NOINST_NAME=""
TARGET="release"
PACK_EMBEDDED=""		# Could be "no", "yes" or empty
PACK_DEBUG=""			# Could be "no", "yes" or empty
EXE_SUFFIX=""

for arg do
  shift
  case "$arg" in
    --embedded)       PACK_EMBEDDED="yes" ;;
    --no-embedded)    PACK_EMBEDDED="no" ;;
    --debug)          PACK_DEBUG="yes" ;;
    --no-debug)       PACK_DEBUG="no" ;;
    --only-debug)     TARGET="debug" ; PACK_DEBUG="no" ;;
    --exe-suffix=*)   EXE_SUFFIX=`echo "$arg" | sed -e "s,--exe-suffix=,,"` ;;
    -*)
      echo "Unknown argument '$arg'"
      usage
      ;;
    *)
      NOINST_NAME="$arg"
      break
  esac
done

if [ x"$NOINST_NAME" = x"" ] ; then
  echo "No base package name given"
  usage
fi
DESTDIR=`echo $NOINST_NAME | sed 's/-noinstall-/-/'`

if [ -e $DESTDIR ] ; then
  echo "Please remove the old $DESTDIR before running this script"
  usage
fi

trap 'echo "Cleaning up and exiting..." ; rm -fr $DESTDIR; exit 1' ERR

# ----------------------------------------------------------------------
# Adjust target name if needed, release with debug info has another name
# ----------------------------------------------------------------------

if [ x"$TARGET" = x"release" -a -f "client/relwithdebinfo/mysql.exe" ]
then
  TARGET="relwithdebinfo"
fi

# ----------------------------------------------------------------------
# Copy executables, and client DLL
# ----------------------------------------------------------------------
MYISAM_BINARIES="myisamchk myisamlog myisampack myisam_ftdump"
MARIA_BINARIES="aria_chk aria_dump_log aria_ftdump aria_pack aria_read_log"
mkdir $DESTDIR
mkdir $DESTDIR/bin
cp client/$TARGET/*.exe                                  $DESTDIR/bin/
cp extra/$TARGET/*.exe                                   $DESTDIR/bin/

# MyISAM
#cp storage/myisam/$TARGET/*.exe                          $DESTDIR/bin/
for eng in $MYISAM_BINARIES ; do 
  cp storage/myisam/$TARGET/$eng.{exe,pdb} $DESTDIR/bin
done

# Maria
for eng in $MARIA_BINARIES ; do 
  cp storage/maria/$TARGET/$eng.{exe,pdb} $DESTDIR/bin
done

if [ x"$TARGET" != x"release" ] ; then
  cp client/$TARGET/mysql.pdb                            $DESTDIR/bin/
  cp client/$TARGET/mysqladmin.pdb                       $DESTDIR/bin/
  cp client/$TARGET/mysqlbinlog.pdb                      $DESTDIR/bin/
  cp client/$TARGET/mysqldump.pdb                        $DESTDIR/bin/
  cp client/$TARGET/mysqlimport.pdb                      $DESTDIR/bin/
  cp client/$TARGET/mysqlshow.pdb                        $DESTDIR/bin/
fi
cp tests/$TARGET/*.exe                                   $DESTDIR/bin/
cp libmysql/$TARGET/libmysql.dll                         $DESTDIR/bin/

cp sql/$TARGET/mysqld.exe                $DESTDIR/bin/mysqld$EXE_SUFFIX.exe
if [ x"$TARGET" != x"release" ] ; then
  cp sql/$TARGET/mysqld.pdb              $DESTDIR/bin/mysqld$EXE_SUFFIX.pdb
fi

if [ x"$PACK_DEBUG" = x"" -a -f "sql/debug/mysqld.exe" -o \
     x"$PACK_DEBUG" = x"yes" ] ; then
  cp sql/debug/mysqld.exe                $DESTDIR/bin/mysqld-debug.exe
  cp sql/debug/mysqld.pdb                $DESTDIR/bin/mysqld-debug.pdb
fi

# ----------------------------------------------------------------------
# Copy data directory, readme files etc
# ----------------------------------------------------------------------

if [ -d win/data ] ; then
  cp -pR win/data $DESTDIR/
fi

mkdir $DESTDIR/Docs
cp Docs/INSTALL-BINARY    $DESTDIR/Docs/
cp Docs/manual.chm        $DESTDIR/Docs/ || /bin/true
cp ChangeLog              $DESTDIR/Docs/ || /bin/true
cp support-files/my-*.ini $DESTDIR/
cp README                 $DESTDIR/

if [ -f COPYING ] ; then
  cp COPYING EXCEPTIONS-CLIENT $DESTDIR/
  cp COPYING                   $DESTDIR/Docs/
fi

# ----------------------------------------------------------------------
# These will be filled in when we enable embedded. Note that if no
# argument is given, it is copied if exists, else a check is done.
# ----------------------------------------------------------------------

copy_embedded()
{
  mkdir -p $DESTDIR/Embedded/DLL/release \
           $DESTDIR/Embedded/static/release \
           $DESTDIR/include
  cp libmysqld/libmysqld.def           $DESTDIR/include/
  cp libmysqld/$TARGET/mysqlserver.lib $DESTDIR/Embedded/static/release/
  cp libmysqld/$TARGET/libmysqld.dll   $DESTDIR/Embedded/DLL/release/
  cp libmysqld/$TARGET/libmysqld.exp   $DESTDIR/Embedded/DLL/release/
  cp libmysqld/$TARGET/libmysqld.lib   $DESTDIR/Embedded/DLL/release/
  if [ x"$TARGET" != x"release" ] ; then
    cp libmysqld/$TARGET/mysqlserver.pdb $DESTDIR/Embedded/static/release/
    cp libmysqld/$TARGET/libmysqld.pdb   $DESTDIR/Embedded/DLL/release/
  fi

  if [ x"$PACK_DEBUG" = x"" -a -f "libmysqld/debug/libmysqld.lib" -o \
       x"$PACK_DEBUG" = x"yes" ] ; then
    mkdir -p $DESTDIR/Embedded/DLL/debug \
             $DESTDIR/Embedded/static/debug
    cp libmysqld/debug/mysqlserver.lib   $DESTDIR/Embedded/static/debug/
    cp libmysqld/debug/mysqlserver.pdb   $DESTDIR/Embedded/static/debug/
    cp libmysqld/debug/libmysqld.dll     $DESTDIR/Embedded/DLL/debug/
    cp libmysqld/debug/libmysqld.exp     $DESTDIR/Embedded/DLL/debug/
    cp libmysqld/debug/libmysqld.lib     $DESTDIR/Embedded/DLL/debug/
    cp libmysqld/debug/libmysqld.pdb     $DESTDIR/Embedded/DLL/debug/
  fi
}

if [ x"$PACK_EMBEDDED" = x"" -a \
     -f "libmysqld/$TARGET/mysqlserver.lib" -a \
     -f "libmysqld/$TARGET/libmysqld.lib" -o \
     x"$PACK_EMBEDDED" = x"yes" ] ; then
  copy_embedded
fi

# ----------------------------------------------------------------------
# Note: Make sure to sync with include/Makefile.am and WiX installer
# XML specifications
# ----------------------------------------------------------------------

mkdir -p $DESTDIR/include
cp include/mysql.h \
   include/mysql_com.h \
   include/mysql_time.h \
   include/my_list.h \
   include/my_alloc.h \
   include/typelib.h \
   include/my_dbug.h \
   include/m_string.h \
   include/my_sys.h \
   include/my_xml.h \
   include/mysql_embed.h \
   include/my_pthread.h \
   include/my_no_pthread.h \
   include/decimal.h \
   include/errmsg.h \
   include/my_global.h \
   include/my_config.h \
   include/my_net.h \
   include/my_getopt.h \
   include/sslopt-longopts.h \
   include/my_dir.h \
   include/sslopt-vars.h \
   'include/sslopt-case.h' \
   include/sql_common.h \
   include/keycache.h \
   include/m_ctype.h \
   include/my_attribute.h \
   include/my_compiler.h \
   include/mysqld_error.h \
   include/sql_state.h \
   include/mysqld_ername.h \
   include/mysql_version.h \
   libmysql/libmysql.def \
   $DESTDIR/include/

mkdir -p $DESTDIR/include/mysql
cp include/mysql/plugin.h $DESTDIR/include/mysql/

# ----------------------------------------------------------------------
# Client libraries, and other libraries
# ----------------------------------------------------------------------

mkdir -p $DESTDIR/lib/opt
mkdir -p $DESTDIR/lib/plugin
cp sql/$TARGET/mysqld.lib $DESTDIR/lib/
cp libmysql/$TARGET/libmysql.dll \
   libmysql/$TARGET/libmysql.lib \
   libmysql/$TARGET/mysqlclient.lib \
   mysys/$TARGET/mysys.lib \
   regex/$TARGET/regex.lib \
   strings/$TARGET/strings.lib \
   zlib/$TARGET/zlib.lib $DESTDIR/lib/opt/
cp storage/*/$TARGET/ha_*.dll $DESTDIR/lib/plugin/

if [ x"$TARGET" != x"release" ] ; then
  cp libmysql/$TARGET/libmysql.pdb \
     libmysql/$TARGET/mysqlclient.pdb \
     mysys/$TARGET/mysys.pdb \
     regex/$TARGET/regex.pdb \
     strings/$TARGET/strings.pdb \
     zlib/$TARGET/zlib.pdb $DESTDIR/lib/opt/
  cp storage/*/$TARGET/ha_*.pdb $DESTDIR/lib/plugin/
fi


if [ x"$PACK_DEBUG" = x"" -a -f "libmysql/debug/libmysql.lib" -o \
     x"$PACK_DEBUG" = x"yes" ] ; then
  mkdir -p $DESTDIR/lib/debug
  mkdir -p $DESTDIR/lib/plugin/debug
  cp libmysql/debug/libmysql.dll \
     libmysql/debug/libmysql.lib \
     libmysql/debug/libmysql.pdb \
     libmysql/debug/mysqlclient.lib \
     libmysql/debug/mysqlclient.pdb \
     mysys/debug/mysys.lib \
     mysys/debug/mysys.pdb \
     regex/debug/regex.lib \
     regex/debug/regex.pdb \
     strings/debug/strings.lib \
     strings/debug/strings.pdb \
     zlib/debug/zlib.lib \
     zlib/debug/zlib.pdb $DESTDIR/lib/debug/
  cp storage/*/debug/ha_*.dll \
     storage/*/debug/ha_*.lib \
     storage/*/debug/ha_*.pdb \
     $DESTDIR/lib/plugin/debug/
fi

# ----------------------------------------------------------------------
# Copy the test directory
# ----------------------------------------------------------------------

mkdir $DESTDIR/mysql-test
cp mysql-test/mysql-test-run.pl $DESTDIR/mysql-test/
cp mysql-test/mysql-stress-test.pl $DESTDIR/mysql-test/
cp mysql-test/README $DESTDIR/mysql-test/
cp -R mysql-test/{t,r,include,suite,std_data,lib,collections} $DESTDIR/mysql-test/

rm -rf $DESTDIR/mysql-test/lib/My/SafeProcess/my_safe_kill.{dir,vcproj}
rm -rf $DESTDIR/mysql-test/lib/My/SafeProcess/my_safe_process.{dir,vcproj}
rm -rf $DESTDIR/mysql-test/lib/My/SafeProcess/{Debug,RelWithDebInfo}/*.{ilk,idb}


# Note that this will not copy "extra" if a soft link
if [ -d mysql-test/extra ] ; then
  mkdir $DESTDIR/mysql-test/extra
  cp -pR mysql-test/extra/* $DESTDIR/mysql-test/extra/
fi

# ----------------------------------------------------------------------
# Copy what could be usable in the "scripts" directory
# ----------------------------------------------------------------------

mysql_scripts="\
mysql_config.pl \
mysql_convert_table_format.pl \
mysql_install_db.pl \
mysql_secure_installation.pl \
mysqld_multi.pl \
mysqldumpslow.pl \
mysqlhotcopy.pl \
mytop.pl \
"

mkdir -p $DESTDIR/scripts

for i in $mysql_scripts
do
  cp scripts/$i $DESTDIR/scripts/$i
done

cp -pR sql/share $DESTDIR/
cp -pR sql-bench $DESTDIR/
rm -f $DESTDIR/sql-bench/*.sh $DESTDIR/sql-bench/Makefile*

# The SQL initialisation code is to be in "share"
cp scripts/*.sql $DESTDIR/share/

# ----------------------------------------------------------------------
# Clean up from possibly copied SCCS directories
# ----------------------------------------------------------------------

rm -rf `/bin/find $DISTDIR -type d -name SCCS -print`

# ----------------------------------------------------------------------
# Copy other files specified on command line DEST=SOURCE
# ----------------------------------------------------------------------

for arg do
  dst=`echo $arg | sed -n 's/=.*$//p'`
  src=`echo $arg | sed -n 's/^.*=//p'`

  if [ x"$dst" = x"" -o x"$src" = x"" ] ; then
    echo "Invalid specification of what to copy"
    usage
  fi

  mkdir -p `dirname $DESTDIR/$dst`
  cp -pR "$src" $DESTDIR/$dst
done

# ----------------------------------------------------------------------
# Finally create the ZIP archive
# ----------------------------------------------------------------------

rm -f $NOINST_NAME.zip
zip -r $NOINST_NAME.zip $DESTDIR
rm -Rf $DESTDIR