~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to scripts/make_binary_distribution.sh

  • Committer: Brian Aker
  • Date: 2008-07-08 21:36:11 UTC
  • mfrom: (77.1.34 codestyle)
  • Revision ID: brian@tangent.org-20080708213611-b0k2zy8eldttqct3
Merging up Monty's changes

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/bin/sh
2
 
# Copyright (C) 2000-2006 MySQL AB
3
 
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.
7
 
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.
12
 
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
16
 
 
17
 
##############################################################################
18
 
#
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}"
22
 
#
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.
28
 
#
29
 
#  In GNU make/automake terms
30
 
#
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"
37
 
#
38
 
#  The temporary directory path given to "--tmp=<path>" has to be
39
 
#  absolute and with no spaces.
40
 
#
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.
44
 
#
45
 
##############################################################################
46
 
 
47
 
##############################################################################
48
 
#
49
 
#  Read the command line arguments that control this script
50
 
#
51
 
##############################################################################
52
 
 
53
 
machine=@MACHINE_TYPE@
54
 
system=@SYSTEM_TYPE@
55
 
SOURCE=`pwd`
56
 
CP="cp -p"
57
 
MV="mv"
58
 
 
59
 
STRIP=1                         # Option ignored
60
 
SILENT=0
61
 
PLATFORM=""
62
 
TMP=/tmp
63
 
SUFFIX=""
64
 
NDBCLUSTER=""                   # Option ignored
65
 
 
66
 
for arg do
67
 
  case "$arg" in
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=;;"` ;;
73
 
    --silent)   SILENT=1 ;;
74
 
    --with-ndbcluster) NDBCLUSTER=1 ;;
75
 
    *)
76
 
      echo "Unknown argument '$arg'"
77
 
      exit 1
78
 
      ;;
79
 
  esac
80
 
done
81
 
 
82
 
# ----------------------------------------------------------------------
83
 
# Adjust "system" output from "uname" to be more human readable
84
 
# ----------------------------------------------------------------------
85
 
 
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'`
90
 
 
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'`
103
 
 
104
 
  PLATFORM="$system-$machine"
105
 
fi
106
 
 
107
 
# Print the platform name for build logs
108
 
echo "PLATFORM NAME: $PLATFORM"
109
 
 
110
 
case $PLATFORM in
111
 
  *netware*) BASE_SYSTEM="netware" ;;
112
 
esac
113
 
 
114
 
# Change the distribution to a long descriptive name
115
 
NEW_NAME=mysql@MYSQL_SERVER_SUFFIX@-@VERSION@-$PLATFORM$SUFFIX
116
 
 
117
 
# ----------------------------------------------------------------------
118
 
# Define BASE, and remove the old BASE directory if any
119
 
# ----------------------------------------------------------------------
120
 
BASE=$TMP/my_dist$SUFFIX
121
 
if [ -d $BASE ] ; then
122
 
 rm -rf $BASE
123
 
fi
124
 
 
125
 
# ----------------------------------------------------------------------
126
 
# Find the TAR to use
127
 
# ----------------------------------------------------------------------
128
 
 
129
 
# This is needed to prefer GNU tar over platform tar because that can't
130
 
# always handle long filenames
131
 
 
132
 
PATH_DIRS=`echo $PATH | \
133
 
    sed -e 's/^:/. /' -e 's/:$/ ./' -e 's/::/ . /g' -e 's/:/ /g' `
134
 
 
135
 
which_1 ()
136
 
{
137
 
  for cmd
138
 
  do
139
 
    for d in $PATH_DIRS
140
 
    do
141
 
      for file in $d/$cmd
142
 
      do
143
 
        if [ -x $file -a ! -d $file ] ; then
144
 
          echo $file
145
 
          exit 0
146
 
        fi
147
 
      done
148
 
    done
149
 
  done
150
 
  exit 1
151
 
}
152
 
 
153
 
tar=`which_1 gnutar gtar`
154
 
if [ $? -ne 0 -o x"$tar" = x"" ] ; then
155
 
  tar=tar
156
 
fi
157
 
 
158
 
 
159
 
##############################################################################
160
 
#
161
 
#  Handle the Unix/Linux packaging using "make install"
162
 
#
163
 
##############################################################################
164
 
 
165
 
if [ x"$BASE_SYSTEM" != x"netware" ] ; then
166
 
 
167
 
  # ----------------------------------------------------------------------
168
 
  # Terminate on any base level error
169
 
  # ----------------------------------------------------------------------
170
 
  set -e
171
 
 
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
 
  # ----------------------------------------------------------------------
178
 
 
179
 
  cd scripts
180
 
  rm -f mysql_install_db
181
 
  @MAKE@ mysql_install_db \
182
 
    prefix=. \
183
 
    bindir=./bin \
184
 
    sbindir=./bin \
185
 
    scriptdir=./bin \
186
 
    libexecdir=./bin \
187
 
    pkgdatadir=./share \
188
 
    localstatedir=./data
189
 
  cd ..
190
 
 
191
 
  cd support-files
192
 
  rm -f mysql.server
193
 
  @MAKE@ mysql.server \
194
 
    bindir=./bin \
195
 
    sbindir=./bin \
196
 
    scriptdir=./bin \
197
 
    libexecdir=./bin \
198
 
    pkgdatadir=@pkgdatadir@
