home *** CD-ROM | disk | FTP | other *** search
/ c't freeware shareware 2001 January / CT_SW0101.ISO / pc / software / spiele / strat / fcraft.tgz / fcraft.tar / clone-000402 / tools / build.sh next >
Linux/UNIX/POSIX Shell Script  |  2000-04-02  |  6KB  |  203 lines

  1. #!/bin/sh
  2. ##
  3. ##    A clone of a famous game.
  4. ##
  5. ##    build.sh    -    The graphics and sound extractor.
  6. ##
  7. ##    (c) Copyright 1999-2000 by Lutz Sammer
  8. ##
  9. ##    $Id: build.sh,v 1.16 2000/03/31 14:50:05 root Exp $
  10. ##
  11.  
  12. # parameters
  13. #
  14. # -z / -I : COMPRESS = gzip --force --best / bzip2 --force
  15. # -p path : ARCHIVE = /cdrom / /mnt/cdrom ..
  16. # -o DIR = /usr/share/games/ale-clone/warii
  17. # -T path : BINPATH = /usr/lib/ale-clone/tools
  18. # -C CONTRIB = /usr/lib/ale-clone/contrib
  19.  
  20. #    compress parameters
  21. GZIP="gzip --force --best"
  22. BZIP2="bzip2 --force"
  23.  
  24. #       cdrom autodetection
  25. CDROM="/cdrom"
  26. [ -d "/mnt/cdrom" ] && CDROM="/mnt/cdrom"
  27.  
  28. ###
  29. ### Change the next, to meet your requirements:
  30. ###
  31.  
  32. #
  33. #       Choose your default compression or use -z or -I.
  34. #
  35. COMPRESS=$GZIP
  36. #COMPRESS=$BZIP2
  37.  
  38. #
  39. #       Here are the input files for sounds, graphics and texts.
  40. #       WARNING: If not from CD, choose below expansion/no-expansion
  41. #               First choice:   installed on dos parition
  42. #               Second choise:  installed in current directory
  43. #               Third choise:   uninstalled on original cdrom
  44. #        or use -p dir
  45. #
  46. #ARCHIVE="/dos/c/games/war2/data/"
  47. #ARCHIVE="./"
  48. ARCHIVE=$CDROM"/data/"
  49.  
  50. #
  51. #       Here are my executeables or -T dir.
  52. #
  53. BINPATH="tools"
  54. #BINPATH="/usr/local/lib/clone/bin"
  55. #BINPATH="/usr/lib/ale-clone/tools"
  56.  
  57. #
  58. #       Here are the extra files contributed or -C dir.
  59. #
  60. CONTRIB="contrib"
  61. #CONTRIB="/usr/lib/ale-clone/contrib"
  62. #CONTRIB="/usr/local/lib/clone/contrib"
  63.  
  64. #
  65. #       Here is the destination for the generated files
  66. #
  67. DIR="data"
  68. #DIR="/usr/local/lib/clone/data"
  69. #DIR="/usr/share/games/ale-clone/WarII"
  70.  
  71. ###
  72. ###    Below this point, you should only search bugs. :-)
  73. ###
  74.  
  75. while [ $# -gt 0 ]; do
  76.     case "$1" in
  77.         -p)    ARCHIVE="$2"; shift ;;
  78.         -o)    DIR="$2"; shift ;;
  79.  
  80.         -z)    COMPRESS="$GZIP" ;;
  81.         -I)    COMPRESS="$BZIP2" ;;
  82.  
  83.         -T)    BINPATH="$2"; shift ;;
  84.         -C)    CONTRIB="$2"; shift ;;
  85.  
  86.         -h)    cat << EOF
  87. build.sh
  88.  -z / -I : COMPRESS = gzip --force --best / bzip2 --force
  89.  -p path : ARCHIVE = /cdrom / /mnt/cdrom ..
  90.  -o DIR = /usr/share/games/ale-clone/warii
  91.  -T path : BINPATH = /usr/lib/ale-clone/tools
  92.  -C CONTRIB = /usr/lib/ale-clone/contrib
  93. EOF
  94.             exit 0;;
  95.  
  96.         *)
  97.             echo 2>&1 "Unknown option: $1"
  98.             exit 1
  99.     esac
  100.     shift
  101. done
  102.  
  103. if [ -d "$ARCHIVE/data/" ]; then
  104.     DATADIR="$ARCHIVE/data/"
  105. else
  106.     DATADIR="$ARCHIVE/"
  107. fi
  108.  
  109. # Create the directory structure
  110.  
  111. [ -d $DIR ] || mkdir $DIR
  112.  
  113. [ -d $DIR/graphic ] || mkdir $DIR/graphic
  114. #comes with 1.17
  115. #[ -d $DIR/graphic/human ] || mkdir $DIR/graphic/human
  116. #[ -d $DIR/graphic/human/units ] || mkdir $DIR/graphic/human/units
  117. #[ -d $DIR/graphic/human/buildings ] || mkdir $DIR/graphic/human/buildings
  118. #[ -d $DIR/graphic/orc ] || mkdir $DIR/graphic/orc
  119. #[ -d $DIR/graphic/orc/units ] || mkdir $DIR/graphic/orc/units
  120. #[ -d $DIR/graphic/orc/buildings ] || mkdir $DIR/graphic/orc/buildings
  121. #[ -d $DIR/graphic/tilesets ] || mkdir $DIR/graphic/tilesets
  122. #[ -d $DIR/graphic/tilesets/summer ] || mkdir $DIR/graphic/tilesets/summer
  123.  
  124. [ -d $DIR/graphic/tileset ] || mkdir $DIR/graphic/tileset
  125. [ -d $DIR/graphic/interface ] || mkdir $DIR/graphic/interface
  126.  
  127. [ -d $DIR/sound ] || mkdir $DIR/sound
  128.  
  129. [ -d $DIR/campaigns ] || mkdir $DIR/campaigns
  130. [ -d $DIR/campaigns/human ] || mkdir $DIR/campaigns/human
  131. [ -d $DIR/campaigns/orc ] || mkdir $DIR/campaigns/orc
  132. [ -d $DIR/campaigns/human-exp ] || mkdir $DIR/campaigns/human-exp
  133. [ -d $DIR/campaigns/orc-exp ] || mkdir $DIR/campaigns/orc-exp
  134. [ -d $DIR/text ] || mkdir $DIR/text
  135.  
  136. [ -d $DIR/puds ] || mkdir $DIR/puds
  137. [ -d $DIR/puds/internal ] || mkdir $DIR/puds/internal
  138. [ -d $DIR/puds/demo ] || mkdir $DIR/puds/demo
  139.  
  140. # New directory structure
  141. [ -d $DIR/graphic/tilesets ] || mkdir $DIR/graphic/tilesets
  142. [ -d $DIR/graphic/tilesets/summer ] || mkdir $DIR/graphic/tilesets/summer
  143. [ -d $DIR/graphic/tilesets/winter ] || mkdir $DIR/graphic/tilesets/winter
  144. [ -d $DIR/graphic/tilesets/wasteland ] || mkdir $DIR/graphic/tilesets/wasteland
  145. [ -d $DIR/graphic/tilesets/swamp ] || mkdir $DIR/graphic/tilesets/swamp
  146. [ -d $DIR/graphic/ui ] || mkdir $DIR/graphic/ui
  147. [ -d $DIR/graphic/ui/human ] || mkdir $DIR/graphic/ui/human
  148. [ -d $DIR/graphic/ui/orc ] || mkdir $DIR/graphic/ui/orc
  149.  
  150. ###############################################################################
  151. ##    Extract
  152. ###############################################################################
  153.  
  154. # ADD -e      To force that the archive is expansion compatible
  155. # ADD -n      To force that the archive is not expansion compatible
  156. $BINPATH/wartool "$DATADIR" "$DIR"
  157.  
  158. # own supplied files
  159.  
  160. cp $CONTRIB/cross.png $DIR/graphic
  161. cp $CONTRIB/mana.png $DIR
  162. cp $CONTRIB/health.png $DIR
  163. cp $CONTRIB/food.png $DIR/graphic
  164. cp $CONTRIB/score.png $DIR/graphic
  165. cp $CONTRIB/ore,stone,coal.png $DIR/graphic
  166. cp $CONTRIB/ale-title.png $DIR
  167.  
  168. ###############################################################################
  169. ##    MISC
  170. ###############################################################################
  171.  
  172. #
  173. #    Compress the sounds
  174. #
  175. find $DIR/sound -type f -name "*.wav" -print -exec $COMPRESS {} \;
  176.  
  177. #
  178. #    Compress the texts
  179. #
  180. find $DIR/text -type f -name "*.txt" -print -exec $COMPRESS {} \;
  181.  
  182. #
  183. #    Copy original puds into data directory
  184. #
  185. echo "Copy puds and compressing"
  186. [ -d $DATADIR/../puds ] && cp -r $DATADIR/../puds/ $DIR/puds
  187. [ -f $DATADIR/../alamo.pud ] && cp -r $DATADIR/../*.pud $DIR/puds
  188. chmod -R +w $DIR/puds
  189. find $DIR/puds -type f -name "*.pud" -print -exec $COMPRESS {} \;
  190.  
  191. #
  192. ##    The default pud.
  193. #
  194. [ -f $DIR/puds/internal/internal12.pud.gz ] \
  195.     && ln -s puds/internal/internal12.pud.gz $DIR/default.pud.gz
  196. [ -f $DIR/puds/internal/internal12.pud.bz2 ] \
  197.     && ln -s puds/internal/internal12.pud.bz2 $DIR/default.pud.bz2
  198.  
  199. #
  200. #    Some checks
  201. #
  202. [ -s $DIR/swamp.rgb ] || echo "This script isn't tested with the non-expansion CD!"
  203.