Skip to content

Commit

Permalink
Windows updates
Browse files Browse the repository at this point in the history
COOT_HOME for windows is in USERPROFILE/COOT now.
Installer will move files from InstallDir to new location if exists.
Wincoot batch script searches for CCP4 installed dictionary actually
generally CCP4 in registry and sets up CCP4.
  • Loading branch information
bernhardcl authored and pemsley committed Oct 8, 2022
1 parent 61fa0c3 commit 52b7761
Show file tree
Hide file tree
Showing 2 changed files with 133 additions and 15 deletions.
72 changes: 65 additions & 7 deletions windows/WinCoot_install_masta.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,39 @@ FunctionEnd
Call un.ErrorHandlerFunction
!macroend

; Macro to move files from INSTDIR to USERPROFILE/COOT
!macro MoveFileToNewHome File isDir
; to avoid duplicate labels...
!define ID ${__LINE__}
; check if file exists
ClearErrors
MessageBox MB_OK `Is "${File}" a dir?`
${If} ${FileExists} "${INSTDIR}\${File}"
# your code here
MessageBox MB_OK "Try rename"
Rename ${INSTDIR}\${File} $%USERPROFILE%\COOT\${File}
IfErrors "" skipit_${ID}
# somehow couldnt rename, try to copy to dest and remove src
# this may be necessary if on different driveletters
ClearErrors
CopyFiles /Silent ${INSTDIR}\${File} $%USERPROFILE%\COOT\${File}
IfErrors "" remove_src_${ID}
# couldnt copy, give message
MessageBox MB_ICONINFORMATION `"${File}" couldnt be moved from it's old place in \
"${INSTDIR}" to new place "$%USERPROFILE%\COOT". \
Consider doing it manually if deemed important.`
goto skipit_${ID}
remove_src_${ID}:
${IF} isDir == "true"
RMDir /r ${INSTDIR}\${File}
${Else}
Delete ${INSTDIR}\${File}
${EndIf}
skipit_${ID}:
${EndIf}
!undef ID
!macroend

; MUI end ------

Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
Expand Down Expand Up @@ -279,6 +312,8 @@ Section "!WinCoot" SEC01
File "${src_dir}\bin\gdk-pixbuf-query-loaders.exe"
; render (or more?) from raster3d?!
File "${src_dir}\bin\render.exe"
; clustalw2
File "${src_dir}\bin\clustalw2.exe"
;gunzip needed?? dont think so
File "C:\msys64\home\bernhard\autobuild\extras\gunzip"
File "C:\msys64\home\bernhard\autobuild\extras\gzip.exe"
Expand Down Expand Up @@ -456,11 +491,7 @@ Section -AddIcons

exit:
SetShellVarContext current
; in case we want to install silently (no user intervention)
; we have to call the finish page function, otherwise runwincoot.bat
; won't be edited.
IfSilent 0 +2
Call FinishPagePreFunction
Call FinishPagePreFunction
IfErrors 0 +5
; ${ErrorHandler} 3 "Error in installation. Could not install icons." 0
DetailPrint "Error in installation. Could not install icons. Continuing."
Expand All @@ -470,6 +501,12 @@ Section -AddIcons
SectionEnd

Section -Post
; first make COOT_HOME in USERPROFILE if it doesnt exist, then move files
IfFileExists "$%USERPROFILE%\COOT\*.*" have_usercoot
CreateDirectory "$%USERPROFILE%\COOT"
Call MoveUserHomeFiles
have_usercoot:

