home *** CD-ROM | disk | FTP | other *** search
/ Internet Magazine 2003 Autumn / INTERNET109.ISO / pc / software / windows / building / mysql / data1.cab / Development / scripts / make_binary_distribution.sh < prev    next >
Encoding:
Linux/UNIX/POSIX Shell Script  |  2003-08-03  |  7.8 KB  |  311 lines

  1. #!/bin/sh
  2. # The default path should be /usr/local
  3.  
  4. # Get some info from configure
  5. # chmod +x ./scripts/setsomevars
  6.  
  7. machine=@MACHINE_TYPE@
  8. system=@SYSTEM_TYPE@
  9. version=@VERSION@
  10. export machine system version
  11. SOURCE=`pwd` 
  12. CP="cp -p"
  13. MV="mv"
  14.  
  15. STRIP=1
  16. DEBUG=0
  17. SILENT=0
  18. TMP=/tmp
  19. SUFFIX=""
  20.  
  21. parse_arguments() {
  22.   for arg do
  23.     case "$arg" in
  24.       --debug)    DEBUG=1;;
  25.       --tmp=*)    TMP=`echo "$arg" | sed -e "s;--tmp=;;"` ;;
  26.       --suffix=*) SUFFIX=`echo "$arg" | sed -e "s;--suffix=;;"` ;;
  27.       --no-strip) STRIP=0 ;;
  28.       --silent)   SILENT=1 ;;
  29.       *)
  30.     echo "Unknown argument '$arg'"
  31.     exit 1
  32.         ;;
  33.     esac
  34.   done
  35. }
  36.  
  37. parse_arguments "$@"
  38.  
  39. #make
  40.  
  41. # This should really be integrated with automake and not duplicate the
  42. # installation list.
  43.  
  44. BASE=$TMP/my_dist$SUFFIX
  45.  
  46. if [ -d $BASE ] ; then
  47.  rm -r -f $BASE
  48. fi
  49.  
  50. BS=""
  51. BIN_FILES=""
  52. BASE_SYSTEM="any"
  53. MYSQL_SHARE=$BASE/share/mysql
  54.  
  55. case $system in
  56.   *netware*)
  57.     BASE_SYSTEM="netware"
  58.     BS=".nlm"
  59.     MYSQL_SHARE=$BASE/share
  60.     ;;
  61. esac
  62.  
  63.  
  64. mkdir $BASE $BASE/bin \
  65.  $BASE/include $BASE/lib $BASE/support-files $BASE/share $BASE/scripts \
  66.  $BASE/mysql-test $BASE/mysql-test/t  $BASE/mysql-test/r \
  67.  $BASE/mysql-test/include $BASE/mysql-test/std_data
  68.  
  69. if [ $BASE_SYSTEM != "netware" ] ; then
  70.  mkdir $BASE/share/mysql $BASE/tests $BASE/sql-bench $BASE/man \
  71.   $BASE/man/man1 $BASE/data $BASE/data/mysql $BASE/data/test
  72.  
  73.  chmod o-rwx $BASE/data $BASE/data/*
  74. fi
  75.  
  76. for i in ChangeLog COPYING COPYING.LIB README Docs/INSTALL-BINARY \
  77.          MySQLEULA.txt Docs/manual.html Docs/manual.txt Docs/manual_toc.html \
  78.          LICENSE.doc README.NW Docs/mysqlbug.txt
  79. do
  80.   if [ -f $i ]
  81.   then
  82.     $CP $i $BASE
  83.   fi
  84. done
  85.  
  86. # Non platform-specific bin dir files:
  87. BIN_FILES="extra/comp_err$BS extra/replace$BS extra/perror$BS \
  88.   extra/resolveip$BS extra/my_print_defaults$BS \
  89.   extra/resolve_stack_dump$BS extra/mysql_waitpid$BS \
  90.   isam/isamchk$BS isam/pack_isam$BS \
  91.   myisam/myisamchk$BS myisam/myisampack$BS myisam/myisamlog$BS \
  92.   sql/mysqld$BS \
  93.   client/mysql$BS client/mysqlshow$BS client/mysqladmin$BS \
  94.   client/mysqldump$BS client/mysqlimport$BS \
  95.   client/mysqltest$BS client/mysqlcheck$BS \
  96.   client/mysqlbinlog$BS 
  97. ";
  98.  
  99. # Platform-specific bin dir files:
  100. if [ $BASE_SYSTEM = "netware" ] ; then
  101.   BIN_FILES="$BIN_FILES \
  102.     netware/mysqld_safe$BS netware/mysql_install_db$BS \
  103.     netware/init_db.sql netware/test_db.sql netware/mysql_explain_log$BS \
  104.     netware/mysqlhotcopy$BS netware/libmysql$BS netware/init_secure_db.sql
  105.     ";
  106. else
  107.   # For all other platforms:
  108.   BIN_FILES="$BIN_FILES \
  109.     client/mysqlmanagerc \
  110.     client/mysqlmanager-pwgen tools/mysqlmanager \
  111.     client/.libs/mysql client/.libs/mysqlshow client/.libs/mysqladmin \
  112.     client/.libs/mysqldump client/.libs/mysqlimport \
  113.     client/.libs/mysqltest client/.libs/mysqlcheck \
  114.     client/.libs/mysqlbinlog client/.libs/mysqlmanagerc \
  115.     client/.libs/mysqlmanager-pwgen tools/.libs/mysqlmanager \
  116.   ";
  117. fi
  118.  
  119. for i in $BIN_FILES
  120. do
  121.   if [ -f $i ]
  122.   then
  123.     $CP $i $BASE/bin
  124.   fi
  125. done
  126.  
  127. if [ x$STRIP = x1 ] ; then
  128.   strip $BASE/bin/*
  129. fi
  130.  
  131. # Copy not binary files
  132. for i in sql/mysqld.sym.gz
  133. do
  134.   if [ -f $i ]
  135.   then
  136.     $CP $i $BASE/bin
  137.   fi
  138. done
  139.  
  140. if [ $BASE_SYSTEM = "netware" ] ; then
  141.     $CP -r netware/*.pl $BASE/scripts
  142. fi
  143.  
  144. for i in \
  145.   libmysql/.libs/libmysqlclient.a libmysql/.libs/libmysqlclient.so* \
  146.   libmysql/libmysqlclient.* libmysql_r/.libs/libmysqlclient_r.a \
  147.   libmysql_r/.libs/libmysqlclient_r.so* libmysql_r/libmysqlclient_r.* \
  148.   mysys/libmysys.a strings/libmystrings.a dbug/libdbug.a \
  149.   libmysqld/.libs/libmysqld.a libmysqld/.libs/libmysqld.so* \
  150.   libmysqld/libmysqld.a netware/libmysql.imp
  151. do
  152.   if [ -f $i ]
  153.   then
  154.     $CP $i $BASE/lib
  155.    fi
  156. done
  157.  
  158. # convert the libs to .lib for NetWare
  159. if [ $BASE_SYSTEM = "netware" ] ; then
  160.     for i in $BASE/lib/*.a
  161.     do
  162.       libname=`basename $i .a`
  163.       $MV $i $BASE/lib/$libname.lib
  164.     done
  165. fi
  166.  
  167. $CP config.h include/* $BASE/include
  168. rm -f $BASE/include/Makefile* $BASE/include/*.in $BASE/include/config-win.h
  169. if [ $BASE_SYSTEM != "netware" ] ; then
  170.   rm -f $BASE/include/config-netware.h
  171. fi
  172.  
  173. if [ $BASE_SYSTEM != "netware" ] ; then
  174.   if [ -d tests ] ; then
  175.     $CP tests/*.res tests/*.tst tests/*.pl $BASE/tests
  176.   fi
  177.   if [ -d man ] ; then
  178.     $CP man/*.1 $BASE/man/man1
  179.   fi
  180. fi
  181.  
  182. $CP support-files/* $BASE/support-files
  183.  
  184. if [ $BASE_SYSTEM = "netware" ] ; then
  185.   rm -f $BASE/support-files/magic \
  186.         $BASE/support-files/mysql.server \
  187.         $BASE/support-files/mysql*.spec \
  188.         $BASE/support-files/mysql-log-rotate \
  189.         $BASE/support-files/binary-configure
  190. fi
  191.  
  192. $CP -r sql/share/* $MYSQL_SHARE
  193. rm -f $MYSQL_SHARE/Makefile* $MYSQL_SHARE/*/*.OLD
  194.  
  195. for i in mysql-test/mysql-test-run mysql-test/install_test_db \
  196.          mysql-test/README \
  197.          netware/mysql_test_run.nlm netware/install_test_db.ncf
  198. do
  199.   if [ -f $i ]
  200.   then
  201.     $CP $i $BASE/mysql-test
  202.    fi
  203. done
  204.  
  205. $CP mysql-test/include/*.inc $BASE/mysql-test/include
  206. $CP mysql-test/std_data/*.dat mysql-test/std_data/*.001 $BASE/mysql-test/std_data
  207. $CP mysql-test/std_data/des_key_file $BASE/mysql-test/std_data
  208. $CP mysql-test/t/*test mysql-test/t/*.opt mysql-test/t/*.slave-mi mysql-test/t/*.sh $BASE/mysql-test/t
  209. $CP mysql-test/r/*result mysql-test/r/*.require $BASE/mysql-test/r
  210.  
  211. if [ $BASE_SYSTEM != "netware" ] ; then
  212.   $CP scripts/* $BASE/bin
  213.   $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
  214.   $BASE/bin/replace \@prefix\@ /usr/local/mysql \@bindir\@ ./bin \@MYSQLD_USER\@ root \@localstatedir\@ /usr/local/mysql/data \@HOSTNAME\@ @HOSTNAME@ < $SOURCE/support-files/mysql.server.sh > $BASE/support-files/mysql.server
  215.   $BASE/bin/replace /my/gnu/bin/hostname /bin/hostname -- $BASE/bin/mysqld_safe
  216.   mv $BASE/support-files/binary-configure $BASE/configure
  217.   chmod a+x $BASE/bin/* $BASE/scripts/* $BASE/support-files/mysql-* $BASE/support-files/mysql.server $BASE/configure
  218.   $CP -r sql-bench/* $BASE/sql-bench
  219.   rm -f $BASE/sql-bench/*.sh $BASE/sql-bench/Makefile* $BASE/lib/*.la
  220. fi
  221.  
  222. 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
  223.  
  224. # Make safe_mysqld a symlink to mysqld_safe for backwards portability
  225. # To be removed in MySQL 4.1
  226. (cd $BASE/bin ; ln -s mysqld_safe safe_mysqld )
  227.  
  228. # Clean up if we did this from a bk tree
  229. if [ -d $BASE/sql-bench/SCCS ] ; then 
  230.   find $BASE/share -name SCCS -print | xargs rm -r -f
  231.   find $BASE/sql-bench -name SCCS -print | xargs rm -r -f
  232. fi
  233.  
  234. # Change the distribution to a long descriptive name
  235. NEW_NAME=mysql@MYSQL_SERVER_SUFFIX@-$version-$system-$machine$SUFFIX
  236. BASE2=$TMP/$NEW_NAME
  237. rm -r -f $BASE2
  238. mv $BASE $BASE2
  239. BASE=$BASE2
  240. #
  241. # If we are compiling with gcc, copy libgcc.a to the distribution as libmygcc.a
  242. #
  243.  
  244. if test "@GXX@" = "yes"
  245. then
  246.   cd $BASE/lib
  247.   gcclib=`@CC@ --print-libgcc-file`
  248.   if test $? -ne 0
  249.   then
  250.     print "Warning: Couldn't find libgcc.a!"
  251.   else
  252.     $CP $gcclib libmygcc.a
  253.   fi
  254.   cd $SOURCE
  255. fi
  256.  
  257. #if we are debugging, do not do tar/gz
  258. if [ x$DEBUG = x1 ] ; then
  259.  exit
  260. fi
  261.  
  262. # This is needed to prefere gnu tar instead of tar because tar can't
  263. # always handle long filenames
  264.  
  265. PATH_DIRS=`echo $PATH | sed -e 's/^:/. /' -e 's/:$/ ./' -e 's/::/ . /g' -e 's/:/ /g' `
  266. which_1 ()
  267. {
  268.   for cmd
  269.   do
  270.     for d in $PATH_DIRS
  271.     do
  272.       for file in $d/$cmd
  273.       do
  274.     if test -x $file -a ! -d $file
  275.     then
  276.       echo $file
  277.       exit 0
  278.     fi
  279.       done
  280.     done
  281.   done
  282.   exit 1
  283. }
  284.  
  285. #
  286. # Create the result tar file
  287. #
  288.  
  289. tar=`which_1 gnutar gtar`
  290. if test "$?" = "1" -o "$tar" = ""
  291. then
  292.   tar=tar
  293. fi
  294.  
  295. echo "Using $tar to create archive"
  296. cd $TMP
  297.  
  298. OPT=cvf
  299. if [ x$SILENT = x1 ] ; then
  300.   OPT=cf
  301. fi
  302.  
  303. $tar $OPT $SOURCE/$NEW_NAME.tar $NEW_NAME
  304. cd $SOURCE
  305. echo "Compressing archive"
  306. gzip -9 $NEW_NAME.tar
  307. echo "Removing temporary directory"
  308. rm -r -f $BASE
  309.  
  310. echo "$NEW_NAME.tar.gz created"
  311.