From 9978d8af597eab630dd65603a5a34cb8321ac3c9 Mon Sep 17 00:00:00 2001
From: David Robert Verelst <dave@dtu.dk>
Date: Thu, 13 Oct 2016 12:43:09 +0200
Subject: [PATCH] more config-wine fixes: gorm doesn't have c:/users dir, use
 z:/ instead

---
 config-wine-hawc2.sh | 25 +++++++++++++++----------
 1 file changed, 15 insertions(+), 10 deletions(-)

diff --git a/config-wine-hawc2.sh b/config-wine-hawc2.sh
index 3dd0e8d..748f8dd 100755
--- a/config-wine-hawc2.sh
+++ b/config-wine-hawc2.sh
@@ -14,33 +14,36 @@ function wine_init_config () {
     fi
 
     # create a directory on the user home drive in which executables are placed
-    EXE_DIR_UNIX="/home/$USER/wine_exe/$WINEARCH/"
     mkdir -p $EXE_DIR_UNIX
 
     echo "-------- copying HAWC2 executables from/to:"
-    echo "$HAWC2EXES/*  $EXE_DIR_UNIX"
-    cp $HAWC2EXES/* "$EXE_DIR_UNIX"
+    echo "$CP_EXE_FROM/*  $EXE_DIR_UNIX/"
+    cp $CP_EXE_FROM/* "$EXE_DIR_UNIX/"
 
     # add C:\bin (/home/$USER/$WINEDIRNAME/drive_c/bin/) to Windows PATH variable
-    EXE_DIR_WINE="c:/users/$USER/My Documents/wine_exe/$WINEARCH/"
+    EXE_DIR_WINE="z:""$EXE_DIR_UNIX"
     echo "-------- adding $EXE_DIR_UNIX to wine system PATH"
     echo "-------- this is equivalent to $EXE_DIR_WINE in Windows terms."
     # create file with registry key name and path as the value
-    printf 'REGEDIT4\n[HKEY_CURRENT_USER\\Environment]\n"PATH"="'"$EXE_DIR_WINE"'"' >> ./tmp.reg
+    # note that the text format of this file can make or brake the procedure
+    # very sensitive to trailing slashes, empty line breaks, etc
+    printf 'REGEDIT4\n[HKEY_CURRENT_USER\\Environment]\n"PATH"="'"$EXE_DIR_WINE"'"\n' >> ./tmp.reg
     WINEARCH=$WINEARCH WINEPREFIX=$WINEDIRNAME wine regedit ./tmp.reg
 
     # do not show GUI crash dialogs
     rm ./tmp.reg
-    printf '[HKEY_CURRENT_USER\\Software\\Wine\\WineDbg]\n"ShowCrashDialog"=dword:00000000' >> ./tmp.reg
+    printf '[HKEY_CURRENT_USER\\Software\\Wine\\WineDbg]\n"ShowCrashDialog"=dword:00000000\n' >> ./tmp.reg
     WINEARCH=$WINEARCH WINEPREFIX=$WINEDIRNAME wine regedit ./tmp.reg
     rm ./tmp.reg
 
-    # add an alias to .bashrc, but only for the 32-bit variant
-    if [[ $WINEARCH == "win32" ]] ; then
+    # add an alias to .bashrc, but only if different than wine
+    if [[ $WINE_ALIAS != "wine" ]] ; then
         echo "-------- adding alias $WINE_ALIAS to ~/.bashrc"
         echo "alias $WINE_ALIAS='$WINE_ENV_VARS wine'" >> ~/.bashrc
         source ~/.bashrc
+    fi
 
+    if [[ $WINEARCH == "win32" ]] ; then
         echo "-------- See if HAWC2 runs..."
         WINEARCH=$WINEARCH WINEPREFIX=$WINEDIRNAME wine hawc2-latest.exe
     fi
@@ -59,7 +62,8 @@ if [[ ${_HOSTNAME_:0:1} == "j" ]] ; then
     WINEDIRNAME="/home/$USER/.wine"
     WINE_ENV_VARS="WINEPREFIX=$WINEDIRNAME"
     WINE_ALIAS="wine"
-    HAWC2EXES=/home/MET/hawc2exe/$WINEARCH
+    CP_EXE_FROM="/home/MET/hawc2exe/$WINEARCH"
+    EXE_DIR_UNIX="/home/$USER/DTU/Software/wine_exe/$WINEARCH/"
     wine_init_config
 fi
 
@@ -72,6 +76,7 @@ WINEARCH="win32"
 WINEDIRNAME="/home/$USER/.wine32"
 WINE_ENV_VARS="WINEARCH=$WINEARCH WINEPREFIX=$WINEDIRNAME"
 WINE_ALIAS="wine32"
-HAWC2EXES=/home/MET/hawc2exe/$WINEARCH
+CP_EXE_FROM="/home/MET/hawc2exe/$WINEARCH"
+EXE_DIR_UNIX="/home/$USER/DTU/Software/wine_exe/$WINEARCH/"
 wine_init_config
 
-- 
GitLab