make_binary_distribution.sh 12.5 KB
Newer Older
unknown's avatar
unknown committed
1
#!/bin/sh
unknown's avatar
unknown committed
2 3 4 5 6 7 8 9 10 11 12 13 14 15
# Copyright (C) 2000-2006 MySQL AB
# 
# 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-1301  USA
unknown's avatar
unknown committed
16

unknown's avatar
unknown committed
17 18 19 20 21 22
# This is a script to create a TAR or ZIP binary distribution out of a
# built source tree. The output file will be put at the top level of
# the source tree, as "mysql-<vsn>....{tar.gz,zip}"
#
# The temporary directory path given to "--tmp=<path>" has to be
# absolute and with no spaces.
unknown's avatar
unknown committed
23 24 25 26

machine=@MACHINE_TYPE@
system=@SYSTEM_TYPE@
version=@VERSION@
unknown's avatar
unknown committed
27
SOURCE=`pwd`
unknown's avatar
unknown committed
28
CP="cp -p"
29
MV="mv"
unknown's avatar
unknown committed
30

31
STRIP=1
32
DEBUG=0
33
SILENT=0
unknown's avatar
unknown committed
34 35
MACHINE=""
PLATFORM=""
unknown's avatar
unknown committed
36
TMP=/tmp
37
SUFFIX=""
unknown's avatar
unknown committed
38
NDBCLUSTER=""
39

unknown's avatar
unknown committed
40 41 42 43 44 45
for arg do
  case "$arg" in
    --debug)    DEBUG=1;;
    --tmp=*)    TMP=`echo "$arg" | sed -e "s;--tmp=;;"` ;;
    --suffix=*) SUFFIX=`echo "$arg" | sed -e "s;--suffix=;;"` ;;
    --no-strip) STRIP=0 ;;
unknown's avatar
unknown committed
46
    --machine=*) MACHINE=`echo "$arg" | sed -e "s;--machine=;;"` ;;
unknown's avatar
unknown committed
47 48 49 50 51 52 53 54 55
    --platform=*) PLATFORM=`echo "$arg" | sed -e "s;--platform=;;"` ;;
    --silent)   SILENT=1 ;;
    --with-ndbcluster) NDBCLUSTER=1 ;;
    *)
      echo "Unknown argument '$arg'"
      exit 1
      ;;
  esac
done
56

unknown's avatar
Merge  
unknown committed
57 58
# Remove vendor from $system
system=`echo $system | sed -e 's/[a-z]*-\(.*\)/\1/g'`
59

unknown's avatar
Merge  
unknown committed
60 61 62 63 64 65 66 67 68 69 70 71
# Map OS names to "our" OS names (eg. darwin6.8 -> osx10.2)
system=`echo $system | sed -e 's/darwin6.*/osx10.2/g'`
system=`echo $system | sed -e 's/darwin7.*/osx10.3/g'`
system=`echo $system | sed -e 's/darwin8.*/osx10.4/g'`
system=`echo $system | sed -e 's/\(aix4.3\).*/\1/g'`
system=`echo $system | sed -e 's/\(aix5.1\).*/\1/g'`
system=`echo $system | sed -e 's/\(aix5.2\).*/\1/g'`
system=`echo $system | sed -e 's/\(aix5.3\).*/\1/g'`
system=`echo $system | sed -e 's/osf5.1b/tru64/g'`
system=`echo $system | sed -e 's/linux-gnu/linux/g'`
system=`echo $system | sed -e 's/solaris2.\([0-9]*\)/solaris\1/g'`
system=`echo $system | sed -e 's/sco3.2v\(.*\)/openserver\1/g'`
unknown's avatar
unknown committed
72

unknown's avatar
unknown committed
73 74 75
if [ x"$MACHINE" != x"" ] ; then
  machine=$MACHINE
fi
unknown's avatar
unknown committed
76

unknown's avatar
unknown committed
77 78 79 80 81
if [ x"$PLATFORM" != x"" ] ; then
  platform="$PLATFORM"
else
  platform="$system-$machine"
