home *** CD-ROM | disk | FTP | other *** search
/ Cricao de Sites - 650 Layouts Prontos / WebMasters.iso / Servidores / xampp-win32-1.6.7-installer.exe / mysql / scripts / make_win_src_distribution_old < prev    next >
Encoding:
Text File  |  2008-04-17  |  11.1 KB  |  561 lines

  1. #!/bin/sh
  2. # Copyright (C) 2003-2006 MySQL AB
  3. # This program is free software; you can redistribute it and/or modify
  4. # it under the terms of the GNU General Public License as published by
  5. # the Free Software Foundation; version 2 of the License.
  6. # This program is distributed in the hope that it will be useful,
  7. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  9. # GNU General Public License for more details.
  10. # You should have received a copy of the GNU General Public License
  11. # along with this program; if not, write to the Free Software
  12. # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  13.  
  14. # NOTE: This script creates a source TAR and ZIP to be used when
  15. # building using Visual Studio 2003 .Net. To gain more flexibility, a
  16. # new CMake build was added. The new build obsoletes this script, Unix
  17. # and Windows share the same source TAR/ZIP.
  18. # Also note that the old build from source created by this script is
  19. # no longer tested by MySQL AB and may not work. Please use the new
  20. # CMake based build.
  21.  
  22. # Terminate loudly on error, we don't want partial package
  23. set -e
  24. trap "echo '*** script failed ***'" 0
  25.  
  26. #
  27. # Script to create a Windows src package
  28. #
  29.  
  30. version=@VERSION@
  31. CP="cp -p"
  32.  
  33. DEBUG=0
  34. SILENT=0
  35. SUFFIX=""
  36. DIRNAME=""
  37. OUTTAR="0"
  38. OUTZIP="0"
  39.  
  40. #
  41. # An "abort" function taking a variable number of strings (one per line)
  42. #
  43.  
  44. abort()
  45. {
  46.   for line
  47.   do
  48.     echo "$line"
  49.   done
  50.   exit 1
  51. }
  52.  
  53.  
  54. #
  55. # This script must run from MySQL top directory
  56. #
  57.  
  58. if [ ! -f scripts/make_win_src_distribution ]; then
  59.   abort "ERROR : You must run this script from the MySQL top-level directory"
  60. fi
  61. SOURCE=`pwd`
  62.  
  63. #
  64. # Check for source compilation/configuration
  65. #
  66.  
  67. if [ ! -f sql/sql_yacc.cc ]; then
  68.   abort "ERROR : Sorry, you must run this script after the complete build," \
  69.         "        hope you know what you are trying to do !!"
  70. fi
  71.  
  72. #
  73. # Debug print of the status
  74. #
  75.  
  76. print_debug() 
  77. {
  78.   for statement 
  79.   do
  80.     if [ "$DEBUG" = "1" ] ; then
  81.       echo $statement
  82.     fi
  83.   done
  84. }
  85.  
  86. #
  87. # Usage of the script
  88. #
  89.  
  90. show_usage() 
  91. {
  92.   echo "MySQL utility script to create a Windows src package, and it takes"
  93.   echo "the following arguments:"
  94.   echo ""
  95.   echo "  --debug   Debug, without creating the package"
  96.   echo "  --tmp     Specify the temporary location"
  97.   echo "  --suffix  Suffix name for the package"
  98.   echo "  --dirname Directory name to copy files (intermediate)"
  99.   echo "  --silent  Show no progress information"
  100.   echo "  --tar     Create tar.gz package"
  101.   echo "  --zip     Create zip package"
  102.   echo "  --help    Show this help message"
  103.  
  104.   exit 0
  105. }
  106.  
  107. #
  108. # Parse the input arguments
  109. #
  110.  
  111. parse_arguments() {
  112.   for arg do
  113.     case "$arg" in
  114.       --add-tar)  ADDTAR=1 ;;
  115.       --debug)    DEBUG=1;;
  116.       --tmp=*)    TMP=`echo "$arg" | sed -e "s;--tmp=;;"` ;;
  117.       --suffix=*) SUFFIX=`echo "$arg" | sed -e "s;--suffix=;;"` ;;
  118.       --dirname=*) DIRNAME=`echo "$arg" | sed -e "s;--dirname=;;"` ;;
  119.       --silent)   SILENT=1 ;;
  120.       --tar)      OUTTAR=1 ;;
  121.       --zip)      OUTZIP=1 ;;
  122.       --help)     show_usage ;;
  123.       *)          abort "Unknown argument '$arg'"
  124.       ;;
  125.     esac
  126.   done
  127. }
  128.  
  129. parse_arguments "$@"
  130.  
  131. #
  132. # Assign the tmp directory if it was set from the environment variables
  133. #
  134.  
  135. for i in $TMP $TMPDIR $TEMPDIR $TEMP /tmp
  136. do
  137.   if [ "$i" ]; then
  138.     print_debug "Setting TMP to '$i'"
  139.     TMP=$i
  140.     break
  141.   fi
  142. done
  143.  
  144.  
  145. #
  146. # Convert argument file from unix to DOS text
  147. #
  148.  
  149. unix_to_dos()
  150. {
  151.   for arg do
  152.     print_debug "Replacing LF -> CRLF from '$arg'"
  153.  
  154.     awk '{sub(/$/,"\r");print}' < $arg   > $arg.tmp
  155.     rm -f $arg
  156.     mv $arg.tmp $arg
  157.   done
  158. }
  159.  
  160.  
  161. #
  162. # Create a tmp dest directory to copy files
  163. #
  164.  
  165. BASE=$TMP/my_win_dist$SUFFIX.$$
  166. trap "rm -r -f $BASE; echo '*** interrupted ***'; exit 1" 1 2 3 13 15
  167.  
  168. if [ -d $BASE ] ; then
  169.   echo "WARNING: Destination directory '$BASE' already exists, deleting it"
  170.   rm -r -f $BASE
  171. fi
  172.  
  173. $CP -r $SOURCE/VC++Files $BASE
  174. # This includes an implicit 'mkdir $BASE' !
  175.  
  176. #
  177. # Process version tags in InstallShield files
  178. #
  179.  
  180. vreplace()
  181. {
  182.   for arg do
  183.     unix_to_dos $arg
  184.     cat $arg | sed -e 's!@''VERSION''@!@VERSION@!' > $arg.tmp
  185.     rm -f $arg
  186.     mv $arg.tmp $arg
  187.   done
  188. }
  189.  
  190. if test -d $BASE/InstallShield
  191. then
  192.   for d in 4.1.XX-gpl 4.1.XX-pro 4.1.XX-classic
  193.   do
  194.     cd $BASE/InstallShield/$d/String\ Tables/0009-English
  195.     vreplace value.shl
  196.     cd ../../Setup\ Files/Compressed\ Files/Language\ Independent/OS\ Independent
  197.     vreplace infolist.txt
  198.   done
  199. fi
  200.  
  201. #
  202. # Move all error message files to root directory
  203. #
  204.  
  205. $CP -r $SOURCE/sql/share $BASE/
  206. rm -r -f "$BASE/share/Makefile"
  207. rm -r -f "$BASE/share/Makefile.in"
  208. rm -r -f "$BASE/share/Makefile.am"
  209.  
  210. mkdir $BASE/Docs $BASE/extra $BASE/include
  211.  
  212. #
  213. # Copy directory files
  214. #
  215.  
  216. copy_dir_files()
  217. {
  218.   for arg do
  219.     print_debug "Copying files from directory '$arg'"
  220.     cd $SOURCE/$arg
  221.     if [ ! -d $BASE/$arg ]; then
  222.        print_debug "Creating directory '$arg'"
  223.        mkdir $BASE/$arg
  224.      fi
  225.     for i in *.c *.cpp *.h *.ih *.i *.ic *.asm *.def *.hpp *.yy *dsp *.dsw \
  226.              README INSTALL* LICENSE AUTHORS NEWS ChangeLog \
  227.              *.inc *.test *.result *.pem Moscow_leap des_key_file \
  228.              *.vcproj *.sln *.dat *.000001 *.require *.opt *.cnf
  229.     do
  230.       if [ -f $i ]
  231.       then
  232.         $CP $SOURCE/$arg/$i $BASE/$arg/$i
  233.       fi
  234.     done
  235.     for i in *.cc
  236.     do
  237.       if [ -f $i ]
  238.       then
  239.         i=`echo $i | sed 's/.cc$//g'`
  240.         $CP $SOURCE/$arg/$i.cc $BASE/$arg/$i.cpp
  241.       fi
  242.     done
  243.   done
  244. }
  245.  
  246. #
  247. # Copy directory contents recursively
  248. #
  249.  
  250. copy_dir_dirs() {
  251.  
  252.   for arg do
  253.  
  254.     cd $SOURCE
  255.     (
  256.     find $arg -type d \
  257.               -and -not -path \*SCCS\* \
  258.               -and -not -path \*.deps\* \
  259.               -and -not -path \*.libs\* \
  260.               -and -not -path \*autom4te.cache -print
  261.     )|(
  262.       while read v
  263.       do
  264.         copy_dir_files $v
  265.       done
  266.     )
  267.  
  268.   done
  269. }
  270.  
  271. #
  272. # Input directories to be copied
  273. #
  274.  
  275. for i in client dbug extra heap include \
  276.          libmysql libmysqld myisam \
  277.          myisammrg mysys regex sql strings sql-common sql/examples \
  278.          tools vio zlib
  279. do
  280.   copy_dir_files $i
  281. done
  282.  
  283. #
  284. # Create project files for ndb
  285. #
  286. make -C $SOURCE/ndb windoze || true
  287.  
  288. #
  289. # Input directories to be copied recursively
  290. #
  291.  
  292. for i in bdb innobase ndb extra/yassl server-tools
  293. do
  294.   copy_dir_dirs $i
  295. done
  296.  
  297. #
  298. # Create dummy innobase configure header
  299. #
  300.  
  301. if [ -f $BASE/innobase/ib_config.h ]; then
  302.   rm -f $BASE/innobase/ib_config.h
  303. fi
  304. touch $BASE/innobase/ib_config.h
  305.  
  306.  
  307. #
  308. # Copy miscellaneous files
  309. #
  310.  
  311. cd $SOURCE
  312. for i in COPYING ChangeLog README EXCEPTIONS-CLIENT\
  313.          INSTALL-SOURCE INSTALL-WIN \
  314.          INSTALL-WIN-SOURCE \
  315.          Docs/INSTALL-BINARY Docs/manual.chm
  316. do
  317.   print_debug "Copying file '$i'"
  318.   if [ -f $i ]
  319.   then
  320.     $CP $i $BASE/$i
  321.   fi
  322. done
  323.  
  324. #
  325. # support files
  326. #
  327. mkdir $BASE/support-files
  328.  
  329. # Rename the cnf files to <file>.ini
  330. for i in support-files/*.cnf
  331. do
  332.   i=`echo $i | sed 's/.cnf$//g'`
  333.   cp $i.cnf $BASE/$i.ini
  334. done
  335.  
  336. #
  337. # Raw dirs from source tree
  338. #
  339.  
  340. for i in scripts sql-bench mysql-test SSL tests
  341. do
  342.   print_debug "Copying directory '$i'"
  343.   if [ -d $i ]
  344.   then
  345.     if [ -d $BASE/$i ]
  346.     then
  347.       $CP -R $i $BASE
  348.     else
  349.       $CP -R $i $BASE/$i
  350.     fi
  351.   fi
  352.   # But remove object files from destination
  353.   find $BASE/$i -type f -name \*.o | xargs rm -f
  354. done
  355.  
  356. #
  357. # Fix some windows files to avoid compiler warnings
  358. #
  359.  
  360. if [ -x extra/replace ] ; then
  361.   ./extra/replace std:: "" < $BASE/sql/sql_yacc.cpp | \
  362.   sed '/^ *switch (yytype)$/ { N; /\n *{$/ { N; /\n *default:$/ { N; /\n *break;$/ { N; /\n *}$/ d; };};};} ' \
  363.   > $BASE/sql/sql_yacc.cpp-new
  364.   mv $BASE/sql/sql_yacc.cpp-new $BASE/sql/sql_yacc.cpp
  365. else
  366.   if [ "$SILENT" = "0" ] ; then
  367.     echo 'WARNING: "extra/replace" not built, can not filter "sql_yacc.ccp"'
  368.     echo 'WARNING: to reduce the number of warnings when building'
  369.   fi
  370. fi
  371.  
  372. #
  373. # Search the tree for plain text files and adapt the line end marker
  374. #
  375. find $BASE \( -name "*.cnf" -o -name "*.ini" \
  376.            -o -name COPYING -o -name ChangeLog -o -name EXCEPTIONS-CLIENT \
  377.            -o -name "INSTALL*" -o -name LICENSE -o -name "README*" \
  378.            -o -name "*.dsp" -o -name "*.dsw" \
  379.            -o -name "*.vcproj" -o -name "*.sln" \) -type f -print \
  380. | while read v
  381.   do
  382.     unix_to_dos $v
  383.   done
  384.  
  385. mv $BASE/README $BASE/README.txt
  386.  
  387. #
  388. # Clean up if we did this from a bk tree
  389. #
  390.  
  391. find $BASE -type d \( -name SCCS -o -name .deps -o -name .libs \) -print0 | \
  392. xargs -0 rm -r -f
  393. rm -r -f "$BASE/mysql-test/var"
  394.  
  395. #
  396. # Initialize the initial data directory
  397. #
  398.  
  399. if [ ! -f scripts/mysql_install_db ] ; then
  400.   if [ "$SILENT" = "0" ] ; then
  401.     echo 'WARNING: "scripts/mysql_install_db" is not built, can not initiate databases'
  402.   fi
  403. elif [ ! -f extra/my_print_defaults ]; then
  404.   if [ "$SILENT" = "0" ] ; then
  405.     echo 'WARNING: "extra/my_print_defaults" is not built, can not initiate databases'
  406.   fi
  407. else
  408.   print_debug "Initializing the 'data' directory"
  409.   scripts/mysql_install_db --no-defaults --windows --datadir=$BASE/data
  410.   if test "$?" = 1
  411.   then
  412.     exit 1;
  413.   fi
  414. fi
  415.  
  416. #
  417. # Specify the distribution package name and copy it
  418. #
  419.  
  420. if test -z $DIRNAME
  421. then
  422.   NEW_DIR_NAME=mysql@MYSQL_SERVER_SUFFIX@-$version$SUFFIX
  423. else
  424.   NEW_DIR_NAME=$DIRNAME
  425. fi
  426. NEW_NAME=$NEW_DIR_NAME-win-src
  427.  
  428. BASE2=$TMP/$NEW_DIR_NAME
  429. rm -r -f $BASE2
  430. mv $BASE $BASE2
  431. BASE=$BASE2
  432.  
  433. #
  434. # If debugging, don't create a zip/tar/gz
  435. #
  436.  
  437. if [ "$DEBUG" = "1" ] ; then
  438.   echo "Please check the distribution files from $BASE"
  439.   echo "Exiting (without creating the package).."
  440.   exit
  441. fi
  442.  
  443. #
  444. # This is needed to prefere gnu tar instead of tar because tar can't
  445. # always handle long filenames
  446. #
  447.  
  448. PATH_DIRS=`echo $PATH | sed -e 's/^:/. /' -e 's/:$/ ./' -e 's/::/ . /g' -e 's/:/ /g' `
  449. which_1 ()
  450. {
  451.   for cmd
  452.   do
  453.     for d in $PATH_DIRS
  454.     do
  455.       for file in $d/$cmd
  456.       do
  457.     if test -x $file -a ! -d $file
  458.     then
  459.       echo $file
  460.       exit 0
  461.     fi
  462.       done
  463.     done
  464.   done
  465.   exit 1
  466. }
  467.  
  468. #
  469. # Create the result zip/tar file
  470. #
  471.  
  472. if [ "$OUTTAR" = "0" ]; then
  473.   if [ "$OUTZIP" = "0" ]; then
  474.     OUTZIP=1
  475.   fi
  476. fi
  477.  
  478. set_tarzip_options()
  479. {
  480.   for arg
  481.   do
  482.     if [ "$arg" = "tar" ]; then
  483.       ZIPFILE1=gnutar
  484.       ZIPFILE2=gtar
  485.       OPT=cf
  486.       EXT=".tar"
  487.       NEED_COMPRESS=1
  488.     else
  489.       ZIPFILE1=zip
  490.       ZIPFILE2=""
  491.       OPT="-r -q"
  492.       EXT=".zip"
  493.       NEED_COMPRESS=0
  494.     fi
  495.   done
  496. }
  497.  
  498.  
  499. #
  500. # Create the archive
  501. #
  502. create_archive()
  503. {
  504.  
  505.   print_debug "Using $tar to create archive"
  506.  
  507.   cd $TMP
  508.  
  509.   rm -f $SOURCE/$NEW_NAME$EXT
  510.   $tar $OPT $SOURCE/$NEW_NAME$EXT $NEW_DIR_NAME
  511.   cd $SOURCE
  512.  
  513.   if [ "$NEED_COMPRESS" = "1" ]
  514.   then
  515.     print_debug "Compressing archive"
  516.     gzip -9 $NEW_NAME$EXT
  517.     EXT="$EXT.gz"
  518.   fi
  519.  
  520.   if [ "$SILENT" = "0" ] ; then
  521.     echo "$NEW_NAME$EXT created successfully !!"
  522.   fi
  523. }
  524.  
  525. if [ "$OUTTAR" = "1" ]; then
  526.   set_tarzip_options 'tar'
  527.  
  528.   tar=`which_1 $ZIPFILE1 $ZIPFILE2`
  529.   if test "$?" = "1" -o "$tar" = ""
  530.   then
  531.     print_debug "Search failed for '$ZIPFILE1', '$ZIPFILE2', using default 'tar'"
  532.     tar=tar
  533.     set_tarzip_options 'tar'
  534.   fi
  535.   
  536.   create_archive 
  537. fi
  538.  
  539. if [ "$OUTZIP" = "1" ]; then
  540.   set_tarzip_options 'zip'
  541.  
  542.   tar=`which_1 $ZIPFILE1 $ZIPFILE2`
  543.   if test "$?" = "1" -o "$tar" = ""
  544.   then
  545.     echo "Search failed for '$ZIPFILE1', '$ZIPFILE2', cannot create zip!"
  546.   fi
  547.  
  548.   create_archive
  549. fi
  550.  
  551. print_debug "Removing temporary directory"
  552. rm -r -f $BASE
  553.  
  554. # No need to report anything if we got here
  555. trap "" 0
  556.  
  557. # End of script
  558.