File: install.nsi

package info (click to toggle)
clisp 1%3A2.44.1-4.1
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 40,080 kB
  • ctags: 12,945
  • sloc: lisp: 77,546; ansic: 32,166; xml: 25,161; sh: 11,568; fortran: 7,094; cpp: 2,636; makefile: 1,234; perl: 164
file content (402 lines) | stat: -rwxr-xr-x 15,099 bytes parent folder | download | duplicates (3)
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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
# installer for GNU CLISP
# using Nullsoft Install System
# (C) 2007 Elliott Slaughter
#
# this source code is a part of CLISP,
# and is released under the GPL v2
# (or newer, as the user sees fit).
#
# usage: place script and additional files
# (is_user_admin and add_to_path) to directory
# where clisp distro is stored, then compile
# with NSIS (latest version used was 2.31).
#
# note: this script globs all files in the current
# directory, ignoring files that match "install*"


# general

    !include MUI.nsh

    # compression method
    SetCompressor /SOLID LZMA
    SetCompressorDictSize 16 # MB

    # http://nsis.sourceforge.net/IsUserAdmin
    !include "is_user_admin.nsh"

    # name and file
    !define VERSION "@VERSION@"
    !define NAME "@NAME@"
    !define FULL_MODULES "@MODULES@"
    !define BASE_MODULES "@BASE_MODULES@"

    # http://nsis.sourceforge.net/Path_Manipulation
    !include "add_to_path.nsh"

    # name and output of file
    Name "${NAME} ${VERSION}"
    OutFile "clisp-${VERSION}-win32-install.exe"

    # default installation folder
    InstallDir "$PROGRAMFILES\clisp-${VERSION}"

    # get installation folder from registry if available
    InstallDirRegKey HKCU "Software\${NAME} ${VERSION}" ""

# variables

    Var LinkingSet
    Var LinkingCmd
    Var UserSetting
    Var STARTMENU_FOLDER
    Var STARTMENU_TEMP

# interface configuration

    !define MUI_ABORTWARNING

# installation types
InstType "Typical"

# page definitions and settings

    #installer pages

    !define MUI_COMPONENTSPAGE_SMALLDESC

    !insertmacro MUI_PAGE_WELCOME
    !insertmacro MUI_PAGE_LICENSE "COPYRIGHT.rtf"
    !insertmacro MUI_PAGE_COMPONENTS
    !insertmacro MUI_PAGE_DIRECTORY

    !define MUI_STARTMENUPAGE_DEFAULTFOLDER "${NAME} ${VERSION}"
    !define MUI_STARTMENUPAGE_REGISTRY_ROOT HKCU
    !define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\${NAME} ${VERSION}"
    !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Start Menu Folder"
    !insertmacro MUI_PAGE_STARTMENU StartMenu $STARTMENU_FOLDER

    !insertmacro MUI_PAGE_INSTFILES

    # uninstaller pages
    !insertmacro MUI_UNPAGE_CONFIRM
    !insertmacro MUI_UNPAGE_INSTFILES

# language files

    !insertmacro MUI_LANGUAGE "English"

# installer sections

# install for all users or just current user?
SectionGroup /e "!Install For"

    Section "All Users" SecAllUsers

        # set shell var context to all
        SetShellVarContext all

        # save in registry
        WriteRegStr HKCU "Software\${NAME} ${VERSION}" "Shell Var Context" "all"

        # save env var context in registry
        WriteRegStr HKCU "Software\${NAME} ${VERSION}" "Environment Context" "all"
    SectionEnd

    Section "Just Me" SecCurUser
    SectionIn 1
        # set shell var context to current
        SetShellVarContext current

        # save in registry
        WriteRegStr HKCU "Software\${NAME} ${VERSION}" "Shell Var Context" "current"

        # save env var context in registry
        WriteRegStr HKCU "Software\${NAME} ${VERSION}" "Environment Context" "current"
    SectionEnd

SectionGroupEnd

