1
+ # Use the modern UI
1
2
!define MULTIUSER_EXECUTIONLEVEL Highest
2
3
!define MULTIUSER_MUI
3
4
!define MULTIUSER_INSTALLMODE_COMMANDLINE
4
- !define MULTIUSER_INSTALLMODE_INSTDIR " janet"
5
5
!include " MultiUser.nsh"
6
6
!include " MUI2.nsh"
7
-
7
+ !include " .\tools\EnvVarUpdate.nsh"
8
+
9
+ # Basics
8
10
Name " Janet"
9
- OutFile " janet-install.exe"
10
-
11
- !define MUI_ABORTWARNING
12
-
11
+ OutFile " janet-installer.exe"
12
+
13
+ # Some Configuration
14
+ !define APPNAME " Janet"
15
+ !define DESCRIPTION " The Janet Programming Language"
16
+ !define HELPURL " http://janet-lang.org"
17
+
18
+ # MUI Configuration
19
+ !define MUI_ICON " assets\icon.ico"
20
+ !define MUI_UNICON " assets\icon.ico"
21
+ !define MUI_HEADERIMAGE
22
+ !define MUI_HEADERIMAGE_BITMAP " assets\janet-w200.png"
23
+ !define MUI_HEADERIMAGE_RIGHT
24
+
25
+ # Show a welcome page first
13
26
!insertmacro MUI_PAGE_WELCOME
27
+
28
+ # License page
14
29
!insertmacro MUI_PAGE_LICENSE " LICENSE"
15
- !insertmacro MUI_PAGE_COMPONENTS
30
+
31
+ # Pick Install Directory
16
32
!insertmacro MULTIUSER_PAGE_INSTALLMODE
17
33
!insertmacro MUI_PAGE_DIRECTORY
18
34
19
- !insertmacro MUI_PAGE_INSTFILES
35
+ page instfiles
20
36
21
- !insertmacro MUI_PAGE_FINISH
37
+ # Need to set a language.
38
+ !insertmacro MUI_LANGUAGE " English"
39
+
40
+ function .onInit
41
+ setShellVarContext all
42
+ functionEnd
22
43
23
- !insertmacro MUI_UNPAGE_CONFIRM
24
- !insertmacro MUI_UNPAGE_INSTFILES
44
+ section " install"
45
+ createDirectory " $INSTDIR\Library"
46
+ createDirectory " $INSTDIR\C"
47
+ createDirectory " $INSTDIR\bin"
48
+ setOutPath $INSTDIR
49
+
50
+ file /oname= bin\janet.exe dist\janet.exe
51
+ file /oname= logo.ico assets\icon.ico
52
+
53
+ file /oname= Library\cook.janet dist\cook.janet
54
+
55
+ file /oname= C\janet.h dist\janet.h
56
+ file /oname= C\janetconf.h dist\janetconf.h
57
+ file /oname= C\janet.lib dist\janet.lib
58
+ file /oname= C\janet.exp dist\janet.exp
59
+ file /oname= C\janet.c dist\janet.c
60
+
61
+ file /oname= bin\jpm.janet dist\jpm
62
+ file /oname= bin\jpm.bat dist\jpm.bat
25
63
26
- !insertmacro MUI_LANGUAGE " English"
64
+ # Uninstaller - See function un.onInit and section "uninstall" for configuration
65
+ writeUninstaller " $INSTDIR\uninstall.exe"
66
+
67
+ # Start Menu
68
+ createShortCut " $SMPROGRAMS\Janet.lnk" " $INSTDIR\janet.exe" " " " $INSTDIR\logo.ico"
69
+
70
+ # HKLM (all users) vs HKCU (current user)
71
+ WriteRegExpandStr HKLM " SYSTEM\CurrentControlSet\Control\Session Manager\Environment" JANET_PATH " $INSTDIR\Library"
72
+ WriteRegExpandStr HKLM " SYSTEM\CurrentControlSet\Control\Session Manager\Environment" JANET_HEADERPATH " $INSTDIR\C"
73
+ WriteRegExpandStr HKLM " SYSTEM\CurrentControlSet\Control\Session Manager\Environment" JANET_BINDIR " $INSTDIR\bin"
74
+
75
+ WriteRegExpandStr HKCU " Environment" JANET_PATH " $INSTDIR\Library"
76
+ WriteRegExpandStr HKCU " Environment" JANET_HEADERPATH " $INSTDIR\C"
77
+ WriteRegExpandStr HKCU " Environment" JANET_BINDIR " $INSTDIR\bin"
78
+
79
+ SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 " STR:Environment" /TIMEOUT= 5000
80
+
81
+ # Update path
82
+ ${EnvVarUpdate} $0 " PATH" " A" " HKCU" " $INSTDIR\bin" ; Append
83
+ ${EnvVarUpdate} $0 " PATH" " A" " HKLM" " $INSTDIR\bin" ; Append
84
+
85
+ # Registry information for add/remove programs
86
+ WriteRegStr HKLM " Software\Microsoft\Windows\CurrentVersion\Uninstall\Janet" " DisplayName" " Janet"
87
+ WriteRegStr HKLM " Software\Microsoft\Windows\CurrentVersion\Uninstall\Janet" " UninstallString" " $INSTDIR\uninstall.exe"
88
+ WriteRegStr HKLM " Software\Microsoft\Windows\CurrentVersion\Uninstall\Janet" " QuietUninstallString" " $INSTDIR\uninstall.exe /S"
89
+ WriteRegStr HKLM " Software\Microsoft\Windows\CurrentVersion\Uninstall\Janet" " InstallLocation" " $INSTDIR"
90
+ WriteRegStr HKLM " Software\Microsoft\Windows\CurrentVersion\Uninstall\Janet" " DisplayIcon" " $INSTDIR\logo.ico"
91
+ WriteRegStr HKLM " Software\Microsoft\Windows\CurrentVersion\Uninstall\Janet" " Publisher" " Janet-Lang.org"
92
+ WriteRegStr HKLM " Software\Microsoft\Windows\CurrentVersion\Uninstall\Janet" " HelpLink" " ${HELPURL}"
93
+ WriteRegStr HKLM " Software\Microsoft\Windows\CurrentVersion\Uninstall\Janet" " URLUpdateInfo" " ${HELPURL}"
94
+ WriteRegStr HKLM " Software\Microsoft\Windows\CurrentVersion\Uninstall\Janet" " URLInfoAbout" " ${HELPURL}"
95
+ WriteRegStr HKLM " Software\Microsoft\Windows\CurrentVersion\Uninstall\Janet" " DisplayVersion" " 0.6.0"
96
+ WriteRegDWORD HKLM " Software\Microsoft\Windows\CurrentVersion\Uninstall\Janet" " VersionMajor" 0
97
+ WriteRegDWORD HKLM " Software\Microsoft\Windows\CurrentVersion\Uninstall\Janet" " VersionMinor" 6
98
+ # There is no option for modifying or repairing the install
99
+ WriteRegDWORD HKLM " Software\Microsoft\Windows\CurrentVersion\Uninstall\Janet" " NoModify" 1
100
+ WriteRegDWORD HKLM " Software\Microsoft\Windows\CurrentVersion\Uninstall\Janet" " NoRepair" 1
101
+ # Set the INSTALLSIZE constant (!defined at the top of this script) so Add/Remove Programs can accurately report the size
102
+ WriteRegDWORD HKLM " Software\Microsoft\Windows\CurrentVersion\Uninstall\Janet" " EstimatedSize" 1000
103
+ sectionEnd
104
+
105
+ # Uninstaller
106
+
107
+ function un.onInit
108
+ SetShellVarContext all
109
+
110
+ # Verify the uninstaller - last chance to back out
111
+ MessageBox MB_OKCANCEL " Permanantly remove Janet?" IDOK next
112
+ Abort
113
+ next:
114
+ functionEnd
115
+
116
+ section " uninstall"
117
+
118
+ # Remove Start Menu launcher
119
+ delete " $SMPROGRAMS\Janet.lnk"
120
+
121
+ # Remove files
122
+ delete $INSTDIR \logo.ico
123
+
124
+ delete $INSTDIR \C\janet.c
125
+ delete $INSTDIR \C\janet.h
126
+ delete $INSTDIR \C\janet.lib
127
+ delete $INSTDIR \C\janet.exp
128
+ delete $INSTDIR \C\janetconf.h
129
+
130
+ delete $INSTDIR \bin\jpm.janet
131
+ delete $INSTDIR \bin\jpm.bat
132
+ delete $INSTDIR \bin\janet.exe
133
+
134
+ delete $INSTDIR \Library\cook.janet
135
+
136
+ # Remove env vars
137
+
138
+ DeleteRegValue HKLM " SYSTEM\CurrentControlSet\Control\Session Manager\Environment" JANET_PATH
139
+ DeleteRegValue HKLM " SYSTEM\CurrentControlSet\Control\Session Manager\Environment" JANET_HEADERPATH
140
+ DeleteRegValue HKLM " SYSTEM\CurrentControlSet\Control\Session Manager\Environment" JANET_BINDIR
141
+
142
+ DeleteRegValue HKCU " Environment" JANET_PATH
143
+ DeleteRegValue HKCU " Environment" JANET_HEADERPATH
144
+ DeleteRegValue HKCU " Environment" JANET_BINDIR
145
+
146
+ # Unset PATH
147
+ ${un.EnvVarUpdate} $0 " PATH" " R" " HKCU" " $INSTDIR\bin" ; Remove
148
+ ${un.EnvVarUpdate} $0 " PATH" " R" " HKLM" " $INSTDIR\bin" ; Remove
149
+
150
+ # make sure windows knows about the change
151
+ SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 " STR:Environment" /TIMEOUT= 5000
152
+
153
+ # Always delete uninstaller as the last action
154
+ delete $INSTDIR \uninstall.exe
155
+
156
+ rmDir " $INSTDIR\Library"
157
+ rmDir " $INSTDIR\C"
158
+ rmDir " $INSTDIR\bin"
27
159
28
- Section " Janet" BfWSection
29
- SetOutPath $INSTDIR
30
- File " janet.exe"
31
- WriteUninstaller " $INSTDIR\janet-uninstall.exe"
32
-
33
- # Start Menu
34
- CreateShortCut " $SMPROGRAMS\Janet.lnk" " $INSTDIR\janet.exe" " " " "
35
- SectionEnd
36
-
37
- Function .onInit
38
- !insertmacro MULTIUSER_INIT
39
- !insertmacro MUI_LANGDLL_DISPLAY
40
- FunctionEnd
41
-
42
- !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
43
- !insertmacro MUI_DESCRIPTION_TEXT ${BfWSection} " The Janet programming language."
44
- !insertmacro MUI_FUNCTION_DESCRIPTION_END
45
-
46
- Section " Uninstall"
47
- Delete " $INSTDIR\janet.exe"
48
- Delete " $INSTDIR\janet-uninstall.exe"
49
- RMDir " $INSTDIR"
50
- SectionEnd
51
-
52
- Function un.onInit
53
- !insertmacro MULTIUSER_UNINIT
54
- !insertmacro MUI_UNGETLANGUAGE
55
- FunctionEnd
160
+ # Remove uninstaller information from the registry
161
+ DeleteRegKey HKLM " Software\Microsoft\Windows\CurrentVersion\Uninstall\Janet"
162
+ sectionEnd
0 commit comments