1 # pspp.nsi - a NSIS script for generating a PSPP MSWindows installer.
2 # Copyright (C) 2012-2013 Harry Thijssen
3 # Copyright (C) 2021 John Darrington
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
20 ;; Turning compression off saves a huge amount of time when working on the
21 ;; installer. Keeping it on makes the installer much smaller.
24 !searchparse /${pspp_version} "." vers_min "."
29 !define MUI_ICON "${Prefix}/share/pspp/icons/pspp.ico"
30 !define MUI_UNICON "${Prefix}/share/pspp/icons/pspp.ico"
32 !define ProgramFiles $Programfiles64
33 !else if ${PtrSize} == 32
34 !define ProgramFiles $Programfiles32
36 !error "Unknown architecture"
38 !define MUI_EXTRAPAGES MUI_EXTRAPAGES.nsh
39 !define AdvUninstLog AdvUninstLog.nsh
42 ;--------------------------------
43 !define APP_NAME "PSPP"
44 !define INSTDIR_REG_ROOT "HKLM"
45 !define INSTDIR_REG_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_NAME}"
47 !include "${MUI_EXTRAPAGES}"
48 !include "${AdvUninstLog}"
50 ;------------------------------- Settings -----------------------------------------------;
53 !define ZSavExt ".zsav"
57 Name "${APP_NAME}" ; The name of the installer
58 OutFile "${OutExe}" ; The file to write
60 ;Request application privileges for Windows 7
61 RequestExecutionLevel highest
63 ;--------------------------------
67 !define MUI_ABORTWARNING
69 ;--------------------------------
72 ;Add the install read me page
73 !insertmacro MUI_PAGE_README "${SourceDir}/COPYING"
75 !insertmacro MUI_PAGE_DIRECTORY
76 !insertmacro MUI_PAGE_INSTFILES
78 !insertmacro MUI_UNPAGE_CONFIRM
79 !insertmacro MUI_UNPAGE_INSTFILES
81 !insertmacro UNATTENDED_UNINSTALL
83 ;--------------------------------
86 !insertmacro MUI_LANGUAGE "English" ;first language is the default language
87 !insertmacro MUI_LANGUAGE "French"
88 !insertmacro MUI_LANGUAGE "German"
89 !insertmacro MUI_LANGUAGE "Spanish"
90 ; !insertmacro MUI_LANGUAGE "SpanishInternational"
91 !insertmacro MUI_LANGUAGE "SimpChinese"
92 ; !insertmacro MUI_LANGUAGE "TradChinese"
93 !insertmacro MUI_LANGUAGE "Japanese"
94 ; !insertmacro MUI_LANGUAGE "Korean"
95 ; !insertmacro MUI_LANGUAGE "Italian"
96 !insertmacro MUI_LANGUAGE "Dutch"
97 ; !insertmacro MUI_LANGUAGE "Danish"
98 ; !insertmacro MUI_LANGUAGE "Swedish"
99 ; !insertmacro MUI_LANGUAGE "Norwegian"
100 ; !insertmacro MUI_LANGUAGE "NorwegianNynorsk"
101 ; !insertmacro MUI_LANGUAGE "Finnish"
102 !insertmacro MUI_LANGUAGE "Greek"
103 !insertmacro MUI_LANGUAGE "Russian"
104 ; !insertmacro MUI_LANGUAGE "Portuguese"
105 !insertmacro MUI_LANGUAGE "PortugueseBR"
106 !insertmacro MUI_LANGUAGE "Polish"
107 !insertmacro MUI_LANGUAGE "Ukrainian"
108 !insertmacro MUI_LANGUAGE "Czech"
109 ; !insertmacro MUI_LANGUAGE "Slovak"
110 ; !insertmacro MUI_LANGUAGE "Croatian"
111 ; !insertmacro MUI_LANGUAGE "Bulgarian"
112 !insertmacro MUI_LANGUAGE "Hungarian"
113 ; !insertmacro MUI_LANGUAGE "Thai"
114 ; !insertmacro MUI_LANGUAGE "Romanian"
115 ; !insertmacro MUI_LANGUAGE "Latvian"
116 ; !insertmacro MUI_LANGUAGE "Macedonian"
117 ; !insertmacro MUI_LANGUAGE "Estonian"
118 !insertmacro MUI_LANGUAGE "Turkish"
119 !insertmacro MUI_LANGUAGE "Lithuanian"
120 !insertmacro MUI_LANGUAGE "Slovenian"
121 ; !insertmacro MUI_LANGUAGE "Serbian"
122 ; !insertmacro MUI_LANGUAGE "SerbianLatin"
123 ; !insertmacro MUI_LANGUAGE "Arabic"
124 ; !insertmacro MUI_LANGUAGE "Farsi"
125 ; !insertmacro MUI_LANGUAGE "Hebrew"
126 ; !insertmacro MUI_LANGUAGE "Indonesian"
127 ; !insertmacro MUI_LANGUAGE "Mongolian"
128 ; !insertmacro MUI_LANGUAGE "Luxembourgish"
129 ; !insertmacro MUI_LANGUAGE "Albanian"
130 ; !insertmacro MUI_LANGUAGE "Breton"
131 ; !insertmacro MUI_LANGUAGE "Belarusian"
132 ; !insertmacro MUI_LANGUAGE "Icelandic"
133 ; !insertmacro MUI_LANGUAGE "Malay"
134 ; !insertmacro MUI_LANGUAGE "Bosnian"
135 ; !insertmacro MUI_LANGUAGE "Kurdish"
136 ; !insertmacro MUI_LANGUAGE "Irish"
137 ; !insertmacro MUI_LANGUAGE "Uzbek"
138 !insertmacro MUI_LANGUAGE "Galician"
139 ; !insertmacro MUI_LANGUAGE "Afrikaans"
140 !insertmacro MUI_LANGUAGE "Catalan"
141 ; !insertmacro MUI_LANGUAGE "Esperanto"
142 ; !insertmacro MUI_LANGUAGE "Asturian"
144 ;--------------------------------
148 !macro FilePresent name
149 !if /FileExists ${name}
152 !error "Missing item: ${name}"
156 Section "PSPP" SecDummy
158 ;; If these are missing, then someone probably forgot to run "make install-html"
159 ;; and/or "make install-pdf"
160 !insertmacro FilePresent "${Prefix}/share/doc/pspp/pspp.html"
161 !insertmacro FilePresent "${Prefix}/share/doc/pspp/pspp.pdf"
163 SetOutPath "$INSTDIR"
164 !insertmacro UNINSTALL.LOG_OPEN_INSTALL
166 SetOutPath "$INSTDIR\etc"
167 File /r "${EnvDir}/etc/*"
169 SetOutPath "$INSTDIR\bin"
171 File ${BinDir}/gdbus.exe
172 File ${BinDir}/glib-compile-schemas.exe
173 File ${BinDir}/pspp.exe
174 File ${BinDir}/psppire.exe
175 File ${BinDir}/pspp-*.exe
176 File ${BinDir}/gtk-update-icon-cache.exe
178 SetOutPath "$INSTDIR\share"
179 File /r "${Prefix}/share/*"
181 SetOutPath "$INSTDIR\share\icons\hicolor"
182 File /r "${EnvDir}/share/icons/hicolor/*"
184 SetOutPath "$INSTDIR\share\icons\Adwaita"
185 File /r /x cursors /x legacy "${EnvDir}/share/icons/Adwaita/*" ;; legacy and cursors are HUGE!
187 SetOutPath "$INSTDIR\share\glib-2.0\schemas"
188 File /r "${EnvDir}/share/glib-2.0/schemas/*"
189 ExecWait '"$INSTDIR\bin\glib-compile-schemas.exe" "$INSTDIR\share\glib-2.0\schemas"' $0
191 SetOutPath "$INSTDIR\share\locale"
192 File /r /x "gtk30-properties.mo" "${EnvDir}/share/locale/*"
194 File "/oname=$INSTDIR\share\README.txt" "${SourceDir}/README"
195 File "/oname=$INSTDIR\share\COPYING.txt" "${SourceDir}/COPYING"
196 File "/oname=$INSTDIR\share\NEWS.txt" "${SourceDir}/NEWS"
197 File "/oname=$INSTDIR\share\THANKS.txt" "${SourceDir}/THANKS"
198 File "/oname=$INSTDIR\share\AUTHORS.txt" "${SourceDir}/AUTHORS"
200 !insertmacro UNINSTALL.LOG_CLOSE_INSTALL
202 # call userInfo plugin to get user info. The plugin puts the result in the stack
203 userInfo::getAccountType
205 strCmp $0 "Admin" Admin
207 WriteRegStr HKCU "Software\Classes\${SavExt}" "" "PSPP System File"
208 WriteRegStr HKCU "Software\Classes\${SavExt}" "Content Type" "application/x-spss-sav"
209 WriteRegStr HKCU "Software\Classes\PSPP System File\DefaultIcon" "" "$INSTDIR\share\pspp\icons\pspp-sav.ico"
210 WriteRegStr HKCU "Software\Classes\PSPP System File\Shell\Open\Command" "" '$INSTDIR\bin\psppire.exe "%1"'
212 WriteRegStr HKCU "Software\Classes\${ZSavExt}" "" "PSPP System File Compressed"
213 # WriteRegStr HKCU "Software\Classes\${ZSavExt}" "Content Type" "application/x-spss-sav"
214 WriteRegStr HKCU "Software\Classes\MIME\Database\Content Type\application/x-spss-sav" "Extension" ".sav"
215 WriteRegStr HKCU "Software\Classes\PSPP System File Compressed\DefaultIcon" "" "$INSTDIR\share\pspp\icons\pspp-zsav.ico"
216 WriteRegStr HKCU "Software\Classes\PSPP System File Compressed\Shell\Open\Command" "" '$INSTDIR\bin\psppire.exe "%1"'
218 WriteRegStr HKCU "Software\Classes\${PorExt}" "" "PSPP Portable File"
219 WriteRegStr HKCU "Software\Classes\${PorExt}" "Content Type" "application/x-spss-por"
220 WriteRegStr HKCU "Software\Classes\MIME\Database\Content Type\application/x-spss-por" "Extension" ".por"
221 WriteRegStr HKCU "Software\Classes\PSPP Portable File\DefaultIcon" "" "$INSTDIR\share\pspp\icons\pspp-por.ico,0"
222 WriteRegStr HKCU "Software\Classes\PSPP Portable File\Shell\Open\Command" "" '$INSTDIR\bin\psppire.exe "%1"'
224 WriteRegStr HKCU "Software\Classes\${SpsExt}" "" "PSPP Syntax File"
225 WriteRegStr HKCU "Software\Classes\${SpsExt}" "Content Type" "application/x-spss-sps"
226 WriteRegStr HKCU "Software\Classes\PSPP Syntax File\DefaultIcon" "" "$INSTDIR\share\pspp\icons\pspp-sps.ico,0"
227 WriteRegStr HKCU "Software\Classes\PSPP Syntax File\Shell\Open\Command" "" '$INSTDIR\bin\psppire.exe "%1"'
229 # registering additional mime types
230 WriteRegStr HKCU "Software\Classes\.txt" "Content Type" "text/plain"
231 WriteRegStr HKCU "Software\Classes\MIME\Database\Content Type\text/plain" "Extension" ".txt"
232 WriteRegStr HKCU "Software\Classes\.text" "Content Type" "text/plain"
233 WriteRegStr HKCU "Software\Classes\MIME\Database\Content Type\text/plain" "Extension" ".text"
234 WriteRegStr HKCU "Software\Classes\.csv" "Content Type" "text/csv"
235 WriteRegStr HKCU "Software\Classes\MIME\Database\Content Type\text/csv" "Extension" ".csv"
236 WriteRegStr HKCU "Software\Classes\.tsv" "Content Type" "text/tab-separated-values"
237 WriteRegStr HKCU "Software\Classes\MIME\Database\Content Type\text/tab-separated-values" "Extension" ".tsv"
238 WriteRegStr HKCU "Software\Classes\.gnumeric" "Content Type" "application/x-gnumeric"
239 WriteRegStr HKCU "Software\Classes\MIME\Database\Content Type\text/plain" "Extension" ".gnumeric"
240 WriteRegStr HKCU "Software\Classes\.ods" "Content Type" "application/vnd.oasis.opendocument.spreadsheet"
241 WriteRegStr HKCU "Software\Classes\MIME\Database\Content Type\application/vnd.oasis.opendocument.spreadsheet" "Extension" ".ods"
243 WriteRegStr HKCU ${INSTDIR_REG_KEY} "DisplayName" "${APP_NAME}"
244 WriteRegStr HKCU ${INSTDIR_REG_KEY} "UninstallString" '"$INSTDIR\UNINSTALL.exe"'
245 WriteRegStr HKCU ${INSTDIR_REG_KEY} "Publisher" "Free Software Foundation, Inc."
246 WriteRegStr HKCU ${INSTDIR_REG_KEY} "DisplayIcon" '"$INSTDIR\bin\psppire.exe"'
247 WriteRegStr HKCU ${INSTDIR_REG_KEY} "DisplayVersion" "${pspp_version}"
250 Admin: ;MultiUser Install
251 SetShellVarContext all
252 WriteRegStr HKCR "${SavExt}" "" "PSPP System File"
253 WriteRegStr HKCR "${SavExt}" "Content Type" "application/x-spss-sav"
254 WriteRegStr HKCR "MIME\Database\Content Type\application/x-spss-sav" "Extension" ".sav"
255 WriteRegStr HKCR "PSPP System File\DefaultIcon" "" "$INSTDIR\share\pspp\icons\pspp-sav.ico,0"
256 WriteRegStr HKCR "PSPP System File\Shell\Open\Command" "" '$INSTDIR\bin\psppire.exe "%1"'
258 WriteRegStr HKCR "${ZSavExt}" "" "PSPP System File Compressed"
259 WriteRegStr HKCR "PSPP System File Compressed\DefaultIcon" "" "$INSTDIR\share\pspp\icons\pspp-zsav.ico,0"
260 WriteRegStr HKCR "PSPP System File Compressed\Shell\Open\Command" "" '$INSTDIR\bin\psppire.exe "%1"'
262 WriteRegStr HKCR "${PorExt}" "" "PSPP Portable File"
263 WriteRegStr HKCR "${PorExt}" "Content Type" "application/x-spss-por"
264 WriteRegStr HKCR "MIME\Database\Content Type\application/x-spss-por" "Extension" ".por"
265 WriteRegStr HKCR "PSPP Portable File\DefaultIcon" "" "$INSTDIR\share\pspp\icons\pspp-por.ico,0"
266 WriteRegStr HKCR "PSPP Portable File\Shell\Open\Command" "" '$INSTDIR\bin\psppire.exe "%1"'
268 WriteRegStr HKCR "${SpsExt}" "" "PSPP Syntax File"
269 WriteRegStr HKCR "${SpsExt}" "Content Type" "application/x-spss-sps"
270 WriteRegStr HKCR "PSPP Syntax File\DefaultIcon" "" "$INSTDIR\share\pspp\icons\pspp-sps.ico,0"
271 WriteRegStr HKCR "PSPP Syntax File\Shell\Open\Command" "" '$INSTDIR\bin\psppire.exe "%1"'
273 # registering additional mime types
274 WriteRegStr HKCR ".txt" "Content Type" "text/plain"
275 WriteRegStr HKCR "MIME\Database\Content Type\text/plain" "Extension" ".txt"
276 WriteRegStr HKCR ".text" "Content Type" "text/plain"
277 WriteRegStr HKCR "MIME\Database\Content Type\text/plain" "Extension" ".text"
278 WriteRegStr HKCR ".csv" "Content Type" "text/csv"
279 WriteRegStr HKCR "MIME\Database\Content Type\text/csv" "Extension" ".csv"
280 WriteRegStr HKCR ".tsv" "Content Type" "text/tab-separated-values"
281 WriteRegStr HKCR "MIME\Database\Content Type\text/tab-separated-values" "Extension" ".tsv"
282 WriteRegStr HKCR ".gnumeric" "Content Type" "application/x-gnumeric"
283 WriteRegStr HKCR "MIME\Database\Content Type\text/plain" "Extension" ".gnumeric"
284 WriteRegStr HKCR ".ods" "Content Type" "application/vnd.oasis.opendocument.spreadsheet"
285 WriteRegStr HKCR "MIME\Database\Content Type\application/vnd.oasis.opendocument.spreadsheet" "Extension" ".ods"
287 WriteRegStr HKLM ${INSTDIR_REG_KEY} "DisplayName" "${APP_NAME}"
288 WriteRegStr HKLM ${INSTDIR_REG_KEY} "UninstallString" '"$INSTDIR\UNINSTALL.exe"'
289 WriteRegStr HKLM ${INSTDIR_REG_KEY} "Publisher" "Free Software Foundation, Inc."
290 WriteRegStr HKLM ${INSTDIR_REG_KEY} "DisplayIcon" '"$INSTDIR\bin\psppire.exe"'
291 WriteRegStr HKLM ${INSTDIR_REG_KEY} "DisplayVersion" "${pspp_version}"
296 # flush the icon cache
297 System::Call 'shell32.dll::SHChangeNotify(i, i, i, i) v (0x08000000, 0, 0, 0)'
299 ; Now create shortcuts
300 SetOutPath "%HOMEDRIVE%HOMEPATH"
301 CreateDirectory "$SMPROGRAMS\${APP_NAME}"
302 CreateShortCut "$SMPROGRAMS\${APP_NAME}\PSPP.lnk" "$INSTDIR\bin\psppire.exe" "" "$INSTDIR\share\pspp\icons\pspp.ico"
303 CreateShortCut "$SMPROGRAMS\${APP_NAME}\README.lnk" "$INSTDIR\share\README.txt"
304 CreateShortCut "$SMPROGRAMS\${APP_NAME}\Manual.lnk" "$INSTDIR\share\doc\pspp\pspp.pdf"
305 CreateShortCut "$SMPROGRAMS\${APP_NAME}\License.lnk" "$INSTDIR\share\COPYING.txt"
306 CreateShortCut "$SMPROGRAMS\${APP_NAME}\NEWS.lnk" "$INSTDIR\share\NEWS.txt"
307 CreateShortCut "$SMPROGRAMS\${APP_NAME}\THANKS.lnk" "$INSTDIR\share\THANKS.txt"
308 CreateShortCut "$SMPROGRAMS\${APP_NAME}\AUTHORS.lnk" "$INSTDIR\share\AUTHORS.txt"
309 CreateShortCut "$SMPROGRAMS\${APP_NAME}\Examples.lnk" "$INSTDIR\share\pspp\examples"
310 CreateShortCut "$SMPROGRAMS\${APP_NAME}\Uninstall PSPP.lnk" "$INSTDIR\Uninstall.exe"
311 CreateShortCut "$DESKTOP\${APP_NAME}.lnk" "$INSTDIR\bin\psppire.exe" "" "$INSTDIR\share\pspp\icons\pspp.ico"
312 IfFileExists "$INSTDIR\bin\gdb.exe" file_found file_not_found
314 IfFileExists "c:\windows\command\start.exe" on-wine on-windows
316 SetOutPath "$INSTDIR"
317 CreateShortcut "$DESKTOP\DebugPSPP.lnk" "$INSTDIR\bin\gdb" 'bin\psppire.exe' '"$INSTDIR\bin"'
318 CreateShortcut "$INSTDIR\DebugPSPP.lnk" "$INSTDIR\bin\gdb" 'bin\psppire.exe' '"$INSTDIR\bin"'
319 SetOutPath "%HOMEDRIVE%HOMEPATH"
322 SetOutPath "$INSTDIR"
323 CreateShortCut "$DESKTOP\PSPPDebug.lnk" "$INSTDIR\bin\DebugPSPP.bat" '"$INSTDIR\bin"'
324 CreateShortcut "$SMPROGRAMS\PSPP\DebugPSPP.lnk" "$INSTDIR\bin\DebugPSPP.BAT" '"$INSTDIR\bin"'
325 SetOutPath "%HOMEDRIVE%HOMEPATH"
326 CreateShortcut "$DESKTOP\GDB Manual.lnk" "http://sourceware.org/gdb/current/onlinedocs/gdb/"
327 CreateShortcut "$SMPROGRAMS\PSPP\GDB Manual.lnk" "http://sourceware.org/gdb/current/onlinedocs/gdb/"
330 CreateShortCut "$DESKTOP\PSPP Manual.lnk" "$INSTDIR\share\doc\pspp\pspp.pdf"
331 CreateShortcut "$SMPROGRAMS\PSPP\PSPP_Commandline.lnk" "$INSTDIR\bin\pspp.exe" '"$INSTDIR\bin"'
334 SetOutPath "$INSTDIR"
335 WriteUninstaller "$INSTDIR\Uninstall.exe"
339 ;--------------------------------
343 ;; Test Versions get a default directory of "PSPP-TESTING"
344 ;; Released Versions have "PSPP"
345 ;; Debug Versions have "PSPP-DEBUG"
346 Var /global DefaultInstallDir
348 StrCpy $DefaultInstallDir "${APP_NAME}-DEBUG"
350 Intop $0 ${vers_min} % 2
352 StrCpy $DefaultInstallDir "${APP_NAME}"
354 StrCpy $DefaultInstallDir "${APP_NAME}-TESTING"
358 MessageBox MB_OKCANCEL "This windoze installer is work in progress. It is known to have deficiencies and is recommended for testing and evaluation purposes only." IDOK continue
359 Abort ; Allow the use to decide not to continue
364 # call userInfo plugin to get user info. The plugin puts the result in the stack
365 userInfo::getAccountType
367 strCmp $0 "Admin" Admin
369 StrCpy $INSTDIR "$PROFILE\$DefaultInstallDir"
372 StrCpy $INSTDIR "${ProgramFiles}\$DefaultInstallDir"
375 !insertmacro UNINSTALL.LOG_PREPARE_INSTALL
378 Function .onInstSuccess
379 !insertmacro UNINSTALL.LOG_UPDATE_INSTALL
386 ;; Remove these directories in a single operation.
387 ;; Doing so makes uninstallation much faster. However don't
388 ;; be tempted to do "Rmdir /r $INSTDIR" - this would wipe out
389 ;; the user's entire system if she had decided that INSTDIR is
390 ;; the C:\ directory.
392 Rmdir /r "$INSTDIR\etc"
393 Rmdir /r "$INSTDIR\bin"
394 Rmdir /r "$INSTDIR\share"
396 !insertmacro UNINSTALL.LOG_UNINSTALL "$INSTDIR"
397 !insertmacro UNINSTALL.LOG_UNINSTALL "$APPDATA\${APP_NAME}"
398 !insertmacro UNINSTALL.LOG_END_UNINSTALL
400 userInfo::getAccountType
402 strCmp $0 "Admin" Admin
404 DeleteRegKey HKCU "Software\Classes\${PorExt}"
405 DeleteRegKey HKCU "Software\Classes\${SavExt}"
406 DeleteRegKey HKCU "Software\Classes\${SpsExt}"
407 DeleteRegKey HKCU "Software\Classes\PSPP Portable File"
408 DeleteRegKey HKCU "Software\Classes\PSPP System File"
409 DeleteRegKey HKCU "Software\Classes\PSPP Syntax File"
411 DeleteRegKey HKCU "${INSTDIR_REG_KEY}"
415 SetShellVarContext all
416 DeleteRegKey HKCR "${PorExt}"
417 DeleteRegKey HKCR "${SavExt}"
418 DeleteRegKey HKCR "${SpsExt}"
419 DeleteRegKey HKCR "PSPP Portable File"
420 DeleteRegKey HKCR "PSPP System File"
421 DeleteRegKey HKCR "PSPP Syntax File"
423 DeleteRegKey HKLM "${INSTDIR_REG_KEY}"
427 ; Now remove shortcuts too
428 RMDIR /r "$SMPROGRAMS\PSPP"
429 Delete "$DESKTOP\PSPP.lnk"
430 Delete "$DESKTOP\PSPPDebug.lnk"
431 Delete "$DESKTOP\PSPP Manual.lnk"
432 Delete "$DESKTOP\GDB Manual.lnk"
434 # call userInfo plugin to get user info. The plugin puts the result in the stack
438 ;----------------------------------------------------
441 !insertmacro UNINSTALL.LOG_BEGIN_UNINSTALL
443 ;--------------------------------------------