fi
unknown's avatar
unknown committed
82

unknown's avatar
unknown committed
83
# FIXME This should really be integrated with automake and not duplicate the
unknown's avatar
unknown committed
84 85
# installation list.

86
BASE=$TMP/my_dist$SUFFIX
87 88

if [ -d $BASE ] ; then
unknown's avatar
unknown committed
89
 rm -rf $BASE
90 91
fi

unknown's avatar
unknown committed
92
BS=""
93
BIN_FILES=""
unknown's avatar
unknown committed
94 95 96 97 98 99 100 101 102 103 104 105
BASE_SYSTEM="any"
MYSQL_SHARE=$BASE/share/mysql

case $system in
  *netware*)
    BASE_SYSTEM="netware"
    BS=".nlm"
    MYSQL_SHARE=$BASE/share
    ;;
esac


106
mkdir $BASE $BASE/bin $BASE/docs \
unknown's avatar
unknown committed
107 108
 $BASE/include $BASE/lib $BASE/support-files $BASE/share $BASE/scripts \
 $BASE/mysql-test $BASE/mysql-test/t  $BASE/mysql-test/r \
unknown's avatar
unknown committed
109
 $BASE/mysql-test/include $BASE/mysql-test/std_data $BASE/mysql-test/lib
unknown's avatar
unknown committed
110 111

if [ $BASE_SYSTEM != "netware" ] ; then
unknown's avatar
unknown committed
112
 mkdir $BASE/share/mysql $BASE/tests $BASE/sql-bench $BASE/man \
unknown's avatar
unknown committed
113
  $BASE/man/man1 $BASE/man/man8 $BASE/data $BASE/data/mysql $BASE/data/test
unknown's avatar
unknown committed
114