SectionGroup /e "!${NAME} Core"

    Section "${NAME} ${VERSION}" SecCore
    SectionIn 1 RO

        SetOutPath $INSTDIR

        # create files
        File /r /x "*.nsi" /x "*.nsh" /x "text_to_rtf.*" /x "COPYRIGHT.rtf" /x "install*.*" ".\"

        # set linking set to base
        StrCpy $LinkingCmd "base"

        # store installation folder in registry
        WriteRegStr HKCU "Software\${NAME} ${VERSION}" "" $INSTDIR

        # create uninstaller
        WriteUninstaller "uninstall.exe"
    SectionEnd

    Section "Base Linking Set" SecBase

        # set linking set to base
        StrCpy $LinkingCmd "base"
    SectionEnd

    Section "Full Linking Set" SecFull
    SectionIn 1

        # set linking set to base
        StrCpy $LinkingCmd "full"
    SectionEnd

    Section "-Add/Remove Programs"

        # add uninstaller to add/remove programs
        StrCmp $UserSetting ${SecAllUsers} WriteRegStr_all
            WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\${NAME} ${VERSION}" \
                "DisplayName" "${NAME} ${VERSION}"
            WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\${NAME} ${VERSION}" \
                "DisplayIcon" "$INSTDIR\clisp.exe,0"
            WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\${NAME} ${VERSION}" \
                "DisplayVersion" "${VERSION}"
            WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\${NAME} ${VERSION}" \
                "InstallLocation" "$INSTDIR"
            WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\${NAME} ${VERSION}" \
                "UninstallString" "$INSTDIR\uninstall.exe"
            WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\${NAME} ${VERSION}" \
                "URLInfoAbout" "http://clisp.cons.org/"
            WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\${NAME} ${VERSION}" \
                "URLUpdateInfo" "http://clisp.cons.org/"
            WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\${NAME} ${VERSION}" \
                "HelpLink" "http://clisp.cons.org/"
            WriteRegDWord HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\${NAME} ${VERSION}" \
                "NoModify" 1
            WriteRegDWord HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\${NAME} ${VERSION}" \
                "NoRepair" 1
        Goto WriteRegStr_done
        WriteRegStr_all:
            WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${NAME} ${VERSION}" \
                "DisplayName" "${NAME} ${VERSION}"
            WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${NAME} ${VERSION}" \
                "DisplayIcon" "$INSTDIR\clisp.exe,0"
            WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${NAME} ${VERSION}" \
                "DisplayVersion" "${VERSION}"
            WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${NAME} ${VERSION}" \
                "InstallLocation" "$INSTDIR"
            WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${NAME} ${VERSION}" \
                "UninstallString" "$INSTDIR\uninstall.exe"
            WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${NAME} ${VERSION}" \
                "URLInfoAbout" "http://clisp.cons.org/"
            WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${NAME} ${VERSION}" \
                "URLUpdateInfo" "http://clisp.cons.org/"
            WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${NAME} ${VERSION}" \
                "HelpLink" "http://clisp.cons.org/"
            WriteRegDWord HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${NAME} ${VERSION}" \
                "NoModify" 1
            WriteRegDWord HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${NAME} ${VERSION}" \
                "NoRepair" 1
        WriteRegStr_done:
    SectionEnd

    Section "-Start Menu"

        # add start menu shortcuts
        !insertmacro MUI_STARTMENU_WRITE_BEGIN StartMenu
            CreateDirectory $SMPROGRAMS\$STARTMENU_FOLDER
            CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\${NAME} ${VERSION}.lnk" "$INSTDIR\clisp.exe" "-K $LinkingCmd"
            CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\Uninstall ${NAME} ${VERSION}.lnk" $INSTDIR\uninstall.exe
        !insertmacro MUI_STARTMENU_WRITE_END
    SectionEnd

    Section "Desktop Shortcut" SecDesktop
    SectionIn 1

        # create shortcut
        createShortCut "$DESKTOP\${NAME} ${VERSION}.lnk" "$INSTDIR\clisp.exe" "-K $LinkingCmd"

        # record installation of desktop shortcut in registry
        WriteRegStr HKCU "Software\${NAME} ${VERSION}" "Desktop Shortcut" "true"
    SectionEnd

    Section "File Associations" SecAssoc
    SectionIn 1

        # add file associations to registry
        WriteRegStr HKCR ".lisp" "" "lispfile"
        WriteRegStr HKCR ".lsp" "" "lispfile"
        WriteRegStr HKCR ".cl" "" "lispfile"
        WriteRegStr HKCR ".fas" "" "fasfile"
        WriteRegStr HKCR ".mem" "" "memfile"

        WriteRegStr HKCR "lispfile" "" "Lisp source file"
        WriteRegDWord HKCR "lispfile" "EditFlags" 0
        WriteRegStr HKCR "lispfile\DefaultIcon" "" "%SystemRoot%\system32\SHELL32.dll,41"
        WriteRegStr HKCR "lispfile\Shell\Compile_with_CLISP" "" "Compile with CLISP"
        WriteRegStr HKCR "lispfile\Shell\Compile_with_CLISP\command" "" '"$INSTDIR\clisp.exe" -K $LinkingCmd -c "%1"'

        WriteRegStr HKCR "fasfile" "" "CLISP compiled file"
        WriteRegDWord HKCR "fasfile" "EditFlags" 0
        WriteRegStr HKCR "fasfile\DefaultIcon" "" "%SystemRoot%\system32\SHELL32.dll,21"
        WriteRegStr HKCR "fasfile\Shell\Execute_with_CLISP" "" "Execute with CLISP"
        WriteRegStr HKCR "fasfile\Shell\Execute_with_CLISP\command" "" '"$INSTDIR\clisp.exe" -K $LinkingCmd "%1"'
        WriteRegStr HKCR "fasfile\Shell\Load_into_CLISP" "" "Load into CLISP"
        WriteRegStr HKCR "fasfile\Shell\Load_into_CLISP\command" "" '"$INSTDIR\clisp.exe" -K $LinkingCmd -i "%1"'

        WriteRegStr HKCR "memfile" "" "CLISP memory image"
        WriteRegDWord HKCR "memfile" "EditFlags" 0
        WriteRegStr HKCR "memfile\DefaultIcon" "" "%SystemRoot%\system32\SHELL32.dll,21"
        WriteRegStr HKCR "memfile\Shell\Run_with_CLISP" "" "Run with CLISP"
        WriteRegStr HKCR "memfile\Shell\Run_with_CLISP\command" "" '"$INSTDIR\clisp.exe" -K $LinkingCmd -M "%1"'

        # record installation of desktop shortcut in registry
        WriteRegStr HKCU "Software\${NAME} ${VERSION}" "File Associations" "true"
    SectionEnd

    Section "PATH Variable" SecPath
    SectionIn 1

        # add to PATH Variable
        Push $INSTDIR
        Call AddToPath
    SectionEnd
