| | @@ -30,10 +30,73 @@ Var RootOwned |
| 30 | 30 | Var ShortcutOwned |
| 31 | 31 | Var UninstallOwned |
| 32 | 32 | Var InstallComplete |
| 33 | +추가: Var Upgrading |
| 34 | +추가: Var StageDir |
| 35 | +추가: Var BackupBits |
| 36 | +추가: Var PublishedBits |
| 37 | +추가: Var RestoreFailed |
| 38 | +추가: Var OldVersion |
| 39 | +추가: Var VersionChanged |
| 33 | 40 | !define APPKEY "Software\Zipelo" |
| 34 | 41 | !define PROGKEY "Software\Classes\Zipelo.Archive" |
| 35 | 42 | !define UNKEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\Zipelo" |
| 36 | 43 | |
| 44 | +추가: ; 기존 앱을 먼저 치우고 새 앱은 마지막에 공개하여 버전 혼합 실행을 줄임. |
| 45 | +추가: !macro BackupFile NAME BIT |
| 46 | +추가: ClearErrors |
| 47 | +추가: Rename "$INSTDIR\${NAME}" "$StageDir\previous\${NAME}" |
| 48 | +추가: IfErrors failed |
| 49 | +추가: IntOp $BackupBits $BackupBits | ${BIT} |
| 50 | +추가: !macroend |
| 51 | +추가: |
| 52 | +추가: !macro PublishFile NAME BIT |
| 53 | +추가: ClearErrors |
| 54 | +추가: Rename "$StageDir\${NAME}" "$INSTDIR\${NAME}" |
| 55 | +추가: IfErrors failed |
| 56 | +추가: IntOp $PublishedBits $PublishedBits | ${BIT} |
| 57 | +추가: !macroend |
| 58 | +추가: |
| 59 | +추가: !macro RestoreFile NAME BIT |
| 60 | +추가: IntOp $0 $PublishedBits & ${BIT} |
| 61 | +추가: ${If} $0 != 0 |
| 62 | +추가: ClearErrors |
| 63 | +추가: Delete "$INSTDIR\${NAME}" |
| 64 | +추가: ${If} ${Errors} |
| 65 | +추가: StrCpy $RestoreFailed 1 |
| 66 | +추가: ${Else} |
| 67 | +추가: IntOp $PublishedBits $PublishedBits ^ ${BIT} |
| 68 | +추가: ${EndIf} |
| 69 | +추가: ${EndIf} |
| 70 | +추가: IntOp $0 $BackupBits & ${BIT} |
| 71 | +추가: ${If} $0 != 0 |
| 72 | +추가: ClearErrors |
| 73 | +추가: Rename "$StageDir\previous\${NAME}" "$INSTDIR\${NAME}" |
| 74 | +추가: ${If} ${Errors} |
| 75 | +추가: StrCpy $RestoreFailed 1 |
| 76 | +추가: ${Else} |
| 77 | +추가: IntOp $BackupBits $BackupBits ^ ${BIT} |
| 78 | +추가: ${EndIf} |
| 79 | +추가: ${EndIf} |
| 80 | +추가: !macroend |
| 81 | +추가: |
| 82 | +추가: !macro CleanupStageFile NAME |
| 83 | +추가: Delete "$StageDir\${NAME}" |
| 84 | +추가: ${If} $InstallComplete == 1 |
| 85 | +추가: Delete "$StageDir\previous\${NAME}" |
| 86 | +추가: ${EndIf} |
| 87 | +추가: !macroend |
| 88 | +추가: |
| 89 | +추가: !macro CheckInstalledFile NAME |
| 90 | +추가: System::Call 'kernel32::GetFileAttributesW(w "$INSTDIR\${NAME}") i.r0' |
| 91 | +추가: ${If} $0 == -1 |
| 92 | +추가: Goto failed |
| 93 | +추가: ${EndIf} |
| 94 | +추가: IntOp $0 $0 & 0x410 |
| 95 | +추가: ${If} $0 != 0 |
| 96 | +추가: Goto failed |
| 97 | +추가: ${EndIf} |
| 98 | +추가: !macroend |
| 99 | +추가: |
| 37 | 100 | Function .onInit |
| 38 | 101 | ${IfNot} ${RunningX64} |
| 39 | 102 | MessageBox MB_OK|MB_ICONSTOP "64비트 Windows가 필요합니다." |
| | @@ -55,8 +118,30 @@ FunctionEnd |
| 55 | 118 | Section "Zipelo" |
| 56 | 119 | ; /D로 바뀐 경로를 파일 쓰기 전에 고정하여 제거 경로와 일치시킴. |
| 57 | 120 | StrCpy $INSTDIR "${INSTALLROOT}" |
| 58 | | -삭제: ; 기존 설치와 등록을 덮어쓰지 않음. |
| 59 | | -삭제: IfFileExists "$INSTDIR" failed |
| 121 | +추가: ; 설치 표식과 제거 등록이 일치하는 기존 설치만 업데이트함. |
| 122 | +추가: IfFileExists "$INSTDIR" upgrade |
| 123 | +추가: Goto fresh |
| 124 | +추가: upgrade: |
| 125 | +추가: System::Call 'kernel32::GetFileAttributesW(w "$INSTDIR") i.r0' |
| 126 | +추가: IntOp $0 $0 & 0x410 |
| 127 | +추가: IntCmp $0 0x10 0 failed failed |
| 128 | +추가: ReadINIStr $0 "$INSTDIR\install.ini" "Zipelo" "Location" |
| 129 | +추가: StrCmp $0 $INSTDIR 0 failed |
| 130 | +추가: ReadRegStr $0 HKCU "${UNKEY}" "UninstallString" |
| 131 | +추가: StrCmp $0 '$\"$INSTDIR\Uninstall.exe$\"' 0 failed |
| 132 | +추가: !insertmacro CheckInstalledFile "Zipelo.exe" |
| 133 | +추가: !insertmacro CheckInstalledFile "zipelo-archive-worker.exe" |
| 134 | +추가: !insertmacro CheckInstalledFile "LICENSE" |
| 135 | +추가: !insertmacro CheckInstalledFile "THIRD-PARTY-LICENSES.txt" |
| 136 | +추가: !insertmacro CheckInstalledFile "BUILD-INFO.json" |
| 137 | +추가: !insertmacro CheckInstalledFile "Uninstall.exe" |
| 138 | +추가: !insertmacro CheckInstalledFile "install.ini" |
| 139 | +추가: ClearErrors |
| 140 | +추가: ReadRegStr $OldVersion HKCU "${UNKEY}" "DisplayVersion" |
| 141 | +추가: IfErrors failed |
| 142 | +추가: StrCpy $Upgrading 1 |
| 143 | +추가: Goto prepare |
| 144 | +추가: fresh: |
| 60 | 145 | System::Call 'advapi32::RegOpenKeyExW(p 0x80000001, w "${APPKEY}", i 0, i 0x20119, *p.r1) i.r0' |
| 61 | 146 | ${If} $0 == 0 |
| 62 | 147 | System::Call 'advapi32::RegCloseKey(p r1)' |
| | @@ -96,7 +181,18 @@ Section "Zipelo" |
| 96 | 181 | System::Call 'kernel32::CreateDirectoryW(w "$INSTDIR", p 0) i.r0' |
| 97 | 182 | IntCmp $0 0 failed |
| 98 | 183 | StrCpy $RootOwned 1 |
| 99 | | -삭제: SetOutPath "$INSTDIR" |
| 184 | +추가: prepare: |
| 185 | +추가: ; 같은 볼륨에 새 파일을 모두 준비한 뒤에만 기존 파일을 이동함. |
| 186 | +추가: ClearErrors |
| 187 | +추가: GetTempFileName $StageDir "$LOCALAPPDATA\Programs" |
| 188 | +추가: IfErrors failed |
| 189 | +추가: Delete "$StageDir" |
| 190 | +추가: System::Call 'kernel32::CreateDirectoryW(w "$StageDir", p 0) i.r0' |
| 191 | +추가: ${If} $0 == 0 |
| 192 | +추가: StrCpy $StageDir "" |
| 193 | +추가: Goto failed |
| 194 | +추가: ${EndIf} |
| 195 | +추가: SetOutPath "$StageDir" |
| 100 | 196 | ClearErrors |
| 101 | 197 | File "payload\Zipelo.exe" |
| 102 | 198 | File "payload\zipelo-archive-worker.exe" |
| | @@ -104,10 +200,37 @@ Section "Zipelo" |
| 104 | 200 | File "payload\THIRD-PARTY-LICENSES.txt" |
| 105 | 201 | File "payload\BUILD-INFO.json" |
| 106 | 202 | IfErrors failed |
| 107 | | -삭제: WriteUninstaller "$INSTDIR\Uninstall.exe" |
| 203 | +추가: WriteUninstaller "$StageDir\Uninstall.exe" |
| 108 | 204 | IfErrors failed |
| 109 | | -삭제: WriteINIStr "$INSTDIR\install.ini" "Zipelo" "Location" "$INSTDIR" |
| 205 | +추가: WriteINIStr "$StageDir\install.ini" "Zipelo" "Location" "$INSTDIR" |
| 110 | 206 | IfErrors failed |
| 207 | +추가: ${If} $Upgrading == 1 |
| 208 | +추가: ; 준비 후 취소하면 기존 설치와 연결은 전혀 바뀌지 않음. |
| 209 | +추가: MessageBox MB_OKCANCEL|MB_ICONINFORMATION "업데이트 준비가 끝났습니다. Zipelo와 압축 작업을 닫고 [확인]을 누르세요. [취소]를 누르면 기존 설치를 유지합니다." /SD IDOK IDCANCEL cancelled |
| 210 | +추가: CreateDirectory "$StageDir\previous" |
| 211 | +추가: IfErrors failed |
| 212 | +추가: !insertmacro BackupFile "Zipelo.exe" 1 |
| 213 | +추가: !insertmacro BackupFile "zipelo-archive-worker.exe" 2 |
| 214 | +추가: !insertmacro BackupFile "LICENSE" 4 |
| 215 | +추가: !insertmacro BackupFile "THIRD-PARTY-LICENSES.txt" 8 |
| 216 | +추가: !insertmacro BackupFile "BUILD-INFO.json" 16 |
| 217 | +추가: !insertmacro BackupFile "Uninstall.exe" 32 |
| 218 | +추가: !insertmacro BackupFile "install.ini" 64 |
| 219 | +추가: ${EndIf} |
| 220 | +추가: !insertmacro PublishFile "zipelo-archive-worker.exe" 2 |
| 221 | +추가: !insertmacro PublishFile "LICENSE" 4 |
| 222 | +추가: !insertmacro PublishFile "THIRD-PARTY-LICENSES.txt" 8 |
| 223 | +추가: !insertmacro PublishFile "BUILD-INFO.json" 16 |
| 224 | +추가: !insertmacro PublishFile "Uninstall.exe" 32 |
| 225 | +추가: !insertmacro PublishFile "install.ini" 64 |
| 226 | +추가: !insertmacro PublishFile "Zipelo.exe" 1 |
| 227 | +추가: ${If} $Upgrading == 1 |
| 228 | +추가: StrCpy $VersionChanged 1 |
| 229 | +추가: ClearErrors |
| 230 | +추가: WriteRegStr HKCU "${UNKEY}" "DisplayVersion" "0.1.0" |
| 231 | +추가: IfErrors failed |
| 232 | +추가: Goto committed |
| 233 | +추가: ${EndIf} |
| 111 | 234 | StrCpy $ShortcutOwned 1 |
| 112 | 235 | CreateShortcut "$SMPROGRAMS\Zipelo.lnk" "$INSTDIR\Zipelo.exe" |
| 113 | 236 | IfErrors failed |
| | @@ -117,19 +240,52 @@ Section "Zipelo" |
| 117 | 240 | WriteRegStr HKCU "${UNKEY}" "DisplayVersion" "0.1.0" |
| 118 | 241 | WriteRegStr HKCU "${UNKEY}" "UninstallString" '$\"$INSTDIR\Uninstall.exe$\"' |
| 119 | 242 | IfErrors failed |
| 243 | +추가: committed: |
| 120 | 244 | StrCpy $InstallComplete 1 |
| 245 | +추가: Call CleanupStage |
| 121 | 246 | Goto done |
| 247 | +추가: cancelled: |
| 248 | +추가: Call Rollback |
| 249 | +추가: SetErrorLevel 2 |
| 250 | +추가: Abort "업데이트를 취소했습니다" |
| 122 | 251 | failed: |
| 123 | 252 | Call Rollback |
| 124 | 253 | SetErrorLevel 1 |
| 125 | | -삭제: MessageBox MB_OK|MB_ICONSTOP "설치를 완료하지 못했습니다. 기존 Zipelo이 있으면 먼저 제거하고, 여유 공간과 쓰기 권한을 확인하세요. 이번 설치 항목을 정리했으며, 사용 중이라 지우지 못한 항목은 상세 보기에서 확인하세요." |
| 254 | +추가: MessageBox MB_OK|MB_ICONSTOP "설치를 완료하지 못했습니다. Zipelo와 압축 작업을 닫고 여유 공간과 쓰기 권한을 확인하세요. 복원하지 못한 파일이 있으면 상세 보기의 백업 경로를 보존하고 다시 설치하지 마세요." /SD IDOK |
| 126 | 255 | Abort |
| 127 | 256 | done: |
| 128 | 257 | SectionEnd |
| 129 | 258 | |
| 130 | 259 | Function Rollback |
| 131 | 260 | ${If} $InstallComplete == 1 |
| 132 | | -삭제: ${OrIf} $RootOwned != 1 |
| 261 | +추가: Return |
| 262 | +추가: ${EndIf} |
| 263 | +추가: ${If} $Upgrading == 1 |
| 264 | +추가: SetOutPath "$TEMP" |
| 265 | +추가: !insertmacro RestoreFile "zipelo-archive-worker.exe" 2 |
| 266 | +추가: !insertmacro RestoreFile "LICENSE" 4 |
| 267 | +추가: !insertmacro RestoreFile "THIRD-PARTY-LICENSES.txt" 8 |
| 268 | +추가: !insertmacro RestoreFile "BUILD-INFO.json" 16 |
| 269 | +추가: !insertmacro RestoreFile "Uninstall.exe" 32 |
| 270 | +추가: !insertmacro RestoreFile "install.ini" 64 |
| 271 | +추가: !insertmacro RestoreFile "Zipelo.exe" 1 |
| 272 | +추가: ${If} $VersionChanged == 1 |
| 273 | +추가: ClearErrors |
| 274 | +추가: WriteRegStr HKCU "${UNKEY}" "DisplayVersion" "$OldVersion" |
| 275 | +추가: ${If} ${Errors} |
| 276 | +추가: StrCpy $RestoreFailed 1 |
| 277 | +추가: ${Else} |
| 278 | +추가: StrCpy $VersionChanged 0 |
| 279 | +추가: ${EndIf} |
| 280 | +추가: ${EndIf} |
| 281 | +추가: ${If} $RestoreFailed == 1 |
| 282 | +추가: DetailPrint "복원 실패: 백업 폴더 $StageDir\previous 를 보존하세요." |
| 283 | +추가: ${EndIf} |
| 284 | +추가: Call CleanupStage |
| 285 | +추가: Return |
| 286 | +추가: ${EndIf} |
| 287 | +추가: Call CleanupStage |
| 288 | +추가: ${If} $RootOwned != 1 |
| 133 | 289 | Return |
| 134 | 290 | ${EndIf} |
| 135 | 291 | SetOutPath "$TEMP" |
| | @@ -154,6 +310,28 @@ Function Rollback |
| 154 | 310 | StrCpy $RootOwned 0 |
| 155 | 311 | FunctionEnd |
| 156 | 312 | |
| 313 | +추가: Function CleanupStage |
| 314 | +추가: ${If} $StageDir == "" |
| 315 | +추가: Return |
| 316 | +추가: ${EndIf} |
| 317 | +추가: SetOutPath "$TEMP" |
| 318 | +추가: !insertmacro CleanupStageFile "Zipelo.exe" |
| 319 | +추가: !insertmacro CleanupStageFile "zipelo-archive-worker.exe" |
| 320 | +추가: !insertmacro CleanupStageFile "LICENSE" |
| 321 | +추가: !insertmacro CleanupStageFile "THIRD-PARTY-LICENSES.txt" |
| 322 | +추가: !insertmacro CleanupStageFile "BUILD-INFO.json" |
| 323 | +추가: !insertmacro CleanupStageFile "Uninstall.exe" |
| 324 | +추가: !insertmacro CleanupStageFile "install.ini" |
| 325 | +추가: RMDir "$StageDir\previous" |
| 326 | +추가: ClearErrors |
| 327 | +추가: RMDir "$StageDir" |
| 328 | +추가: ${If} ${Errors} |
| 329 | +추가: DetailPrint "임시 파일 또는 복원 백업이 남아 있음: $StageDir" |
| 330 | +추가: ${Else} |
| 331 | +추가: StrCpy $StageDir "" |
| 332 | +추가: ${EndIf} |
| 333 | +추가: FunctionEnd |
| 334 | +추가: |
| 157 | 335 | Function .onInstFailed |
| 158 | 336 | Call Rollback |
| 159 | 337 | SetErrorLevel 1 |