ClearErrors
WriteUninstaller "$INSTDIR\uninst.exe"
; NO MESSING WITH THE REGISTRY!!!!
Expand Down Expand Up @@ -562,6 +599,7 @@ Section Uninstall
Delete "$INSTDIR\bin\lidia.exe"
Delete "$INSTDIR\bin\mini-rsr-bin.exe"
Delete "$INSTDIR\bin\render.exe"
Delete "$INSTDIR\bin\clustalw2.exe"
Delete "$INSTDIR\bin\Microsoft.VC90.CRT.manifest"
Delete "$INSTDIR\bin\pango-querymodules.exe"
Delete "$INSTDIR\bin\pango-view.exe"
Expand Down Expand Up @@ -706,7 +744,7 @@ Function .onInit
; no more examples dir (have data dir now)
; so default start dir is $INSTDIR
${If} $STARTDIR == ""
StrCpy $STARTDIR "$INSTDIR"
StrCpy $STARTDIR "$%USERPROFILE%"
${EndIf}
IfErrors 0 +6
;${ErrorHandler} 6 "Error in installation. Could not initiate installation." 1
Expand Down Expand Up @@ -988,9 +1026,9 @@ ${If} $update = 0
CreateShortCut "$DESKTOP\WinCoot.lnk" "$SYSDIR\cmd.exe" '/c "$INSTDIR\wincoot.bat"' "$INSTDIR\bin\coot-icon.ico" 0 SW_SHOWMINIMIZED
CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\WinCoot.lnk" "$SYSDIR\cmd.exe" '/c "$INSTDIR\wincoot.bat"' "$INSTDIR\bin\coot-icon.ico" 0 SW_SHOWMINIMIZED
Sleep 10
SetOutPath "$INSTDIR"
CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\DynaRama.lnk" "$SYSDIR\cmd.exe" '/c "$INSTDIR\bin\dynarama.bat"' "$INSTDIR\bin\rama_all.ico"
Sleep 10
SetOutPath "$INSTDIR"
WriteIniStr "$INSTDIR\WinCoot.url" "InternetShortcut" "URL" "${PRODUCT_WEB_SITE}"
WriteIniStr "$INSTDIR\Coot.url" "InternetShortcut" "URL" "${PRODUCT_WEB_SITE_2}"
CreateShortCut "$SMPROGRAMS\WinCoot\WinCoot Website.lnk" "$INSTDIR\${PRODUCT_NAME}.url"
Expand Down Expand Up @@ -1030,3 +1068,23 @@ Function ErrorHandler
${EndIf}

FunctionEnd

; Function to move potentially existing WinCoot files and directories from
; INSTALLDIR to USERPROFILE\COOT
Function MoveUserHomeFiles
; what shall we move? preferences, backup, downloads dirs, state and history
; state and history files...
!insertmacro "MoveFileToNewHome" ".coot-preferences" "true"
!insertmacro "MoveFileToNewHome" "coot-backup" "true"
!insertmacro "MoveFileToNewHome" "coot-download" "true"
!insertmacro "MoveFileToNewHome" "coot-ccp4" "true"
!insertmacro "MoveFileToNewHome" "coot-molprobity" "true"
!insertmacro "MoveFileToNewHome" "coot-refmac" "true"
!insertmacro "MoveFileToNewHome" "coot-acedrg" "true"
!insertmacro "MoveFileToNewHome" "coot-pisa" "true"
!insertmacro "MoveFileToNewHome" "0-coot-history.scm" "false"
!insertmacro "MoveFileToNewHome" "0-coot.state.py" "false"
!insertmacro "MoveFileToNewHome" ".coot.py" "false"
!insertmacro "MoveFileToNewHome" "0-coot.state.scm" "false"
!insertmacro "MoveFileToNewHome" "0-coot-history.scm" "false"
FunctionEnd
76 changes: 68 additions & 8 deletions windows/wincoot.bat
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,94 @@
@set LC_NUMERIC=en
title WinCoot

REM First try to find a dictionary. Search in the registry for a
REM CCP4 installation and then setup CCP4.

set COOT_PREFIX=yourWinCootdirectory
if not exist "%CLIBD_MON%" (
echo no $CLIBD_MON found trying to setup CCP4
call :setup_ccp4
)

REM main line

set COOT_PREFIX=%~dp0
set COOT_GUILE_PREFIX=%COOT_PREFIX:\=/%

set COOT_HOME=%COOT_PREFIX%
REM New COOT_HOME is in User directory now
set COOT_HOME=%USERPROFILE%\COOT
set COOT_BACKUP_DIR=%COOT_PREFIX%\coot-backup

