home *** CD-ROM | disk | FTP | other *** search
/ CD BIT 75 / CD BIT 75.iso / Software / mysql-4.0.22-win / data1.cab / Development / scripts / make_binary_distribution next >
Encoding:
Text File  |  2004-10-28  |  8.5 KB  |  353 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=i686
  8. system=pc-linux
  9. version=4.0.22
  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 COPYING.LIB README Docs/INSTALL-BINARY \
  89.          EXCEPTIONS-CLIENT 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.     $CP scripts/mysqlhotcopy $BASE/scripts/mysqlhotcopy.pl
  155. fi
  156.  
  157. for i in \
  158.   libmysql/.libs/libmysqlclient.a libmysql/.libs/libmysqlclient.so* \
  159.   libmysql/libmysqlclient.* libmysql_r/.libs/libmysqlclient_r.a \
  160.   libmysql_r/.libs/libmysqlclient_r.so* libmysql_r/libmysqlclient_r.* \
  161.   mysys/libmysys.a strings/libmystrings.a dbug/libdbug.a \
  162.   libmysqld/.libs/libmysqld.a libmysqld/.libs/libmysqld.so* \
  163.   libmysqld/libmysqld.a netware/libmysql.imp
  164. do
  165.   if [ -f $i ]
  166.   then
  167.     $CP $i $BASE/lib
  168.    fi
  169. done
  170.  
  171. # convert the .a to .lib for NetWare
  172. if [ $BASE_SYSTEM = "netware" ] ; then
  173.     for i in $BASE/lib/*.a
  174.     do
  175.       libname=`basename $i .a`
  176.       $MV $i $BASE/lib/$libname.lib
  177.     done
  178. fi
  179.  
  180. $CP config.h include/* $BASE/include
  181. rm -f $BASE/include/Makefile* $BASE/include/*.in $BASE/include/config-win.h
  182. if [ $BASE_SYSTEM != "netware" ] ; then
  183.   rm -f $BASE/include/config-netware.h
  184. fi
  185.  
  186. if [ $BASE_SYSTEM != "netware" ] ; then
  187.   if [ -d tests ] ; then
  188.     $CP tests/*.res tests/*.tst tests/*.pl $BASE/tests
  189.   fi
  190.   if [ -d man ] ; then
  191.     $CP man/*.1 $BASE/man/man1
  192.   fi
  193. fi
  194.  
  195. $CP support-files/* $BASE/support-files
  196.  
  197. if [ $BASE_SYSTEM = "netware" ] ; then
  198.   rm -f $BASE/support-files/magic \
  199.         $BASE/support-files/mysql.server \
  200.         $BASE/support-files/mysql*.spec \
  201.         $BASE/support-files/mysql-log-rotate \
  202.         $BASE/support-files/binary-configure
  203. fi
  204.  
  205. $CP -r sql/share/* $MYSQL_SHARE
  206. rm -f $MYSQL_SHARE/Makefile* $MYSQL_SHARE/*/*.OLD
  207.  
  208. for i in mysql-test/mysql-test-run mysql-test/install_test_db \
  209.          mysql-test/README \
  210.          netware/mysql_test_run.nlm netware/install_test_db.ncf
  211. do
  212.   if [ -f $i ]
  213.   then
  214.     $CP $i $BASE/mysql-test
  215.    fi
  216. done
  217.  
  218. $CP mysql-test/include/*.inc $BASE/mysql-test/include
  219. $CP mysql-test/std_data/*.dat mysql-test/std_data/*.001 $BASE/mysql-test/std_data
  220. $CP mysql-test/std_data/des_key_file $BASE/mysql-test/std_data
  221. $CP mysql-test/t/*test mysql-test/t/*.opt mysql-test/t/*.slave-mi mysql-test/t/*.sh $BASE/mysql-test/t
  222. $CP mysql-test/r/*result mysql-test/r/*.require $BASE/mysql-test/r
  223.  
  224. if [ $BASE_SYSTEM != "netware" ] ; then
  225.   chmod a+x $BASE/bin/*
  226.   $CP scripts/* $BASE/bin
  227.   $BASE/bin/replace \@localstatedir\@ ./data \@bindir\@ ./bin \@scriptdir\@ ./bin \@libexecdir\@ ./bin \@sbindir\@ ./bin \@prefix\@ . \@HOSTNAME\@ /bin/hostname < $SOURCE/scripts/mysql_install_db.sh > $BASE/scripts/mysql_install_db
  228.   $BASE/bin/replace \@prefix\@ /usr/local/mysql \@bindir\@ ./bin \@MYSQLD_USER\@ root \@localstatedir\@ /usr/local/mysql/data \@HOSTNAME\@ /bin/hostname < $SOURCE/support-files/mysql.server.sh > $BASE/support-files/mysql.server
  229.   $BASE/bin/replace /my/gnu/bin/hostname /bin/hostname -- $BASE/bin/mysqld_safe
  230.   mv $BASE/support-files/binary-configure $BASE/configure
  231.   chmod a+x $BASE/bin/* $BASE/scripts/* $BASE/support-files/mysql-* $BASE/support-files/mysql.server $BASE/configure
  232.   $CP -r sql-bench/* $BASE/sql-bench
  233.   rm -f $BASE/sql-bench/*.sh $BASE/sql-bench/Makefile* $BASE/lib/*.la
  234. fi
  235.  
  236. 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
  237.  
  238.  
  239. #
  240. # Remove system dependent files
  241. #
  242. if [ $BASE_SYSTEM = "netware" ] ; then
  243.     rm -f $BASE/MySQLEULA.txt
  244. else
  245.     rm -f $BASE/README.NW
  246. fi
  247.  
  248. # Make safe_mysqld a symlink to mysqld_safe for backwards portability
  249. # To be removed in MySQL 4.1
  250. (cd $BASE/bin ; ln -s mysqld_safe safe_mysqld )
  251.  
  252. # Clean up if we did this from a bk tree
  253. if [ -d $BASE/sql-bench/SCCS ] ; then 
  254.   find $BASE/share -name SCCS -print | xargs rm -r -f
  255.   find $BASE/sql-bench -name SCCS -print | xargs rm -r -f
  256. fi
  257.  
  258. # Change the distribution to a long descriptive name
  259. NEW_NAME=mysql-$version-$system-$machine$SUFFIX
  260. BASE2=$TMP/$NEW_NAME
  261. rm -r -f $BASE2
  262. mv $BASE $BASE2
  263. BASE=$BASE2
  264. #
  265. # If we are compiling with gcc, copy libgcc.a to the distribution as libmygcc.a
  266. #
  267.  
  268. if test "yes" = "yes"
  269. then
  270.   cd $BASE/lib
  271.   gcclib=`gcc --print-libgcc-file`
  272.   if test $? -ne 0
  273.   then
  274.     print "Warning: Couldn't find libgcc.a!"
  275.   else
  276.     $CP $gcclib libmygcc.a
  277.   fi
  278.   cd $SOURCE
  279. fi
  280.  
  281. #if we are debugging, do not do tar/gz
  282. if [ x$DEBUG = x1 ] ; then
  283.  exit
  284. fi
  285.  
  286. # This is needed to prefere gnu tar instead of tar because tar can't
  287. # always handle long filenames
  288.  
  289. PATH_DIRS=`echo $PATH | sed -e 's/^:/. /' -e 's/:$/ ./' -e 's/::/ . /g' -e 's/:/ /g' `
  290. which_1 ()
  291. {
  292.   for cmd
  293.   do
  294.     for d in $PATH_DIRS
  295.     do
  296.       for file in $d/$cmd
  297.       do
  298.     if test -x $file -a ! -d $file
  299.     then
  300.       echo $file
  301.       exit 0
  302.     fi
  303.       done
  304.     done
  305.   done
  306.   exit 1
  307. }
  308.  
  309. if [ $BASE_SYSTEM != "netware" ] ; then
  310.  
  311.   #
  312.   # Create the result tar file
  313.   #
  314.   
  315.   tar=`which_1 gnutar gtar`
  316.   if test "$?" = "1" -o "$tar" = ""
  317.   then
  318.     tar=tar
  319.   fi
  320.   
  321.   echo "Using $tar to create archive"
  322.   cd $TMP
  323.   
  324.   OPT=cvf
  325.   if [ x$SILENT = x1 ] ; then
  326.     OPT=cf
  327.   fi
  328.   
  329.   $tar $OPT $SOURCE/$NEW_NAME.tar $NEW_NAME
  330.   cd $SOURCE
  331.   echo "Compressing archive"
  332.   rm -f $NEW_NAME.tar.gz
  333.   gzip -9 $NEW_NAME.tar
  334.   echo "Removing temporary directory"
  335.   rm -r -f $BASE
  336.   
  337.   echo "$NEW_NAME.tar.gz created"
  338. else
  339.  
  340.   #
  341.   # Create a zip file for NetWare users
  342.   #
  343.  
  344.   cd $TMP
  345.   if test -e "$SOURCE/$NEW_NAME.zip"; then rm $SOURCE/$NEW_NAME.zip; fi
  346.   zip -r $SOURCE/$NEW_NAME.zip $NEW_NAME
  347.   echo "Removing temporary directory"
  348.   rm -r -f $BASE
  349.  
  350.   echo "$NEW_NAME.zip created"
  351.  
  352. fi
  353.