make_binary_distribution.sh 5.67 KB
Newer Older
bk@work.mysql.com's avatar
bk@work.mysql.com committed
1 2 3 4 5 6 7 8 9 10 11
#!/bin/sh
# The default path should be /usr/local

# Get some info from configure
# chmod +x ./scripts/setsomevars

machine=@MACHINE_TYPE@
system=@SYSTEM_TYPE@
version=@VERSION@
export machine system version
SOURCE=`pwd` 
monty@donna.mysql.com's avatar
monty@donna.mysql.com committed
12
CP="cp -p"
bk@work.mysql.com's avatar
bk@work.mysql.com committed
13

14
STRIP=1
15
DEBUG=0
16
SILENT=0
bk@work.mysql.com's avatar
bk@work.mysql.com committed
17
TMP=/tmp
18 19
SUFFIX=""

20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
parse_arguments() {
  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 ;;
      --silent)   SILENT=1 ;;
      *)
	echo "Unknown argument '$arg'"
	exit 1
        ;;
    esac
  done
}

parse_arguments "$@"
37

bk@work.mysql.com's avatar
bk@work.mysql.com committed
38 39 40 41 42
#make

# This should really be integrated with automake and not duplicate the
# installation list.

43
BASE=$TMP/my_dist$SUFFIX
44 45

if [ -d $BASE ] ; then
46
 rm -r -f $BASE
47 48
fi

bk@work.mysql.com's avatar
bk@work.mysql.com committed
49 50
mkdir $BASE $BASE/bin $BASE/data $BASE/data/mysql $BASE/data/test \
 $BASE/include $BASE/lib $BASE/support-files $BASE/share $BASE/share/mysql \
51 52
 $BASE/tests $BASE/scripts $BASE/sql-bench $BASE/mysql-test \
 $BASE/mysql-test/t  $BASE/mysql-test/r \
53
 $BASE/mysql-test/include $BASE/mysql-test/std_data $BASE/man
54
 
bk@work.mysql.com's avatar
bk@work.mysql.com committed
55 56 57 58 59
chmod o-rwx $BASE/data $BASE/data/*

for i in sql/ChangeLog COPYING COPYING.LIB README Docs/INSTALL-BINARY \
         Docs/manual.html Docs/manual.txt Docs/manual_toc.html
do
monty@donna.mysql.com's avatar
monty@donna.mysql.com committed
60
  $CP $i $BASE
bk@work.mysql.com's avatar
bk@work.mysql.com committed
61 62 63
done

for i in extra/comp_err extra/replace extra/perror extra/resolveip \
64 65
  extra/my_print_defaults extra/resolve_stack_dump \
  isam/isamchk isam/pack_isam myisam/myisamchk \
66
  myisam/myisampack sql/mysqld sql/mysqlbinlog \
67
  client/mysql sql/mysqld client/mysqlshow client/mysqlcheck \
68
  client/mysqladmin client/mysqldump client/mysqlimport client/mysqltest \
monty@hundin.mysql.fi's avatar
monty@hundin.mysql.fi committed
69
  client/mysqlmanagerc client/mysqlmanager-pwgen tools/mysqlmanager \
70
  client/.libs/mysql client/.libs/mysqlshow client/.libs/mysqladmin \
71
  client/.libs/mysqldump client/.libs/mysqlimport client/.libs/mysqltest \
monty@hundin.mysql.fi's avatar
monty@hundin.mysql.fi committed
72
  client/.libs/mysqlcheck \
monty@hundin.mysql.fi's avatar
monty@hundin.mysql.fi committed
73
  client/.libs/mysqlmanagerc client/.libs/mysqlmanager-pwgen \
monty@hundin.mysql.fi's avatar
monty@hundin.mysql.fi committed
74
  tools/.libs/mysqlmanager
75 76 77
do
  if [ -f $i ]
  then
monty@donna.mysql.com's avatar
monty@donna.mysql.com committed
78
    $CP $i $BASE/bin
79 80
  fi
done
81 82 83 84

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

for i in sql/mysqld.sym.gz
87
do
88 89
  if [ -f $i ]
  then
monty@donna.mysql.com's avatar
monty@donna.mysql.com committed
90
    $CP $i $BASE/bin
91 92 93
  fi
done

94
for i in libmysql/.libs/libmysqlclient.a libmysql/.libs/libmysqlclient.so* libmysql/libmysqlclient.* libmysql_r/.libs/libmysqlclient_r.a libmysql_r/.libs/libmysqlclient_r.so* libmysql_r/libmysqlclient_r.* mysys/libmysys.a strings/libmystrings.a dbug/libdbug.a libmysqld/.libs/libmysqld.a libmysqld/.libs/libmysqld.so* libmysqld/libmysqld.a
bk@work.mysql.com's avatar
bk@work.mysql.com committed
95
do
96 97
  if [ -f $i ]
  then
monty@donna.mysql.com's avatar
monty@donna.mysql.com committed
98
    $CP $i $BASE/lib
99
   fi
bk@work.mysql.com's avatar
bk@work.mysql.com committed
100 101
done

monty@donna.mysql.com's avatar
monty@donna.mysql.com committed
102
$CP config.h include/* $BASE/include
bk@work.mysql.com's avatar
bk@work.mysql.com committed
103 104
rm $BASE/include/Makefile*; rm $BASE/include/*.in

monty@donna.mysql.com's avatar
monty@donna.mysql.com committed
105 106
$CP tests/*.res tests/*.tst tests/*.pl $BASE/tests
$CP support-files/* $BASE/support-files
107
$CP man/*.? $BASE/man
108

monty@donna.mysql.com's avatar
monty@donna.mysql.com committed
109
$CP -r sql/share/* $BASE/share/mysql
110 111
rm -f $BASE/share/mysql/Makefile* $BASE/share/mysql/*/*.OLD

