Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: [Linux] MWDF - V.5.02  (Read 1462 times)

jcd

  • Bay Watcher
    • View Profile
[Linux] MWDF - V.5.02
« on: June 02, 2014, 10:45:28 am »

i took the trouble of porting, compiling where needed, packing and uploading this version of MWDF for linux.  ;)
used the usual script, posted at the end of this post, adapted for slightly more options (to compile dtherapist or not, to create shortcuts or not) and new urls for packages (e.g. dropbox for MWDF, therapist from splinterz git)

used:
MWDF v5.02 (obviously)
dfhack-0.34.11-r4
splinterz latest github for linux-therapist
arch linux dwarffortress-0.34.11-4-x86_64 package for base

uploaded here: http://dffd.wimbli.com/file.php?id=8604


the (heavily tweaked from yaymeh's original) zsh script i have used to build follows:
Code: [Select]
#!/bin/zsh
### Might not work in bash. Will definitely not work in sh.
#### to be more precise: Everything except the language patch should work in bash.
echo "run this script inside a nice custom DF_Masterwork folder somewhere in your filesystem, or let it default in ~/DF_Masterwork"
# try to guess if the user moved the script to a nice custom install dir - otherwise use default $HOME/DF_Masterwork
echo $PWD | grep -qi "master\fortress\|DF\|dwarf" && installdir=$PWD || installdir="$HOME/DF_Masterwork";

# warn
{ echo "Installing DF to: $installdir \n ctrl+c to abort, ENTER to continue."; read nope; }

cp -v "$0" "$installdir/install_DF_Masterwork"

## only 64bit atm
[[ $(uname -m) == "x86_64" ]] || { echo "There is no precompiled 32-bit version of bundled libraries and Therapist available at the moment - only wine/windows version of DF might work \n ctrl+c to abort, ENTER to continue anyways."; read nope; }


#inform the user of the versions currently downloaded and how to change these
echo ""
echo ""
echo "the software in the links below will be downloaded"
echo "if there has been an update and the dl links change"
echo "we will have to point the script to the correct links"
echo "for download with wget, change the urls in the downloads list"
echo ""
echo "for git, use the git lines in the script currently commented out"
echo ""
echo "current download links:
'https://dl.dropboxusercontent.com/u/60111839/template.lng'
'http://dffd.wimbli.com/download.php?id=8067&f=dfhack-0.34.11-r4-Linux.7z'
'http://mirror.selfnet.de/archlinux/multilib/os/x86_64/dwarffortress-0.34.11-4-x86_64.pkg.tar.xz'
'git://github.com/splintermind/Dwarf-Therapist.git'
'http://dffd.wimbli.com/download.php?id=5315&f=MasterworkDF+V4j.rar'"
{ echo "Press ctrl+c to abort, ENTER to continue."; read nope; }

#ask the user if he wants a wineprefix installed, and where
echo ""
echo ""
echo "do you want a new wineprefix installed (to run the masterwork exe for config)?"
echo "if you choose not make a new prefix, the default /home/$USER/.wine prefix will be used to launch the exe"
echo "y for new prefix, just ENTER for no new prefix, ctrl+c to abort"
read winechoice
if [ "$winechoice" = "y" ]; then
echo "specify the new full wineprefix path"
echo "or leave it blank to default to $installdir/.wine_df"
read winechoice
newwine="1"
if [ "$winechoice" = "" ]; then
wineinstalldir=$installdir/.wine_df
else
wineinstalldir=$winechoice
fi
else
newwine="0"
wineinstalldir=/home/$USER/.wine
fi

if [ "$winechoice" = "y" ]; then
echo "specify the new full wineprefix path"
echo "or leave it blank to default to $installdir/.wine_df"
read winechoice
newwine="1"
if [ "$winechoice" = "" ]; then
wineinstalldir=$installdir/.wine_df
else
wineinstalldir=$winechoice
fi
else
newwine="0"
wineinstalldir=/home/$USER/.wine
fi

#ask the user if he wants shortcuts
echo ""
echo ""
echo "do you want desktop shortcuts for MWDF, MWDF launcher(for options), Sounsense, Therapist?"
echo "y for yes, just ENTER for no, ctrl+c to abort"
read shortcutchoice
if [ "$shortcutchoice" = "y" ]; then
shortcutchoice="1"
else
shortcutchoice="0"
fi

#ask the user if he wants to compile therapist or just download the source
echo ""
echo ""
echo "do you want to compile dwarftherapist or just pull the source from git?"
echo "y for yes, just ENTER for just download, ctrl+c to abort"
read therapistchoice
if [ "$therapistchoice" = "y" ]; then
therapistchoice="1"
else
therapistchoice="0"
fi

## *sigh* using archlinux package instead of official download now because it works better... uhm... on archlinux at least, that is :D if someone knows a better alternative please post it
# 'http://www.bay12games.com/dwarves/df_34_11_linux.tar.bz2'
## yaymeh: Using splintermind's git instead of 'http://dffd.wimbli.com/download.php?id=5315&f=MasterworkDF+V4i.7z' for bugfixes
## jcd:    Will use the official v4j from http://dffd.wimbli.com/download.php?id=5315&f=MasterworkDF+V4j.rar since the SWP needs constant looking into
##    but revert to the latest SWP in git for bugfixes if you want
##edit - updated for Dropbox-MW-5.02-7
downloads=(
'https://dl.dropboxusercontent.com/u/60111839/template.lng'
'http://dffd.wimbli.com/download.php?id=8067&f=dfhack-0.34.11-r4-Linux.7z'
'http://mirror.selfnet.de/archlinux/multilib/os/x86_64/dwarffortress-0.34.11-4-x86_64.pkg.tar.xz'
'https://www.dropbox.com/s/z8d0u55k53b8u50/Masterwork%20DF%20V.5.02.7z');


# masterword df subdirectory
masterpath='masterwork-dwarf-fortress'

# check if exists || create new
[ -d  "$installdir" ] || mkdir "$installdir"
cd $installdir || exit 0

# check if we have all libraries installed & complain
for dependancy in libgail libgailutil libgdk-x11-2.0 libGLU libSDL_image-1.2 libSDL_image-1.2 libsndfile libopenal;
do
ldconfig -p | grep -q $dependancy || { echo "you might need to install a package that provides the library $dependancy \n ctrl+c to abort, ENTER to continue anyways."; read nope; }
done;

# check if we have all programs installed & complain/quit
for dependancy in wget wine winetricks unzip zsh tar 7z dos2unix git unrar;
do
which "$dependancy" || { echo "please install $dependancy, p.e.: 'sudo apt-get install $dependancy'"; exit 1; }
done;

#get and extract downloads

for download in $downloads
do
s=$download
filename=${s##*/}
echo $filename
[ -f $filename ] || wget -N "$download"; #JCD wget -N doesn't redownload unless modified, still we need to change the download urls manually on version changes
#damn spaces are converted to % in urls - special treatment here - should have done it with regex, but quick'n'dirty is faster and works
#just remember to change the case trigger conditions below too if the filename changes
if [ "$filename" = "Masterwork%20DF%20V.5.02.7z" ]; then
filename='Masterwork DF V.5.02.7z'
echo $filename
fi

case $filename in
(*.tar.bz2) tar xvjf "$filename" ;;
(*.pkg.tar.xz) tar xf "$filename" ;;
(*.zip) unzip "$filename" ;;
(*V.5.02.7z) 7z x -o$masterpath "$filename" ;; #quick n dirty fix again for main mwdf.. should work into it sometime
(*.7z) 7z x "$filename" ;;
esac
done;

#use splinterz latest therapist
git clone git://github.com/splintermind/Dwarf-Therapist.git
## ... or update
cd Dwarf-Therapist || { echo "WTF!? can't cd into Dwarf-Therapist folder"; exit 1; }
git pull || { echo "git pull failed for Dwarf-Therapist"; exit 1; }
## THROW AWAY ALL CHANGES
git reset --hard
# hey, I don't know how git works, better do that one again :P
git pull || { echo "git pull failed for Dwarf-Therapist"; exit 1; }
cd $installdir


#dunno what's this, yaymeh must know
unset IFS;
# eeeeh... I give up. Leave it like that. :P now let's <just take the archlinux package and> make a mess
# old raws need to go though. Also some configs etc.
rm opt/df_linux/raw opt/df_linux/data  -r
cp -v opt/df_linux/* ./$masterpath/Dwarf\ Fortress/ -r

#patch language  in DF binary (masterworks skills etc)  (jcd: why do we have to do this that way?? - cannot check this right now)
echo "\n\nPATCHING LANGUAGE... this could take a while..."
IFS=$(echo -en "\n\b"); for line in $(cat template.lng | tr -d "\r" | grep "|.*|.*|" | grep -v "box\|Tanner\|Cof"); do echo "$line" | IFS="|" read nope from to nope; to="${(r:${#from}:: :)${to[1,${#from}]}}"; [ "$from" != "$to" ] && { echo -n "#$from#=>#$to# //// "; sed -i "s|$from|$to|g" "./$masterpath/Dwarf Fortress/libs/Dwarf_Fortress";} done;

# and there goes dfhack...
cp -v dfhack-0.34.11-r4-Linux/* "$masterpath/Dwarf Fortress/" -r
chmod -v +x "./$masterpath/Dwarf Fortress/dfhack"

# shitty bundled version ruins everything, where did that even come from again?
#rm -v "./$masterpath/Dwarf Fortress/libs/libstdc++.so.6"
#It came from the official DF linux release, now using archlinux package ;)

md5=$(md5sum "./$masterpath/Dwarf Fortress/libs/Dwarf_Fortress" | sed "s/ .*//")

#patch new df binary md5sum into dfhack symbols.xml
sed -i "s#<md5-hash value='c55e1718c93247e702b35108c8d90e69'/>#\0\n<md5-hash value='$md5'/>#" "./$masterpath/Dwarf Fortress/hack/symbols.xml"

#compile DFTherapist if asked
if [ "$therapistchoice" = "1" ]; then
cd Dwarf-Therapist
qmake -qt=5
make
cp bin/release/DwarfTherapist DwarfTherapist
cd ..
fi


# wine stuff if requested
if [ "$newwine" = "1" ]; then
export WINEARCH=win32
export WINEPREFIX=$wineinstalldir/.wine_df
winetricks -q dotnet40 corefonts
fi

# therapist / patch checksum + stuff
new_weird_checksum_for_therapist="0x${md5:0:8}"
sed -i "s/0xe966ee88/$new_weird_checksum_for_therapist/g" Dwarf-Therapist/etc/memory_layouts/linux/v034.11.ini
cp -v "./$masterpath/MasterworkDwarfFortress/Utilities/DwarfTherapist/etc/game_data.ini" "./Dwarf-Therapist/etc"
cp -v "./$masterpath/MasterworkDwarfFortress/Utilities/DwarfTherapist/etc/default_gridviews.dtg" "./Dwarf-Therapist/etc/default_gridviews.dtg"

# configuration need desktop icon or something.
if [ "$newwine" = "1" ]; then
echo "
[Desktop Entry]
Name=DF Masterwork configuration (wine)
Exec=env WINEPREFIX=\"$installdir/.wine_df\" wine explorer /desktop=DFMWconfig,$(xrandr -q | grep "*" | sed "s/ *\([^ ]*\) .*/\1/") \"$installdir/$masterpath/Masterwork Dwarf Fortress.exe\"
Type=Application
StartupNotify=true
Path=$installdir/$masterpath
Icon=WHAT_I_DONT_HAVE_AN_ICON_GET_YOUR_OWN_ICON
" >| ~/Desktop/dfMasterwork_config.desktop
else
echo "
[Desktop Entry]
Name=DF Masterwork configuration (wine)
Exec= wine explorer /desktop=DFMWconfig,$(xrandr -q | grep "*" | sed "s/ *\([^ ]*\) .*/\1/") \"$installdir/$masterpath/Masterwork Dwarf Fortress.exe\"
Type=Application
StartupNotify=true
Path=$installdir/$masterpath
Icon=WHAT_I_DONT_HAVE_AN_ICON_GET_YOUR_OWN_ICON
" >| ~/Desktop/dfMasterwork_config.desktop
fi

if [ "$shortcutchoice" = "1" ]; then
# df needs desktop icon or something too.
echo "
[Desktop Entry]
Name=DF Masterwork (native DFhack)
Exec=\'$installdir/$masterpath/Dwarf Fortress/dfhack\'
Type=Application
StartupNotify=false
Path=$installdir/$masterpath
Icon=WHAT_I_DONT_HAVE_AN_ICON_GET_YOUR_OWN_ICON
Terminal=true
" >| ~/Desktop/dfMasterwork_native.desktop

# therapist needs desktop icon or something too too.
echo "
[Desktop Entry]
Name=Dwarf Therapist (native, Splintermind Branch)
Exec=\'$installdir/Dwarf-Therapist/DwarfTherapist\'
Type=Application
StartupNotify=false
Path=$installdir/Dwarf-Therapist
Icon=WHAT_I_DONT_HAVE_AN_ICON_GET_YOUR_OWN_ICON
Terminal=false
" >| ~/Desktop/dfMasterwork_Therapist_native.desktop

# soundsense needs desktop icon or something too too too.
echo "
[Desktop Entry]
Name=Soundsense (native)
Exec=\'$installdir/$masterpath/MasterworkDwarfFortress/Utilities/soundSense/soundSense.sh\'
Type=Application
StartupNotify=false
Path=$installdir/Dwarf-Therapist
Icon=WHAT_I_DONT_HAVE_AN_ICON_GET_YOUR_OWN_ICON
Terminal=true
" >| ~/Desktop/dfMasterwork_SOUNDSENSE.desktop
fi

# change some default settings
## fullscreen makes your window manager sad.
sed -i "s/\[WINDOWED:NO\]/\[WINDOWED:YES\]/" "$masterpath/Dwarf Fortress/data/init/init.txt"
## truetype crashes in build menu etc
sed -i "s/\[TRUETYPE:YES\]/\[TRUETYPE:NO\]/" "$masterpath/Dwarf Fortress/data/init/init.txt"


# soundsense start script is broken
dos2unix $installdir/$masterpath/MasterworkDwarfFortress/Utilities/soundSense/soundSense.sh
chmod +x $installdir/$masterpath/MasterworkDwarfFortress/Utilities/soundSense/soundSense.sh

# Therapist needs ptrace
grep -q 1 /proc/sys/kernel/yama/ptrace_scope || { echo "\n\n\nGlobal Ptrace Scope is currently set to 1. To run therapist, you need to 'sudo setcap cap_sys_ptrace=eip Dwarf-Therapist/bin/release/DwarfTherapist' (or run it as root) \n Trying now:" && sudo setcap cap_sys_ptrace=eip Dwarf-Therapist/bin/release/DwarfTherapist }
« Last Edit: June 02, 2014, 03:14:36 pm by jcd »
Logged