Changeset View
Standalone View
extragear/kexi/kexi/NullsoftInstaller.nsi
- This file was added.
1 | ; basic script template for NullsoftInstallerPackager | ||||
---|---|---|---|---|---|
2 | ; | ||||
3 | ; Copyright 2010 Patrick Spendrin <ps_ml@gmx.de> | ||||
4 | ; Copyright 2016 Kevin Funk <kfunk@kde.org> | ||||
5 | ; Copyright 2018 Jarosław Staniek <staniek@kde.org> | ||||
6 | | ||||
7 | ; registry stuff | ||||
8 | !define regkey "Software\@{company}\@{productname}\@{version}" | ||||
9 | !define uninstkey "Software\Microsoft\Windows\CurrentVersion\Uninstall\@{productname} @{version}" | ||||
10 | | ||||
11 | !define uninstall_string "Uninstall @{productname} @{version}" | ||||
12 | !define uninstaller "${uninstall_string}.exe" | ||||
13 | | ||||
14 | BrandingText "Generated by Craft https://community.kde.org/Craft" | ||||
15 | | ||||
16 | ;-------------------------------- | ||||
17 | | ||||
18 | XPStyle on | ||||
19 | ShowInstDetails hide | ||||
20 | ShowUninstDetails hide | ||||
21 | ManifestDPIAware true | ||||
22 | | ||||
23 | Name "@{productname} @{version}" | ||||
24 | Caption "$(^Name)" | ||||
25 | | ||||
vonreth: What is `^Name` | |||||
It's notation of the special variable Name defined in line Name "productname version" staniek: It's notation of the special variable Name defined in line
Name "@{productname} @{version}" | |||||
26 | OutFile "@{setupname}" | ||||
27 | | ||||
28 | !define MULTIUSER_EXECUTIONLEVEL Highest | ||||
29 | !define MULTIUSER_MUI | ||||
30 | !define MULTIUSER_INSTALLMODE_COMMANDLINE | ||||
31 | !define MULTIUSER_INSTALLMODE_DEFAULT_REGISTRY_KEY "${regkey}" | ||||
32 | !define MULTIUSER_INSTALLMODE_DEFAULT_REGISTRY_VALUENAME "Install_Mode" | ||||
33 | !define MULTIUSER_INSTALLMODE_INSTDIR "@{productname}\@{version}" | ||||
34 | !define MULTIUSER_INSTALLMODE_INSTDIR_REGISTRY_KEY "${regkey}" | ||||
35 | !define MULTIUSER_INSTALLMODE_INSTDIR_REGISTRY_VALUENAME "Install_Dir" | ||||
36 | | ||||
37 | ;Start Menu Folder Page Configuration | ||||
38 | Var StartMenuFolder | ||||
39 | !define MUI_STARTMENUPAGE_REGISTRY_ROOT "SHCTX" | ||||
40 | !define MUI_STARTMENUPAGE_REGISTRY_KEY "${regkey}" | ||||
41 | !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Start Menu Folder" | ||||
42 | !define MUI_STARTMENUPAGE_DEFAULTFOLDER "${MULTIUSER_INSTALLMODE_INSTDIR}" | ||||
43 | | ||||
44 | ;!define MULTIUSER_USE_PROGRAMFILES64 | ||||
45 | @{multiuser_use_programfiles64} | ||||
46 | ;!define MULTIUSER_USE_PROGRAMFILES64 | ||||
47 | | ||||
48 | @{nsis_include_internal} | ||||
49 | @{nsis_include} | ||||
50 | | ||||
51 | !include "MultiUser.nsh" | ||||
52 | !include "MUI2.nsh" | ||||
53 | !include "LogicLib.nsh" | ||||
54 | !include "x64.nsh" | ||||
55 | !include "process.nsh" | ||||
56 | !include "FileAssociation.nsh" | ||||
57 | | ||||
58 | ;!define MUI_ICON | ||||
59 | @{installerIcon} | ||||
60 | ;!define MUI_ICON | ||||
61 | | ||||
62 | !insertmacro MUI_PAGE_WELCOME | ||||
63 | | ||||
64 | ;!insertmacro MUI_PAGE_LICENSE | ||||
65 | @{license} | ||||
66 | ;!insertmacro MUI_PAGE_LICENSE | ||||
67 | | ||||
68 | !insertmacro MULTIUSER_PAGE_INSTALLMODE | ||||
69 | !insertmacro MUI_PAGE_DIRECTORY | ||||
70 | !insertmacro MUI_PAGE_STARTMENU Application $StartMenuFolder | ||||
71 | | ||||
72 | !define MUI_COMPONENTSPAGE_NODESC | ||||
73 | ;!insertmacro MUI_PAGE_COMPONENTS | ||||
74 | @{sections_page} | ||||
75 | ;!insertmacro MUI_PAGE_COMPONENTS | ||||
76 | | ||||
77 | !insertmacro MUI_PAGE_INSTFILES | ||||
78 | !insertmacro MUI_UNPAGE_CONFIRM | ||||
79 | !insertmacro MUI_UNPAGE_INSTFILES | ||||
80 | !define MUI_FINISHPAGE_LINK "Visit @{productname} home page" | ||||
81 | !define MUI_FINISHPAGE_LINK_LOCATION "@{website}" | ||||
82 | !define MUI_FINISHPAGE_NOAUTOCLOSE | ||||
83 | !define MUI_FINISHPAGE_RUN "$WINDIR\explorer.exe" | ||||
84 | !define MUI_FINISHPAGE_RUN_TEXT "Run @{productname}" | ||||
85 | !define MUI_FINISHPAGE_RUN_PARAMETERS "$SMPROGRAMS\$StartMenuFolder\$(^Name).lnk" | ||||
We removed that from the default script as the process gets executed in admin scope, not user scope. vonreth: We removed that from the default script as the process gets executed in admin scope, not user… | |||||
I see. How about using https://nsis.sourceforge.io/ShellExecAsUser_plug-in ? For I am using: Function LaunchLink ExecShell "" "${startmenu}\@{productname} @{version}.lnk" FunctionEnd staniek: I see. How about using https://nsis.sourceforge.io/ShellExecAsUser_plug-in ?
For I am using… | |||||
I had some bad experience with nsis plugins, most are ages old and unmaintained. vonreth: I had some bad experience with nsis plugins, most are ages old and unmaintained.
How does the… | |||||
It does not, I do confirm KEXI is then started as admin, which is indeed not what we want. I plan to test the ShellExecAsUser function which can solve it. I do not think that WinAPI or plugin will dissappear, it's pretty popular feature I see used in installers. staniek: > How does the ExecShell .lnk solve the issue?
It does not, I do confirm KEXI is then started… | |||||
Found different approach without plugins: http://mdb-blog.blogspot.com/2013/01/nsis-lunch-program-as-user-from-uac.html It works for me. See MUI_FINISHPAGE_RUN above. staniek: Found different approach without plugins: http://mdb-blog.blogspot.com/2013/01/nsis-lunch… | |||||
Hm your not looping it through explorer.exe? You might also wan't to use the sysnative path (https://github.com/KDE/craft/blob/master/bin/Packager/Nsis/process.nsh#L24) (just had the issue with cmd) vonreth: Hm your not looping it through explorer.exe?
Its kind of ugly but if it works...
You might… | |||||
Don't understand "not looping" :) It's passed to explorer via UI_FINISHPAGE_RUN. Tested on win7 64bit. Using what other projects confirm that works, as usual - even if it's undocumented MS would not remove the behavior so easily since people depend on that in many places I bet. staniek: Don't understand "not looping" :) It's passed to explorer via UI_FINISHPAGE_RUN. Tested on win7… | |||||
86 | !insertmacro MUI_PAGE_FINISH | ||||
87 | | ||||
88 | !insertmacro MUI_LANGUAGE "English" | ||||
89 | | ||||
90 | SetDateSave on | ||||
91 | SetDatablockOptimize on | ||||
92 | CRCCheck on | ||||
93 | SilentInstall normal | ||||
94 | | ||||
95 | InstallDir "@{defaultinstdir}\${MULTIUSER_INSTALLMODE_INSTDIR}" | ||||
96 | InstallDirRegKey HKLM "${regkey}" "Install_Dir" | ||||
97 | | ||||
98 | Var /global ExistingInstallation | ||||
99 | | ||||
100 | Function .onInit | ||||
101 | !insertmacro MULTIUSER_INIT | ||||
102 | !if @{architecture} == "x64" | ||||
103 | ${IfNot} ${RunningX64} | ||||
104 | MessageBox MB_OK|MB_ICONEXCLAMATION "This installer can only be run on 64-bit Windows." | ||||
105 | Abort | ||||
106 | ${EndIf} | ||||
107 | !endif | ||||
108 | ReadRegStr $R0 HKLM "${regkey}" "Install_Dir" | ||||
109 | ${IfNot} $R0 == "" | ||||
110 | StrCpy $ExistingInstallation $R0 | ||||
111 | ${EndIf} | ||||
112 | FunctionEnd | ||||
113 | | ||||
114 | Function un.onInit | ||||
115 | !insertmacro MULTIUSER_UNINIT | ||||
116 | FunctionEnd | ||||
117 | | ||||
118 | ; GetParentDir | ||||
119 | ; input, top of stack (e.g. C:\Program Files\Foo) | ||||
120 | ; output, top of stack (replaces, with e.g. C:\Program Files) | ||||
121 | ; modifies no other variables. | ||||
122 | ; Usage: | ||||
123 | ; Push "C:\Program Files\Directory\Whatever" | ||||
124 | ; Call GetParent | ||||
125 | ; Pop $R0 | ||||
126 | ; ; at this point $R0 will equal "C:\Program Files\Directory" | ||||
127 | Function un.GetParentDir | ||||
128 | Exch $R0 | ||||
129 | Push $R1 | ||||
130 | Push $R2 | ||||
131 | Push $R3 | ||||
132 | | ||||
133 | StrCpy $R1 0 | ||||
I'm getting goose bumps vonreth: I'm getting goose bumps
you could just use a @{} define for the containing folder? | |||||
It's from https://nsis.sourceforge.io/Get_parent_directory and I think I've been using it several times across the years. Is there a docs on how to obtain parent folder in NSIS? Because the NSIS grammar still does not support advanced expressions it seems? staniek: It's from https://nsis.sourceforge.io/Get_parent_directory and I think I've been using it… | |||||
134 | StrLen $R2 $R0 | ||||
135 | loop: | ||||
136 | IntOp $R1 $R1 + 1 | ||||
137 | IntCmp $R1 $R2 get 0 get | ||||
138 | StrCpy $R3 $R0 1 -$R1 | ||||
139 | StrCmp $R3 "\" get | ||||
140 | Goto loop | ||||
141 | | ||||
142 | get: | ||||
143 | StrCpy $R0 $R0 -$R1 | ||||
144 | | ||||
145 | Pop $R3 | ||||
146 | Pop $R2 | ||||
147 | Pop $R1 | ||||
148 | Exch $R0 | ||||
vonreth: we don't ship the redist installer anymore but the dlls directly. | |||||
149 | FunctionEnd | ||||
150 | | ||||
151 | ;-------------------------------- | ||||
152 | | ||||
vonreth: Not needed anymore see base script | |||||
staniek: In PostInstallRoutines.py? | |||||
As far as I know kde just got clever enough to not need it after a relocation (installer) vonreth: As far as I know kde just got clever enough to not need it after a relocation (installer) | |||||
153 | AutoCloseWindow false | ||||
154 | | ||||
155 | | ||||
156 | ; beginning (invisible) section | ||||
157 | Section | ||||
158 | ${IfNot} $ExistingInstallation == "" | ||||
159 | ExecWait '"$ExistingInstallation\${uninstaller}" /S _?=$ExistingInstallation' | ||||
160 | ${EndIf} | ||||
161 | WriteRegStr HKLM "${regkey}" "Install_Dir" "$INSTDIR" | ||||
162 | ; write uninstall strings | ||||
163 | WriteRegStr SHCTX "${uninstkey}" "DisplayName" "$(^Name)" | ||||
164 | WriteRegStr SHCTX "${uninstkey}" "UninstallString" '"$INSTDIR\${uninstaller}"' | ||||
kdeinit5 is broken, better use the nsis extension, for killing the processes ,used in the base script vonreth: kdeinit5 is broken, better use the nsis extension, for killing the processes ,used in the base… | |||||
165 | WriteRegStr SHCTX "${uninstkey}" "DisplayIcon" "$INSTDIR\@{iconname}" | ||||
@vonreth Does the killing dbus-daemon make sense? staniek: @vonreth Does the killing dbus-daemon make sense? | |||||
The process script should kill everything running from the program folder, so dbus should be dead by now vonreth: The process script should kill everything running from the program folder, so dbus should be… | |||||
166 | WriteRegStr SHCTX "${uninstkey}" "URLInfoAbout" "@{website}" | ||||
167 | WriteRegStr SHCTX "${uninstkey}" "Publisher" "@{company}" | ||||
168 | WriteRegStr SHCTX "${uninstkey}" "DisplayVersion" "@{version}" | ||||
169 | | ||||
170 | @{registy_hook} | ||||
171 | | ||||
172 | ; TODO: find a way to extend the default script | ||||
173 | ; TODO? WriteRegStr HKCR "*\shell\OpenWith@{productname}\@{version}" "" "Edit with @{productname} @{version}" | ||||
174 | ; TODO? WriteRegStr HKCR "*\shell\OpenWith@{productname}\@{version}\command" "" '"$INSTDIR\executable" "%V"' | ||||
175 | | ||||
176 | ${registerExtension} "$INSTDIR\@{assoc_executable}" "@{assoc_extension}" "@{assoc_description}" | ||||
177 | | ||||
178 | SetOutPath $INSTDIR | ||||
179 | | ||||
180 | | ||||
181 | ; package all files, recursively, preserving attributes | ||||
182 | ; assume files are in the correct places | ||||
183 | | ||||
184 | File /a "@{dataPath}" | ||||
185 | File /a "@{7za}" | ||||
186 | File /a "@{icon}" | ||||
187 | nsExec::ExecToLog '"$INSTDIR\7za.exe" x -r -y "$INSTDIR\@{dataName}" -o"$INSTDIR"' | ||||
188 | Delete "$INSTDIR\7za.exe" | ||||
189 | Delete "$INSTDIR\@{dataName}" | ||||
190 | | ||||
191 | AddSize @{installSize} | ||||
192 | | ||||
193 | WriteUninstaller "${uninstaller}" | ||||
194 | SectionEnd | ||||
195 | | ||||
196 | ; create shortcuts | ||||
197 | Section | ||||
198 | SetShellVarContext all | ||||
199 | !insertmacro MUI_STARTMENU_WRITE_BEGIN Application | ||||
200 | CreateDirectory "$SMPROGRAMS\$StartMenuFolder" | ||||
201 | SetOutPath $INSTDIR ; for working directory | ||||
202 | @{shortcuts} | ||||
203 | CreateShortCut "$SMPROGRAMS\$StartMenuFolder\${uninstall_string}.lnk" "$INSTDIR\${uninstaller}" | ||||
204 | !insertmacro MUI_STARTMENU_WRITE_END | ||||
This is the reason for 2 warnings: 6000: unknown variable/constant "{assoc_extension}" detected, ignoring (macro:UnRegisterExtensionCall:3) 6000: unknown variable/constant "{assoc_description}" detected, ignoring (macro:UnRegisterExtensionCall:4) You need to use the craft style nsis vars @{foo} vonreth: This is the reason for
```
2 warnings:
6000: unknown variable/constant "{assoc_extension}"… | |||||
205 | SectionEnd | ||||
206 | | ||||
207 | ; Uninstaller | ||||
208 | ; All section names prefixed by "Un" will be in the uninstaller | ||||
209 | | ||||
210 | UninstallText "This will uninstall $(^Name)." | ||||
211 | | ||||
212 | Section "Uninstall" | ||||
213 | SetShellVarContext all | ||||
214 | | ||||
215 | !insertmacro EndProcessWithDialog | ||||
216 | | ||||
217 | ${If} $MultiUser.InstallMode == "CurrentUser" | ||||
218 | SetShellVarContext current | ||||
219 | ${EndIf} | ||||
220 | | ||||
221 | DeleteRegKey SHCTX "${uninstkey}" | ||||
222 | DeleteRegKey SHCTX "${regkey}" | ||||
223 | | ||||
224 | !insertmacro MUI_STARTMENU_GETFOLDER Application $StartMenuFolder | ||||
225 | RMDir /r "$SMPROGRAMS\$StartMenuFolder" | ||||
226 | | ||||
227 | ; remove parent folder in the Start menu if it is @{productname}" and is completely empty | ||||
228 | Push "$SMPROGRAMS\$StartMenuFolder" | ||||
229 | Call un.GetParentDir | ||||
230 | Call un.GetParentDir | ||||
231 | Pop $R0 | ||||
232 | StrCpy $R0 "$R0\@{productname}" | ||||
233 | RMDir "$R0" ; remove parent folder of start menu if completely empty | ||||
234 | | ||||
235 | RMDir /r "$INSTDIR" | ||||
236 | | ||||
237 | ; remove parent folder of the inst dir if it is @{productname}" and is completely empty | ||||
238 | Push "$INSTDIR" | ||||
239 | Call un.GetParentDir | ||||
240 | Call un.GetParentDir | ||||
241 | Pop $R0 | ||||
242 | StrCpy $R0 "$R0\@{productname}" | ||||
243 | RMDir "$R0" | ||||
244 | | ||||
245 | ${unregisterExtension} "@{assoc_extension}" "@{assoc_description}" | ||||
246 | | ||||
247 | SectionEnd |
What is ^Name