monty@donna.mysql.com's avatar
monty@donna.mysql.com committed
112 113 114
$CP mysql-test/mysql-test-run mysql-test/install_test_db $BASE/mysql-test/
$CP mysql-test/README $BASE/mysql-test/README
$CP mysql-test/include/*.inc $BASE/mysql-test/include
monty@donna.mysql.fi's avatar
monty@donna.mysql.fi committed
115
$CP mysql-test/std_data/*.dat mysql-test/std_data/*.001 $BASE/mysql-test/std_data
116
$CP mysql-test/t/*.test mysql-test/t/*.opt mysql-test/t/*.sh $BASE/mysql-test/t
monty@donna.mysql.com's avatar
monty@donna.mysql.com committed
117
$CP mysql-test/r/*.result mysql-test/r/*.require $BASE/mysql-test/r
bk@work.mysql.com's avatar
bk@work.mysql.com committed
118

monty@donna.mysql.com's avatar
monty@donna.mysql.com committed
119
$CP scripts/* $BASE/bin
bk@work.mysql.com's avatar
bk@work.mysql.com committed
120 121
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

122
$BASE/bin/replace \@localstatedir\@ ./data \@bindir\@ ./bin \@scriptdir\@ ./bin \@libexecdir\@ ./bin \@sbindir\@ ./bin \@prefix\@ . \@HOSTNAME\@ @HOSTNAME@ < $SOURCE/scripts/mysql_install_db.sh > $BASE/scripts/mysql_install_db
bk@work.mysql.com's avatar
bk@work.mysql.com committed
123
$BASE/bin/replace \@prefix\@ /usr/local/mysql \@bindir\@ ./bin \@MYSQLD_USER\@ root \@localstatedir\@ /usr/local/mysql/data < $SOURCE/support-files/mysql.server.sh > $BASE/support-files/mysql.server
124
$BASE/bin/replace /my/gnu/bin/hostname /bin/hostname -- $BASE/bin/mysqld_safe
bk@work.mysql.com's avatar
bk@work.mysql.com committed
125 126 127

mv $BASE/support-files/binary-configure $BASE/configure
chmod a+x $BASE/bin/* $BASE/scripts/* $BASE/support-files/mysql-* $BASE/configure
monty@donna.mysql.com's avatar
monty@donna.mysql.com committed
128
$CP -r sql-bench/* $BASE/sql-bench
bk@work.mysql.com's avatar
bk@work.mysql.com committed
129 130
rm -f $BASE/sql-bench/*.sh $BASE/sql-bench/Makefile* $BASE/lib/*.la

131 132 133 134 135 136 137
# Clean up if we did this from a bk tree
if [ -d $BASE/sql-bench/SCCS ] ; then 
  find $BASE/share -name SCCS -print | xargs rm -r -f
  find $BASE/sql-bench -name SCCS -print | xargs rm -r -f
fi

# Change the distribution to a long descriptive name
138
NEW_NAME=mysql@MYSQL_SERVER_SUFFIX@-$version-$system-$machine$SUFFIX
bk@work.mysql.com's avatar
bk@work.mysql.com committed
139
BASE2=$TMP/$NEW_NAME
140
rm -r -f $BASE2
bk@work.mysql.com's avatar
bk@work.mysql.com committed
141 142 143 144 145 146 147 148 149 150 151 152 153 154
mv $BASE $BASE2
BASE=$BASE2
#
# If we are compiling with gcc, copy libgcc.a to the distribution as libmygcc.a
#

if test "@GXX@" = "yes"
then
  cd $BASE/lib
  gcclib=`@CC@ --print-libgcc-file`
  if test $? -ne 0
  then
    print "Warning: Couldn't find libgcc.a!"
  else
monty@donna.mysql.com's avatar
monty@donna.mysql.com committed
155
    $CP $gcclib libmygcc.a
bk@work.mysql.com's avatar
bk@work.mysql.com committed
156 157 158 159
  fi
  cd $SOURCE
fi

160 161 162 163 164
#if we are debugging, do not do tar/gz
if [ x$DEBUG = x1 ] ; then
 exit
fi

bk@work.mysql.com's avatar
bk@work.mysql.com committed
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
# This is needed to prefere gnu tar instead of tar because tar can't
# always handle long filenames

PATH_DIRS=`echo $PATH | sed -e 's/^:/. /' -e 's/:$/ ./' -e 's/::/ . /g' -e 's/:/ /g' `
which_1 ()
{
  for cmd
  do
    for d in $PATH_DIRS
    do
      for file in $d/$cmd
      do
	if test -x $file -a ! -d $file
	then
	  echo $file
	  exit 0
	fi
      done
    done
  done
  exit 1
}

#
# Create the result tar file
#

tar=`which_1 gtar`
if test "$?" = "1" -o "$tar" = ""
then
  tar=tar
fi

echo "Using $tar to create archive"
cd $TMP
200 201 202 203 204 205 206

OPT=cvf
if [ x$SILENT = x1 ] ; then
  OPT=cf
fi

$tar $OPT $SOURCE/$NEW_NAME.tar $NEW_NAME
bk@work.mysql.com's avatar
bk@work.mysql.com committed
207 208 209 210
cd $SOURCE
echo "Compressing archive"
gzip -9 $NEW_NAME.tar
echo "Removing temporary directory"
211
rm -r -f $BASE
bk@work.mysql.com's avatar
bk@work.mysql.com committed
212 213

echo "$NEW_NAME.tar.gz created"