MDANSE_installer.nsi 6.66 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
!include "MUI.nsh"
!include "x64.nsh"
!include "LogicLib.nsh"

!ifndef ARCH
  !error "No architecture defined (win32 or win-amd64)"
!endif


!ifndef VERSION
  !define VERSION 'DEV'
!endif

!ifndef REVISION
  !define REVISION '???'
!endif

; The name of the installer
Name "MDANSE ${VERSION}"

; The name of the installer file to write
OutFile "MDANSE_${VERSION}_${ARCH}.exe"

RequestExecutionLevel admin #NOTE: You still need to check user rights with UserInfo!

; The default installation directory
InstallDir "$PROGRAMFILES\Institut Laue-Langevin\MDANSE_${VERSION}_${ARCH}"

; Registry key to check for directory (so if you install again, it will overwrite the old one automatically)
InstallDirRegKey HKLM "Software\Institut Laue-Langevin\MDANSE_${VERSION}_${ARCH}" "Install_Dir"

; Will show the details of installation
ShowInstDetails show

; Will show the details of uninstallation
ShowUnInstDetails show

!define PUBLISHER "Institut Laue-Langevin"
!define WEB_SITE "https://github.com/eurydyce/MDANSE"
!define UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\MDANSE_${VERSION}_${ARCH}"
!define UNINST_ROOT_KEY "HKLM"

!define ICONS_DIR $INSTDIR\icons

; Prompt the user in case he wants to cancel the installation
!define MUI_ABORTWARNING

; define the icon for the installer file and the installer 'bandeau'
!define MUI_ICON   "icons\MDANSE.ico"
!define MUI_UNICON "icons\MDANSE_uninstall.ico"
!define MUI_WELCOMEFINISHPAGE_BITMAP "icons\MDANSE_resized.bmp"
!define MUI_UNWELCOMEFINISHPAGE_BITMAP "icons\MDANSE_uninstall_resized.bmp"

!define WEB_ICON   "icons\website.ico"

!define MUI_WELCOMEPAGE_TEXT "This wizard will guide you through the installation of \
MDANSE release ${VERSION} (Rev ${REVISION}).\
\n\nMDANSE (Molecular Dynamics ANalysis for Neutron Scattering Experiments) is an program for the analysis of Molecular Dynamics simulations. \
It is especially designed for the computation and decomposition of neutron scattering spectra. \
The structure and dynamics of the simulated systems can be characterized in terms of various space \
and time correlation functions."

; Insert a "Welcome" page in the installer
!insertmacro MUI_PAGE_WELCOME

; Insert a "License" page in the installer
!insertmacro MUI_PAGE_LICENSE "LICENSE.txt"

; Insert a page to browse for the installation directory
!insertmacro MUI_PAGE_DIRECTORY

; Insert a page for actual installation (+display) of MDANSE
!insertmacro MUI_PAGE_INSTFILES

; Insert in the finish page the possibility to run MDANSE
!define MUI_FINISHPAGE_RUN_NOTCHECKED
!define MUI_FINISHPAGE_RUN_TEXT "Start MDANSE ${VERSION}"
!define MUI_FINISHPAGE_RUN "$INSTDIR\MDANSE_launcher.bat"
; Insert in the finish page the possibility to view the changelog
!define MUI_FINISHPAGE_SHOWREADME_TEXT "View Changelog"
!define MUI_FINISHPAGE_SHOWREADME_NOTCHECKED
!define MUI_FINISHPAGE_SHOWREADME "$INSTDIR\CHANGELOG.txt"
; Actually insert the finish page to the installer
!insertmacro MUI_PAGE_FINISH

; Uninstaller pages
!insertmacro MUI_UNPAGE_INSTFILES

; Set the installer language to english
!insertmacro MUI_LANGUAGE "English"

;RequestExecutionLevel user

Function .onInit
  ${If} ${ARCH} == "win-amd64"
    StrCpy $INSTDIR "$PROGRAMFILES64\Institut Laue-Langevin\MDANSE_${VERSION}_${ARCH}"
  ${Else}
    StrCpy $INSTDIR "$PROGRAMFILES\Institut Laue-Langevin\MDANSE_${VERSION}_${ARCH}"
  ${EndIf}
FunctionEnd