SectionGroupEnd

# component descriptions

    # language strings
    LangString DESC_SecAllUsers ${LANG_ENGLISH} "Install ${NAME} ${VERSION} for all users. (Requires administrative privileges.)"
    LangString DESC_SecCurUser ${LANG_ENGLISH} "Install ${NAME} ${VERSION} for current user only."
    LangString DESC_SecCore ${LANG_ENGLISH} "${NAME} ${VERSION}, an ANSI Common Lisp implementation."
    LangString DESC_SecBase ${LANG_ENGLISH} "Enable basic linking set. (Includes ${BASE_MODULES}.)"
    LangString DESC_SecFull ${LANG_ENGLISH} "Enable full linking set. (Includes ${BASE_MODULES} ${FULL_MODULES}.)"
    LangString DESC_SecDesktop ${LANG_ENGLISH} "Create a desktop shortcut for ${NAME}."
    LangString DESC_SecAssoc ${LANG_ENGLISH} "Associate ${NAME} with files of types .lisp, .lsp, .cl, .fas, and .mem."
    LangString DESC_SecPath ${LANG_ENGLISH} "Add ${NAME} directory to PATH environment variable."

    # assign language strings to sections
    !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
        !insertmacro MUI_DESCRIPTION_TEXT ${SecAllUsers} $(DESC_SecAllUsers)
        !insertmacro MUI_DESCRIPTION_TEXT ${SecCurUser} $(DESC_SecCurUser)
        !insertmacro MUI_DESCRIPTION_TEXT ${SecCore} $(DESC_SecCore)
        !insertmacro MUI_DESCRIPTION_TEXT ${SecBase} $(DESC_SecBase)
        !insertmacro MUI_DESCRIPTION_TEXT ${SecFull} $(DESC_SecFull)
        !insertmacro MUI_DESCRIPTION_TEXT ${SecDesktop} $(DESC_SecDesktop)
        !insertmacro MUI_DESCRIPTION_TEXT ${SecAssoc} $(DESC_SecAssoc)
        !insertmacro MUI_DESCRIPTION_TEXT ${SecPath} $(DESC_SecPath)
    !insertmacro MUI_FUNCTION_DESCRIPTION_END