unknown's avatar
unknown committed
115 116
 chmod o-rwx $BASE/data $BASE/data/*
fi
unknown's avatar
unknown committed
117

unknown's avatar
unknown committed
118 119 120 121 122
# Copy files if they exists, warn for those that don't
copyfileto()
{
  destdir=$1
  shift
unknown's avatar
unknown committed
123 124
  for i
  do
unknown's avatar
unknown committed
125 126 127 128 129 130 131 132 133 134 135
    if [ -f $i ] ; then
      $CP $i $destdir
    elif [ -d $i ] ; then
      echo "Warning: Will not copy directory \"$i\""
    else
      echo "Warning: Listed file not found   \"$i\""
    fi
  done
}

copyfileto $BASE/docs ChangeLog Docs/mysql.info
136

unknown's avatar
unknown committed
137
copyfileto $BASE COPYING COPYING.LIB README Docs/INSTALL-BINARY \
138
         EXCEPTIONS-CLIENT LICENSE.mysql
unknown's avatar
unknown committed
139

140 141 142 143 144
# Non platform-specific bin dir files:
BIN_FILES="extra/comp_err$BS extra/replace$BS extra/perror$BS \
  extra/resolveip$BS extra/my_print_defaults$BS \
  extra/resolve_stack_dump$BS extra/mysql_waitpid$BS \
  myisam/myisamchk$BS myisam/myisampack$BS myisam/myisamlog$BS \
145
  myisam/myisam_ftdump$BS \
146 147
  sql/mysqld$BS sql/mysqld-debug$BS \
  sql/mysql_tzinfo_to_sql$BS \
148
  server-tools/instance-manager/mysqlmanager$BS \
149 150 151
  client/mysql$BS client/mysqlshow$BS client/mysqladmin$BS \
  client/mysqldump$BS client/mysqlimport$BS \
  client/mysqltest$BS client/mysqlcheck$BS \
152
  client/mysqlbinlog$BS client/mysql_upgrade$BS \
153 154 155 156
  tests/mysql_client_test$BS \
  libmysqld/examples/mysql_client_test_embedded$BS \
  libmysqld/examples/mysqltest_embedded$BS \
  ";
157 158 159 160 161 162

# Platform-specific bin dir files:
if [ $BASE_SYSTEM = "netware" ] ; then
  BIN_FILES="$BIN_FILES \
    netware/mysqld_safe$BS netware/mysql_install_db$BS \
    netware/init_db.sql netware/test_db.sql netware/mysql_explain_log$BS \
unknown's avatar
unknown committed
163
    netware/mysqlhotcopy$BS netware/libmysql$BS netware/init_secure_db.sql \
164
    ";
unknown's avatar
unknown committed
165
# For all other platforms:
166 167
else
  BIN_FILES="$BIN_FILES \
168 169
    client/mysqltestmanagerc \
    client/mysqltestmanager-pwgen tools/mysqltestmanager \
170 171 172
    client/.libs/mysql client/.libs/mysqlshow client/.libs/mysqladmin \
    client/.libs/mysqldump client/.libs/mysqlimport \
    client/.libs/mysqltest client/.libs/mysqlcheck \
173 174
    client/.libs/mysqlbinlog client/.libs/mysqltestmanagerc \
    client/.libs/mysqltestmanager-pwgen tools/.libs/mysqltestmanager \
175 176 177
    tests/.libs/mysql_client_test \
    libmysqld/examples/.libs/mysql_client_test_embedded \
    libmysqld/examples/.libs/mysqltest_embedded \
178 179 180
  ";
fi

unknown's avatar
unknown committed
181
copyfileto $BASE/bin $BIN_FILES
182 183 184 185

if [ x$STRIP = x1 ] ; then
  strip $BASE/bin/*
fi
186

unknown's avatar
unknown committed
187
# Copy not binary files
unknown's avatar
unknown committed
188
copyfileto $BASE/bin sql/mysqld.sym.gz
189

unknown's avatar
unknown committed
190
if [ $BASE_SYSTEM = "netware" ] ; then
unknown's avatar
unknown committed
191
    $CP netware/*.pl $BASE/scripts
unknown's avatar
unknown committed
192
    $CP scripts/mysqlhotcopy $BASE/scripts/mysqlhotcopy.pl
unknown's avatar
unknown committed
193 194
fi

unknown's avatar
unknown committed
195
copyfileto $BASE/lib \
unknown's avatar
unknown committed
196 197 198 199 200 201 202 203 204 205 206 207 208 209
  libmysql/.libs/libmysqlclient.a \
  libmysql/.libs/libmysqlclient.so* \
  libmysql/.libs/libmysqlclient.sl* \
  libmysql/.libs/libmysqlclient*.dylib \
  libmysql/libmysqlclient.* \
  libmysql_r/.libs/libmysqlclient_r.a \
  libmysql_r/.libs/libmysqlclient_r.so* \
  libmysql_r/.libs/libmysqlclient_r.sl* \
  libmysql_r/.libs/libmysqlclient_r*.dylib \
  libmysql_r/libmysqlclient_r.* \
  libmysqld/.libs/libmysqld.a \
  libmysqld/.libs/libmysqld.so* \
  libmysqld/.libs/libmysqld.sl* \
  libmysqld/.libs/libmysqld*.dylib \
210
  mysys/libmysys.a strings/libmystrings.a dbug/libdbug.a \
unknown's avatar
unknown committed
211 212
  libmysqld/libmysqld.a netware/libmysql.imp \
  zlib/.libs/libz.a
unknown's avatar
unknown committed
213

unknown's avatar
unknown committed
214
# convert the .a to .lib for NetWare
unknown's avatar
unknown committed
215 216 217 218 219 220
if [ $BASE_SYSTEM = "netware" ] ; then
    for i in $BASE/lib/*.a
    do
      libname=`basename $i .a`
      $MV $i $BASE/lib/$libname.lib
    done
unknown's avatar
unknown committed
221
    rm -f $BASE/lib/*.la
unknown's avatar
unknown committed
222 223
fi

unknown's avatar
unknown committed
224 225
copyfileto $BASE/include config.h include/*

unknown's avatar
unknown committed
226 227 228 229
rm -f $BASE/include/Makefile* $BASE/include/*.in $BASE/include/config-win.h
if [ $BASE_SYSTEM != "netware" ] ; then
  rm -f $BASE/include/config-netware.h
fi
unknown's avatar
unknown committed
230

231 232
if [ $BASE_SYSTEM != "netware" ] ; then
  if [ -d tests ] ; then
233
    $CP tests/*.res tests/*.tst tests/*.pl $BASE/tests
234 235 236
  fi
  if [ -d man ] ; then
    $CP man/*.1 $BASE/man/man1
unknown's avatar
unknown committed
237
    $CP man/*.8 $BASE/man/man8
238
  fi
unknown's avatar
unknown committed
239
fi
240

unknown's avatar
unknown committed
241 242 243
copyfileto $BASE/support-files support-files/*

copyfileto $BASE/share scripts/*.sql
244

unknown's avatar
unknown committed
245 246 247
$CP -r sql/share/* $MYSQL_SHARE
rm -f $MYSQL_SHARE/Makefile* $MYSQL_SHARE/*/*.OLD

