team-ljyzipelo

공개

Merge pull request #66 from Team-LJY/features/windows-installer

Rust 앱과 작업자의 Windows 개발판 설치 파일 생성
작성자
LeeJunyoung
작성 시각
커밋
696f0a77538c4afd8c2a48e411e519dfac516c6b
이 시점의 파일 보기

변경된 파일 5개

+542-0
추가packaging/windows/rust/README.md+47-0
@@ -0,0 +1,47 @@
1추가: # Rust Windows 개발판 설치 파일
2추가:
3추가: NSIS를 사용해 Linux에서 Windows x64 설치 EXE를 생성합니다. Rust 앱과 별도 작업자를
4추가: 교차 빌드하며 가짜 작업자 기능은 활성화하지 않습니다.
5추가:
6추가: ```sh
7추가: python3 packaging/windows/rust/build.py \
8추가: --app-manifest /path/to/app/experiments/rust-ui-memory-app/Cargo.toml \
9추가: --worker-manifest /path/to/worker/experiments/rust-archive-worker/Cargo.toml \
10추가: --target-dir /path/to/cargo-target \
11추가: --output /path/to/new-installer-output
12추가: ```
13추가:
14추가: Cargo 1.99.1, Windows GNU Rust target, MinGW-w64와 makensis가 필요합니다.
15추가: 도구는 자동 설치하지 않습니다. 기본 profile은 release이고 개발 검증에는 --profile dev를 사용할 수 있습니다.
16추가: 출력 폴더는 새 경로여야 하며 기존 파일을 덮어쓰지 않습니다. 입력 저장소는 커밋된 상태여야 합니다. 캐시는 실행 파일과 소스 커밋별로 분리하며 빌드 중 소스 변경을 거부합니다.
17추가: 앱과 작업자 PR이 병합되기 전에는 각 PR의 별도 소스 경로를 인자로 지정합니다.
18추가: 빌드 정보에는 소스 커밋, 실행 파일 SHA-256, target, profile, 기능 목록을 기록합니다.
19추가:
20추가: 설치 파일을 더블클릭하면 현재 사용자의 LocalAppData/Programs/Zipelo-Dev에
21추가: Zipelo.exe, zipelo-archive-worker.exe, MIT LICENSE, BUILD-INFO.json과 제거 프로그램을 설치합니다.
22추가: 설치 경로는 위 위치로 고정되며 명령행 /D로 다른 위치를 지정해도 파일 쓰기 전에 고정 위치를 적용합니다.
23추가: 설치와 제거는 같은 경로 상수를 사용합니다.
24추가: 기존 폴더나 등록이 있으면 중단하며 덮어쓰기 업데이트는 지원하지 않습니다.
25추가: 시작 메뉴에 Zipelo 개발판 바로가기를 추가합니다.
26추가:
27추가: 마지막 화면의 [적용]을 누르면 HKCU의 ZipeloDev.Archive ProgID와 RegisteredApplications에
28추가: .zip, .tar, .gz, .tgz 연결 후보를 등록하고 ms-settings:defaultapps를 엽니다.
29추가: .tar.gz는 마지막 확장자 .gz로 연결됩니다. 기본 앱은 사용자가 Windows 설정에서 직접 선택합니다.
30추가: JAR, RAR, 7z는 등록하지 않습니다. [마침]만 누르면 연결 후보를 등록하지 않습니다.
31추가: 관리자 권한, HKLM, UserChoice 변경을 사용하지 않습니다.
32추가: 제거 시 알려진 앱 파일과 등록 값만 정리하며 폴더 전체를 재귀 삭제하지 않습니다.
33추가: 실행 파일 삭제 실패 시 등록과 제거 프로그램을 보존하여 재시도할 수 있습니다.
34추가:
35추가: 현재는 개발 검증용입니다. PR62 화면의 실제 작업자 연결, Windows에서의 설치/제거와 설정 실행,
36추가: 지원 형식별 실제 파일 열기, 재설치/권한 실패/잠긴 파일 검증, 포함 의존성의 배포 고지 검토는 남아 있습니다.
37추가: 이번 EXE 생성만으로 해당 항목을 인증하거나 출시하지 않습니다.
38추가: Windows 실행 검증 전에는 README 다운로드 버튼이나 release에 배포하지 않습니다.
39추가:
40추가: 검증은 저장소 루트에서 python3 tests/ci/run_rust.py local을 실행하고 위 명령으로
41추가: 실제 앱과 작업자를 교차 빌드하여 NSIS를 컴파일합니다. BUILD-INFO.json과 설치 EXE의
42추가: 해시를 함께 확인합니다. NSIS 부트스트랩은 32비트 PE일 수 있으며 설치되는 두 앱은 x64 PE입니다.
43추가:
44추가: 연결 등록은 [Microsoft 기본 프로그램 문서](https://learn.microsoft.com/en-us/windows/win32/shell/default-programs)의
45추가: Capabilities/RegisteredApplications 구조를 사용하며,
46추가: [Windows 기본 앱 설정 열기](https://learn.microsoft.com/en-us/windows/apps/develop/launch/launch-default-apps-settings)의
47추가: ms-settings URI를 사용합니다.
추가packaging/windows/rust/build.py+104-0
@@ -0,0 +1,104 @@
1추가: """Rust 앱과 작업자를 교차 빌드해 Windows 개발용 설치 파일을 생성함."""
2추가:
3추가: import argparse
4추가: import hashlib
5추가: import json
6추가: import os
7추가: from pathlib import Path
8추가: import shutil
9추가: import struct
10추가: import subprocess
11추가:
12추가: ROOT = Path(__file__).resolve().parents[3]
13추가: TARGET = "x86_64-pc-windows-gnu"
14추가:
15추가:
16추가: def pe_machine(path):
17추가: with Path(path).open("rb") as stream:
18추가: header = stream.read(64)
19추가: if len(header) != 64 or header[:2] != b"MZ":
20추가: raise ValueError("PE 실행 파일이 아님")
21추가: stream.seek(struct.unpack_from("<I", header, 60)[0])
22추가: signature = stream.read(6)
23추가: if len(signature) != 6 or signature[:4] != b"PE\0\0":
24추가: raise ValueError("PE 헤더가 잘못됨")
25추가: return struct.unpack_from("<H", signature, 4)[0]
26추가:
27추가:
28추가: def build_binary(manifest, binary, target_dir, profile, features=()):
29추가: manifest = Path(manifest).resolve(strict=True)
30추가: commit = subprocess.check_output(
31추가: ["git", "-C", str(manifest.parent), "rev-parse", "HEAD"], text=True
32추가: ).strip()
33추가: dirty = subprocess.check_output(
34추가: ["git", "-C", str(manifest.parent), "status", "--porcelain"], text=True
35추가: )
36추가: if dirty.strip():
37추가: raise ValueError("소스에 커밋하지 않은 변경이 있음")
38추가: # 작업 복사본 간 mtime 기반 캐시 혼합을 방지함.
39추가: target_dir = target_dir / binary / commit
40추가: command = ["cargo", "+1.99.1", "build", "--locked", "--manifest-path", str(manifest),
41추가: "--target", TARGET, "--target-dir", str(target_dir), "--profile", profile,
42추가: "--bin", binary]
43추가: if features:
44추가: command += ["--features", ",".join(features)]
45추가: environment = dict(os.environ)
46추가: linker = environment.get("CARGO_TARGET_X86_64_PC_WINDOWS_GNU_LINKER")
47추가: linker = linker or shutil.which("x86_64-w64-mingw32-gcc") or shutil.which("x86_64-w64-mingw32-gcc-posix")
48추가: if not linker or not shutil.which(linker):
49추가: raise ValueError("MinGW-w64 교차 링커를 찾지 못함")
50추가: environment["CARGO_TARGET_X86_64_PC_WINDOWS_GNU_LINKER"] = linker
51추가: subprocess.run(command, env=environment, check=True)
52추가: output = target_dir / TARGET / ("debug" if profile == "dev" else profile) / (binary + ".exe")
53추가: if pe_machine(output) != 0x8664:
54추가: raise ValueError("x64 Windows 실행 파일이 아님")
55추가: current_commit = subprocess.check_output(
56추가: ["git", "-C", str(manifest.parent), "rev-parse", "HEAD"], text=True
57추가: ).strip()
58추가: dirty = subprocess.check_output(
59추가: ["git", "-C", str(manifest.parent), "status", "--porcelain"], text=True
60추가: )
61추가: if current_commit != commit or dirty.strip():
62추가: raise ValueError("빌드 중 소스가 바뀜")
63추가: return output, {"commit": commit, "sha256": hashlib.sha256(output.read_bytes()).hexdigest(),
64추가: "binary": binary, "features": list(features)}
65추가:
66추가:
67추가: def build(args):
68추가: output = Path(args.output).resolve()
69추가: output.mkdir(parents=True, exist_ok=False)
70추가: target_dir = Path(args.target_dir).resolve()
71추가: records = {}
72추가: payload = output / "payload"
73추가: payload.mkdir()
74추가: for name, manifest, binary, features in (
75추가: ("Zipelo.exe", args.app_manifest, "zipelo-ui-memory-app", ("ui",)),
76추가: ("zipelo-archive-worker.exe", args.worker_manifest, "zipelo-archive-worker", ()),
77추가: ):
78추가: source, records[name] = build_binary(manifest, binary, target_dir, args.profile, features)
79추가: shutil.copyfile(source, payload / name)
80추가: shutil.copyfile(ROOT / "LICENSE", payload / "LICENSE")
81추가: records = {"development_only": True, "windows_execution_verified": False,
82추가: "profile": args.profile, "target": TARGET, "files": records}
83추가: (payload / "BUILD-INFO.json").write_text(json.dumps(records, indent=4) + "\n", encoding="utf-8")
84추가: shutil.copyfile(Path(__file__).with_name("installer.nsi"), output / "installer.nsi")
85추가: subprocess.run(["makensis", "-WX", "installer.nsi"], cwd=output, check=True)
86추가: installer = output / "Zipelo-0.1.0-dev-windows-x64-setup.exe"
87추가: if pe_machine(installer) not in (0x14C, 0x8664):
88추가: raise ValueError("NSIS 설치 실행 파일이 아님")
89추가: print(installer)
90추가: print("SHA-256 " + hashlib.sha256(installer.read_bytes()).hexdigest())
91추가:
92추가:
93추가: def main():
94추가: parser = argparse.ArgumentParser(description=__doc__)
95추가: parser.add_argument("--app-manifest", required=True)
96추가: parser.add_argument("--worker-manifest", required=True)
97추가: parser.add_argument("--output", required=True)
98추가: parser.add_argument("--target-dir", required=True)
99추가: parser.add_argument("--profile", choices=("dev", "release"), default="release")
100추가: build(parser.parse_args())
101추가:
102추가:
103추가: if __name__ == "__main__":
104추가: main()
추가packaging/windows/rust/installer.nsi+264-0
@@ -0,0 +1,264 @@
1추가: Unicode true
2추가: !include "MUI2.nsh"
3추가: !include "nsDialogs.nsh"
4추가: !include "LogicLib.nsh"
5추가: !include "x64.nsh"
6추가: !include "FileFunc.nsh"
7추가: Name "Zipelo 개발판"
8추가: OutFile "Zipelo-0.1.0-dev-windows-x64-setup.exe"
9추가: !define INSTALLROOT "$LOCALAPPDATA\Programs\Zipelo-Dev"
10추가: InstallDir "${INSTALLROOT}"
11추가: RequestExecutionLevel user
12추가: SetCompressor /SOLID lzma
13추가: SetOverwrite off
14추가: AllowSkipFiles off
15추가: ShowInstDetails show
16추가: !define MUI_ABORTWARNING
17추가: !define MUI_CUSTOMFUNCTION_ABORT Rollback
18추가: !insertmacro MUI_PAGE_WELCOME
19추가: !insertmacro MUI_PAGE_INSTFILES
20추가: Page custom FinishCreate
21추가: !insertmacro MUI_UNPAGE_CONFIRM
22추가: !insertmacro MUI_UNPAGE_INSTFILES
23추가: !insertmacro MUI_LANGUAGE "Korean"
24추가: Var Dialog
25추가: Var ApplyButton
26추가: Var Mutex
27추가: Var RootOwned
28추가: Var ShortcutOwned
29추가: Var UninstallOwned
30추가: Var InstallComplete
31추가: !define APPKEY "Software\Zipelo-Dev"
32추가: !define PROGKEY "Software\Classes\ZipeloDev.Archive"
33추가: !define UNKEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\Zipelo-Dev"
34추가:
35추가: Function .onInit
36추가: ${IfNot} ${RunningX64}
37추가: MessageBox MB_OK|MB_ICONSTOP "64비트 Windows가 필요합니다."
38추가: Abort
39추가: ${EndIf}
40추가: SetShellVarContext current
41추가: SetRegView 64
42추가: System::Call 'kernel32::SetLastError(i 0)'
43추가: System::Call 'kernel32::CreateMutexW(p 0, i 0, w "Local\ZipeloDevSetup") p.r0 ?e'
44추가: Pop $1
45추가: StrCpy $Mutex $0
46추가: ${If} $0 == 0
47추가: ${OrIf} $1 != 0
48추가: MessageBox MB_OK "다른 설치나 제거를 마친 뒤 다시 실행하세요."
49추가: Abort
50추가: ${EndIf}
51추가: FunctionEnd
52추가:
53추가: Section "Zipelo"
54추가: ; /D로 바뀐 경로를 파일 쓰기 전에 고정하여 제거 경로와 일치시킴.
55추가: StrCpy $INSTDIR "${INSTALLROOT}"
56추가: ; 기존 설치와 등록을 덮어쓰지 않음.
57추가: IfFileExists "$INSTDIR" failed
58추가: System::Call 'advapi32::RegOpenKeyExW(p 0x80000001, w "${APPKEY}", i 0, i 0x20119, *p.r1) i.r0'
59추가: ${If} $0 == 0
60추가: System::Call 'advapi32::RegCloseKey(p r1)'
61추가: Goto failed
62추가: ${ElseIf} $0 != 2
63추가: Goto failed
64추가: ${EndIf}
65추가: System::Call 'advapi32::RegOpenKeyExW(p 0x80000001, w "${PROGKEY}", i 0, i 0x20119, *p.r1) i.r0'
66추가: ${If} $0 == 0
67추가: System::Call 'advapi32::RegCloseKey(p r1)'
68추가: Goto failed
69추가: ${ElseIf} $0 != 2
70추가: Goto failed
71추가: ${EndIf}
72추가: System::Call 'advapi32::RegOpenKeyExW(p 0x80000001, w "${UNKEY}", i 0, i 0x20119, *p.r1) i.r0'
73추가: ${If} $0 == 0
74추가: System::Call 'advapi32::RegCloseKey(p r1)'
75추가: Goto failed
76추가: ${ElseIf} $0 != 2
77추가: Goto failed
78추가: ${EndIf}
79추가: ; 공유 등록 값이 이미 있으면 형식과 관계없이 보존함.
80추가: System::Call 'advapi32::RegOpenKeyExW(p 0x80000001, w "Software\RegisteredApplications", i 0, i 0x20119, *p.r1) i.r0'
81추가: ${If} $0 == 0
82추가: System::Call 'advapi32::RegQueryValueExW(p r1, w "Zipelo 개발판", p 0, p 0, p 0, p 0) i.r2'
83추가: System::Call 'advapi32::RegCloseKey(p r1)'
84추가: ${If} $2 != 2
85추가: Goto failed
86추가: ${EndIf}
87추가: ${ElseIf} $0 != 2
88추가: Goto failed
89추가: ${EndIf}
90추가: IfFileExists "$SMPROGRAMS\Zipelo 개발판.lnk" failed
91추가: ClearErrors
92추가: CreateDirectory "$LOCALAPPDATA\Programs"
93추가: IfErrors failed
94추가: System::Call 'kernel32::CreateDirectoryW(w "$INSTDIR", p 0) i.r0'
95추가: IntCmp $0 0 failed
96추가: StrCpy $RootOwned 1
97추가: SetOutPath "$INSTDIR"
98추가: ClearErrors
99추가: File "payload\Zipelo.exe"
100추가: File "payload\zipelo-archive-worker.exe"
101추가: File "payload\LICENSE"
102추가: File "payload\BUILD-INFO.json"
103추가: IfErrors failed
104추가: WriteUninstaller "$INSTDIR\Uninstall.exe"
105추가: IfErrors failed
106추가: WriteINIStr "$INSTDIR\install.ini" "Zipelo" "Location" "$INSTDIR"
107추가: IfErrors failed
108추가: StrCpy $ShortcutOwned 1
109추가: CreateShortcut "$SMPROGRAMS\Zipelo 개발판.lnk" "$INSTDIR\Zipelo.exe"
110추가: IfErrors failed
111추가: StrCpy $UninstallOwned 1
112추가: WriteRegStr HKCU "${UNKEY}" "DisplayName" "Zipelo 개발판"
113추가: WriteRegStr HKCU "${UNKEY}" "DisplayVersion" "0.1.0-dev"
114추가: WriteRegStr HKCU "${UNKEY}" "UninstallString" '$\"$INSTDIR\Uninstall.exe$\"'
115추가: IfErrors failed
116추가: StrCpy $InstallComplete 1
117추가: Goto done
118추가: failed:
119추가: Call Rollback
120추가: SetErrorLevel 1
121추가: MessageBox MB_OK|MB_ICONSTOP "설치를 완료하지 못했습니다. 기존 Zipelo 개발판이 있으면 먼저 제거하고, 여유 공간과 쓰기 권한을 확인하세요. 이번 설치 항목을 정리했으며, 사용 중이라 지우지 못한 항목은 상세 보기에서 확인하세요."
122추가: Abort
123추가: done:
124추가: SectionEnd
125추가:
126추가: Function Rollback
127추가: ${If} $InstallComplete == 1
128추가: ${OrIf} $RootOwned != 1
129추가: Return
130추가: ${EndIf}
131추가: SetOutPath "$TEMP"
132추가: ${If} $ShortcutOwned == 1
133추가: Delete "$SMPROGRAMS\Zipelo 개발판.lnk"
134추가: ${EndIf}
135추가: ${If} $UninstallOwned == 1
136추가: DeleteRegValue HKCU "${UNKEY}" "DisplayName"
137추가: DeleteRegValue HKCU "${UNKEY}" "DisplayVersion"
138추가: DeleteRegValue HKCU "${UNKEY}" "UninstallString"
139추가: DeleteRegKey /ifempty HKCU "${UNKEY}"
140추가: ${EndIf}
141추가: Delete "$INSTDIR\Zipelo.exe"
142추가: Delete "$INSTDIR\zipelo-archive-worker.exe"
143추가: Delete "$INSTDIR\LICENSE"
144추가: Delete "$INSTDIR\BUILD-INFO.json"
145추가: Delete "$INSTDIR\install.ini"
146추가: Delete "$INSTDIR\Uninstall.exe"
147추가: RMDir "$INSTDIR"
148추가: StrCpy $RootOwned 0
149추가: FunctionEnd
150추가:
151추가: Function .onInstFailed
152추가: Call Rollback
153추가: SetErrorLevel 1
154추가: FunctionEnd
155추가:
156추가: Function FinishCreate
157추가: GetDlgItem $0 $HWNDPARENT 1
158추가: SendMessage $0 ${WM_SETTEXT} 0 "STR:마침"
159추가: GetDlgItem $0 $HWNDPARENT 3
160추가: EnableWindow $0 0
161추가: nsDialogs::Create 1018
162추가: Pop $Dialog
163추가: ${If} $Dialog == error
164추가: Abort
165추가: ${EndIf}
166추가: ${NSD_CreateLabel} 0 0 100% 28u "Zipelo 설치가 끝났습니다."
167추가: Pop $0
168추가: ${NSD_CreateLabel} 0 32u 100% 40u "[적용]을 누르면 Zipelo를 연결 프로그램으로 등록하고 Windows 기본 앱 설정을 엽니다. 기본 앱은 설정에서 직접 선택하세요."
169추가: Pop $0
170추가: ${NSD_CreateButton} 0 84u 100% 26u "적용"
171추가: Pop $ApplyButton
172추가: ${NSD_OnClick} $ApplyButton ApplyAssociations
173추가: nsDialogs::Show
174추가: FunctionEnd
175추가:
176추가: Function ApplyAssociations
177추가: Pop $0
178추가: ClearErrors
179추가: WriteRegStr HKCU "${PROGKEY}" "" "Zipelo 압축파일"
180추가: WriteRegStr HKCU "${PROGKEY}\shell\open\command" "" '$\"$INSTDIR\Zipelo.exe$\" $\"%1$\"'
181추가: WriteRegStr HKCU "${APPKEY}\Capabilities" "ApplicationName" "Zipelo 개발판"
182추가: WriteRegStr HKCU "${APPKEY}\Capabilities" "ApplicationDescription" "압축파일 열기와 풀기"
183추가: WriteRegStr HKCU "${APPKEY}\Capabilities\FileAssociations" ".zip" "ZipeloDev.Archive"
184추가: WriteRegStr HKCU "${APPKEY}\Capabilities\FileAssociations" ".tar" "ZipeloDev.Archive"
185추가: WriteRegStr HKCU "${APPKEY}\Capabilities\FileAssociations" ".gz" "ZipeloDev.Archive"
186추가: WriteRegStr HKCU "${APPKEY}\Capabilities\FileAssociations" ".tgz" "ZipeloDev.Archive"
187추가: WriteRegStr HKCU "Software\RegisteredApplications" "Zipelo 개발판" "${APPKEY}\Capabilities"
188추가: IfErrors register_failed
189추가: System::Call 'shell32::SHChangeNotify(i 0x8000000, i 0, p 0, p 0)'
190추가: ExecShell "open" "ms-settings:defaultapps"
191추가: IfErrors settings_failed
192추가: Return
193추가: register_failed:
194추가: MessageBox MB_OK|MB_ICONSTOP "연결 프로그램을 등록하지 못했습니다. 쓰기 권한을 확인한 뒤 다시 적용하세요."
195추가: Return
196추가: settings_failed:
197추가: MessageBox MB_OK "Windows 설정을 열지 못했습니다. 설정에서 앱 > 기본 앱을 직접 열어주세요."
198추가: FunctionEnd
199추가:
200추가: Function un.onInit
201추가: SetShellVarContext current
202추가: SetRegView 64
203추가: System::Call 'kernel32::SetLastError(i 0)'
204추가: System::Call 'kernel32::CreateMutexW(p 0, i 0, w "Local\ZipeloDevSetup") p.r0 ?e'
205추가: Pop $1
206추가: StrCpy $Mutex $0
207추가: ${If} $0 == 0
208추가: ${OrIf} $1 != 0
209추가: Abort
210추가: ${EndIf}
211추가: StrCmp $INSTDIR "${INSTALLROOT}" 0 invalid
212추가: ReadINIStr $0 "$INSTDIR\install.ini" "Zipelo" "Location"
213추가: StrCmp $0 $INSTDIR 0 invalid
214추가: Return
215추가: invalid:
216추가: MessageBox MB_OK|MB_ICONSTOP "설치 위치를 확인하지 못했습니다. 파일을 삭제하지 않습니다."
217추가: Abort
218추가: FunctionEnd
219추가:
220추가: Section "Uninstall"
221추가: SetOutPath "$TEMP"
222추가: ClearErrors
223추가: Delete "$INSTDIR\Zipelo.exe"
224추가: Delete "$INSTDIR\zipelo-archive-worker.exe"
225추가: IfErrors uninstall_failed
226추가: Delete "$INSTDIR\LICENSE"
227추가: Delete "$INSTDIR\BUILD-INFO.json"
228추가: Delete "$SMPROGRAMS\Zipelo 개발판.lnk"
229추가: IfErrors uninstall_failed
230추가: ; 자신이 등록한 값만 제거하고 다른 파일과 키를 보존함.
231추가: ReadRegStr $0 HKCU "Software\RegisteredApplications" "Zipelo 개발판"
232추가: ${If} $0 == "${APPKEY}\Capabilities"
233추가: DeleteRegValue HKCU "Software\RegisteredApplications" "Zipelo 개발판"
234추가: ${EndIf}
235추가: DeleteRegValue HKCU "${APPKEY}\Capabilities\FileAssociations" ".zip"
236추가: DeleteRegValue HKCU "${APPKEY}\Capabilities\FileAssociations" ".tar"
237추가: DeleteRegValue HKCU "${APPKEY}\Capabilities\FileAssociations" ".gz"
238추가: DeleteRegValue HKCU "${APPKEY}\Capabilities\FileAssociations" ".tgz"
239추가: DeleteRegValue HKCU "${APPKEY}\Capabilities" "ApplicationName"
240추가: DeleteRegValue HKCU "${APPKEY}\Capabilities" "ApplicationDescription"
241추가: DeleteRegKey /ifempty HKCU "${APPKEY}\Capabilities\FileAssociations"
242추가: DeleteRegKey /ifempty HKCU "${APPKEY}\Capabilities"
243추가: DeleteRegKey /ifempty HKCU "${APPKEY}"
244추가: DeleteRegValue HKCU "${PROGKEY}\shell\open\command" ""
245추가: DeleteRegValue HKCU "${PROGKEY}" ""
246추가: DeleteRegKey /ifempty HKCU "${PROGKEY}\shell\open\command"
247추가: DeleteRegKey /ifempty HKCU "${PROGKEY}\shell\open"
248추가: DeleteRegKey /ifempty HKCU "${PROGKEY}\shell"
249추가: DeleteRegKey /ifempty HKCU "${PROGKEY}"
250추가: DeleteRegValue HKCU "${UNKEY}" "DisplayName"
251추가: DeleteRegValue HKCU "${UNKEY}" "DisplayVersion"
252추가: DeleteRegValue HKCU "${UNKEY}" "UninstallString"
253추가: DeleteRegKey /ifempty HKCU "${UNKEY}"
254추가: Delete "$INSTDIR\install.ini"
255추가: Delete "$INSTDIR\Uninstall.exe"
256추가: RMDir "$INSTDIR"
257추가: System::Call 'shell32::SHChangeNotify(i 0x8000000, i 0, p 0, p 0)'
258추가: Goto un_done
259추가: uninstall_failed:
260추가: SetErrorLevel 1
261추가: MessageBox MB_OK|MB_ICONSTOP "Zipelo와 작업자를 닫은 뒤 제거 프로그램을 다시 실행하세요."
262추가: Abort
263추가: un_done:
264추가: SectionEnd
추가tests/ci/test_windows_installer.py+124-0
@@ -0,0 +1,124 @@
1추가: import argparse
2추가: import importlib.util
3추가: from pathlib import Path
4추가: import struct
5추가: import re
6추가: import shutil
7추가: import subprocess
8추가: import tempfile
9추가: import sys
10추가: from unittest.mock import patch
11추가: import unittest
12추가:
13추가: ROOT = Path(__file__).resolve().parents[2]
14추가: SPEC = importlib.util.spec_from_file_location("windows_installer", ROOT / "packaging/windows/rust/build.py")
15추가: MODULE = importlib.util.module_from_spec(SPEC)
16추가: SPEC.loader.exec_module(MODULE)
17추가:
18추가:
19추가: class InstallerInputTests(unittest.TestCase):
20추가: def setUp(self):
21추가: runs = ROOT / "tests/windows-installer/runs"
22추가: runs.mkdir(parents=True, exist_ok=True)
23추가: self.directory = tempfile.TemporaryDirectory(dir=runs)
24추가: self.addCleanup(self.directory.cleanup)
25추가: self.root = Path(self.directory.name)
26추가:
27추가: def test_truncated_and_non_pe_payloads_are_rejected(self):
28추가: for content in (b"", b"MZ", b"not an executable" * 8,
29추가: b"MZ" + bytes(58) + struct.pack("<I", 65535)):
30추가: payload = self.root / "invalid.exe"
31추가: payload.write_bytes(content)
32추가: with self.assertRaises(ValueError):
33추가: MODULE.pe_machine(payload)
34추가:
35추가: def test_x64_coff_machine_is_read_from_pe_offset(self):
36추가: payload = self.root / "header.exe"
37추가: payload.write_bytes(b"MZ" + bytes(58) + struct.pack("<I", 128)
38추가: + bytes(64) + b"PE\0\0" + struct.pack("<H", 0x8664))
39추가: self.assertEqual(MODULE.pe_machine(payload), 0x8664)
40추가: payload.write_bytes(payload.read_bytes()[:128] + b"badPE!")
41추가: with self.assertRaises(ValueError):
42추가: MODULE.pe_machine(payload)
43추가:
44추가: def test_existing_output_is_preserved_before_any_build(self):
45추가: output = self.root / "output"
46추가: output.mkdir()
47추가: sentinel = output / "user-data"
48추가: sentinel.write_bytes(b"preserve")
49추가: args = argparse.Namespace(output=output, target_dir=self.root / "target")
50추가: with self.assertRaises(FileExistsError):
51추가: MODULE.build(args)
52추가: self.assertEqual(sentinel.read_bytes(), b"preserve")
53추가: self.assertEqual(list(output.iterdir()), [sentinel])
54추가: self.assertFalse(args.target_dir.exists())
55추가:
56추가: @unittest.skipUnless(shutil.which("makensis"), "NSIS가 설치되지 않음")
57추가: def test_nsis_compiles_payloads_and_finish_callbacks(self):
58추가: payload = self.root / "payload"
59추가: payload.mkdir()
60추가: for name in ("Zipelo.exe", "zipelo-archive-worker.exe", "LICENSE", "BUILD-INFO.json"):
61추가: (payload / name).write_bytes(b"compile-only test fixture")
62추가: shutil.copyfile(ROOT / "packaging/windows/rust/installer.nsi", self.root / "installer.nsi")
63추가: completed = subprocess.run(["makensis", "-WX", "installer.nsi"], cwd=self.root,
64추가: stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True)
65추가: self.assertEqual(completed.returncode, 0, completed.stdout)
66추가: installer = self.root / "Zipelo-0.1.0-dev-windows-x64-setup.exe"
67추가: self.assertIn(MODULE.pe_machine(installer), (0x14C, 0x8664))
68추가: self.assertGreater(installer.stat().st_size, 100000)
69추가:
70추가: def test_command_line_directory_is_reset_before_install_side_effects(self):
71추가: source = (ROOT / "packaging/windows/rust/installer.nsi").read_text()
72추가: section = source.split('Section "Zipelo"', 1)[1].split("SectionEnd", 1)[0]
73추가: commands = [line.strip() for line in section.splitlines()
74추가: if line.strip() and not line.strip().startswith(";")]
75추가: self.assertEqual(commands[0], 'StrCpy $INSTDIR "${INSTALLROOT}"')
76추가: root = re.search(r'^!define INSTALLROOT "([^"\n]+)"$', source, re.MULTILINE)
77추가: self.assertIsNotNone(root)
78추가: self.assertEqual(root.group(1), "$LOCALAPPDATA\\Programs\\Zipelo-Dev")
79추가: self.assertIn('InstallDir "${INSTALLROOT}"', source)
80추가: uninstaller = source.split("Function un.onInit", 1)[1].split("FunctionEnd", 1)[0]
81추가: self.assertIn('StrCmp $INSTDIR "${INSTALLROOT}" 0 invalid', uninstaller)
82추가:
83추가: def test_source_commit_change_cannot_reuse_an_old_binary(self):
84추가: repo = self.root / "source"
85추가: repo.mkdir()
86추가: manifest = repo / "Cargo.toml"
87추가: manifest.write_text("fixture")
88추가: real_run = subprocess.run
89추가: environment = dict(MODULE.os.environ, GIT_AUTHOR_NAME="Zipelo test",
90추가: GIT_AUTHOR_EMAIL="[email protected]", GIT_COMMITTER_NAME="Zipelo test",
91추가: GIT_COMMITTER_EMAIL="[email protected]")
92추가:
93추가: def git(*args):
94추가: real_run(["git", *args], cwd=repo, env=environment, check=True,
95추가: stdout=subprocess.PIPE, stderr=subprocess.PIPE)
96추가:
97추가: git("init", "-b", "features/installer-fixture")
98추가: git("add", ".")
99추가: git("commit", "-m", "첫 시험 소스를 기록함")
100추가:
101추가: def cached_compiler(command, **options):
102추가: if command[0] != "cargo":
103추가: return real_run(command, **options)
104추가: target = Path(command[command.index("--target-dir") + 1])
105추가: output = target / MODULE.TARGET / "debug/fixture.exe"
106추가: output.parent.mkdir(parents=True, exist_ok=True)
107추가: if not output.exists():
108추가: header = b"MZ" + bytes(58) + struct.pack("<I", 128) + bytes(64)
109추가: output.write_bytes(header + b"PE\0\0" + struct.pack("<H", 0x8664)
110추가: + manifest.read_bytes())
111추가: return subprocess.CompletedProcess(command, 0)
112추가:
113추가: with patch.dict(MODULE.os.environ, {"CARGO_TARGET_X86_64_PC_WINDOWS_GNU_LINKER": sys.executable}):
114추가: with patch.object(MODULE.subprocess, "run", side_effect=cached_compiler):
115추가: first, first_record = MODULE.build_binary(manifest, "fixture", self.root / "target", "dev")
116추가: manifest.write_text("changed fixture")
117추가: git("add", ".")
118추가: git("commit", "-m", "변경된 시험 소스를 기록함")
119추가: with patch.object(MODULE.subprocess, "run", side_effect=cached_compiler):
120추가: second, second_record = MODULE.build_binary(manifest, "fixture", self.root / "target", "dev")
121추가: self.assertNotEqual(first_record["commit"], second_record["commit"])
122추가: self.assertNotEqual(first_record["sha256"], second_record["sha256"])
123추가: self.assertTrue(second.read_bytes().endswith(b"changed fixture"))
124추가: self.assertTrue(first.read_bytes().endswith(b"fixture"))
추가tests/windows-installer/.gitignore+3-0
@@ -0,0 +1,3 @@
1추가: runs/
2추가: artifacts*/
3추가: *.log