home *** CD-ROM | disk | FTP | other *** search
/ Internet Magazine 2004 July / INTERNET119.ISO / pc / software / windows / building / mysql / data1.cab / Development / scripts / make_binary_distribution.sh < prev    next >
Encoding:
Linux/UNIX/POSIX Shell Script  |  2004-02-11  |  7.9 KB  |  323 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 $BASE/docs \
  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 \
  77.          Docs/manual.html \
  78.          Docs/manual.txt \
  79.          Docs/manual_toc.html \
  80.                  Docs/mysql.info
  81. do
  82.   if [ -f $i ]
  83.   then
  84.     $CP $i $BASE/docs
  85.   fi
  86. done
  87.  
  88. for i in COPYING README Docs/INSTALL-BINARY \
  89.          MySQLEULA.txt LICENSE.doc README.NW 
  90. do
  91.   if [ -f $i ]
  92.   then
  93.     $CP $i $BASE
  94.   fi
  95. done
  96.  
  97. # Non platform-specific bin dir files:
  98. BIN_FILES="extra/comp_err$BS extra/replace$BS extra/perror$BS \
  99.   extra/resolveip$BS extra/my_print_defaults$BS \
  100.   extra/resolve_stack_dump$BS extra/mysql_waitpid$BS \
  101.   isam/isamchk$BS isam/pack_isam$BS \
  102.   myisam/myisamchk$BS myisam/myisampack$BS myisam/myisamlog$BS \
  103.   myisam/myisam_ftdump$BS \
  104.   sql/mysqld$BS \
  105.   client/mysql$BS client/mysqlshow$BS client/mysqladmin$BS \
  106.   client/mysqldump$BS client/mysqlimport$BS \
  107.   client/mysqltest$BS client/mysqlcheck$BS \
  108.   client/mysqlbinlog$BS 
  109. ";
  110.  
  111. # Platform-specific bin dir files:
  112. if [ $BASE_SYSTEM = "netware" ] ; then
  113.   BIN_FILES="$BIN_FILES \
  114.     netware/mysqld_safe$BS netware/mysql_install_db$BS \
  115.     netware/init_db.sql netware/test_db.sql netware/mysql_explain_log$BS \
  116.     netware/mysqlhotcopy$BS netware/libmysql$BS netware/init_secure_db.sql
  117.     ";
  118. else
  119.   # For all other platforms:
  120.   BIN_FILES="$BIN_FILES \
  121.     client/mysqlmanagerc \
  122.     client/mysqlmanager-pwgen tools/mysqlmanager \
  123.     client/.libs/mysql client/.libs/mysqlshow client/.libs/mysqladmin \
  124.     client/.libs/mysqldump client/.libs/mysqlimport \
  125.     client/.libs/mysqltest client/.libs/mysqlcheck \
  126.     client/.libs/mysqlbinlog client/.libs/mysqlmanagerc \
  127.     client/.libs/mysqlmanager-pwgen tools/.libs/mysqlmanager \
  128.   ";
  129. fi
  130.  
  131. for i in $BIN_FILES
  132. do
  133.   if [ -f $i ]
  134.   then
  135.     $CP $i $BASE/bin
  136.   fi
  137. done
  138.  
  139. if [ x$STRIP = x1 ] ; then
  140.   strip $BASE/bin/*
  141. fi
  142.  
  143. # Copy not binary files
  144. for i in sql/mysqld.sym.gz
  145. do
  146.   if [ -f $i ]
  147.   then
  148.     $CP $i $BASE/bin
  149.   fi
  150. done
  151.  
  152. if [ $BASE_SYSTEM = "netware" ] ; then
  153.     $CP -r netware/*.pl $BASE/scripts
  154. fi
  155.  
  156. for i in \
  157.   libmysql/.libs/libmysqlclient.a libmysql/.libs/libmysqlclient.so* \
  158.   libmysql/libmysqlclient.* libmysql_r/.libs/libmysqlclient_r.a \
  159.   libmysql_r/.libs/libmysqlclient_r.so* libmysql_r/libmysqlclient_r.* \
  160.   mysys/libmysys.a strings/libmystrings.a dbug/libdbug.a \
  161.   libmysqld/.libs/libmysqld.a libmysqld/.libs/libmysqld.so* \
  162.   libmysqld/libmysqld.a netware/libmysql.imp
  163. do
  164.   if [ -f $i ]
  165.   then
  166.     $CP $i $BASE/lib
  167.    fi
  168. done
  169.  
  170. # convert the libs to .lib for NetWare
  171. if [ $BASE_SYSTEM = "netware" ] ; then
  172.     for i in $BASE/lib/*.a
  173.     do
  174.       libname=`basename $i .a`
  175.       $MV $i $BASE/lib/$libname.lib
  176.     done
  177. fi
  178.  
  179. $CP config.h include/* $BASE/include
  180. rm -f $BASE/include/Makefile* $BASE/include/*.in $BASE/include/config-win.h
  181. if [ $BASE_SYSTEM != "netware" ] ; then
  182.   rm -f $BASE/include/config-netware.h
  183. fi
  184.  
  185. if [ $BASE_SYSTEM != "netware" ] ; then
  186.   if [ -d tests ] ; then
  187.     $CP tests/*.res tests/*.tst tests/*.pl $BASE/tests
  188.   fi
  189.   if [ -d man ] ; then
  190.     $CP man/*.1 $BASE/man/man1
  191.   fi
  192. fi
  193.  
  194. $CP support-files/* $BASE/support-files
  195.  
  196. if [ $BASE_SYSTEM = "netware" ] ; then
  197.   rm -f $BASE/support-files/magic \
  198.         $BASE/support-files/mysql.server \
  199.         $BASE/support-files/mysql*.spec \
  200.         $BASE/support-files/mysql-log-rotate \
  201.         $BASE/support-files/binary-configure
  202. fi
  203.  
  204. $CP -r sql/share/* $MYSQL_SHARE
  205. rm -f $MYSQL_SHARE/Makefile* $MYSQL_SHARE/*/*.OLD
  206.  
  207. for i in mysql-test/mysql-test-run mysql-test/install_test_db \
  208.          mysql-test/README \
  209.          netware/mysql_test_run.nlm netware/install_test_db.ncf
  210. do
  211.   if [ -f $i ]
  212.   then
  213.     $CP $i $BASE/mysql-test
  214.    fi
  215. done
  216.  
  217. $CP mysql-test/include/*.inc $BASE/mysql-test/include
  218. $CP mysql-test/std_data/*.dat mysql-test/std_data/*.001 $BASE/mysql-test/std_data
  219. $CP mysql-test/std_data/des_key_file $BASE/mysql-test/std_data
  220. $CP mysql-test/t/*test mysql-test/t/*.opt mysql-test/t/*.slave-mi mysql-test/t/*.sh $BASE/mysql-test/t
  221. $CP mysql-test/r/*result mysql-test/r/*.require $BASE/mysql-test/r
  222.  
  223. if [ $BASE_SYSTEM != "netware" ] ; then
  224.   $CP scripts/* $BASE/bin
  225.   $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
  226.   $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
  227.   $BASE/bin/replace /my/gnu/bin/hostname /bin/hostname -- $BASE/bin/mysqld_safe
  228.   mv $BASE/support-files/binary-configure $BASE/configure
  229.   chmod a+x $BASE/bin/* $BASE/scripts/* $BASE/support-files/mysql-* $BASE/support-files/mysql.server $BASE/configure
  230.   $CP -r sql-bench/* $BASE/sql-bench
  231.   rm -f $BASE/sql-bench/*.sh $BASE/sql-bench/Makefile* $BASE/lib/*.la
  232. fi
  233.  
  234. 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
  235.  
  236. # Make safe_mysqld a symlink to mysqld_safe for backwards portability
  237. # To be removed in MySQL 4.1
  238. (cd $BASE/bin ; ln -s mysqld_safe safe_mysqld )
  239.  
  240. # Clean up if we did this from a bk tree
  241. if [ -d $BASE/sql-bench/SCCS ] ; then 
  242.   find $BASE/share -name SCCS -print | xargs rm -r -f
  243.   find $BASE/sql-bench -name SCCS -print | xargs rm -r -f
  244. fi
  245.  
  246. # Change the distribution to a long descriptive name
  247. NEW_NAME=mysql@MYSQL_SERVER_SUFFIX@-$version-$system-$machine$SUFFIX
  248. BASE2=$TMP/$NEW_NAME
  249. rm -r -f $BASE2
  250. mv $BASE $BASE2
  251. BASE=$BASE2
  252. #
  253. # If we are compiling with gcc, copy libgcc.a to the distribution as libmygcc.a
  254. #
  255.  
  256. if test "@GXX@" = "yes"
  257. then
  258.   cd $BASE/lib
  259.   gcclib=`@CC@ --print-libgcc-file`
  260.   if test $? -ne 0
  261.   then
  262.     print "Warning: Couldn't find libgcc.a!"
  263.   else
  264.     $CP $gcclib libmygcc.a
  265.   fi
  266.   cd $SOURCE
  267. fi
  268.  
  269. #if we are debugging, do not do tar/gz
  270. if [ x$DEBUG = x1 ] ; then
  271.  exit
  272. fi
  273.  
  274. # This is needed to prefere gnu tar instead of tar because tar can't
  275. # always handle long filenames
  276.  
  277. PATH_DIRS=`echo $PATH | sed -e 's/^:/. /' -e 's/:$/ ./' -e 's/::/ . /g' -e 's/:/ /g' `
  278. which_1 ()
  279. {
  280.   for cmd
  281.   do
  282.     for d in $PATH_DIRS
  283.     do
  284.       for file in $d/$cmd
  285.       do
  286.     if test -x $file -a ! -d $file
  287.     then
  288.       echo $file
  289.       exit 0
  290.     fi
  291.       done
  292.     done
  293.   done
  294.   exit 1
  295. }
  296.  
  297. #
  298. # Create the result tar file
  299. #
  300.  
  301. tar=`which_1 gnutar gtar`
  302. if test "$?" = "1" -o "$tar" = ""
  303. then
  304.   tar=tar
  305. fi
  306.  
  307. echo "Using $tar to create archive"
  308. cd $TMP
  309.  
  310. OPT=cvf
  311. if [ x$SILENT = x1 ] ; then
  312.   OPT=cf
  313. fi
  314.  
  315. $tar $OPT $SOURCE/$NEW_NAME.tar $NEW_NAME
  316. cd $SOURCE
  317. echo "Compressing archive"
  318. gzip -9 $NEW_NAME.tar
  319. echo "Removing temporary directory"
  320. rm -r -f $BASE
  321.  
  322. echo "$NEW_NAME.tar.gz created"
  323.