# installer functions

Function .onInit

    StrCpy $UserSetting ${SecCurUser}
    StrCpy $LinkingSet ${SecFull}

    # if the user does *not* have administrator privileges,
    # then make section SecAllUsers readonly
    Call IsUserAdmin
    Pop $0
    StrCmp $0 "true" onInit_cont 0
        # Set the fifth bit to set the read only flag.
        !define READ_ONLY 0x00000010
        SectionGetFlags ${SecAllUsers} $0
        IntOp $0 $0 | ${READ_ONLY}
        SectionSetFlags ${SecAllUsers} $0
        !undef READ_ONLY
    onInit_cont:

FunctionEnd

Function .onSelChange

    !insertmacro StartRadioButtons $UserSetting
        !insertmacro RadioButton ${SecAllUsers}
        !insertmacro RadioButton ${SecCurUser}
    !insertmacro EndRadioButtons

    !insertmacro StartRadioButtons $LinkingSet
        !insertmacro RadioButton ${SecBase}
        !insertmacro RadioButton ${SecFull}
    !insertmacro EndRadioButtons

FunctionEnd

# uninstaller sections

Section "un.Install For"

    # get state of SetShellVarContext
    ReadRegStr $R0 HKCU "Software\${NAME} ${VERSION}" "Shell Var Context"
    StrCmp $R0 "all" SetShellUserContext_all
        Goto SetShellUserContext_done
    SetShellUserContext_all:
        SetShellVarContext all
    SetShellUserContext_done:

SectionEnd

Section "Uninstall"

    Delete $INSTDIR\uninstall.exe

    # delete files
    RMDir /r $INSTDIR

    # delete uninstaller from add/remove programs
    ReadRegStr $R0 HKCU "SOFTWARE\${NAME} ${VERSION}" "Environment Context"
    StrCmp $R0 "all" DeleteRegStr_all
        DeleteRegKey HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\${NAME} ${VERSION}"
    Goto DeleteRegStr_done
    DeleteRegStr_all:
        DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${NAME} ${VERSION}"
    DeleteRegStr_done:

    # delete desktop shortcut if it was created by the installer
    ReadRegStr $R0 HKCU "Software\${NAME} ${VERSION}" "Desktop Shortcut"
    StrCmp $R0 "true" deleteDesktopShortcut
        Goto doneDeletingDesktopShortcut
    deleteDesktopShortcut:
        Delete "$DESKTOP\${NAME} ${VERSION}.lnk"
    doneDeletingDesktopShortcut:

    # delete file associations if they were created by the installer
    ReadRegStr $R0 HKCU "Software\${NAME} ${VERSION}" "File Associations"
    StrCmp $R0 "true" DeleteFileAssociations
        Goto DeleteFileAssociations_done
    DeleteFileAssociations:
        DeleteRegKey HKCR ".lisp"
        DeleteRegKey HKCR ".lsp"
        DeleteRegKey HKCR ".cl"
        DeleteRegKey HKCR ".fas"
        DeleteRegKey HKCR ".mem"
        DeleteRegKey HKCR "lispfile"
        DeleteRegKey HKCR "fasfile"
        DeleteRegKey HKCR "memfile"
    DeleteFileAssociations_done:

    Push $INSTDIR
    Call un.RemoveFromPath

    # delete contents of start menu folder
    !insertmacro MUI_STARTMENU_GETFOLDER StartMenu $STARTMENU_TEMP

    Delete "$SMPROGRAMS\$STARTMENU_TEMP\${NAME} ${VERSION}.lnk"
    Delete "$SMPROGRAMS\$STARTMENU_TEMP\Uninstall ${NAME} ${VERSION}.lnk"

    # delete empty start menu parent diretories
    StrCpy $STARTMENU_TEMP "$SMPROGRAMS\$STARTMENU_TEMP"

    startMenuDeleteLoop:
        ClearErrors
        RMDir $STARTMENU_TEMP
        GetFullPathName $STARTMENU_TEMP "$STARTMENU_TEMP\.."

        IfErrors startMenuDeleteLoopDone

        StrCmp $STARTMENU_TEMP $SMPROGRAMS startMenuDeleteLoopDone startMenuDeleteLoop
    startMenuDeleteLoopDone:

    DeleteRegKey /ifempty HKCU "Software\${NAME} ${VERSION}"
SectionEnd