set COOT_SHARE=%COOT_PREFIX%\share

if not exist "%CLIBD_MON%" (
echo no $CLIBD_MON found setting COOT_REFMAC_LIB_DIR
set COOT_REFMAC_LIB_DIR=%COOT_SHARE%\coot\lib
Call :setup_coot_dictionary
)

set COOT_SCHEME_DIR=%COOT_SHARE%/coot/scheme
set COOT_STANDARD_RESIDUES=%COOT_SHARE%\coot\standard-residues.pdb
set COOT_PIXMAPS_DIR=%COOT_SHARE%\coot\pixmaps
set COOT_RESOURCES_FILE=%COOT_SHARE%\coot\cootrc
set COOT_DATA_DIR=%COOT_SHARE%\coot
set COOT_REF_STRUCTS=%COOT_SHARE%\coot\reference-structures
set COOT_PYTHON_DIR=%COOT_PREFIX%\python27\lib\site-packages\coot
REM set COOT_REF_SEC_STRUCTS=%COOT_SHARE%\coot\ss-reference-structures

set PYTHONHOME=%COOT_PREFIX%\python27
set COOT_PYTHON_DIR=%COOT_PREFIX%\lib\python2.7\site-packages\coot
REM set PYTHONHOME=%COOT_PREFIX%\python27

set GUILE_LOAD_PATH=%COOT_GUILE_PREFIX%/share/guile/1.8;%COOT_GUILE_PREFIX%/share/guile;%COOT_GUILE_PREFIX%/share/guile/gtk-2.0;%COOT_GUILE_PREFIX%/share/guile/gui;%COOT_GUILE_PREFIX%/share/guile/www;%COOT_GUILE_PREFIX%/share/guile/site

set SYMINFO=%COOT_SHARE%\coot\syminfo.lib

set PATH=%COOT_PREFIX%\bin;%COOT_PREFIX%\lib;%COOT_PREFIX%\python27;%PATH%;%COOT_PREFIX%\bin\extras
set PATH=%COOT_PREFIX%\bin;%COOT_PREFIX%\lib;%PATH%;%COOT_PREFIX%\bin\extras

coot-bin.exe %*

Exit /B %ERRORLEVEL%


REM function to setup CCP4
:setup_ccp4
set /a CCP4_MAJOR=10

:loop_start
set /a CCP4_MAJOR=CCP4_MAJOR-1

call :find_ccp4 HKCU\SOFTWARE\CCP4-%CCP4_MAJOR%
if exist "%CLIBD_MON%" (goto :loop_end)

call :find_ccp4 HKLM\SOFTWARE\WOW6432Node\CCP4-%CCP4_MAJOR%
if exist "%CLIBD_MON%" (goto :loop_end)

if %CCP4_MAJOR% gtr 6 (goto :loop_start)
:loop_end

Exit /B 0


REM Function to find CCP4 in the registry and call ccp4 setup bat
:find_ccp4
REM Check in Registry for CCP4 InstallDir
for /f "skip=1 tokens=3" %%A in (
'reg query %1 /v InstallDir 2^>Nul'
) do set CCP4DIR=%%~A
if not exist "%CCP4DIR%" (Exit /B 0)

REM find latest dir
for /f " tokens=*" %%i in (
'dir "%CCP4DIR%\%CCP4_MAJOR%.*" /b /ad-h /t:c /od'
) do set SETUPFILE=%CCP4DIR%\%%i\ccp4.setup.bat
if not exist "%SETUPFILE%" (Exit /B 0)

REM Finally, setup CCP4
call "%SETUPFILE%"
Exit /B 0

:setup_coot_dictionary
set COOT_REFMAC_LIB_DIR=%COOT_SHARE%\coot\lib
set WARN=No valid dictionary found, no refinement possible!
if not exist "%COOT_REFMAC_LIB_DIR%" (
REM check for Phenix place too
if not exist "%COOT_MONOMER_LIB_DIR%" (
msg "%USERNAME%" WinCoot WARNING:: %WARN%
)
)
Exit /B 0

0 comments on commit 52b7761

Please sign in to comment.