| 1 |
; For license of this file, see <project-root-folder>/LICENSE.md. |
| 2 |
|
| 3 |
;-------------------------------- |
| 4 |
; Unicode baby. |
| 5 |
Unicode True |
| 6 |
|
| 7 |
;-------------------------------- |
| 8 |
; Do necessary inclusions. |
| 9 |
!include NSIS.definitions.nsh |
| 10 |
!include MUI2.nsh |
| 11 |
!include nsProcess.nsh |
| 12 |
|
| 13 |
;-------------------------------- |
| 14 |
; Basic values definitions. |
| 15 |
|
| 16 |
; Name and file. |
| 17 |
Name "${APP_NAME}" |
| 18 |
|
| 19 |
; Set custom branding text. |
| 20 |
BrandingText "${APP_NAME}" |
| 21 |
|
| 22 |
; Set compression. |
| 23 |
SetCompressor /SOLID /FINAL lzma |
| 24 |
|
| 25 |
; Default installation folder. |
| 26 |
InstallDir "C:\${APP_NAME}" |
| 27 |
InstallDirRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_NAME}" "InstallLocation" |
| 28 |
|
| 29 |
; Require administrator access. |
| 30 |
RequestExecutionLevel admin |
| 31 |
|
| 32 |
;-------------------------------- |
| 33 |
; Interface Settings |
| 34 |
|
| 35 |
; Show "are you sure" dialog when cancelling installation. |
| 36 |
!define MUI_ABORTWARNING |
| 37 |
|
| 38 |
;-------------------------------- |
| 39 |
; Pages |
| 40 |
|
| 41 |
; Pages for installator. |
| 42 |
!insertmacro MUI_PAGE_WELCOME |
| 43 |
!insertmacro MUI_PAGE_LICENSE "${LICENSE_FILE}" |
| 44 |
!insertmacro MUI_PAGE_DIRECTORY |
| 45 |
!insertmacro MUI_PAGE_COMPONENTS |
| 46 |
|
| 47 |
; Start menu folder page configuration. |
| 48 |
!define MUI_STARTMENUPAGE_REGISTRY_ROOT "HKCU" |
| 49 |
!define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\${APP_NAME}" |
| 50 |
!define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Start Menu Folder" |
| 51 |
|
| 52 |
!insertmacro MUI_PAGE_INSTFILES |
| 53 |
|
| 54 |
; Offer user to launch the application right when it is installed. |
| 55 |
!define MUI_FINISHPAGE_RUN |
| 56 |
!define MUI_FINISHPAGE_RUN_TEXT "Start ${APP_NAME} now" |
| 57 |
!define MUI_FINISHPAGE_RUN_FUNCTION "LaunchApplication" |
| 58 |
|
| 59 |
!insertmacro MUI_PAGE_FINISH |
| 60 |
|
| 61 |
; Pages for uninstallator. |
| 62 |
!insertmacro MUI_UNPAGE_CONFIRM |
| 63 |
!insertmacro MUI_UNPAGE_INSTFILES |
| 64 |
!insertmacro MUI_UNPAGE_FINISH |
| 65 |
|
| 66 |
;-------------------------------- |
| 67 |
; Languages. |
| 68 |
|
| 69 |
!insertmacro MUI_LANGUAGE "English" |
| 70 |
|
| 71 |
;-------------------------------- |
| 72 |
; Helper macros. |
| 73 |
|
| 74 |
!macro ExecWaitJob _exec |
| 75 |
StrCpy $9 0 |
| 76 |
System::Call 'kernel32::CreateIoCompletionPort(i -1,i0,i0,i0)i.r1' |
| 77 |
${IfThen} $1 != 0 ${|} IntOp $9 $9 + 1 ${|} |
| 78 |
System::Call 'kernel32::CreateJobObject(i0,i0)i.r2' |
| 79 |
${IfThen} $2 != 0 ${|} IntOp $9 $9 + 1 ${|} |
| 80 |
System::Call '*(i 0,i $1)i.r0' |
| 81 |
System::Call 'kernel32::SetInformationJobObject(i $2,i 7,i $0,i 8)i.r3' |
| 82 |
${IfThen} $3 != 0 ${|} IntOp $9 $9 + 1 ${|} |
| 83 |
System::Free $0 |
| 84 |
System::Call '*(i,i,i,i)i.r0' |
| 85 |
System::Alloc 72 |
| 86 |
pop $4 |
| 87 |
System::Call "*$4(i 72)" |
| 88 |
System::Call 'kernel32::CreateProcess(i0,t ${_exec},i0,i0,i0,i 0x01000004,i0,i0,i $4,i $0)i.r3' |
| 89 |
${IfThen} $3 != 0 ${|} IntOp $9 $9 + 1 ${|} |
| 90 |
System::Free $4 |
| 91 |
System::Call "*$0(i.r3,i.r4,i,i)" |
| 92 |
System::Free $0 |
| 93 |
System::Call 'kernel32::AssignProcessToJobObject(i $2,i $3)i.r0' |
| 94 |
${IfThen} $0 != 0 ${|} IntOp $9 $9 + 1 ${|} |
| 95 |
System::Call 'kernel32::ResumeThread(i $4)i.r0' |
| 96 |
${IfThen} $0 != -1 ${|} IntOp $9 $9 + 1 ${|} |
| 97 |
System::Call 'kernel32::CloseHandle(i $3)' |
| 98 |
System::Call 'kernel32::CloseHandle(i $4)' |
| 99 |
!define __ExecWaitJob__ ExecWaitJob${__LINE__} |
| 100 |
${__ExecWaitJob__}ioportwait: |
| 101 |
System::Call 'kernel32::GetQueuedCompletionStatus(i $1,*i.r3,*i,*i.r4,i -1)i.r0' |
| 102 |
${IfThen} $0 = 0 ${|} StrCpy $9 0 ${|} |
| 103 |
${IfThen} $3 != 4 ${|} goto ${__ExecWaitJob__}ioportwait ${|} |
| 104 |
System::Call 'kernel32::CloseHandle(i $2)' |
| 105 |
System::Call 'kernel32::CloseHandle(i $1)' |
| 106 |
!undef __ExecWaitJob__ |
| 107 |
${IfThen} $9 < 6 ${|} MessageBox mb_iconstop `ExecWaitJob "${_exec}" failed!` ${|} |
| 108 |
!macroend |
| 109 |
|
| 110 |
; If you are using solid compression, files that are required before |
| 111 |
; the actual installation should be stored first in the data block, |
| 112 |
; because this will make your installer start faster. |
| 113 |
!insertmacro MUI_RESERVEFILE_LANGDLL |
| 114 |
|
| 115 |
;-------------------------------- |
| 116 |
; Sections. |
| 117 |
|
| 118 |
; Installer sections. |
| 119 |
Section "!Core" Core |
| 120 |
IfFileExists $INSTDIR\Uninstall.exe Uninstall NotInstalled |
| 121 |
|
| 122 |
Uninstall: |
| 123 |
!insertmacro ExecWaitJob '"$INSTDIR\Uninstall.exe /S"' |
| 124 |
|
| 125 |
NotInstalled: |
| 126 |
SetOutPath "$INSTDIR" |
| 127 |
|
| 128 |
; Install core application files. |
| 129 |
File /r /x "rssguard-*.*" "${BINARY_TREE}\" |
| 130 |
|
| 131 |
; Create uninstaller. |
| 132 |
WriteUninstaller "$INSTDIR\Uninstall.exe" |
| 133 |
|
| 134 |
; Add to Add/Remove programs. |
| 135 |
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_NAME}" "DisplayName" "${APP_NAME}" |
| 136 |
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_NAME}" "DisplayIcon" "$INSTDIR\${EXE_NAME}" |
| 137 |
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_NAME}" "DisplayVersion" "${APP_VERSION}" |
| 138 |
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_NAME}" "InstallLocation" "$INSTDIR" |
| 139 |
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_NAME}" "UninstallString" "$\"$INSTDIR\Uninstall.exe$\"" |
| 140 |
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_NAME}" "QuietUninstallString" "$\"$INSTDIR\Uninstall.exe$\" /S" |
| 141 |
|
| 142 |
; Open documentation. |
| 143 |
ExecShell "open" "https://rssguard.readthedocs.io/en/stable/downloads.html#windows" |
| 144 |
SectionEnd |
| 145 |
|
| 146 |
SectionGroup /e "Plugins" |
| 147 |
Section "Feedly" PluginFeedly |
| 148 |
SetOutPath "$INSTDIR\plugins" |
| 149 |
File "${PLUGIN_FEEDLY}" |
| 150 |
SectionEnd |
| 151 |
|
| 152 |
Section "Gmail" PluginGmail |
| 153 |
SetOutPath "$INSTDIR\plugins" |
| 154 |
File "${PLUGIN_GMAIL}" |
| 155 |
SectionEnd |
| 156 |
|
| 157 |
Section "Google Reader API" PluginGreader |
| 158 |
SetOutPath "$INSTDIR\plugins" |
| 159 |
File "${PLUGIN_GREADER}" |
| 160 |
SectionEnd |
| 161 |
|
| 162 |
Section "Nextcloud News" PluginNextcloud |
| 163 |
SetOutPath "$INSTDIR\plugins" |
| 164 |
File "${PLUGIN_NEXTCLOUD}" |
| 165 |
SectionEnd |
| 166 |
|
| 167 |
Section "RSS/ATOM/JSON" PluginStandard |
| 168 |
SectionIn RO |
| 169 |
SetOutPath "$INSTDIR\plugins" |
| 170 |
File "${PLUGIN_STANDARD}" |
| 171 |
SectionEnd |
| 172 |
|
| 173 |
Section "Tiny Tiny RSS" PluginTtrss |
| 174 |
SetOutPath "$INSTDIR\plugins" |
| 175 |
File "${PLUGIN_TTRSS}" |
| 176 |
SectionEnd |
| 177 |
SectionGroupEnd |
| 178 |
|
| 179 |
Section "Desktop Icon" DesktopIcon |
| 180 |
CreateShortCut "$DESKTOP\${APP_NAME}.lnk" "$INSTDIR\${EXE_NAME}" |
| 181 |
SectionEnd |
| 182 |
|
| 183 |
Section "Start Menu Shortcuts" StartMenuShortcuts |
| 184 |
CreateDirectory "$SMPROGRAMS\${APP_NAME}" |
| 185 |
CreateShortCut "$SMPROGRAMS\${APP_NAME}\${APP_NAME}.lnk" "$INSTDIR\${EXE_NAME}" |
| 186 |
CreateShortCut "$SMPROGRAMS\${APP_NAME}\Uninstall.lnk" "$INSTDIR\Uninstall.exe" |
| 187 |
SectionEnd |
| 188 |
|
| 189 |
LangString DESC_Core ${LANG_ENGLISH} "Core installation files for ${APP_NAME}." |
| 190 |
LangString DESC_DesktopIcon ${LANG_ENGLISH} "Desktop icon for ${APP_NAME}." |
| 191 |
LangString DESC_StartMenuShortcuts ${LANG_ENGLISH} "Start Menu Shortcuts for ${APP_NAME}." |
| 192 |
|
| 193 |
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN |
| 194 |
!insertmacro MUI_DESCRIPTION_TEXT ${Core} $(DESC_Core) |
| 195 |
!insertmacro MUI_DESCRIPTION_TEXT ${DesktopIcon} $(DESC_DesktopIcon) |
| 196 |
!insertmacro MUI_DESCRIPTION_TEXT ${StartMenuShortcuts} $(DESC_StartMenuShortcuts) |
| 197 |
!insertmacro MUI_FUNCTION_DESCRIPTION_END |
| 198 |
|
| 199 |
; Uninstaller section. |
| 200 |
Section "Uninstall" |
| 201 |
exeTest: |
| 202 |
${nsProcess::FindProcess} "${EXE_NAME}" $R0 |
| 203 |
StrCmp $R0 0 0 notRunning |
| 204 |
MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION '${APP_NAME} (${EXE_NAME}) is still running. Quit it first and then proceed.' IDOK exeTest IDCANCEL quitMe |
| 205 |
|
| 206 |
quitMe: |
| 207 |
Abort |
| 208 |
|
| 209 |
notRunning: |
| 210 |
; Here remove all files, but skip "data" folder. |
| 211 |
Push "$INSTDIR" |
| 212 |
Push "data4" |
| 213 |
Call un.RmDirsButOne |
| 214 |
|
| 215 |
; Remove top-level files. |
| 216 |
Delete "$INSTDIR\*" |
| 217 |
|
| 218 |
; Remove directory itself if empty. |
| 219 |
RMDir "$INSTDIR" |
| 220 |
|
| 221 |
RMDir /r "$SMPROGRAMS\${APP_NAME}" |
| 222 |
Delete "$DESKTOP\${APP_NAME}.lnk" |
| 223 |
DeleteRegKey HKCU "Software\${APP_NAME}" |
| 224 |
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_NAME}" |
| 225 |
SectionEnd |
| 226 |
|
| 227 |
;-------------------------------- |
| 228 |
; Custom functions. |
| 229 |
|
| 230 |
Function LaunchApplication |
| 231 |
Exec '"$WINDIR\explorer.exe" "$INSTDIR\${EXE_NAME}"' |
| 232 |
FunctionEnd |
| 233 |
|
| 234 |
Function un.RmDirsButOne |
| 235 |
Exch $R0 ; exclude dir |
| 236 |
Exch |
| 237 |
Exch $R1 ; route dir |
| 238 |
Push $R2 |
| 239 |
Push $R3 |
| 240 |
|
| 241 |
ClearErrors |
| 242 |
FindFirst $R3 $R2 "$R1\*.*" |
| 243 |
IfErrors Exit |
| 244 |
|
| 245 |
Top: |
| 246 |
StrCmp $R2 "." Next |
| 247 |
StrCmp $R2 ".." Next |
| 248 |
StrCmp $R2 $R0 Next |
| 249 |
IfFileExists "$R1\$R2\*.*" 0 Next |
| 250 |
RmDir /r "$R1\$R2" |
| 251 |
|
| 252 |
#Goto Exit ;uncomment this to stop it being recursive (delete only one dir) |
| 253 |
|
| 254 |
Next: |
| 255 |
ClearErrors |
| 256 |
FindNext $R3 $R2 |
| 257 |
IfErrors Exit |
| 258 |
Goto Top |
| 259 |
|
| 260 |
Exit: |
| 261 |
FindClose $R3 |
| 262 |
|
| 263 |
Pop $R3 |
| 264 |
Pop $R2 |
| 265 |
Pop $R1 |
| 266 |
Pop $R0 |
| 267 |
FunctionEnd |
| 268 |
|
| 269 |
; Executed when installer starts. |
| 270 |
Function .onInit |
| 271 |
IntOp $0 ${SF_SELECTED} | ${SF_RO} |
| 272 |
SectionSetFlags ${Core} $0 |
| 273 |
FunctionEnd |