199
 
  cd ..
200
 
 
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@ \
211
 
    mandir=@mandir@ \
212
 
    infodir=@infodir@
213
 
 
214
 
  # ----------------------------------------------------------------------
215
 
  # Rename top directory, and set DEST to the new directory
216
 
  # ----------------------------------------------------------------------
217
 
  mv $BASE@prefix@ $BASE/$NEW_NAME
218
 
  DEST=$BASE/$NEW_NAME
219
 
 
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
229
 
    else
230
 
      echo "Warning: Compiler result '$gcclib' not found / no file!"
231
 
    fi
232
 
  fi
233
 
 
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
236
 
  mkdir $DEST/scripts
237
 
  mv $DEST/bin/mysql_install_db $DEST/scripts/
238
 
 
239
 
  # Note, no legacy "safe_mysqld" link to "mysqld_safe" in 5.1
240
 
 
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/
247
 
  else
248
 
    echo "ERROR: no license files found"
249
 
    exit 1
250
 
  fi
251
 
 
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/
256
 
 
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
260
 
 
261
 
  # FIXME mysqld-debug is handled seperately (see phase_save_server() in
262
 
  # Do-compile)
263
 
  if [ -f sql/mysqld-debug ] ; then
264
 
    cp sql/mysqld-debug $DEST/bin/
265
 
  fi
266
 
 
267
 
  # ----------------------------------------------------------------------
268
 
  # Create the result tar file
269
 
  # ----------------------------------------------------------------------
270
 
 
271
 
  echo "Using $tar to create archive"
272
 
  OPT=cvf
273
 
  if [ x$SILENT = x1 ] ; then
274
 
    OPT=cf
275
 
  fi
276
 
 
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"
281
 
 
282
 
  echo "Removing temporary directory"
283
 
  rm -rf $BASE
284
 
  exit 0
285
 
fi
286
 
 
287
 
 
288
 
##############################################################################
289
 
#
290
 
#  Handle the Netware case, until integrated above
291
 
#
292
 
##############################################################################
293
 
 
294
 
BS=".nlm"
295
 
MYSQL_SHARE=$BASE/share
296
 
 
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
302
 
 
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
308
 
# binary file.
309
 
copyfileto()
310
 
{
311
 
  destdir=$1
312
 
  shift
313
 
  for i
314
 
  do
315
 
    if [ -f $i ] ; then
316
 
      $CP $i $destdir
317
 
    elif [ -d $i ] ; then
318
 
      echo "Warning: Will not copy directory \"$i\""
319
 
    else
320
 
      echo "Warning: Listed file not found   \"$i\""
321
 
    fi
322
 
  done
323
 
}
324
 
 
325
 
copyfileto $BASE/docs ChangeLog Docs/mysql.info
326
 
 
327
 
copyfileto $BASE COPYING COPYING.LIB README Docs/INSTALL-BINARY \
328
 
         EXCEPTIONS-CLIENT LICENSE.mysql
329
 
 
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 \
346
 
  ";
347
 
 
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 \
353
 
    ";
354
 
 
355
 
copyfileto $BASE/bin $BIN_FILES
356
 
 
357
 
$CP netware/*.pl $BASE/scripts
358
 
$CP scripts/mysqlhotcopy $BASE/scripts/mysqlhotcopy.pl
359
 
 
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 \
377
 
  zlib/.libs/libz.a
378
 
 
379
 
# convert the .a to .lib for NetWare
380
 
for i in $BASE/lib/*.a
381
 
do
382
 
  libname=`basename $i .a`
383
 
  $MV $i $BASE/lib/$libname.lib
384
 
done
385
 
rm -f $BASE/lib/*.la
386
 
 
387
 
 
388
 
copyfileto $BASE/include config.h include/*
389
 
 
390
 
rm -f $BASE/include/Makefile* $BASE/include/*.in $BASE/include/config-win.h
391
 
 
392
 
copyfileto $BASE/support-files support-files/*
393
 
 
394
 
copyfileto $BASE/share scripts/*.sql
395
 
 
396
 
$CP -r sql/share/* $MYSQL_SHARE
397
 
rm -f $MYSQL_SHARE/Makefile* $MYSQL_SHARE/*/*.OLD
398
 
 
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
405
 
 
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 \
423
 
    $BASE/mysql-test/r
424
 
 
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
430
 
fi
431
 
 
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
436
 
 
437
 
#
438
 
# Copy system dependent files
439
 
#
440
 
./scripts/fill_help_tables < ./Docs/manual.texi >> ./netware/init_db.sql
441
 
 
442
 
#
443
 
# Remove system dependent files
444
 
#
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 \
452
 
        $BASE/INSTALL-BINARY
453
 
 
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
458
 
fi
459
 
 
460
 
BASE2=$TMP/$NEW_NAME
461
 
rm -rf $BASE2
462
 
mv $BASE $BASE2
463
 
BASE=$BASE2
464
 
 
465
 
#
466
 
# Create a zip file for NetWare users
467
 
#
468
 
rm -f $NEW_NAME.zip
469
 
(cd $TMP; zip -r "$SOURCE/$NEW_NAME.zip" $NEW_NAME)
470
 
echo "$NEW_NAME.zip created"
471
 
 
472
 
echo "Removing temporary directory"
473
 
rm -rf $BASE