2
# Copyright (C) 2000-2006 MySQL AB
4
# This program is free software; you can redistribute it and/or modify
5
# it under the terms of the GNU General Public License as published by
6
# the Free Software Foundation; version 2 of the License.
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
# GNU General Public License for more details.
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17
##############################################################################
19
# This is a script to create a TAR or ZIP binary distribution out of a
20
# built source tree. The output file will be put at the top level of
21
# the source tree, as "mysql-<vsn>....{tar.gz,zip}"
23
# Note that the structure created by this script is slightly different from
24
# what a normal "make install" would produce. No extra "mysql" sub directory
25
# will be created, i.e. no "$prefix/include/mysql", "$prefix/lib/mysql" or
26
# "$prefix/share/mysql". This is because the build system explicitly calls
27
# make with pkgdatadir=<datadir>, etc.
29
# In GNU make/automake terms
31
# "pkglibdir" is set to the same as "libdir"
32
# "pkgincludedir" is set to the same as "includedir"
33
# "pkgdatadir" is set to the same as "datadir"
34
# "pkgplugindir" is set to "$pkglibdir/plugin"
35
# "pkgsuppdir" is set to "@prefix@/support-files",
36
# normally the same as "datadir"
38
# The temporary directory path given to "--tmp=<path>" has to be
39
# absolute and with no spaces.
41
# Note that for best result, the original "make" should be done with
42
# the same arguments as used for "make install" below, especially the
43
# 'pkglibdir', as the RPATH should to be set correctly.
45
##############################################################################
47
##############################################################################
49
# Read the command line arguments that control this script
51
##############################################################################
53
machine=@MACHINE_TYPE@
59
STRIP=1 # Option ignored
64
NDBCLUSTER="" # Option ignored
68
--tmp=*) TMP=`echo "$arg" | sed -e "s;--tmp=;;"` ;;
69
--suffix=*) SUFFIX=`echo "$arg" | sed -e "s;--suffix=;;"` ;;
70
--no-strip) STRIP=0 ;;
71
--machine=*) machine=`echo "$arg" | sed -e "s;--machine=;;"` ;;
72
--platform=*) PLATFORM=`echo "$arg" | sed -e "s;--platform=;;"` ;;
74
--with-ndbcluster) NDBCLUSTER=1 ;;
76
echo "Unknown argument '$arg'"
82
# ----------------------------------------------------------------------
83
# Adjust "system" output from "uname" to be more human readable
84
# ----------------------------------------------------------------------
86
if [ x"$PLATFORM" = x"" ] ; then
87
# FIXME move this to the build tools
88
# Remove vendor from $system
89
system=`echo $system | sed -e 's/[a-z]*-\(.*\)/\1/g'`
91
# Map OS names to "our" OS names (eg. darwin6.8 -> osx10.2)
92
system=`echo $system | sed -e 's/darwin6.*/osx10.2/g'`
93
system=`echo $system | sed -e 's/darwin7.*/osx10.3/g'`
94
system=`echo $system | sed -e 's/darwin8.*/osx10.4/g'`
95
system=`echo $system | sed -e 's/\(aix4.3\).*/\1/g'`
96
system=`echo $system | sed -e 's/\(aix5.1\).*/\1/g'`
97
system=`echo $system | sed -e 's/\(aix5.2\).*/\1/g'`
98
system=`echo $system | sed -e 's/\(aix5.3\).*/\1/g'`
99
system=`echo $system | sed -e 's/osf5.1b/tru64/g'`
100
system=`echo $system | sed -e 's/linux-gnu/linux/g'`
101
system=`echo $system | sed -e 's/solaris2.\([0-9]*\)/solaris\1/g'`
102
system=`echo $system | sed -e 's/sco3.2v\(.*\)/openserver\1/g'`
104
PLATFORM="$system-$machine"
107
# Print the platform name for build logs
108
echo "PLATFORM NAME: $PLATFORM"
111
*netware*) BASE_SYSTEM="netware" ;;
114
# Change the distribution to a long descriptive name
115
NEW_NAME=mysql@MYSQL_SERVER_SUFFIX@-@VERSION@-$PLATFORM$SUFFIX
117
# ----------------------------------------------------------------------
118
# Define BASE, and remove the old BASE directory if any
119
# ----------------------------------------------------------------------
120
BASE=$TMP/my_dist$SUFFIX
121
if [ -d $BASE ] ; then
125
# ----------------------------------------------------------------------
126
# Find the TAR to use
127
# ----------------------------------------------------------------------
129
# This is needed to prefer GNU tar over platform tar because that can't
130
# always handle long filenames
132
PATH_DIRS=`echo $PATH | \
133
sed -e 's/^:/. /' -e 's/:$/ ./' -e 's/::/ . /g' -e 's/:/ /g' `
143
if [ -x $file -a ! -d $file ] ; then
153
tar=`which_1 gnutar gtar`
154
if [ $? -ne 0 -o x"$tar" = x"" ] ; then
159
##############################################################################
161
# Handle the Unix/Linux packaging using "make install"
163
##############################################################################
165
if [ x"$BASE_SYSTEM" != x"netware" ] ; then
167
# ----------------------------------------------------------------------
168
# Terminate on any base level error
169
# ----------------------------------------------------------------------
172
# ----------------------------------------------------------------------
173
# Really ugly, one script, "mysql_install_db", needs prefix set to ".",
174
# i.e. makes access relative the current directory. This matches
175
# the documentation, so better not change this. And for another script,
176
# "mysql.server", we make some relative, others not.
177
# ----------------------------------------------------------------------
180
rm -f mysql_install_db
181
@MAKE@ mysql_install_db \
193
@MAKE@ mysql.server \
198
pkgdatadir=@pkgdatadir@
201
# ----------------------------------------------------------------------
202
# Do a install that we later are to pack. Use the same paths as in
203
# the build for the relevant directories.
204
# ----------------------------------------------------------------------
205
@MAKE@ DESTDIR=$BASE install \
206
pkglibdir=@pkglibdir@ \
207
pkgincludedir=@pkgincludedir@ \
208
pkgdatadir=@pkgdatadir@ \
209
pkgplugindir=@pkgplugindir@ \
210
pkgsuppdir=@pkgsuppdir@ \
214
# ----------------------------------------------------------------------
215
# Rename top directory, and set DEST to the new directory
216
# ----------------------------------------------------------------------
217
mv $BASE@prefix@ $BASE/$NEW_NAME
220
# ----------------------------------------------------------------------
221
# If we compiled with gcc, copy libgcc.a to the dist as libmygcc.a
222
# ----------------------------------------------------------------------
223
if [ x"@GXX@" = x"yes" ] ; then
224
gcclib=`@CC@ @CFLAGS@ --print-libgcc-file 2>/dev/null` || true
225
if [ -z "$gcclib" ] ; then
226
echo "Warning: Compiler doesn't tell libgcc.a!"
227
elif [ -f "$gcclib" ] ; then
228
$CP $gcclib $DEST/lib/libmygcc.a
230
echo "Warning: Compiler result '$gcclib' not found / no file!"
234
# FIXME let this script be in "bin/", where it is in the RPMs?
235
# http://dev.mysql.com/doc/refman/5.1/en/mysql-install-db-problems.html
237
mv $DEST/bin/mysql_install_db $DEST/scripts/
239
# Note, no legacy "safe_mysqld" link to "mysqld_safe" in 5.1
241
# Copy readme and license files
242
cp README Docs/INSTALL-BINARY $DEST/
243
if [ -f COPYING -a -f EXCEPTIONS-CLIENT ] ; then
244
cp COPYING EXCEPTIONS-CLIENT $DEST/
245
elif [ -f LICENSE.mysql ] ; then
246
cp LICENSE.mysql $DEST/
248
echo "ERROR: no license files found"
252
# FIXME should be handled by make file, and to other dir
253
mkdir -p $DEST/bin $DEST/support-files
254
cp scripts/mysqlaccess.conf $DEST/bin/
255
cp support-files/magic $DEST/support-files/
257
# Create empty data directories, set permission (FIXME why?)
258
mkdir $DEST/data $DEST/data/mysql $DEST/data/test
259
chmod o-rwx $DEST/data $DEST/data/mysql $DEST/data/test
261
# FIXME mysqld-debug is handled seperately (see phase_save_server() in
263
if [ -f sql/mysqld-debug ] ; then
264
cp sql/mysqld-debug $DEST/bin/
267
# ----------------------------------------------------------------------
268
# Create the result tar file
269
# ----------------------------------------------------------------------
271
echo "Using $tar to create archive"
273
if [ x$SILENT = x1 ] ; then
277
echo "Creating and compressing archive"
278
rm -f $NEW_NAME.tar.gz
279
(cd $BASE ; $tar $OPT - $NEW_NAME) | gzip -9 > $NEW_NAME.tar.gz
280
echo "$NEW_NAME.tar.gz created"
282
echo "Removing temporary directory"
288
##############################################################################
290
# Handle the Netware case, until integrated above
292
##############################################################################
295
MYSQL_SHARE=$BASE/share
297
mkdir $BASE $BASE/bin $BASE/docs \
298
$BASE/include $BASE/lib $BASE/support-files $BASE/share $BASE/scripts \
299
$BASE/mysql-test $BASE/mysql-test/t $BASE/mysql-test/r \
300
$BASE/mysql-test/include $BASE/mysql-test/std_data $BASE/mysql-test/lib \
301
$BASE/mysql-test/suite
303
# Copy files if they exists, warn for those that don't.
304
# Note that when listing files to copy, we might list the file name
305
# twice, once in the directory location where it is built, and a
306
# second time in the ".libs" location. In the case the first one
307
# is a wrapper script, the second one will overwrite it with the
317
elif [ -d $i ] ; then
318
echo "Warning: Will not copy directory \"$i\""
320
echo "Warning: Listed file not found \"$i\""
325
copyfileto $BASE/docs ChangeLog Docs/mysql.info
327
copyfileto $BASE COPYING COPYING.LIB README Docs/INSTALL-BINARY \
328
EXCEPTIONS-CLIENT LICENSE.mysql
330
# Non platform-specific bin dir files:
331
BIN_FILES="extra/comp_err$BS extra/replace$BS extra/perror$BS \
332
extra/resolveip$BS extra/my_print_defaults$BS \
333
extra/resolve_stack_dump$BS extra/mysql_waitpid$BS \
334
storage/myisam/myisamchk$BS storage/myisam/myisampack$BS \
335
storage/myisam/myisamlog$BS storage/myisam/myisam_ftdump$BS \
336
sql/mysqld$BS sql/mysqld-debug$BS \
337
sql/mysql_tzinfo_to_sql$BS \
338
client/mysql$BS client/mysqlshow$BS client/mysqladmin$BS \
339
client/mysqlslap$BS \
340
client/mysqldump$BS client/mysqlimport$BS \
341
client/mysqltest$BS client/mysqlcheck$BS \
342
client/mysqlbinlog$BS client/mysql_upgrade$BS \
343
tests/mysql_client_test$BS \
344
libmysqld/examples/mysql_client_test_embedded$BS \
345
libmysqld/examples/mysqltest_embedded$BS \
348
# Platform-specific bin dir files:
349
BIN_FILES="$BIN_FILES \
350
netware/mysqld_safe$BS netware/mysql_install_db$BS \
351
netware/init_db.sql netware/test_db.sql \
352
netware/mysqlhotcopy$BS netware/libmysql$BS netware/init_secure_db.sql \
355
copyfileto $BASE/bin $BIN_FILES
357
$CP netware/*.pl $BASE/scripts
358
$CP scripts/mysqlhotcopy $BASE/scripts/mysqlhotcopy.pl
360
copyfileto $BASE/lib \
361
libmysql/.libs/libmysqlclient.a \
362
libmysql/.libs/libmysqlclient.so* \
363
libmysql/.libs/libmysqlclient.sl* \
364
libmysql/.libs/libmysqlclient*.dylib \
365
libmysql/libmysqlclient.* \
366
libmysql_r/.libs/libmysqlclient_r.a \
367
libmysql_r/.libs/libmysqlclient_r.so* \
368
libmysql_r/.libs/libmysqlclient_r.sl* \
369
libmysql_r/.libs/libmysqlclient_r*.dylib \
370
libmysql_r/libmysqlclient_r.* \
371
libmysqld/.libs/libmysqld.a \
372
libmysqld/.libs/libmysqld.so* \
373
libmysqld/.libs/libmysqld.sl* \
374
libmysqld/.libs/libmysqld*.dylib \
375
mysys/libmysys.a strings/libmystrings.a dbug/libdbug.a \
376
libmysqld/libmysqld.a netware/libmysql.imp \
379
# convert the .a to .lib for NetWare
380
for i in $BASE/lib/*.a
382
libname=`basename $i .a`
383
$MV $i $BASE/lib/$libname.lib
388
copyfileto $BASE/include config.h include/*
390
rm -f $BASE/include/Makefile* $BASE/include/*.in $BASE/include/config-win.h
392
copyfileto $BASE/support-files support-files/*
394
copyfileto $BASE/share scripts/*.sql
396
$CP -r sql/share/* $MYSQL_SHARE
397
rm -f $MYSQL_SHARE/Makefile* $MYSQL_SHARE/*/*.OLD
399
copyfileto $BASE/mysql-test \
400
mysql-test/mysql-test-run mysql-test/install_test_db \
401
mysql-test/mysql-test-run.pl mysql-test/README \
402
mysql-test/mysql-stress-test.pl \
403
mysql-test/valgrind.supp \
404
netware/mysql_test_run.nlm netware/install_test_db.ncf
406
$CP mysql-test/lib/*.pl $BASE/mysql-test/lib
407
$CP mysql-test/t/*.def $BASE/mysql-test/t
408
$CP mysql-test/include/*.inc $BASE/mysql-test/include
409
$CP mysql-test/include/*.sql $BASE/mysql-test/include
410
$CP mysql-test/include/*.test $BASE/mysql-test/include
411
$CP mysql-test/t/*.def $BASE/mysql-test/t
412
$CP mysql-test/std_data/*.dat mysql-test/std_data/*.frm \
413
mysql-test/std_data/*.MYD mysql-test/std_data/*.MYI \
414
mysql-test/std_data/*.pem mysql-test/std_data/Moscow_leap \
415
mysql-test/std_data/Index.xml \
416
mysql-test/std_data/des_key_file mysql-test/std_data/*.*001 \
417
mysql-test/std_data/*.cnf mysql-test/std_data/*.MY* \
418
$BASE/mysql-test/std_data
419
$CP mysql-test/t/*.test mysql-test/t/*.imtest \
420
mysql-test/t/*.disabled mysql-test/t/*.opt \
421
mysql-test/t/*.slave-mi mysql-test/t/*.sh mysql-test/t/*.sql $BASE/mysql-test/t
422
$CP mysql-test/r/*.result mysql-test/r/*.require \
425
# Copy the additional suites "as is", they are in flux
426
$tar cf - mysql-test/suite | ( cd $BASE ; $tar xf - )
427
# Clean up if we did this from a bk tree
428
if [ -d mysql-test/SCCS ] ; then
429
find $BASE/mysql-test -name SCCS -print | xargs rm -rf
432
rm -f $BASE/bin/Makefile* $BASE/bin/*.in $BASE/bin/*.sh \
433
$BASE/bin/mysql_install_db $BASE/bin/make_binary_distribution \
434
$BASE/bin/setsomevars $BASE/support-files/Makefile* \
435
$BASE/support-files/*.sh
438
# Copy system dependent files
440
./scripts/fill_help_tables < ./Docs/manual.texi >> ./netware/init_db.sql
443
# Remove system dependent files
445
rm -f $BASE/support-files/magic \
446
$BASE/support-files/mysql.server \
447
$BASE/support-files/mysql*.spec \
448
$BASE/support-files/mysql-log-rotate \
449
$BASE/support-files/binary-configure \
450
$BASE/support-files/build-tags \
451
$BASE/support-files/MySQL-shared-compat.spec \
454
# Clean up if we did this from a bk tree
455
if [ -d $BASE/sql-bench/SCCS ] ; then
456
find $BASE/share -name SCCS -print | xargs rm -rf
457
find $BASE/sql-bench -name SCCS -print | xargs rm -rf
466
# Create a zip file for NetWare users
469
(cd $TMP; zip -r "$SOURCE/$NEW_NAME.zip" $NEW_NAME)
470
echo "$NEW_NAME.zip created"
472
echo "Removing temporary directory"