unknown's avatar
unknown committed
248 249
copyfileto $BASE/mysql-test \
         mysql-test/mysql-test-run mysql-test/install_test_db \
unknown's avatar
unknown committed
250
         mysql-test/mysql-test-run.pl mysql-test/README \
251
	 mysql-test/valgrind.supp \
unknown's avatar
unknown committed
252
         netware/mysql_test_run.nlm netware/install_test_db.ncf
253

unknown's avatar
unknown committed
254
$CP mysql-test/lib/*.pl  $BASE/mysql-test/lib
unknown's avatar
unknown committed
255
$CP mysql-test/t/*.def $BASE/mysql-test/t
unknown's avatar
unknown committed
256
$CP mysql-test/include/*.inc $BASE/mysql-test/include
257
$CP mysql-test/include/*.test $BASE/mysql-test/include
258
$CP mysql-test/t/*.def $BASE/mysql-test/t
259
$CP mysql-test/std_data/*.dat mysql-test/std_data/*.frm \
260
    mysql-test/std_data/*.MYD mysql-test/std_data/*.MYI \
261 262
    mysql-test/std_data/*.pem mysql-test/std_data/Moscow_leap \
    mysql-test/std_data/des_key_file mysql-test/std_data/*.*001 \
263
    mysql-test/std_data/*.cnf mysql-test/std_data/*.MY* \
264
    $BASE/mysql-test/std_data
265 266
$CP mysql-test/t/*.test mysql-test/t/*.imtest \
    mysql-test/t/*.disabled mysql-test/t/*.opt \
267
    mysql-test/t/*.slave-mi mysql-test/t/*.sh mysql-test/t/*.sql $BASE/mysql-test/t
268
$CP mysql-test/r/*.result mysql-test/r/*.require \
269
    $BASE/mysql-test/r
unknown's avatar
unknown committed
270 271

if [ $BASE_SYSTEM != "netware" ] ; then
272
  chmod a+x $BASE/bin/*
unknown's avatar
unknown committed
273 274 275 276 277 278
  copyfileto $BASE/bin scripts/*
  $BASE/bin/replace \@localstatedir\@ ./data \@bindir\@ ./bin \@scriptdir\@ \
      ./bin \@libexecdir\@ ./bin \@sbindir\@ ./bin \@prefix\@ . \@HOSTNAME\@ \
      @HOSTNAME@ \@pkgdatadir\@ ./support-files \
      < scripts/mysql_install_db.sh > $BASE/scripts/mysql_install_db
  $BASE/bin/replace \@prefix\@ /usr/local/mysql \@bindir\@ ./bin \
unknown's avatar
Merge  
unknown committed
279 280
      \@sbindir\@ ./bin \@libexecdir\@ ./bin \
      \@MYSQLD_USER\@ @MYSQLD_USER@ \@localstatedir\@ /usr/local/mysql/data \
unknown's avatar
unknown committed
281 282
      \@HOSTNAME\@ @HOSTNAME@ \
      < support-files/mysql.server.sh > $BASE/support-files/mysql.server
unknown's avatar
unknown committed
283 284
  $BASE/bin/replace /my/gnu/bin/hostname /bin/hostname -- $BASE/bin/mysqld_safe
  mv $BASE/support-files/binary-configure $BASE/configure
unknown's avatar
unknown committed
285 286
  chmod a+x $BASE/bin/* $BASE/scripts/* $BASE/support-files/mysql-* \
      $BASE/support-files/mysql.server $BASE/configure
unknown's avatar
unknown committed
287 288
  $CP -r sql-bench/* $BASE/sql-bench
  rm -f $BASE/sql-bench/*.sh $BASE/sql-bench/Makefile* $BASE/lib/*.la
289
  rm -f $BASE/bin/*.sql
unknown's avatar
unknown committed
290
fi
unknown's avatar
unknown committed
291

unknown's avatar
unknown committed
292 293 294 295
rm -f $BASE/bin/Makefile* $BASE/bin/*.in $BASE/bin/*.sh \
    $BASE/bin/mysql_install_db $BASE/bin/make_binary_distribution \
    $BASE/bin/setsomevars $BASE/support-files/Makefile* \
    $BASE/support-files/*.sh
unknown's avatar
unknown committed
296

297 298 299 300
#
# Copy system dependent files
#
if [ $BASE_SYSTEM = "netware" ] ; then
unknown's avatar
unknown committed
301
  ./scripts/fill_help_tables < ./Docs/manual.texi >> ./netware/init_db.sql
302 303
fi

unknown's avatar
unknown committed
304 305 306 307
#
# Remove system dependent files
#
if [ $BASE_SYSTEM = "netware" ] ; then
308 309 310 311 312
  rm -f $BASE/support-files/magic \
        $BASE/support-files/mysql.server \
        $BASE/support-files/mysql*.spec \
        $BASE/support-files/mysql-log-rotate \
        $BASE/support-files/binary-configure \
unknown's avatar
unknown committed
313 314 315
        $BASE/support-files/build-tags \
	$BASE/support-files/MySQL-shared-compat.spec \
        $BASE/support-files/ndb-config-2-node.ini \
316
        $BASE/INSTALL-BINARY
unknown's avatar
unknown committed
317 318
fi

319
# Make safe_mysqld a symlink to mysqld_safe for backwards portability
unknown's avatar
unknown committed
320 321 322
if [ $BASE_SYSTEM != "netware" ] ; then
  (cd $BASE/bin ; ln -s mysqld_safe safe_mysqld )
fi
323

324
# Clean up if we did this from a bk tree
unknown's avatar
unknown committed
325 326 327
if [ -d $BASE/sql-bench/SCCS ] ; then
  find $BASE/share -name SCCS -print | xargs rm -rf
  find $BASE/sql-bench -name SCCS -print | xargs rm -rf
328 329
fi

unknown's avatar
unknown committed
330 331
# NDB Cluster
if [ x$NDBCLUSTER = x1 ]; then
332 333
  ( cd ndb            ; @MAKE@ DESTDIR=$BASE/ndb-stage install )
  ( cd mysql-test/ndb ; @MAKE@ DESTDIR=$BASE/ndb-stage install )
334 335 336
  $CP $BASE/ndb-stage@bindir@/* $BASE/bin/.
  $CP $BASE/ndb-stage@libexecdir@/* $BASE/bin/.
  $CP $BASE/ndb-stage@pkglibdir@/* $BASE/lib/.
unknown's avatar
unknown committed
337
  $CP $BASE/ndb-stage@pkgdatadir@/* $BASE/share/mysql/.
338
  $CP -r $BASE/ndb-stage@pkgincludedir@/ndb $BASE/include
339 340
  $CP -r $BASE/ndb-stage@prefix@/mysql-test/ndb $BASE/mysql-test/. || exit 1
  rm -rf $BASE/ndb-stage
unknown's avatar
unknown committed
341 342
fi

343
# Change the distribution to a long descriptive name
unknown's avatar
unknown committed
344
NEW_NAME=mysql@MYSQL_SERVER_SUFFIX@-$version-$platform$SUFFIX
unknown's avatar
unknown committed
345 346

# Print the platform name for build logs
unknown's avatar
unknown committed
347
echo "PLATFORM NAME: $platform"
unknown's avatar
unknown committed
348

unknown's avatar
unknown committed
349
BASE2=$TMP/$NEW_NAME
unknown's avatar
unknown committed
350
rm -rf $BASE2
unknown's avatar
unknown committed
351 352 353 354 355 356
mv $BASE $BASE2
BASE=$BASE2
#
# If we are compiling with gcc, copy libgcc.a to the distribution as libmygcc.a
#

unknown's avatar
unknown committed
357
if [ x"@GXX@" = x"yes" ] ; then
358
  gcclib=`@CC@ @CFLAGS@ --print-libgcc-file`
unknown's avatar
unknown committed
359
  if [ $? -ne 0 ] ; then
unknown's avatar
unknown committed
360
    echo "Warning: Couldn't find libgcc.a!"
unknown's avatar
unknown committed
361
  else
unknown's avatar
unknown committed
362
    $CP $gcclib $BASE/lib/libmygcc.a
unknown's avatar
unknown committed
363 364 365
  fi
fi

366 367 368 369 370
#if we are debugging, do not do tar/gz
if [ x$DEBUG = x1 ] ; then
 exit
fi

unknown's avatar
unknown committed
371 372 373
# This is needed to prefere gnu tar instead of tar because tar can't
# always handle long filenames

unknown's avatar
unknown committed
374 375 376
PATH_DIRS=`echo $PATH | \
    sed -e 's/^:/. /' -e 's/:$/ ./' -e 's/::/ . /g' -e 's/:/ /g' `

unknown's avatar
unknown committed
377 378 379 380 381 382 383 384
which_1 ()
{
  for cmd
  do
    for d in $PATH_DIRS
    do
      for file in $d/$cmd
      do
unknown's avatar
unknown committed
385
	if [ -x $file -a ! -d $file ] ; then
unknown's avatar
unknown committed
386 387 388 389 390 391 392 393 394
	  echo $file
	  exit 0
	fi
      done
    done
  done
  exit 1
}

unknown's avatar
unknown committed
395
if [ $BASE_SYSTEM != "netware" ] ; then
unknown's avatar
unknown committed
396 397 398 399

  #
  # Create the result tar file
  #
unknown's avatar
unknown committed
400

unknown's avatar
unknown committed
401
  tar=`which_1 gnutar gtar`
unknown's avatar
unknown committed
402
  if [ "$?" = "1" -o x"$tar" = x"" ] ; then
unknown's avatar
unknown committed
403 404
    tar=tar
  fi
unknown's avatar
unknown committed
405

unknown's avatar
unknown committed
406
  echo "Using $tar to create archive"
unknown's avatar
unknown committed
407

unknown's avatar
unknown committed
408 409 410 411
  OPT=cvf
  if [ x$SILENT = x1 ] ; then
    OPT=cf
  fi
unknown's avatar
unknown committed
412 413

  echo "Creating and compressing archive"
unknown's avatar
unknown committed
414
  rm -f $NEW_NAME.tar.gz
unknown's avatar
unknown committed
415
  (cd $TMP ; $tar $OPT -  $NEW_NAME) | gzip -9 > $NEW_NAME.tar.gz
unknown's avatar
unknown committed
416
  echo "$NEW_NAME.tar.gz created"
unknown's avatar
unknown committed
417

unknown's avatar
unknown committed
418
else
419

unknown's avatar
unknown committed
420 421 422
  #
  # Create a zip file for NetWare users
  #
423

unknown's avatar
unknown committed
424 425
  rm -f $NEW_NAME.zip
  (cd $TMP; zip -r "$SOURCE/$NEW_NAME.zip" $NEW_NAME)
unknown's avatar
unknown committed
426
  echo "$NEW_NAME.zip created"
unknown's avatar
unknown committed
427

unknown's avatar
unknown committed
428
fi
unknown's avatar
unknown committed
429

430
echo "Removing temporary directory"
unknown's avatar
unknown committed
431
rm -rf $BASE