From 7be11ce06d07241e0f3d38c56368dd3b8c08f7a9 Mon Sep 17 00:00:00 2001
From: David Robert Verelst <dave@dtu.dk>
Date: Wed, 12 Oct 2016 16:22:42 +0200
Subject: [PATCH] more fixes to wine configurator

---
 config-wine-hawc2.sh | 39 +++++++++++++++++++++++----------------
 1 file changed, 23 insertions(+), 16 deletions(-)

diff --git a/config-wine-hawc2.sh b/config-wine-hawc2.sh
index f86b727..3dd0e8d 100755
--- a/config-wine-hawc2.sh
+++ b/config-wine-hawc2.sh
@@ -1,15 +1,18 @@
 #!/bin/bash
 
-function wine_init_config(){
+function wine_init_config () {
+
+    echo "-------- initialize winecfg"
+    # execute winecfg to trigger init configuration, might fail to complete
+    # on Jess since winefix has not been executed
+    WINEARCH=$WINEARCH WINEPREFIX=$WINEDIRNAME wine winecfg
 
     # winefix only applies to Jess
     if [[ ${_HOSTNAME_:0:1} == "j" ]] ; then
-        `$WINE_ENV_VARS` winefix
+        echo "-------- apply winefix"
+        WINEARCH=$WINEARCH WINEPREFIX=$WINEDIRNAME winefix
     fi
 
-    # try to execute a non existant executable to trigger init configuration
-    `$WINE_ENV_VARS` wine dummy
-
     # 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
@@ -22,33 +25,36 @@ function wine_init_config(){
     EXE_DIR_WINE="c:/users/$USER/My Documents/wine_exe/$WINEARCH/"
     echo "-------- adding $EXE_DIR_UNIX to wine system PATH"
     echo "-------- this is equivalent to $EXE_DIR_WINE in Windows terms."
-    echo
     # 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
-    $WINE_ENV_VARS wine regedit ./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
-    $WINE_ENV_VARS wine regedit ./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 [[ ${_HOSTNAME_:0:1} == "g" ]] ; then
+    if [[ $WINEARCH == "win32" ]] ; then
         echo "-------- adding alias $WINE_ALIAS to ~/.bashrc"
         echo "alias $WINE_ALIAS='$WINE_ENV_VARS wine'" >> ~/.bashrc
         source ~/.bashrc
 
-    echo "-------- See if HAWC2 runs..."
-    $WINE_ENV_VARS wine hawc2-latest.exe
+        echo "-------- See if HAWC2 runs..."
+        WINEARCH=$WINEARCH WINEPREFIX=$WINEDIRNAME wine hawc2-latest.exe
+    fi
 
 }
 
 _HOSTNAME_=`hostname`
 
-# default 64-bit mode only relevant on Jess
+# 64-bit mode only relevant on Jess
 if [[ ${_HOSTNAME_:0:1} == "j" ]] ; then
-    echo "-------- SETUP DEFAULT 64-bit wine environment in ~/.wine"
+    echo
+    echo "====================================================================="
+    echo "-------- SETUP 64-bit wine environment in ~/.wine"
+    echo "====================================================================="
     WINEARCH="win64"
     WINEDIRNAME="/home/$USER/.wine"
     WINE_ENV_VARS="WINEPREFIX=$WINEDIRNAME"
@@ -58,12 +64,13 @@ if [[ ${_HOSTNAME_:0:1} == "j" ]] ; then
 fi
 
 # 32-bit mode for both Gorm and Jess
+echo
+echo "====================================================================="
 echo "-------- SETUP 32-bit wine environment in ~/.wine32"
+echo "====================================================================="
 WINEARCH="win32"
-WINEDIRNAME="/home/$USER/.wine32-clean"
+WINEDIRNAME="/home/$USER/.wine32"
 WINE_ENV_VARS="WINEARCH=$WINEARCH WINEPREFIX=$WINEDIRNAME"
-export WINEARCH=$WINEARCH
-export WINEPREFIX=$WINEDIRNAME
 WINE_ALIAS="wine32"
 HAWC2EXES=/home/MET/hawc2exe/$WINEARCH
 wine_init_config
-- 
GitLab