make_win_src_distribution.sh
上传用户:romrleung
上传日期:2022-05-23
资源大小:18897k
文件大小:10k
源码类别:

MySQL数据库

开发平台:

Visual C++

  1. #!/bin/sh
  2. #
  3. # Script to create a Windows src package
  4. #
  5. version=@VERSION@
  6. export version
  7. CP="cp -p"
  8. DEBUG=0
  9. SILENT=0
  10. SUFFIX=""
  11. DIRNAME=""
  12. OUTTAR="0"
  13. OUTZIP="0"
  14. #
  15. # An "abort" function taking a variable number of strings (one per line)
  16. #
  17. abort()
  18. {
  19.   for line
  20.   do
  21.     echo "$line"
  22.   done
  23.   exit 1
  24. }
  25. #
  26. # This script must run from MySQL top directory
  27. #
  28. if [ ! -f scripts/make_win_src_distribution ]; then
  29.   abort "ERROR : You must run this script from the MySQL top-level directory"
  30. fi
  31. SOURCE=`pwd`
  32. #
  33. # Check for source compilation/configuration
  34. #
  35. if [ ! -f sql/sql_yacc.cc ]; then
  36.   abort "ERROR : Sorry, you must run this script after the complete build," 
  37.         "        hope you know what you are trying to do !!"
  38. fi
  39. #
  40. # Debug print of the status
  41. #
  42. print_debug() 
  43. {
  44.   for statement 
  45.   do
  46.     if [ "$DEBUG" = "1" ] ; then
  47.       echo $statement
  48.     fi
  49.   done
  50. }
  51. #
  52. # Usage of the script
  53. #
  54. show_usage() 
  55. {
  56.   echo "MySQL utility script to create a Windows src package, and it takes"
  57.   echo "the following arguments:"
  58.   echo ""
  59.   echo "  --debug   Debug, without creating the package"
  60.   echo "  --tmp     Specify the temporary location"
  61.   echo "  --suffix  Suffix name for the package"
  62.   echo "  --dirname Directory name to copy files (intermediate)"
  63.   echo "  --silent  Do not list verbosely files processed"
  64.   echo "  --tar     Create tar.gz package"
  65.   echo "  --zip     Create zip package"
  66.   echo "  --help    Show this help message"
  67.   exit 0
  68. }
  69. #
  70. # Parse the input arguments
  71. #
  72. parse_arguments() {
  73.   for arg do
  74.     case "$arg" in
  75.       --add-tar)  ADDTAR=1 ;;
  76.       --debug)    DEBUG=1;;
  77.       --tmp=*)    TMP=`echo "$arg" | sed -e "s;--tmp=;;"` ;;
  78.       --suffix=*) SUFFIX=`echo "$arg" | sed -e "s;--suffix=;;"` ;;
  79.       --dirname=*) DIRNAME=`echo "$arg" | sed -e "s;--dirname=;;"` ;;
  80.       --silent)   SILENT=1 ;;
  81.       --tar)      OUTTAR=1 ;;
  82.       --zip)      OUTZIP=1 ;;
  83.       --help)     show_usage ;;
  84.       *)          abort "Unknown argument '$arg'"
  85.       ;;
  86.     esac
  87.   done
  88. }
  89. parse_arguments "$@"
  90. #
  91. # Assign the tmp directory if it was set from the environment variables
  92. #
  93. for i in $TMP $TMPDIR $TEMPDIR $TEMP /tmp
  94. do
  95.   if [ "$i" ]; then
  96.     print_debug "Setting TMP to '$i'"
  97.     TMP=$i
  98.     break
  99.   fi
  100. done
  101. #
  102. # Convert argument file from unix to DOS text
  103. #
  104. unix_to_dos()
  105. {
  106.   for arg do
  107.     print_debug "Replacing LF -> CRLF from '$arg'"
  108.     awk '{sub(/$/,"r");print}' < $arg   > $arg.tmp
  109.     rm -f $arg
  110.     mv $arg.tmp $arg
  111.   done
  112. }
  113. #
  114. # Create a tmp dest directory to copy files
  115. #
  116. BASE=$TMP/my_win_dist$SUFFIX
  117. if [ -d $BASE ] ; then
  118.   print_debug "Destination directory '$BASE' already exists, deleting it"
  119.   rm -r -f $BASE
  120. fi
  121. $CP -r $SOURCE/VC++Files $BASE
  122. # This includes an implicit 'mkdir $BASE' !
  123. #
  124. # Process version tags in InstallShield files
  125. #
  126. vreplace()
  127. {
  128.   for arg do
  129.     unix_to_dos $arg
  130.     cat $arg | sed -e 's!@''VERSION''@!@VERSION@!' > $arg.tmp
  131.     rm -f $arg
  132.     mv $arg.tmp $arg
  133.   done
  134. }
  135. if test -d $BASE/InstallShield
  136. then
  137.   for d in 4.1.XX-gpl 4.1.XX-pro 4.1.XX-classic
  138.   do
  139.     cd $BASE/InstallShield/$d/String Tables/0009-English
  140.     vreplace value.shl
  141.     cd ../../Setup Files/Compressed Files/Language Independent/OS Independent
  142.     vreplace infolist.txt
  143.   done
  144. fi
  145. #
  146. # Move all error message files to root directory
  147. #
  148. $CP -r $SOURCE/sql/share $BASE/
  149. rm -r -f "$BASE/share/Makefile"
  150. rm -r -f "$BASE/share/Makefile.in"
  151. rm -r -f "$BASE/share/Makefile.am"
  152. mkdir $BASE/Docs $BASE/extra $BASE/include
  153. #
  154. # Copy directory files
  155. #
  156. copy_dir_files()
  157. {
  158.   for arg do
  159.     print_debug "Copying files from directory '$arg'"
  160.     cd $SOURCE/$arg
  161.     if [ ! -d $BASE/$arg ]; then
  162.        print_debug "Creating directory '$arg'"
  163.        mkdir $BASE/$arg
  164.      fi
  165.     for i in *.c *.cpp *.h *.ih *.i *.ic *.asm *.def *.hpp *.dsp *.dsw 
  166.              README INSTALL* LICENSE AUTHORS NEWS ChangeLog 
  167.              *.inc *.test *.result *.pem Moscow_leap des_key_file 
  168.              *.vcproj *.sln *.dat *.000001 *.require *.opt
  169.     do
  170.       if [ -f $i ]
  171.       then
  172.         $CP $SOURCE/$arg/$i $BASE/$arg/$i
  173.       fi
  174.     done
  175.     for i in *.cc
  176.     do
  177.       if [ -f $i ]
  178.       then
  179.         i=`echo $i | sed 's/.cc$//g'`
  180.         $CP $SOURCE/$arg/$i.cc $BASE/$arg/$i.cpp
  181.       fi
  182.     done
  183.   done
  184. }
  185. #
  186. # Copy directory contents recursively
  187. #
  188. copy_dir_dirs() {
  189.   for arg do
  190.     cd $SOURCE
  191.     (
  192.     find $arg -type d 
  193.               -and -not -path *SCCS* 
  194.               -and -not -path *.deps* 
  195.               -and -not -path *.libs* 
  196.               -and -not -path *autom4te.cache -print
  197.     )|(
  198.       while read v
  199.       do
  200.         copy_dir_files $v
  201.       done
  202.     )
  203.   done
  204. }
  205. #
  206. # Input directories to be copied
  207. #
  208. for i in client dbug extra heap include isam 
  209.          libmysql libmysqld merge myisam 
  210.          myisammrg mysys regex sql strings sql-common sql/examples 
  211.          tools vio zlib
  212. do
  213.   copy_dir_files $i
  214. done
  215. #
  216. # Create project files for ndb
  217. #
  218. make -C $SOURCE/ndb windoze
  219. #
  220. # Input directories to be copied recursively
  221. #
  222. for i in bdb innobase ndb
  223. do
  224.   copy_dir_dirs $i
  225. done
  226. #
  227. # Create dummy innobase configure header
  228. #
  229. if [ -f $BASE/innobase/ib_config.h ]; then
  230.   rm -f $BASE/innobase/ib_config.h
  231. fi
  232. touch $BASE/innobase/ib_config.h
  233. #
  234. # Copy miscellaneous files
  235. #
  236. cd $SOURCE
  237. for i in COPYING ChangeLog README EXCEPTIONS-CLIENT
  238.          INSTALL-SOURCE INSTALL-WIN 
  239.          INSTALL-WIN-SOURCE 
  240.          Docs/INSTALL-BINARY Docs/manual.chm
  241. do
  242.   print_debug "Copying file '$i'"
  243.   if [ -f $i ]
  244.   then
  245.     $CP $i $BASE/$i
  246.   fi
  247. done
  248. #
  249. # support files
  250. #
  251. mkdir $BASE/support-files
  252. # Rename the cnf files to <file>.ini
  253. for i in support-files/*.cnf
  254. do
  255.   i=`echo $i | sed 's/.cnf$//g'`
  256.   cp $i.cnf $BASE/$i.ini
  257. done
  258. #
  259. # Raw dirs from source tree
  260. #
  261. for i in scripts sql-bench mysql-test SSL tests
  262. do
  263.   print_debug "Copying directory '$i'"
  264.   if [ -d $i ]
  265.   then
  266.     if [ -d $BASE/$i ]
  267.     then
  268.       $CP -R $i $BASE
  269.     else
  270.       $CP -R $i $BASE/$i
  271.     fi
  272.   fi
  273.   # But remove object files from destination
  274.   find $BASE/$i -type f -name *.o | xargs rm -f
  275. done
  276. #
  277. # Fix some windows files to avoid compiler warnings
  278. #
  279. ./extra/replace std:: "" < $BASE/sql/sql_yacc.cpp | sed '/^ *switch (yytype)$/ { N; /n *{$/ { N; /n *default:$/ { N; /n *break;$/ { N; /n *}$/ d; };};};} ' > $BASE/sql/sql_yacc.cpp-new
  280. mv $BASE/sql/sql_yacc.cpp-new $BASE/sql/sql_yacc.cpp
  281. #
  282. # Search the tree for plain text files and adapt the line end marker
  283. #
  284. find $BASE ( -name "*.dsp" -o -name "*.dsw" -o -name "*.cnf" -o -name "*.ini" 
  285.            -o -name COPYING -o -name ChangeLog -o -name EXCEPTIONS-CLIENT 
  286.            -o -name "INSTALL*" -o -name LICENSE -o -name "README*" 
  287.            -o -name "*.vcproj" -o -name "*.sln" ) -type f -print 
  288. | while read v
  289.   do
  290.     unix_to_dos $v
  291.   done
  292. # File extension '.txt' matches too many other files, error messages etc.
  293. unix_to_dos $BASE/Docs/*.txt 
  294. mv $BASE/README $BASE/README.txt
  295. #
  296. # Clean up if we did this from a bk tree
  297. #
  298. if [ -d $BASE/SSL/SCCS ]
  299. then
  300.   find $BASE/ -type d -name SCCS -printf " "%p"" | xargs rm -r -f
  301. fi
  302. find $BASE/ -type d -name .deps -printf " "%p"" | xargs rm -r -f
  303. find $BASE/ -type d -name .libs -printf " "%p"" | xargs rm -r -f
  304. rm -r -f "$BASE/mysql-test/var"
  305. #
  306. # Initialize the initial data directory
  307. #
  308. if [ -f scripts/mysql_install_db ]; then
  309.   print_debug "Initializing the 'data' directory"
  310.   scripts/mysql_install_db --no-defaults --windows --datadir=$BASE/data
  311.   if test "$?" = 1
  312.   then
  313.     exit 1;
  314.   fi
  315. fi
  316. #
  317. # Specify the distribution package name and copy it
  318. #
  319. if test -z $DIRNAME
  320. then
  321.   NEW_DIR_NAME=mysql@MYSQL_SERVER_SUFFIX@-$version$SUFFIX
  322. else
  323.   NEW_DIR_NAME=$DIRNAME
  324. fi
  325. NEW_NAME=$NEW_DIR_NAME-win-src
  326. BASE2=$TMP/$NEW_DIR_NAME
  327. rm -r -f $BASE2
  328. mv $BASE $BASE2
  329. BASE=$BASE2
  330. #
  331. # If debugging, don't create a zip/tar/gz
  332. #
  333. if [ "$DEBUG" = "1" ] ; then
  334.   echo "Please check the distribution files from $BASE"
  335.   echo "Exiting (without creating the package).."
  336.   exit
  337. fi
  338. #
  339. # This is needed to prefere gnu tar instead of tar because tar can't
  340. # always handle long filenames
  341. #
  342. PATH_DIRS=`echo $PATH | sed -e 's/^:/. /' -e 's/:$/ ./' -e 's/::/ . /g' -e 's/:/ /g' `
  343. which_1 ()
  344. {
  345.   for cmd
  346.   do
  347.     for d in $PATH_DIRS
  348.     do
  349.       for file in $d/$cmd
  350.       do
  351. if test -x $file -a ! -d $file
  352. then
  353.   echo $file
  354.   exit 0
  355. fi
  356.       done
  357.     done
  358.   done
  359.   exit 1
  360. }
  361. #
  362. # Create the result zip/tar file
  363. #
  364. if [ "$OUTTAR" = "0" ]; then
  365.   if [ "$OUTZIP" = "0" ]; then
  366.     OUTZIP=1
  367.   fi
  368. fi
  369. set_tarzip_options()
  370. {
  371.   for arg
  372.   do
  373.     if [ "$arg" = "tar" ]; then
  374.       ZIPFILE1=gnutar
  375.       ZIPFILE2=gtar
  376.       OPT=cvf
  377.       EXT=".tar"
  378.       NEED_COMPRESS=1
  379.       if [ "$SILENT" = "1" ] ; then
  380.         OPT=cf
  381.       fi
  382.     else
  383.       ZIPFILE1=zip
  384.       ZIPFILE2=""
  385.       OPT="-r"
  386.       EXT=".zip"
  387.       NEED_COMPRESS=0
  388.       if [ "$SILENT" = "1" ] ; then
  389.         OPT="$OPT -q"
  390.       fi
  391.     fi
  392.   done
  393. }
  394. #
  395. # Create the archive
  396. #
  397. create_archive()
  398. {
  399.   print_debug "Using $tar to create archive"
  400.   cd $TMP
  401.   rm -f $SOURCE/$NEW_NAME$EXT
  402.   $tar $OPT $SOURCE/$NEW_NAME$EXT $NEW_DIR_NAME
  403.   cd $SOURCE
  404.   if [ "$NEED_COMPRESS" = "1" ]
  405.   then
  406.     print_debug "Compressing archive"
  407.     gzip -9 $NEW_NAME$EXT
  408.     EXT="$EXT.gz"
  409.   fi
  410.   if [ "$SILENT" = "0" ] ; then
  411.     echo "$NEW_NAME$EXT created successfully !!"
  412.   fi
  413. }
  414. if [ "$OUTTAR" = "1" ]; then
  415.   set_tarzip_options 'tar'
  416.   tar=`which_1 $ZIPFILE1 $ZIPFILE2`
  417.   if test "$?" = "1" -o "$tar" = ""
  418.   then
  419.     print_debug "Search failed for '$ZIPFILE1', '$ZIPFILE2', using default 'tar'"
  420.     tar=tar
  421.     set_tarzip_options 'tar'
  422.   fi
  423.   
  424.   create_archive 
  425. fi
  426. if [ "$OUTZIP" = "1" ]; then
  427.   set_tarzip_options 'zip'
  428.   tar=`which_1 $ZIPFILE1 $ZIPFILE2`
  429.   if test "$?" = "1" -o "$tar" = ""
  430.   then
  431.     echo "Search failed for '$ZIPFILE1', '$ZIPFILE2', cannot create zip!"
  432.   fi
  433.  
  434.   create_archive
  435. fi
  436. print_debug "Removing temporary directory"
  437. rm -r -f $BASE
  438. # End of script