cross-packer 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (126) hide show
  1. package/LICENSE +661 -0
  2. package/README.md +151 -0
  3. package/README.zh-CN.md +151 -0
  4. package/dist/archive/ar.d.ts +12 -0
  5. package/dist/archive/seven-za.d.ts +32 -0
  6. package/dist/archive/tar.d.ts +30 -0
  7. package/dist/archive/zip-reader.d.ts +17 -0
  8. package/dist/asar/dependency/collect.d.ts +2 -0
  9. package/dist/asar/dependency/detector.d.ts +8 -0
  10. package/dist/asar/dependency/hoister.d.ts +27 -0
  11. package/dist/asar/dependency/utils.d.ts +59 -0
  12. package/dist/asar/fileset/matcher.d.ts +12 -0
  13. package/dist/asar/fileset/platform-fileset.d.ts +36 -0
  14. package/dist/asar/fileset/transformer.d.ts +2 -0
  15. package/dist/asar/fileset/unpack-detector.d.ts +10 -0
  16. package/dist/asar/fileset/walker.d.ts +14 -0
  17. package/dist/asar/pack.d.ts +23 -0
  18. package/dist/asar/packer/app-collector.d.ts +2 -0
  19. package/dist/asar/packer/collector.d.ts +18 -0
  20. package/dist/asar/packer/concurrency.d.ts +1 -0
  21. package/dist/asar/packer/integrity.d.ts +8 -0
  22. package/dist/asar/packer/nm-collector.d.ts +7 -0
  23. package/dist/asar/packer/stream-builder.d.ts +18 -0
  24. package/dist/cli.d.ts +2 -0
  25. package/dist/config/index.d.ts +97 -0
  26. package/dist/electron/dist-zip.d.ts +18 -0
  27. package/dist/electron/download.d.ts +21 -0
  28. package/dist/index.d.ts +11 -0
  29. package/dist/packer/common/app-update-yml.d.ts +5 -0
  30. package/dist/packer/common/extra-resources.d.ts +39 -0
  31. package/dist/packer/common/staging.d.ts +3 -0
  32. package/dist/packer/common/template.d.ts +2 -0
  33. package/dist/packer/linux/linux.d.ts +2 -0
  34. package/dist/packer/mac/mac.d.ts +23 -0
  35. package/dist/packer/win/nsis.d.ts +24 -0
  36. package/dist/packer/win/resedit.d.ts +5 -0
  37. package/dist/packer/win/toolchain.d.ts +8 -0
  38. package/dist/packer/win/win.d.ts +12 -0
  39. package/dist/pipeline/pipeline.d.ts +41 -0
  40. package/dist/pipeline/targets.d.ts +28 -0
  41. package/dist/shared/hash.d.ts +2 -0
  42. package/dist/shared/logger.d.ts +39 -0
  43. package/dist/shared/platform.d.ts +26 -0
  44. package/dist/shared/types.d.ts +68 -0
  45. package/dist/update/blockmap.d.ts +13 -0
  46. package/dist/update/metadata.d.ts +20 -0
  47. package/dist/update/version.d.ts +7 -0
  48. package/package.json +71 -0
  49. package/src/archive/ar.ts +41 -0
  50. package/src/archive/seven-za.ts +160 -0
  51. package/src/archive/tar.ts +142 -0
  52. package/src/archive/zip-reader.ts +61 -0
  53. package/src/asar/dependency/collect.ts +437 -0
  54. package/src/asar/dependency/detector.ts +73 -0
  55. package/src/asar/dependency/hoister.ts +714 -0
  56. package/src/asar/dependency/utils.ts +225 -0
  57. package/src/asar/fileset/matcher.ts +101 -0
  58. package/src/asar/fileset/platform-fileset.ts +416 -0
  59. package/src/asar/fileset/transformer.ts +154 -0
  60. package/src/asar/fileset/unpack-detector.ts +38 -0
  61. package/src/asar/fileset/walker.ts +115 -0
  62. package/src/asar/pack.ts +186 -0
  63. package/src/asar/packer/app-collector.ts +74 -0
  64. package/src/asar/packer/collector.ts +134 -0
  65. package/src/asar/packer/concurrency.ts +24 -0
  66. package/src/asar/packer/integrity.ts +53 -0
  67. package/src/asar/packer/nm-collector.ts +194 -0
  68. package/src/asar/packer/stream-builder.ts +723 -0
  69. package/src/cli.ts +182 -0
  70. package/src/config/index.ts +365 -0
  71. package/src/electron/dist-zip.ts +65 -0
  72. package/src/electron/download.ts +121 -0
  73. package/src/index.ts +14 -0
  74. package/src/packer/common/app-update-yml.ts +21 -0
  75. package/src/packer/common/extra-resources.ts +83 -0
  76. package/src/packer/common/staging.ts +33 -0
  77. package/src/packer/common/template.ts +24 -0
  78. package/src/packer/linux/linux.ts +329 -0
  79. package/src/packer/mac/mac.ts +495 -0
  80. package/src/packer/win/nsis.ts +244 -0
  81. package/src/packer/win/resedit.ts +60 -0
  82. package/src/packer/win/toolchain.ts +63 -0
  83. package/src/packer/win/win.ts +421 -0
  84. package/src/pipeline/pipeline.ts +149 -0
  85. package/src/pipeline/targets.ts +67 -0
  86. package/src/shared/hash.ts +15 -0
  87. package/src/shared/logger.ts +91 -0
  88. package/src/shared/platform.ts +41 -0
  89. package/src/shared/types.ts +82 -0
  90. package/src/update/blockmap.ts +247 -0
  91. package/src/update/metadata.ts +97 -0
  92. package/src/update/version.ts +59 -0
  93. package/templates/linux/app.desktop +11 -0
  94. package/templates/linux/control +9 -0
  95. package/templates/linux/postinst +10 -0
  96. package/templates/linux/postrm +8 -0
  97. package/templates/linux/preinst +49 -0
  98. package/templates/linux/prerm +43 -0
  99. package/templates/mac/Info.plist +18 -0
  100. package/templates/mac/app-update.yml +4 -0
  101. package/templates/win/nsis/README.md +51 -0
  102. package/templates/win/nsis/THIRD-PARTY-NOTICES.md +20 -0
  103. package/templates/win/nsis/assistedInstaller.nsh +154 -0
  104. package/templates/win/nsis/assistedMessages.yml +368 -0
  105. package/templates/win/nsis/common.nsh +147 -0
  106. package/templates/win/nsis/empty-license.txt +1 -0
  107. package/templates/win/nsis/include/FileAssociation.nsh +123 -0
  108. package/templates/win/nsis/include/StdUtils.nsh +496 -0
  109. package/templates/win/nsis/include/StrContains.nsh +48 -0
  110. package/templates/win/nsis/include/UAC.nsh +299 -0
  111. package/templates/win/nsis/include/allowOnlyOneInstallerInstance.nsh +164 -0
  112. package/templates/win/nsis/include/extractAppPackage.nsh +138 -0
  113. package/templates/win/nsis/include/getProcessInfo.nsh +157 -0
  114. package/templates/win/nsis/include/installUtil.nsh +248 -0
  115. package/templates/win/nsis/include/installer.nsh +247 -0
  116. package/templates/win/nsis/include/nsProcess.nsh +28 -0
  117. package/templates/win/nsis/include/webPackage.nsh +64 -0
  118. package/templates/win/nsis/installSection.nsh +110 -0
  119. package/templates/win/nsis/installer.nsi +132 -0
  120. package/templates/win/nsis/messages.yml +240 -0
  121. package/templates/win/nsis/multiUser.nsh +134 -0
  122. package/templates/win/nsis/multiUserUi.nsh +230 -0
  123. package/templates/win/nsis/oneClick.nsh +19 -0
  124. package/templates/win/nsis/portable.nsi +91 -0
  125. package/templates/win/nsis/uninstaller.nsh +263 -0
  126. package/templates/win/nsis-header.nsh +57 -0
