#!/usr/bin/env bash # ----------------------------------------------------------------------------- # TANGO D SANDBOX # ----------------------------------------------------------------------------- # This script allows for a very quick installation of DSSS, DMD, and Tango. # The primary objective is to get an environment setup as quickly as possible # with the option to pick and choose which versions you want to run. The # resulting installation is a completely separate environment from your system # one, so it makes for easy testing of code. Always use the binaries provided # in the environment and never anything in your path, otherwise the code will # probably not compile due to conflicts. # # It is encouraged to use this script to setup multiple sandboxes. Each one is # completely separate from your main system and the other sandboxes. # # Please send any bug reports or suggestions to the email below. # # Author: Sean Kerr a.k.a. feti # Version: 0.6 # ----------------------------------------------------------------------------- # Usage: ./tango_sandbox.sh # # WARNING: This script is meant to run on 32bit Linux installs. If you're # running it on something else, please do not complain that it does # not work. # # WARNING: This script may fail to compile code if one or more libraries are # not compatible with DMD or Tango, or because of a conflict between # the Tango version you chose to install with a particular DMD # version. If this occurs it is completely safe to wipe out the # installation directory and start again with new settings. # ----------------------------------------------------------------------------- # CHANGELOG # 0.2 - Added default options # 0.3 - Fixed installation directory bug with tilde and relative paths # - Added SVN support for tango # 0.4 - Added profile feature # - Added MiniD installation option # 0.5 - Modified profile format # - Moved from sh to bash and consolidated code # - Added Derelict installation option # - Configuration is saved to /config # - Can load settings from configuration file # - Added DWT installation option # ----------------------------------------------------------------------------- # ----------------------------------------------------------------------------- # PROFILES # ----------------------------------------------------------------------------- PROFILE_1_DESC="(Tango) DMD 1.033, DSSS 0.78, Tango 0.99.7" PROFILE_1_DERELICT_INST=0 PROFILE_1_DERELICT_REV=latest PROFILE_1_DMD=1.033 PROFILE_1_DMD_INST=1 PROFILE_1_DSSS=0.78 PROFILE_1_DWT=3.4-1 PROFILE_1_DWT_INST=0 PROFILE_1_MINID_INST=0 PROFILE_1_MINID_REV=latest PROFILE_1_REQ_MERC=0 PROFILE_1_REQ_SVN=0 PROFILE_1_TANGO=0.99.7 PROFILE_1_TANGO_SVN=0 PROFILE_1_TANGO_REV=latest PROFILE_2_DESC="(MiniD) DMD 1.037, DSSS 0.78, Tango SVN r4048, MiniD SVN latest" PROFILE_2_DERELICT_INST=0 PROFILE_2_DERELICT_REV=latest PROFILE_2_DMD=1.037 PROFILE_2_DMD_INST=1 PROFILE_2_DSSS=0.78 PROFILE_2_DWT=3.4-1 PROFILE_2_DWT_INST=0 PROFILE_2_MINID_INST=1 PROFILE_2_MINID_REV=latest PROFILE_2_REQ_MERC=0 PROFILE_2_REQ_SVN=1 PROFILE_2_TANGO= PROFILE_2_TANGO_SVN=1 PROFILE_2_TANGO_REV=4048 PROFILE_3_DESC="(Derelict) DMD 1.037, DSSS 0.78, Tango SVN r4048, Derelict SVN latest" PROFILE_3_DERELICT_INST=1 PROFILE_3_DERELICT_REV=latest PROFILE_3_DMD=1.037 PROFILE_3_DMD_INST=1 PROFILE_3_DSSS=0.78 PROFILE_3_DWT=3.4-1 PROFILE_3_DWT_INST=0 PROFILE_3_MINID_INST=0 PROFILE_3_MINID_REV=latest PROFILE_3_REQ_MERC=0 PROFILE_3_REQ_SVN=1 PROFILE_3_TANGO= PROFILE_3_TANGO_SVN=1 PROFILE_3_TANGO_REV=4048 PROFILE_4_DESC="(DWT) DMD 1.033, DSSS 0.78, Tango 0.99.7, DWT 3.4-1" PROFILE_4_DERELICT_INST=0 PROFILE_4_DERELICT_REV=latest PROFILE_4_DMD=1.033 PROFILE_4_DMD_INST=1 PROFILE_4_DSSS=0.78 PROFILE_4_DWT=3.4-1 PROFILE_4_DWT_INST=1 PROFILE_4_MINID_INST=0 PROFILE_4_MINID_REV=latest PROFILE_4_REQ_MERC=0 PROFILE_4_REQ_SVN=0 PROFILE_4_TANGO=0.99.7 PROFILE_4_TANGO_SVN=0 PROFILE_4_TANGO_REV=latest # ------------------------------------------------------------------------------ # FUNCTIONS # ------------------------------------------------------------------------------ # check for a binary dependency and then sets the global variable dep_$1 to the # path of the binary, otherwise dep_$1 is set to 0 # # @param $1 the binary # @param $2 the error to display if the binary does not exist # # @return void function ts_check_dep () { if [ $# -lt 1 ] || [ $# -gt 2 ] ; then ts_error "Invalid parameter count to ts_check_dep()" fi path=$(which $1) if [ "$path" != "" ] ; then eval "dep_$1=$path" return fi # manually check paths (in case the user path doesn't contain all bin dirs) for i in /sbin /usr/sbin /usr/local/sbin /bin /usr/bin /usr/local/bin; do if [ -f $i/$1 ] ; then eval "dep_$1=$i/$1" return fi done eval "dep_$1=0" if [ $# -eq 2 ] ; then ts_error "$2" fi } # check for a library # # @param $1 the library # @param $2 the error to display if the binary does not exist # # @return void function ts_check_lib () { if [ $# -ne 2 ] ; then ts_error "Invalid parameter count to ts_check_lib()" fi if [ "$($dep_ldconfig -p | grep $1)" = "" ] ; then ts_error "$2" fi } # download a file # # @param $1 the url # # @return void function ts_download () { if [ $# -ne 1 ] ; then ts_error "Invalid parameter count to ts_download()" fi if [ $dep_wget != 0 ] ; then wget -a $log "$1" elif [ $dep_fetch != 0 ] ; then fetch "$2" >> $log 2>&1 fi } # download an svn revision # # @param $1 application name # @param $2 repository name # @param $3 repository revision # @param $4 absolute url # # @return void function ts_download_svn () { if [ $# -ne 4 ] ; then ts_error "Invalid parameter count to ts_download_svn()" fi eval "mkdir $2-svn-\${$2_rev} >> $log 2>&1" if [ "$3" = "latest" ] ; then echo "Downloading $1 from SVN ($3)" eval "svn co \"$4\" \"$2-svn-\${$2_rev}\"/ >> $log 2>&1" else echo "Downloading $1 from SVN ($3)" eval "svn co -r \"$3\" \"$4\" \"$2-svn-\${$2_rev}\"/ >> $log 2>&1" fi } # print an error and exit # # @param $1 the error message # # @return void function ts_error () { if [ $# -ne 1 ] ; then echo "Invalid parameter count to ts_error()" exit 1 fi echo "$1" exit 1 } # indicates that space exists in a string by printing 0, otherwise 1 # # @param $1 the string # # @return void function ts_has_space () { if [ $# -ne 1 ] ; then ts_error "Invalid parameter count to ts_has_space()" fi for i in $1; do if [ $i != "$1" ] ;then echo 0 return fi break done echo 1 } # accept a boolean as user input (1/0) # # @param $1 the variable name to set if there is a value entered # @param $2 the default value if nothing is entered # @param $3 the message to display # # @return void function ts_input_bool () { if [ $# -ne 3 ] ; then ts_error "Invalid parameter count to ts_input_bool()" fi if [ "$2" = "1" ] ; then default=y else default=n fi local input echo -n "$3 (default: $default) [y/n] " read input if [ "$input" = "" ] ; then eval "$1=$2" return elif [ "$input" = "y" ] || [ "$input" = "Y" ] ; then eval "$1=1" return fi eval "$1=0" } # accept any value as user input as long as it does not contain space # # @param $1 the variable name to set if there is a value entered # @param $2 the default value if nothing is entered # @param $3 the message to display # # @return void function ts_input_value () { if [ $# -ne 3 ] ; then ts_error "Invalid parameter count to ts_input_value()" fi if [ "$2" != "" ] ; then default="(default: $2) " else default="" fi local input while [ 1 ] ; do echo -n "$3 $default" read input if [ $(ts_has_space "$input") -eq 1 ] ; then break fi echo echo "Invalid entry (no spaces allowed)" echo done if [ "$input" = "" ] ; then eval "$1=$2" elif [ "$input" != "" ] ; then eval "$1=$input" fi } # resolve a system path and print the result # # @param $1 the path # # @return void function ts_resolve_path () { if [ $# -ne 1 ] ; then ts_error "Invalid parameter count to ts_resolve_path()" fi path="$1" # check empty value if [ "$path" = "" ] ; then echo "" return fi if [ $(ts_has_space "$path") -eq 0 ] ; then echo "" return fi # check for tilde and relative path if [ ${path:0:1} = "~" ] ; then if [ ${path:1:1} != "/" ] ; then echo "" return fi # expand tilde echo ${HOME}${path:1} elif [ ${path:0:1} != "/" ] ; then # relative path echo $(pwd)/$path else echo $path fi } # ------------------------------------------------------------------------------ # CHECK DEPENDENCIES # ------------------------------------------------------------------------------ # binaries ts_check_dep bzip2 "Install bzip2 and try again" ts_check_dep gcc "Install GCC and try again" ts_check_dep grep "Install grep and try again" ts_check_dep hg ts_check_dep ldconfig "Could not find a suitable ldconfig" ts_check_dep make "Install make and try again" ts_check_dep sed "Install sed and try again" ts_check_dep svn ts_check_dep tar "Install Tar and try again" ts_check_dep unzip "Install unzip and try again" ts_check_dep wget if [ $dep_wget = 0 ] ; then ts_check_dep fetch "Install wget or fetch and try again" fi # libraries ts_check_lib libstdc++.so.5 "Install libstdc++5 and try again" # ------------------------------------------------------------------------------ # LOAD CONFIGURATION OR SELECT PROFILE # ------------------------------------------------------------------------------ echo ts_input_bool prev_config 0 \ "Do you have a previous configuration you would like to use?" if [ $prev_config -eq 1 ] ; then while [ 1 ] ; do echo ts_input_value config "" "Enter the configuration file path:" config=$(ts_resolve_path $config) # check empty value if [ "$config" = "" ] || [ ! -e "$config" ] ; then echo echo "Invalid configuration file" continue fi # load configuration settings . $config break done else while [ 1 ] ; do echo echo "Please select a profile" echo profiles=0 for ((i=1; 1; i++)) do eval "desc=\$PROFILE_${i}_DESC" [ "$desc" != "" ] || break echo "[$i] $desc" ((profiles += 1)) done echo ts_input_value profile 1 "profile" for ((i=1; i <= $profiles; i++)) do if [ "$profile" = "$i" ] ; then break 2 fi done echo echo "Invalid entry" done eval "derelict_inst=\$PROFILE_${profile}_DERELICT_INST" eval "derelict_rev=\$PROFILE_${profile}_DERELICT_REV" eval "dmd=\$PROFILE_${profile}_DMD" eval "dmd_inst=\$PROFILE_${profile}_DMD_INST" eval "dsss=\$PROFILE_${profile}_DSSS" eval "dwt=\$PROFILE_${profile}_DWT" eval "dwt_inst=\$PROFILE_${profile}_DWT_INST" eval "minid_inst=\$PROFILE_${profile}_MINID_INST" eval "minid_rev=\$PROFILE_${profile}_MINID_REV" eval "tango=\$PROFILE_${profile}_TANGO" eval "tango_svn=\$PROFILE_${profile}_TANGO_SVN" eval "tango_rev=\$PROFILE_${profile}_TANGO_REV" eval "req_svn=\$PROFILE_${profile}_REQ_SVN" fi if [ $dep_hg = 0 ] && [ $req_merc -eq 1 ] ; then echo ts_error "You chose a profile that requires Mercurial, but you do not have it installed" fi if [ $dep_svn = 0 ] && [ $req_svn -eq 1 ] ; then echo ts_error "You chose a profile that requires Subversion, but you do not have it installed" fi # ------------------------------------------------------------------------------ # PREPARE INSTALLATION DIRECTORY # ------------------------------------------------------------------------------ while [ 1 ] ; do echo ts_input_value install_dir "" \ "Please enter an installation directory (no spaces):" install_dir=$(ts_resolve_path "$install_dir") # check empty value if [ "$install_dir" != "" ] ; then log=$install_dir/install.log break fi echo echo "Invalid installation directory" done # ------------------------------------------------------------------------------ # PICK SOFTWARE VERSIONS # ------------------------------------------------------------------------------ ts_input_value dsss $dsss "Which version of DSSS would you like?" ts_input_value dmd $dmd "Which version of DMD would you like?" if [ $dep_svn != 0 ] ; then ts_input_bool tango_svn $tango_svn \ "Would you like to download Tango from SVN instead of standard download?" if [ $tango_svn -eq 1 ] ; then ts_input_value tango_rev $tango_rev \ "Which SVN revision of Tango would you like?" fi fi if [ $dep_svn = "" ] || [ $tango_svn -eq 0 ] ; then ts_input_value tango $tango "Which version of Tango would you like?" fi ts_input_bool dwt_inst $dwt_inst "Would you like to install DWT?" if [ $dwt_inst -eq 1 ] ; then ts_input_value dwt $dwt "Which version of DWT would you like?" fi ts_input_bool derelict_inst $derelict_inst "Would you like to install Derelict?" if [ $derelict_inst -eq 1 ] ; then ts_input_value derelict_rev $derelict_rev \ "Which SVN revision of Derelict would you like?" fi ts_input_bool minid_inst $minid_inst "Would you like to install MiniD?" if [ $minid_inst -eq 1 ] ; then ts_input_value minid_rev $minid_rev \ "Which SVN revision of MiniD would you like?" fi # ------------------------------------------------------------------------------ # PRINT INSTALLATION CONFIGURATION # ------------------------------------------------------------------------------ echo echo "Installation dir: $install_dir" echo "DSSS version: $dsss" echo "DMD version: $dmd" if [ $dep_svn != 0 ] && [ $derelict_inst -eq 1 ] ; then echo "Derelict revision: $derelict_rev" fi if [ $dwt_inst -eq 1 ] ; then echo "DWT version: $dwt" fi if [ $dep_svn != 0 ] && [ $minid_inst -eq 1 ] ; then echo "MiniD revision: $minid_rev" fi if [ $dep_svn != 0 ] && [ $tango_svn -eq 1 ] ; then echo "Tango revision: $tango_rev" else echo "Tango version: $tango" fi echo echo "Press any key to start the installation process, or Ctrl+C to cancel" read _ # ------------------------------------------------------------------------------ # INITIALIZE INSTALLATION DIRECTORY # ------------------------------------------------------------------------------ if [ ! -e $install_dir ] ; then mkdir -p $install_dir 2>/dev/null || \ ts_error "Permission denied to create installation directory" mkdir $install_dir/bin $install_dir/etc $install_dir/import \ $install_dir/lib $install_dir/res $install_dir/src \ $install_dir/tests touch $log else echo "WARNING: $install_dir already exists" echo " If you overwrite the contents, everything will be removed" echo " except for previously downloaded source." echo ts_input_bool overwrite 0 "Overwrite?" if [ $overwrite -eq 1 ] ; then cd $install_dir for i in *; do if [ "$i" != "src" ] ; then rm -rf "$i" fi done mkdir $install_dir/bin $install_dir/etc $install_dir/import \ $install_dir/lib $install_dir/res $install_dir/tests echo -n '' > $log if [ ! -e src ] ; then mkdir src fi else exit 1 fi fi # ------------------------------------------------------------------------------ # DOWNLOAD/INSTALL DSSS # ------------------------------------------------------------------------------ cd $install_dir/src if [ -e dsss-${dsss}-x86-gnuWlinux.tar.bz2 ] ; then dsss_dir=dsss-${dsss}-x86-gnuWlinux dsss_file=${dsss_dir}.tar.bz2 echo "Using existing DSSS source $dsss_file" elif [ -e dsss-${dsss}-dmd-gnuWlinux-x86.tar.bz2 ] ; then dsss_dir=dsss-${dsss}-dmd-gnuWlinux-x86 dsss_file=${dsss_dir}.tar.bz2 echo "Using existing DSSS source $dsss_file" else echo "Downloading DSSS" dsss_dir=dsss-${dsss}-x86-gnuWlinux dsss_file=${dsss_dir}.tar.bz2 ts_download "http://svn.dsource.org/projects/dsss/downloads/${dsss}/dsss-${dsss}-x86-gnuWlinux.tar.bz2" if [ ! -e dsss-${dsss}-x86-gnuWlinux.tar.bz2 ] ; then # try the other dsss format dsss_dir=dsss-${dsss}-dmd-gnuWlinux-x86 dsss_file=${dsss_dir}.tar.bz2 ts_download "http://svn.dsource.org/projects/dsss/downloads/${dsss}/dsss-${dsss}-dmd-gnuWlinux-x86.tar.bz2" if [ ! -e dsss-${dsss}-dmd-gnuWlinux-x86.tar.bz2 ] ; then echo echo "ERROR: DSSS failed to download (version may be invalid)" echo "View $log for details" exit 1 fi fi fi if [ ! -e $dsss_dir ] ; then echo "Uncompressing DSSS" tar -vjxf $dsss_file >> $log 2>&1 if [ ! -e $dsss_dir ] ; then echo echo "ERROR: $install_dir/src/$dsss_file is corrupt and could not be" \ "uncompressed, please remove it and start over" echo "View $log for details" exit 1 fi fi echo "Copying DSSS files" cd .. cp src/$dsss_dir/bin/dsss bin/ >> $log 2>&1 cp src/$dsss_dir/bin/rebuild bin/ >> $log 2>&1 cp src/$dsss_dir/bin/rebuild_choosedc bin/ >> $log 2>&1 cd bin ln -s rebuild rerun >> $log 2>&1 cd .. cp -r src/$dsss_dir/etc/* etc/ >> $log 2>&1 echo "profile=dmd-posix-tango" > etc/rebuild/default # ------------------------------------------------------------------------------ # DOWNLOAD/INSTALL DMD # ------------------------------------------------------------------------------ cd $install_dir/src if [ ! -e dmd.${dmd}.zip ] ; then echo "Downloading DMD" ts_download "http://ftp.digitalmars.com/dmd.${dmd}.zip" if [ ! -e dmd.${dmd}.zip ] ; then echo echo "ERROR: DMD failed to download (version may be invalid)" echo "View $log for details" exit 1 fi else echo "Using existing DMD source dmd.${dmd}.zip" fi if [ ! -e dmd-${dmd} ] ; then echo "Uncompressing DMD" unzip -d dmd-${dmd} -o dmd.${dmd}.zip >> $log 2>&1 if [ ! -e dmd-${dmd} ] ; then echo echo "ERROR: $install_dir/src/dmd.${dmd}.zip is corrupt and could" \ "not be uncompressed, please remove it and start over" echo "View $log for details" exit 1 fi fi echo "Copying DMD files" cd .. cp src/dmd-${dmd}/dmd/bin/* bin/ >> $log 2>&1 cp src/dmd-${dmd}/dmd/lib/* lib/ >> $log 2>&1 rm -f bin/*.dll bin/*.exe bin/*.hlp >> $log 2>&1 chmod +x bin/dmd bin/dumpobj bin/obj2asm bin/rdmd >> $log 2>&1 echo "[Environment]" > bin/dmd.conf echo "DFLAGS=" >> bin/dmd.conf echo "DFLAGS=-I%@P%/../import -L-L%@P%/../lib -version=Posix" \ "-version=Tango -defaultlib=tango-base-dmd -debuglib=tango-base-dmd" \ "-L-ltango-user-dmd" >> bin/dmd.conf cat etc/rebuild/dmd-posix-tango | \ sed -e "s#cmd=dmd#cmd=${install_dir}/bin/dmd#g" \ -e "s#compiler=dmd#compiler=${install_dir}/bin/dmd#g" \ -e "s#inifile=dmd.conf#inifile=${install_dir}/bin/dmd.conf#g" > .tmp_file mv .tmp_file etc/rebuild/dmd-posix-tango # ------------------------------------------------------------------------------ # DOWNLOAD/INSTALL TANGO # ------------------------------------------------------------------------------ cd $install_dir/src if [ $dep_svn = 0 ] || [ $tango_svn -eq 0 ] ; then tango_dir=tango-${tango}-src if [ ! -e tango-${tango}-src.zip ] ; then echo "Downloading Tango" ts_download "http://downloads.dsource.org/projects/tango/${tango}/tango-${tango}-src.zip" if [ ! -e tango-${tango}-src.zip ] ; then echo echo "ERROR: Tango failed to download (version may be invalid)" echo "View $log for details" exit 1 fi else echo "Using existing Tango source tango-${tango}-src.zip" fi if [ ! -e tango-${tango}-src ] ; then echo "Uncompressing Tango" unzip -o tango-${tango}-src.zip >> $log 2>&1 if [ ! -e tango-${tango}-src ] ; then echo echo "ERROR: $install_dir/src/tango-${tango}-src.zip is corrupt" \ "and could not be uncompressed, please remove it and start over" echo "View $log for details" exit 1 fi fi else tango_dir=tango-svn-${tango_rev} if [ -e tango-svn-${tango_rev} ] && [ $tango_rev = latest ] ; then cd tango-svn-${tango_rev} svn update >> $log 2>&1 cd .. elif [ ! -e tango-svn-${tango_rev} ] ; then ts_download_svn Tango tango $tango_rev \ "http://svn.dsource.org/projects/tango/trunk/" if [ ! -e tango-svn-${tango_rev} ] ; then echo echo "ERROR: Tango failed to download from SVN (revision may be" \ "invalid)" echo "View $log for details" exit 1 fi fi fi cd .. cd src/"$tango_dir"/lib cat dmd-posix.mak | sed -e "s#DC=dmd#DC=${install_dir}/bin/dmd#g" > .tmp_file mv .tmp_file dmd-posix.mak cat build-tango.sh | sed -e "s#build dmd #build ${install_dir}/bin/dmd #g" > .tmp_file mv .tmp_file build-tango.sh chmod +x build-tango.sh echo "Building Tango" ./build-dmd.sh >> $log 2>&1 ./build-tango.sh dmd >> $log 2>&1 if [ ! -e ../lib/libtango-base-dmd.a ] || [ ! -e ../lib/libtango-user-dmd.a ] ; then echo echo "ERROR: Tango failed to build" echo "View $log for details" exit 1 fi echo "Copying Tango files" cd .. cp lib/libtango-base-dmd.a ../../lib/ >> $log 2>&1 cp lib/libtango-user-dmd.a ../../lib/ >> $log 2>&1 cp object.di ../../import/ >> $log 2>&1 cp -r std ../../import/ >> $log 2>&1 cp -r tango ../../import/ >> $log 2>&1 cd $install_dir/tests echo "import tango.io.Stdout;" > tango_test.d echo "int main () {" >> tango_test.d echo " Stdout(\"Tango Works!\").newline;" >> tango_test.d echo " return 0;" >> tango_test.d echo "}" >> tango_test.d echo "Compiling $install_dir/tango_test.d" ../bin/dmd tango_test.d >> $log 2>&1 if [ ! -e tango_test ] ; then echo echo "ERROR: Failed to compile $install_dir/tango_test.d" echo "View $log for details" exit 1 fi # ------------------------------------------------------------------------------ # DOWNLOAD/INSTALL DERELICT # ------------------------------------------------------------------------------ cd $install_dir/src if [ $dep_svn != 0 ] && [ $derelict_inst -eq 1 ] ; then if [ -e derelict-svn-${derelict_rev} ] && [ $derelict_rev = latest ] ; then cd derelict-svn-${derelict_rev} svn update >> $log 2>&1 cd .. elif [ ! -e derelict-svn-${derelict_rev} ] ; then ts_download_svn Derelict derelict $derelict_rev \ "http://svn.dsource.org/projects/derelict/trunk/" fi if [ ! -e derelict-svn-${derelict_rev} ] ; then echo echo "ERROR: Derelict failed to download from SVN (revision may be" \ "invalid)" echo "View $log for details" exit 1 fi echo "Building Derelict" cd derelict-svn-${derelict_rev} ../../bin/dsss build >> $log 2>&1 if [ ! -e lib/libDerelictAL.a ] ; then echo echo "ERROR: Derelict failed to build" echo "View $log for details" exit 1 fi echo "Copying Derelict files" cp lib/*.a ../../lib/ >> $log 2>&1 mkdir ../../import/derelict >> $log 2>&1 cp -r DerelictAL/derelict/openal ../../import/derelict/ >> $log 2>&1 cp -r DerelictFT/derelict/freetype ../../import/derelict/ >> $log 2>&1 cp -r DerelictGL/derelict/opengl ../../import/derelict/ >> $log 2>&1 cp -r DerelictGLU/derelict/opengl/* ../../import/derelict/opengl/ >> $log 2>&1 cp -r DerelictIL/derelict/devil ../../import/derelict/ >> $log 2>&1 cp -r DerelictILU/derelict/devil/* ../../import/derelict/devil/ >> $log 2>&1 cp -r DerelictILUT/derelict/devil/* ../../import/derelict/devil/ >> $log 2>&1 cp -r DerelictODE/derelict/ode ../../import/derelict/ >> $log 2>&1 cp -r DerelictOgg/derelict/ogg ../../import/derelict/ >> $log 2>&1 cp -r DerelictSDL/derelict/sdl ../../import/derelict/ >> $log 2>&1 cp -r DerelictSDLImage/derelict/sdl/* ../../import/derelict/sdl/ >> $log 2>&1 cp -r DerelictSDLMixer/derelict/sdl/* ../../import/derelict/sdl/ >> $log 2>&1 cp -r DerelictSDLNet/derelict/sdl/* ../../import/derelict/sdl/ >> $log 2>&1 cp -r DerelictSDLttf/derelict/sdl/* ../../import/derelict/sdl/ >> $log 2>&1 cp -r DerelictUtil/derelict/util ../../import/derelict/ >> $log 2>&1 cp -r DerelictVorbis/derelict/ogg/* ../../import/derelict/ogg/ >> $log 2>&1 cd ../../import/derelict find . -name '.svn' | xargs rm -rf echo echo "NOTICE: Derelict is not dynamically linked for you due to dependencies" echo fi # ------------------------------------------------------------------------------ # DOWNLOAD/INSTALL DWT # ------------------------------------------------------------------------------ cd $install_dir/src if [ $dwt_inst -eq 1 ] ; then if [ ! -e dwt-linux-${dwt}.tar.bz2 ] ; then echo "Downloading DWT" ts_download "http://downloads.dsource.org/projects/dwt/releases/dwt-linux-3.4-1.tar.bz2" if [ ! -e dwt-linux-${dwt}.tar.bz2 ] ; then echo echo "ERROR: DWT failed to download (version may be invalid)" echo "View $log for details" exit 1 fi else echo "Using existing DWT source dwt-linux-${dwt}.tar.bz2" fi if [ ! -e dwt-addons-${dwt}.tar.bz2 ] ; then echo "Downloading DWT addons" ts_download "http://downloads.dsource.org/projects/dwt/releases/dwt-addons-3.4-1.tar.bz2" if [ ! -e dwt-addons-${dwt}.tar.bz2 ] ; then echo echo "ERROR: DWT addons failed to download (version may be invalid)" echo "View $log for details" exit 1 fi else echo "Using existing DWT addons source dwt-addons-${dwt}.tar.bz2" fi if [ ! -e dwt-linux-${dwt} ] || [ ! -e dwt-addons-${dwt} ] ; then echo "Uncompressing DWT" tar -vjxf dwt-linux-${dwt}.tar.bz2 >> $log 2>&1 if [ ! -e dwt-linux ] ; then echo echo "ERROR: $install_dir/src/dwt-linux-${dwt}.tar.bz2 is corrupt" \ "and could not be uncompressed, please remove it and start over" echo "View $log for details" exit 1 fi tar -vjxf dwt-addons-${dwt}.tar.bz2 >> $log 2>&1 if [ ! -e dwt-addons ] ; then echo echo "ERROR: $install_dir/src/dwt-addons-${dwt}.tar.bz2 is corrupt" \ "and could not be uncompressed, please remove it and start over" echo "View $log for details" exit 1 fi mv dwt-linux dwt-linux-${dwt} >> $log 2>&1 mv dwt-addons dwt-addons-${dwt} >> $log 2>&1 fi echo "Copying DWT files" cp -r dwt-addons-${dwt}/dwtx ../import/ >> $log 2>&1 cp -r dwt-linux-${dwt}/dwt ../import/ >> $log 2>&1 mkdir ../res/dwt cp -r dwt-addons-${dwt}/res/* ../res/dwt/ >> $log 2>&1 echo "DFLAGS+=-J%@P%/../res/dwt" >> ../bin/dmd.conf echo echo "NOTICE: The DWT addons package requires resource files which have" \ "been placed into $install_dir/res/dwt and dmd.conf has been" \ "modified to use this resource directory" echo cd $install_dir/tests echo "import dwt.DWT;" >> dwt_test.d echo "import dwt.layout.RowLayout;" >> dwt_test.d echo "import dwt.widgets.Button;" >> dwt_test.d echo "import dwt.widgets.Display;" >> dwt_test.d echo "import dwt.widgets.Shell;" >> dwt_test.d echo "void main () {" >> dwt_test.d echo " Display display = new Display();" >> dwt_test.d echo " RowLayout layout = new RowLayout();" >> dwt_test.d echo " Shell shell = new Shell(display);" >> dwt_test.d echo " layout.wrap = true;" >> dwt_test.d echo " shell.setLayout(layout);" >> dwt_test.d echo " auto button1 = new Button(shell, DWT.PUSH);" >> dwt_test.d echo " button1.setText(\"B1\");" >> dwt_test.d echo " auto button2 = new Button(shell, DWT.PUSH);" >> dwt_test.d echo " button2.setText(\"Wide Button 2\");" >> dwt_test.d echo " auto button3 = new Button(shell, DWT.PUSH);" >> dwt_test.d echo " button3.setText(\"Button 3\");" >> dwt_test.d echo " shell.pack();" >> dwt_test.d echo " shell.open();" >> dwt_test.d echo " while (!shell.isDisposed()) {" >> dwt_test.d echo " if (!display.readAndDispatch())" >> dwt_test.d echo " display.sleep();" >> dwt_test.d echo " }" >> dwt_test.d echo "}" >> dwt_test.d echo "[dwt_test.d]" >> dsss_dwt.conf echo "Compiling DWT test (this may take a few minutes, go grab a beer)" ../bin/dsss --config=dsss_dwt.conf build dwt_test.d >> $log 2>&1 if [ ! -e dwt_test ] ; then echo echo "ERROR: Failed to compile $install_dir/dwt_test.d" echo "View $log for details" exit 1 fi fi # ------------------------------------------------------------------------------ # DOWNLOAD/INSTALL MINID # ------------------------------------------------------------------------------ cd $install_dir/src if [ $dep_svn != 0 ] && [ $minid_inst -eq 1 ] ; then if [ -e minid-svn-${minid_rev} ] && [ $minid_rev = latest ] ; then cd minid-svn-${minid_rev} svn update >> $log 2>&1 cd .. elif [ ! -e minid-svn-${minid_rev} ] ; then ts_download_svn MiniD minid $minid_rev \ "http://svn.dsource.org/projects/minid/trunk/" fi if [ ! -e minid-svn-${minid_rev} ] ; then echo echo "ERROR: MiniD failed to download from SVN (revision may be" \ "invalid)" echo "View $log for details" exit 1 fi echo "Building MiniD" cd minid-svn-${minid_rev} ../../bin/dsss build >> $log 2>&1 if [ ! -e libDD-minid.a ] ; then echo echo "ERROR: MiniD failed to build" echo "View $log for details" exit 1 fi echo "Copying MiniD files" cp libDD-minid.a ../../lib/ >> $log 2>&1 cp -r minid ../../import/ >> $log 2>&1 cat ../../bin/dmd.conf | sed -e 's#DFLAGS=#DFLAGS=-L-lDD-minid #g' > .tmp_file mv .tmp_file ../../bin/dmd.conf echo echo "NOTICE: MiniD is dynamically linked for you" echo fi # ------------------------------------------------------------------------------ # SAVE CONFIGURATION # ------------------------------------------------------------------------------ cd $install_dir echo "derelict_inst=$derelict_inst" > config echo "derelict_rev=$derelict_rev" >> config echo "dmd=$dmd" >> config echo "dmd_inst=$dmd_inst" >> config echo "dsss=$dsss" >> config echo "minid_inst=$minid_inst" >> config echo "minid_rev=$minid_rev" >> config echo "tango=$tango" >> config echo "tango_svn=$tango_svn" >> config echo "tango_rev=$tango_rev" >> config echo "req_svn=$req_svn" >> config echo echo "Configuration saved to $install_dir/config" echo echo "Installation Successful! Go have some fun, but remember to always use" \ "the binaries provided in $install_dir/bin to compile your application!" echo echo "If you would like to run the tests, they are in $install_dir/tests"