Section "MDANSE ${VERSION}" SEC01
  SetShellVarContext all
  SetOutPath "$INSTDIR"
  SetOverwrite on
  File /r /x *.pyc /x *.pyo /x *.log /x *.egg-info "${PYTHON_INST}\*"
  File "CHANGELOG.txt"
  File "LICENSE.txt"
  File "MDANSE_launcher.bat"
  File "MDANSE_command_shell.bat"
  CreateDirectory "${ICONS_DIR}"
  SetOutPath "${ICONS_DIR}"
  SetOverwrite on
  File /oname=run.ico "${MUI_ICON}"
  File /oname=uninstall.ico "${MUI_UNICON}"
  File /oname=web.ico "${WEB_ICON}"
  File /oname=terminal.ico "icons\MDANSE_terminal.ico"
  SetOutPath "$INSTDIR"
  SetOverwrite on
  CreateShortCut "$DESKTOP\MDANSE_${VERSION}_${ARCH}.lnk" "$INSTDIR\MDANSE_launcher.bat" "" "${ICONS_DIR}\run.ico" 0
  CreateDirectory "$SMPROGRAMS\Institut Laue-Langevin\MDANSE_${VERSION}_${ARCH}"
  CreateShortCut "$SMPROGRAMS\Institut Laue-Langevin\MDANSE_${VERSION}_${ARCH}\MDANSE.lnk" "$INSTDIR\MDANSE_launcher.bat" "" "${ICONS_DIR}\run.ico" 0
  CreateShortCut "$SMPROGRAMS\Institut Laue-Langevin\MDANSE_${VERSION}_${ARCH}\MDANSE_command_shell.lnk" \
					"$SYSDIR\cmd.exe" \
					'/K "$INSTDIR\MDANSE_command_shell.bat"' \
					"${ICONS_DIR}\terminal.ico" 0					
  WriteIniStr "$INSTDIR\MDANSE.url" "InternetShortcut" "URL" "${WEB_SITE}"
  CreateShortCut "$SMPROGRAMS\Institut Laue-Langevin\MDANSE_${VERSION}_${ARCH}\Website.lnk" "$INSTDIR\MDANSE.url" "" "${ICONS_DIR}\web.ico" 0
  CreateShortCut "$SMPROGRAMS\Institut Laue-Langevin\MDANSE_${VERSION}_${ARCH}\Uninstall.lnk" "$INSTDIR\uninst.exe" "" "${ICONS_DIR}\uninstall.ico" 0

  WriteRegStr ${UNINST_ROOT_KEY} "${UNINST_KEY}" "DisplayName" "MDANSE_${VERSION}_${ARCH}"
  WriteRegStr ${UNINST_ROOT_KEY} "${UNINST_KEY}" "UninstallString" "$INSTDIR\uninst.exe"
  WriteRegStr ${UNINST_ROOT_KEY} "${UNINST_KEY}" "DisplayIcon" "${ICONS_DIR}\run.ico"
  WriteRegStr ${UNINST_ROOT_KEY} "${UNINST_KEY}" "DisplayVersion" "${VERSION}"
  WriteRegStr ${UNINST_ROOT_KEY} "${UNINST_KEY}" "URLInfoAbout" "${WEB_SITE}"
  WriteRegStr ${UNINST_ROOT_KEY} "${UNINST_KEY}" "Publisher" "${PUBLISHER}"
  
  WriteUninstaller "$INSTDIR\uninst.exe"
  SetAutoClose false
SectionEnd

Function un.onInit
  !insertmacro MUI_UNGETLANGUAGE
  MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "Are you really sure you want to uninstall MDANSE ${VERSION} ?" IDYES +2
  Abort
FunctionEnd

Section uninstall
  SetShellVarContext all
  Delete "$INSTDIR\MDANSE.url"
  Delete "$INSTDIR\uninst.exe"
  Delete "$INSTDIR\CHANGELOG.txt"
  Delete "$INSTDIR\MDANSE_launcher.bat"
  Delete "$INSTDIR\MDANSE_command_shell.bat"
  Delete "$INSTDIR\python27.dll"
  Delete "${ICONS_DIR}\run.ico"
  Delete "${ICONS_DIR}\terminal.ico"
  Delete "${ICONS_DIR}\uninstall.ico"
  Delete "${ICONS_DIR}\web.ico"

  Delete "$DESKTOP\MDANSE_${VERSION}_${ARCH}.lnk"
    
  Delete "$SMPROGRAMS\Institut Laue-Langevin\MDANSE_${VERSION}_${ARCH}\MDANSE_command_shell.lnk"
  Delete "$SMPROGRAMS\Institut Laue-Langevin\MDANSE_${VERSION}_${ARCH}\Uninstall.lnk"
  Delete "$SMPROGRAMS\Institut Laue-Langevin\MDANSE_${VERSION}_${ARCH}\Website.lnk"
  Delete "$SMPROGRAMS\Institut Laue-Langevin\MDANSE_${VERSION}_${ARCH}\MDANSE.lnk"
  RMDir /r "$SMPROGRAMS\Institut Laue-Langevin\MDANSE_${VERSION}_${ARCH}"
  RMDir /r "$INSTDIR"

  DeleteRegKey ${UNINST_ROOT_KEY} "${UNINST_KEY}"
  SetAutoClose false
SectionEnd