@@ -0,0 +1,157 @@
1
+ ; NSIS PROCESS INFO LIBRARY - GetProcessInfo.nsh
2
+ ; Version 1.1 - Mar 28th, 2011
3
+ ;
4
+ ; Description:
5
+ ; Gets process information.
6
+ ;
7
+ ; Usage example:
8
+ ; ${GetProcessInfo} 0 $0 $1 $2 $3 $4
9
+ ; DetailPrint "pid=$0 parent_pid=$1 priority=$2 process_name=$3 exe=$4"
10
+ ;
11
+ ; History:
12
+ ; 1.1 - 28/03/2011 - Added uninstall function, include guards, file header. Fixed getting full exe path on pre vista systems. (Sergius)
13
+ ;
14
+
15
+ !ifndef GETPROCESSINFO_INCLUDED
16
+ !define GETPROCESSINFO_INCLUDED
17
+
18
+ !define PROCESSINFO.TH32CS_SNAPPROCESS 2
19
+ !define PROCESSINFO.INVALID_HANDLE_VALUE -1
20
+
21
+ !define GetProcessInfo '!insertmacro GetProcessInfo'
22
+
23
+ ;@in pid_in - if 0 - get current process info
24
+ ;@out pid_out - real process id (may be useful, if pid_in=0)
25
+ ;@out ppid - parent process id
26
+ ;@out priority
27
+ ;@out name - name of process
28
+ ;@out fullname - fully-qualified path of process
29
+ !macro GetProcessInfo pid_in pid_out ppid priority name fullname
30
+ Push ${pid_in}
31
+ !ifdef BUILD_UNINSTALLER
32
+ Call un._GetProcessInfo
33
+ !else
34
+ Call _GetProcessInfo
35
+ !endif
36
+ ;name;pri;ppid;fname;pid;
37
+ Pop ${name}
38
+ Pop ${priority}
39
+ Pop ${ppid}
40
+ Pop ${fullname}
41
+ Pop ${pid_out}
42
+ !macroend
43
+
44
+ !macro FUNC_GETPROCESSINFO
45
+ Exch $R3 ;pid
46
+ Push $0
47
+ Push $1
48
+ Push $2
49
+ Push $3
50
+ Push $4
51
+ Push $5
52
+ Push $R0 ;hSnapshot
53
+ Push $R1 ;result
54
+ Push $R9 ;PROCESSENTRY32;MODULEENTRY32 and so on
55
+ Push $R8
56
+
57
+ ;zero registers to waste trash, if error occurred
58
+ StrCpy $0 ""
59
+ StrCpy $1 ""
60
+ StrCpy $2 ""
61
+ StrCpy $3 ""
62
+ StrCpy $4 ""
63
+ StrCpy $5 ""
64
+
65
+ IntCmp $R3 0 0 skip_pid_detection skip_pid_detection
66
+ System::Call 'kernel32::GetCurrentProcess() i.R0'
67
+ System::Call "Kernel32::GetProcessId(i R0) i.R3"
68
+
69
+ skip_pid_detection:
70
+ System::Call 'Kernel32::CreateToolhelp32Snapshot(i ${PROCESSINFO.TH32CS_SNAPPROCESS},i R3) i.R0'
71
+
72
+ IntCmp $R0 ${PROCESSINFO.INVALID_HANDLE_VALUE} end ;someting wrong
73
+
74
+ ;$R9=PROCESSENTRY32
75
+ ;typedef struct tagPROCESSENTRY32 {
76
+ ; DWORD dwSize;
77
+ ; DWORD cntUsage;
78
+ ; DWORD th32ProcessID;
79
+ ; ULONG_PTR th32DefaultHeapID;
80
+ ; DWORD th32ModuleID;
81
+ ; DWORD cntThreads;
82
+ ; DWORD th32ParentProcessID;
83
+ ; LONG pcPriClassBase;
84
+ ; DWORD dwFlags;
85
+ ; TCHAR szExeFile[MAX_PATH];
86
+ ;}PROCESSENTRY32, *PPROCESSENTRY32;
87
+ ;dwSize=4*9+2*260
88
+
89
+ System::Alloc 1024
90
+ pop $R9
91
+ System::Call "*$R9(i 556)"
92
+
93
+ System::Call 'Kernel32::Process32FirstW(i R0, i $R9) i.R1'
94
+ StrCmp $R1 0 end
95
+
96
+ nnext_iteration:
97
+ System::Call "*$R9(i,i,i.R1)" ;get PID
98
+ IntCmp $R1 $R3 exitloop
99
+
100
+ System::Call 'Kernel32::Process32NextW(i R0, i $R9) i.R1'
101
+ IntCmp $R1 0 0 nnext_iteration nnext_iteration
102
+
103
+ exitloop:
104
+ ;$0 - pid
105
+ ;$1 - threads
106
+ ;$2 - ppid
107
+ ;$3 - priority
108
+ ;$4 - process name
109
+ System::Call "*$R9(i,i,i.r0,i,i,i.r1,i.r2,i.r3,i,&w256.r4)" ; Get next module
110
+
111
+ ;free:
112
+ System::Free $R9
113
+ System::Call "Kernel32::CloseToolhelp32Snapshot(i R0)"
114
+
115
+ ;===============
116
+ ;now get full path and commandline
117
+
118
+ System::Call "Kernel32::OpenProcess(i 1040, i 0, i r0)i .R0"
119
+
120
+ StrCmp $R0 0 end
121
+
122
+ IntOp $R8 0 + 256
123
+ System::Call "psapi::GetModuleFileNameExW(i R0,i 0,t .r5, *i $R8)i .R1"
124
+
125
+ end:
126
+ Pop $R8
127
+ Pop $R9
128
+ Pop $R1
129
+ Pop $R0
130
+ Exch $5
131
+ Exch 1
132
+ Exch $4
133
+ Exch 2
134
+ Exch $3
135
+ Exch 3
136
+ Exch $2
137
+ Exch 4
138
+ Pop $1
139
+ Exch 4
140
+ Exch $0
141
+ Exch 5
142
+ Pop $R3
143
+ !macroend ;FUNC_GETPROCESSINFO
144
+
145
+ !ifndef BUILD_UNINSTALLER
146
+ Function _GetProcessInfo
147
+ !insertmacro FUNC_GETPROCESSINFO
148
+ FunctionEnd
149
+ !endif
150
+
151
+ !ifdef BUILD_UNINSTALLER
152
+ Function un._GetProcessInfo
153
+ !insertmacro FUNC_GETPROCESSINFO
154
+ FunctionEnd
155
+ !endif
156
+
157
+ !endif ;GETPROCESSINFO_INCLUDED
@@ -0,0 +1,248 @@
1
+ !macro moveFile FROM TO
2
+ ClearErrors
3
+ Rename `${FROM}` `${TO}`
4
+ ${if} ${errors}
5
+ # not clear - can NSIS rename on another drive or not, so, in case of error, just copy
6
+ ClearErrors
7
+ !insertmacro copyFile `${FROM}` `${TO}`
8
+ Delete `${FROM}`
9
+ ${endif}
10
+ !macroend
11
+
12
+ !macro copyFile FROM TO
13
+ ${StdUtils.GetParentPath} $R5 `${TO}`
14
+ CreateDirectory `$R5`
15
+ ClearErrors
16
+ CopyFiles /SILENT `${FROM}` `${TO}`
17
+ !macroend
18
+
19
+ Function GetInQuotes
20
+ Exch $R0
21
+ Push $R1
22
+ Push $R2
23
+ Push $R3
24
+
25
+ StrCpy $R2 -1
26
+ IntOp $R2 $R2 + 1
27
+ StrCpy $R3 $R0 1 $R2
28
+ StrCmp $R3 "" 0 +3
29
+ StrCpy $R0 ""
30
+ Goto Done
31
+ StrCmp $R3 '"' 0 -5
32
+
33
+ IntOp $R2 $R2 + 1
34
+ StrCpy $R0 $R0 "" $R2
35
+
36
+ StrCpy $R2 0
37
+ IntOp $R2 $R2 + 1
38
+ StrCpy $R3 $R0 1 $R2
39
+ StrCmp $R3 "" 0 +3
40
+ StrCpy $R0 ""
41
+ Goto Done
42
+ StrCmp $R3 '"' 0 -5
43
+
44
+ StrCpy $R0 $R0 $R2
45
+ Done:
46
+
47
+ Pop $R3
48
+ Pop $R2
49
+ Pop $R1
50
+ Exch $R0
51
+ FunctionEnd
52
+
53
+ !macro GetInQuotes Var Str
54
+ Push "${Str}"
55
+ Call GetInQuotes
56
+ Pop "${Var}"
57
+ !macroend
58
+
59
+ Function GetFileParent
60
+ Exch $R0
61
+ Push $R1
62
+ Push $R2
63
+ Push $R3
64
+
65
+ StrCpy $R1 0
66
+ StrLen $R2 $R0
67
+
68
+ loop:
69
+ IntOp $R1 $R1 + 1
70
+ IntCmp $R1 $R2 get 0 get
71
+ StrCpy $R3 $R0 1 -$R1
72
+ StrCmp $R3 "\" get
73
+ Goto loop
74
+
75
+ get:
76
+ StrCpy $R0 $R0 -$R1
77
+
78
+ Pop $R3
79
+ Pop $R2
80
+ Pop $R1
81
+ Exch $R0
82
+ FunctionEnd
83
+
84
+ Var /GLOBAL isTryToKeepShortcuts
85
+
86
+ !macro setIsTryToKeepShortcuts
87
+ StrCpy $isTryToKeepShortcuts "true"
88
+ !ifdef allowToChangeInstallationDirectory
89
+ ${ifNot} ${isUpdated}
90
+ StrCpy $isTryToKeepShortcuts "false"
91
+ ${endIf}
92
+ !endif
93
+ !macroend
94
+
95
+ # https://nsis-dev.github.io/NSIS-Forums/html/t-172971.html
96
+ !macro readReg VAR ROOT_KEY SUB_KEY NAME
97
+ ${if} "${ROOT_KEY}" == "SHELL_CONTEXT"
98
+ ReadRegStr "${VAR}" SHELL_CONTEXT "${SUB_KEY}" "${NAME}"
99
+ ${elseif} "${ROOT_KEY}" == "HKEY_CURRENT_USER"
100
+ ReadRegStr "${VAR}" HKEY_CURRENT_USER "${SUB_KEY}" "${NAME}"
101
+ ${elseif} "${ROOT_KEY}" == "HKEY_LOCAL_MACHINE"
102
+ ReadRegStr "${VAR}" HKEY_LOCAL_MACHINE "${SUB_KEY}" "${NAME}"
103
+ ${else}
104
+ MessageBox MB_OK "Unsupported ${ROOT_KEY}"
105
+ ${endif}
106
+ !macroend
107
+
108
+ Function handleUninstallResult
109
+ Var /GLOBAL rootKey_uninstallResult
110
+ Exch $rootKey_uninstallResult
111
+
112
+ ${if} "$rootKey_uninstallResult" == "SHELL_CONTEXT"
113
+ !ifmacrodef customUnInstallCheck
114
+ !insertmacro customUnInstallCheck
115
+ Return
116
+ !endif
117
+ ${elseif} "$rootKey_uninstallResult" == "HKEY_CURRENT_USER"
118
+ !ifmacrodef customUnInstallCheckCurrentUser
119
+ !insertmacro customUnInstallCheckCurrentUser
120
+ Return
121
+ !endif
122
+ ${endif}
123
+
124
+ IfErrors 0 +3
125
+ DetailPrint `Uninstall was not successful. Not able to launch uninstaller!`
126
+ Return
127
+
128
+ ${if} $R0 != 0
129
+ MessageBox MB_OK|MB_ICONEXCLAMATION "$(uninstallFailed): $R0"
130
+ DetailPrint `Uninstall was not successful. Uninstaller error code: $R0.`
131
+ SetErrorLevel 2
132
+ Quit
133
+ ${endif}
134
+ FunctionEnd
135
+
136
+ !macro handleUninstallResult ROOT_KEY
137
+ Push "${ROOT_KEY}"
138
+ Call handleUninstallResult
139
+ !macroend
140
+
141
+ # http://stackoverflow.com/questions/24595887/waiting-for-nsis-uninstaller-to-finish-in-nsis-installer-either-fails-or-the-uni
142
+ Function uninstallOldVersion
143
+ Var /GLOBAL uninstallerFileName
144
+ Var /Global uninstallerFileNameTemp
145
+ Var /GLOBAL installationDir
146
+ Var /GLOBAL uninstallString
147
+ Var /GLOBAL rootKey
148
+
149
+ ClearErrors
150
+ Exch $rootKey
151
+
152
+ Push 0
153
+ Pop $R0
154
+
155
+ !insertmacro readReg $uninstallString "$rootKey" "${UNINSTALL_REGISTRY_KEY}" UninstallString
156
+ ${if} $uninstallString == ""
157
+ !ifdef UNINSTALL_REGISTRY_KEY_2
158
+ !insertmacro readReg $uninstallString "$rootKey" "${UNINSTALL_REGISTRY_KEY_2}" UninstallString
159
+ !endif
160
+ ${if} $uninstallString == ""
161
+ ClearErrors
162
+ Return
163
+ ${endif}
164
+ ${endif}
165
+
166
+ # uninstaller should be copied out of app installation dir (because this dir will be deleted), so, extract uninstaller file name
167
+ !insertmacro GetInQuotes $uninstallerFileName "$uninstallString"
168
+
169
+ !insertmacro readReg $installationDir "$rootKey" "${INSTALL_REGISTRY_KEY}" InstallLocation
170
+ ${if} $installationDir == ""
171
+ ${andIf} $uninstallerFileName != ""
172
+ # https://github.com/electron-userland/electron-builder/issues/735#issuecomment-246918567
173
+ Push $uninstallerFileName
174
+ Call GetFileParent
175
+ Pop $installationDir
176
+ ${endif}
177
+
178
+ ${if} $installationDir == ""
179
+ ${andIf} $uninstallerFileName == ""
180
+ ClearErrors
181
+ Return
182
+ ${endif}
183
+
184
+ ${if} $installMode == "CurrentUser"
185
+ ${orIf} $rootKey == "HKEY_CURRENT_USER"
186
+ StrCpy $0 "/currentuser"
187
+ ${else}
188
+ StrCpy $0 "/allusers"
189
+ ${endif}
190
+
191
+ !insertMacro setIsTryToKeepShortcuts
192
+
193
+ ${if} $isTryToKeepShortcuts == "true"
194
+ !insertmacro readReg $R5 "$rootKey" "${INSTALL_REGISTRY_KEY}" KeepShortcuts
195
+ # if true, it means that old uninstaller supports --keep-shortcuts flag
196
+ ${if} $R5 == "true"
197
+ ${andIf} ${FileExists} "$appExe"
198
+ StrCpy $0 "$0 --keep-shortcuts"
199
+ ${endIf}
200
+ ${endIf}
201
+
202
+ ${if} ${isDeleteAppData}
203
+ StrCpy $0 "$0 --delete-app-data"
204
+ ${else}
205
+ # always pass --updated flag - to ensure that if DELETE_APP_DATA_ON_UNINSTALL is defined, user data will be not removed
206
+ StrCpy $0 "$0 --updated"
207
+ ${endif}
208
+
209
+ StrCpy $uninstallerFileNameTemp "$PLUGINSDIR\old-uninstaller.exe"
210
+ !insertmacro copyFile "$uninstallerFileName" "$uninstallerFileNameTemp"
211
+
212
+ # Retry counter
213
+ StrCpy $R5 0
214
+
215
+ UninstallLoop:
216
+ IntOp $R5 $R5 + 1
217
+
218
+ ${if} $R5 > 5
219
+ MessageBox MB_RETRYCANCEL|MB_ICONEXCLAMATION "$(appCannotBeClosed)" /SD IDCANCEL IDRETRY OneMoreAttempt
220
+ Return
221
+ ${endIf}
222
+
223
+ OneMoreAttempt:
224
+ ExecWait '"$uninstallerFileNameTemp" /S /KEEP_APP_DATA $0 _?=$installationDir' $R0
225
+ ifErrors TryInPlace CheckResult
226
+
227
+ TryInPlace:
228
+ # the execution failed - might have been caused by some group policy restrictions
229
+ # we try to execute the uninstaller in place
230
+ ExecWait '"$uninstallerFileName" /S /KEEP_APP_DATA $0 _?=$installationDir' $R0
231
+ ifErrors DoesNotExist
232
+
233
+ CheckResult:
234
+ ${if} $R0 == 0
235
+ Return
236
+ ${endIf}
237
+
238
+ Sleep 1000
239
+ Goto UninstallLoop
240
+
241
+ DoesNotExist:
242
+ SetErrors
243
+ FunctionEnd
244
+
245
+ !macro uninstallOldVersion ROOT_KEY
246
+ Push "${ROOT_KEY}"
247
+ Call uninstallOldVersion
248
+ !macroend
@@ -0,0 +1,247 @@
1
+ # functions (nsis macro) for installer
2
+
3
+ !include "extractAppPackage.nsh"
4
+
5
+ !ifdef APP_PACKAGE_URL
6
+ !include webPackage.nsh
7
+ !endif
8
+
9
+ !macro installApplicationFiles
10
+ !ifdef APP_BUILD_DIR
11
+ File /r "${APP_BUILD_DIR}\*.*"
12
+ !else
13
+ !ifdef APP_PACKAGE_URL
14
+ Var /GLOBAL packageFile
15
+ Var /GLOBAL isPackageFileExplicitlySpecified
16
+
17
+ ${StdUtils.GetParameter} $packageFile "package-file" ""
18
+ ${if} $packageFile == ""
19
+ !ifdef APP_64_NAME
20
+ !ifdef APP_32_NAME
21
+ !ifdef APP_ARM64_NAME
22
+ ${if} ${IsNativeARM64}
23
+ StrCpy $packageFile "${APP_ARM64_NAME}"
24
+ StrCpy $1 "${APP_ARM64_HASH}"
25
+ ${elseif} ${IsNativeAMD64}
26
+ StrCpy $packageFile "${APP_64_NAME}"
27
+ StrCpy $1 "${APP_64_HASH}"
28
+ ${else}
29
+ StrCpy $packageFile "${APP_32_NAME}"
30
+ StrCpy $1 "${APP_32_HASH}"
31
+ ${endif}
32
+ !else
33
+ ${if} ${RunningX64}
34
+ StrCpy $packageFile "${APP_64_NAME}"
35
+ StrCpy $1 "${APP_64_HASH}"
36
+ ${else}
37
+ StrCpy $packageFile "${APP_32_NAME}"
38
+ StrCpy $1 "${APP_32_HASH}"
39
+ ${endif}
40
+ !endif
41
+ !else
42
+ StrCpy $packageFile "${APP_64_NAME}"
43
+ StrCpy $1 "${APP_64_HASH}"
44
+ !endif
45
+ !else
46
+ StrCpy $packageFile "${APP_32_NAME}"
47
+ StrCpy $1 "${APP_32_HASH}"
48
+ !endif
49
+ StrCpy $4 "$packageFile"
50
+ StrCpy $packageFile "$EXEDIR/$packageFile"
51
+ StrCpy $isPackageFileExplicitlySpecified "false"
52
+ ${else}
53
+ StrCpy $isPackageFileExplicitlySpecified "true"
54
+ ${endIf}
55
+
56
+ # we do not check file hash is specifed explicitly using --package-file because it is clear that user definitely want to use this file and it is user responsibility to check
57
+ # 1. auto-updater uses --package-file and validates checksum
58
+ # 2. user can user another package file (use case - one installer suitable for any app version (use latest version))
59
+ ${if} ${FileExists} "$packageFile"
60
+ ${if} $isPackageFileExplicitlySpecified == "true"
61
+ Goto fun_extract
62
+ ${else}
63
+ ${StdUtils.HashFile} $3 "SHA2-512" "$packageFile"
64
+ ${if} $3 == $1
65
+ Goto fun_extract
66
+ ${else}
67
+ MessageBox MB_OK "Package file $4 found locally, but checksum doesn't match — expected $1, actual $3.$\r$\nLocal file is ignored and package will be downloaded from Internet."
68
+ ${endIf}
69
+ ${endIf}
70
+ ${endIf}
71
+
72
+ !insertmacro downloadApplicationFiles
73
+
74
+ fun_extract:
75
+ !insertmacro extractUsing7za "$packageFile"
76
+
77
+ # electron always uses per user app data
78
+ ${if} $installMode == "all"
79
+ SetShellVarContext current
80
+ ${endif}
81
+
82
+ !insertmacro moveFile "$packageFile" "$LOCALAPPDATA\${APP_PACKAGE_STORE_FILE}"
83
+
84
+ ${if} $installMode == "all"
85
+ SetShellVarContext all
86
+ ${endif}
87
+ !else
88
+ !insertmacro extractEmbeddedAppPackage
89
+ # electron always uses per user app data
90
+ ${if} $installMode == "all"
91
+ SetShellVarContext current
92
+ ${endif}
93
+ !insertmacro copyFile "$EXEPATH" "$LOCALAPPDATA\${APP_INSTALLER_STORE_FILE}"
94
+ ${if} $installMode == "all"
95
+ SetShellVarContext all
96
+ ${endif}
97
+ !endif
98
+ !endif
99
+
100
+ File "/oname=${UNINSTALL_FILENAME}" "${UNINSTALLER_OUT_FILE}"
101
+ !macroend
102
+
103
+ !macro registryAddInstallInfo
104
+ WriteRegStr SHELL_CONTEXT "${INSTALL_REGISTRY_KEY}" InstallLocation "$INSTDIR"
105
+ WriteRegStr SHELL_CONTEXT "${INSTALL_REGISTRY_KEY}" KeepShortcuts "true"
106
+ WriteRegStr SHELL_CONTEXT "${INSTALL_REGISTRY_KEY}" ShortcutName "${SHORTCUT_NAME}"
107
+ !ifdef MENU_FILENAME
108
+ WriteRegStr SHELL_CONTEXT "${INSTALL_REGISTRY_KEY}" MenuDirectory "${MENU_FILENAME}"
109
+ !endif
110
+
111
+ ${if} $installMode == "all"
112
+ StrCpy $0 "/allusers"
113
+ StrCpy $1 ""
114
+ ${else}
115
+ StrCpy $0 "/currentuser"
116
+ StrCpy $1 ""
117
+ ${endIf}
118
+
119
+ WriteRegStr SHELL_CONTEXT "${UNINSTALL_REGISTRY_KEY}" DisplayName "${UNINSTALL_DISPLAY_NAME}$1"
120
+ # https://github.com/electron-userland/electron-builder/issues/750
121
+ StrCpy $2 "$INSTDIR\${UNINSTALL_FILENAME}"
122
+ WriteRegStr SHELL_CONTEXT "${UNINSTALL_REGISTRY_KEY}" UninstallString '"$2" $0'
123
+ WriteRegStr SHELL_CONTEXT "${UNINSTALL_REGISTRY_KEY}" QuietUninstallString '"$2" $0 /S'
124
+
125
+ WriteRegStr SHELL_CONTEXT "${UNINSTALL_REGISTRY_KEY}" "DisplayVersion" "${VERSION}"
126
+ !ifdef UNINSTALLER_ICON
127
+ WriteRegStr SHELL_CONTEXT "${UNINSTALL_REGISTRY_KEY}" "DisplayIcon" "$INSTDIR\uninstallerIcon.ico"
128
+ !else
129
+ WriteRegStr SHELL_CONTEXT "${UNINSTALL_REGISTRY_KEY}" "DisplayIcon" "$appExe,0"
130
+ !endif
131
+
132
+ !ifdef COMPANY_NAME
133
+ WriteRegStr SHELL_CONTEXT "${UNINSTALL_REGISTRY_KEY}" "Publisher" "${COMPANY_NAME}"
134
+ !endif
135
+
136
+ !ifdef APP_DESCRIPTION
137
+ WriteRegStr SHELL_CONTEXT "${UNINSTALL_REGISTRY_KEY}" "Comments" "${APP_DESCRIPTION}"
138
+ !endif
139
+
140
+ !ifdef UNINSTALL_URL_HELP
141
+ WriteRegStr SHELL_CONTEXT "${UNINSTALL_REGISTRY_KEY}" "HelpLink" "${UNINSTALL_URL_HELP}"
142
+ !endif
143
+
144
+ !ifdef UNINSTALL_URL_INFO_ABOUT
145
+ WriteRegStr SHELL_CONTEXT "${UNINSTALL_REGISTRY_KEY}" "URLInfoAbout" "${UNINSTALL_URL_INFO_ABOUT}"
146
+ !endif
147
+
148
+ !ifdef UNINSTALL_URL_UPDATE_INFO
149
+ WriteRegStr SHELL_CONTEXT "${UNINSTALL_REGISTRY_KEY}" "URLUpdateInfo" "${UNINSTALL_URL_UPDATE_INFO}"
150
+ !endif
151
+
152
+ !ifdef UNINSTALL_URL_README
153
+ WriteRegStr SHELL_CONTEXT "${UNINSTALL_REGISTRY_KEY}" "Readme" "${UNINSTALL_URL_README}"
154
+ !endif
155
+
156
+ WriteRegDWORD SHELL_CONTEXT "${UNINSTALL_REGISTRY_KEY}" NoModify 1
157
+ WriteRegDWORD SHELL_CONTEXT "${UNINSTALL_REGISTRY_KEY}" NoRepair 1
158
+
159
+ # allow user to define ESTIMATED_SIZE to avoid GetSize call
160
+ !ifdef ESTIMATED_SIZE
161
+ IntFmt $0 "0x%08X" ${ESTIMATED_SIZE}
162
+ !else
163
+ ${GetSize} "$INSTDIR" "/S=0K" $0 $1 $2
164
+ IntFmt $0 "0x%08X" $0
165
+ !endif
166
+
167
+ WriteRegDWORD SHELL_CONTEXT "${UNINSTALL_REGISTRY_KEY}" "EstimatedSize" "$0"
168
+ !macroend
169
+
170
+ !macro cleanupOldMenuDirectory
171
+ ${if} $oldMenuDirectory != ""
172
+ !ifdef MENU_FILENAME
173
+ ${if} $oldMenuDirectory != "${MENU_FILENAME}"
174
+ RMDir "$SMPROGRAMS\$oldMenuDirectory"
175
+ ${endIf}
176
+ !else
177
+ RMDir "$SMPROGRAMS\$oldMenuDirectory"
178
+ !endif
179
+ ${endIf}
180
+ !macroend
181
+
182
+ !macro createMenuDirectory
183
+ !ifdef MENU_FILENAME
184
+ CreateDirectory "$SMPROGRAMS\${MENU_FILENAME}"
185
+ ClearErrors
186
+ !endif
187
+ !macroend
188
+
189
+ !macro addStartMenuLink keepShortcuts
190
+ !ifndef DO_NOT_CREATE_START_MENU_SHORTCUT
191
+ # The keepShortcuts mechanism is NOT enabled.
192
+ # Menu shortcut will be recreated.
193
+ ${if} $keepShortcuts == "false"
194
+ !insertmacro cleanupOldMenuDirectory
195
+ !insertmacro createMenuDirectory
196
+
197
+ CreateShortCut "$newStartMenuLink" "$appExe" "" "$appExe" 0 "" "" "${APP_DESCRIPTION}"
198
+ # clear error (if shortcut already exists)
199
+ ClearErrors
200
+ WinShell::SetLnkAUMI "$newStartMenuLink" "${APP_ID}"
201
+ # The keepShortcuts mechanism IS enabled.
202
+ # The menu shortcut could either not exist (it shouldn't be recreated) or exist in an obsolete location.
203
+ ${elseif} $oldStartMenuLink != $newStartMenuLink
204
+ ${andIf} ${FileExists} "$oldStartMenuLink"
205
+ !insertmacro createMenuDirectory
206
+
207
+ Rename $oldStartMenuLink $newStartMenuLink
208
+ WinShell::UninstShortcut "$oldStartMenuLink"
209
+ WinShell::SetLnkAUMI "$newStartMenuLink" "${APP_ID}"
210
+
211
+ !insertmacro cleanupOldMenuDirectory
212
+ ${endIf}
213
+ !endif
214
+ !macroend
215
+
216
+ !macro addDesktopLink keepShortcuts
217
+ !ifndef DO_NOT_CREATE_DESKTOP_SHORTCUT
218
+ # https://github.com/electron-userland/electron-builder/pull/1432
219
+ ${ifNot} ${isNoDesktopShortcut}
220
+ # The keepShortcuts mechanism is NOT enabled.
221
+ # Shortcuts will be recreated.
222
+ ${if} $keepShortcuts == "false"
223
+ CreateShortCut "$newDesktopLink" "$appExe" "" "$appExe" 0 "" "" "${APP_DESCRIPTION}"
224
+ ClearErrors
225
+ WinShell::SetLnkAUMI "$newDesktopLink" "${APP_ID}"
226
+ # The keepShortcuts mechanism IS enabled.
227
+ # The desktop shortcut could exist in an obsolete location (due to name change).
228
+ ${elseif} $oldDesktopLink != $newDesktopLink
229
+ ${andIf} ${FileExists} "$oldDesktopLink"
230
+ Rename $oldDesktopLink $newDesktopLink
231
+ WinShell::UninstShortcut "$oldDesktopLink"
232
+ WinShell::SetLnkAUMI "$newDesktopLink" "${APP_ID}"
233
+
234
+ !ifdef RECREATE_DESKTOP_SHORTCUT
235
+ ${elseif} $oldDesktopLink != $newDesktopLink
236
+ ${orIfNot} ${FileExists} "$oldDesktopLink"
237
+ ${ifNot} ${isUpdated}
238
+ CreateShortCut "$newDesktopLink" "$appExe" "" "$appExe" 0 "" "" "${APP_DESCRIPTION}"
239
+ ClearErrors
240
+ WinShell::SetLnkAUMI "$newDesktopLink" "${APP_ID}"
241
+ ${endIf}
242
+ !endif
243
+ ${endIf}
244
+ System::Call 'Shell32::SHChangeNotify(i 0x8000000, i 0, i 0, i 0)'
245
+ ${endIf}
246
+ !endif
247
+ !macroend
@@ -0,0 +1,28 @@
1
+ !define nsProcess::FindProcess `!insertmacro nsProcess::FindProcess`
2
+
3
+ !macro nsProcess::FindProcess _FILE _ERR
4
+ nsProcess::_FindProcess /NOUNLOAD `${_FILE}`
5
+ Pop ${_ERR}
6
+ !macroend
7
+
8
+
9
+ !define nsProcess::KillProcess `!insertmacro nsProcess::KillProcess`
10
+
11
+ !macro nsProcess::KillProcess _FILE _ERR
12
+ nsProcess::_KillProcess /NOUNLOAD `${_FILE}`
13
+ Pop ${_ERR}
14
+ !macroend
15
+
16
+ !define nsProcess::CloseProcess `!insertmacro nsProcess::CloseProcess`
17
+
18
+ !macro nsProcess::CloseProcess _FILE _ERR
19
+ nsProcess::_CloseProcess /NOUNLOAD `${_FILE}`
20
+ Pop ${_ERR}
21
+ !macroend
22
+
23
+
24
+ !define nsProcess::Unload `!insertmacro nsProcess::Unload`
25
+
26
+ !macro nsProcess::Unload
27
+ nsProcess::_Unload
28
+ !macroend