Merge pull request #77 from Team-LJY/features/release-packages
Ubuntu 패키지 추가와 Windows 설치 파일 갱신
- 작성자
- LeeJunyoung
- 작성 시각
- 커밋
bac1ef669245a010c5c7b3e237f1f1ba2aae8a3b
변경된 파일 14개
+538-10| @@ -0,0 +1,16 @@ | ||
| 1 | 추가: # Ubuntu Rust 패키지 | |
| 2 | 추가: | |
| 3 | 추가: Ubuntu 26.04 amd64에서 현재 저장소의 실제 앱과 작업자를 빌드합니다. 배포 게시와 서명은 수행하지 않습니다. | |
| 4 | 추가: | |
| 5 | 추가: ```sh | |
| 6 | 추가: python3 packaging/ubuntu/rust/build.py --target-dir tests/ci/package-target --output tests/release-packages/runs/ubuntu | |
| 7 | 추가: sudo dpkg -i tests/release-packages/runs/ubuntu/zipelo_0.1.0~dev1_amd64.deb | |
| 8 | 추가: zipelo /path/to/archive.zip | |
| 9 | 추가: sudo dpkg -r zipelo | |
| 10 | 추가: ``` | |
| 11 | 추가: | |
| 12 | 추가: Rust 1.99.1, dpkg-deb와 desktop-file-validate가 필요합니다. 출력은 새 경로여야 하며 기본은 release 빌드입니다. 개발 검증은 --profile dev를 명시합니다. 앱과 작업자는 같은 커밋에서 빌드하며 BUILD-INFO.json에 커밋과 SHA-256을 기록합니다. | |
| 13 | 추가: | |
| 14 | 추가: sudo로 처음 설치하면 postinst가 SUDO_USER의 ZIP, 7z, TAR.GZ, GZ, TAR 기본 앱을 xdg-mime으로 적용합니다. 최초 설치에서 기존 기본 앱 선택을 바꿉니다. 업그레이드와 재설정에서는 사용자의 기본 앱 선택을 유지합니다. 다른 패키지 관리자로 설치해 SUDO_USER가 없으면 사용자 설정을 추측하지 않고 연결 후보만 등록합니다. 이 경우 사용자 계정에서 xdg-mime default zipelo.desktop application/zip 등을 실행해야 합니다. 제거는 사용자 MIME 설정을 지우지 않으며 다른 앱을 기본 앱으로 다시 선택할 수 있습니다. | |
| 15 | 추가: | |
| 16 | 추가: 이 패키지의 검사 범위는 Ubuntu 26.04입니다. 다른 Ubuntu 버전과 Windows 실기는 별도 확인이 필요합니다. |
| @@ -0,0 +1,74 @@ | ||
| 1 | 추가: """Rust 앱과 작업자를 Ubuntu amd64 패키지로 생성함.""" | |
| 2 | 추가: | |
| 3 | 추가: import argparse | |
| 4 | 추가: import hashlib | |
| 5 | 추가: import importlib.util | |
| 6 | 추가: import json | |
| 7 | 추가: from pathlib import Path | |
| 8 | 추가: import shutil | |
| 9 | 추가: import subprocess | |
| 10 | 추가: | |
| 11 | 추가: ROOT = Path(__file__).resolve().parents[3] | |
| 12 | 추가: SPEC = importlib.util.spec_from_file_location("windows_build", ROOT / "packaging/windows/rust/build.py") | |
| 13 | 추가: WINDOWS = importlib.util.module_from_spec(SPEC) | |
| 14 | 추가: SPEC.loader.exec_module(WINDOWS) | |
| 15 | 추가: TARGET = "x86_64-unknown-linux-gnu" | |
| 16 | 추가: | |
| 17 | 추가: | |
| 18 | 추가: def build(args): | |
| 19 | 추가: output = Path(args.output).resolve() | |
| 20 | 추가: output.mkdir(parents=True, exist_ok=False) | |
| 21 | 추가: stage = output / "stage" | |
| 22 | 추가: lib = stage / "usr/lib/zipelo" | |
| 23 | 추가: lib.mkdir(parents=True) | |
| 24 | 추가: records = {} | |
| 25 | 추가: for name, manifest, binary, features in ( | |
| 26 | 추가: ("Zipelo", ROOT / "experiments/rust-ui-memory-app/Cargo.toml", "zipelo-ui-memory-app", ("ui",)), | |
| 27 | 추가: ("zipelo-archive-worker", ROOT / "experiments/rust-archive-worker/Cargo.toml", "zipelo-archive-worker", ()), | |
| 28 | 추가: ): | |
| 29 | 추가: source, records[name] = WINDOWS.build_binary(manifest, binary, Path(args.target_dir).resolve(), args.profile, features, TARGET) | |
| 30 | 추가: shutil.copy2(source, lib / name) | |
| 31 | 추가: if (lib / name).read_bytes()[:4] != b"\x7fELF": | |
| 32 | 추가: raise ValueError("Linux 실행 파일이 아님") | |
| 33 | 추가: (lib / "BUILD-INFO.json").write_text(json.dumps({"target": TARGET, "profile": args.profile, "files": records}, indent=4) + "\n") | |
| 34 | 추가: bindir = stage / "usr/bin" | |
| 35 | 추가: bindir.mkdir() | |
| 36 | 추가: (bindir / "zipelo").symlink_to("../lib/zipelo/Zipelo") | |
| 37 | 추가: desktop = stage / "usr/share/applications" | |
| 38 | 추가: desktop.mkdir(parents=True) | |
| 39 | 추가: shutil.copyfile(Path(__file__).with_name("zipelo.desktop"), desktop / "zipelo.desktop") | |
| 40 | 추가: subprocess.run(["desktop-file-validate", str(desktop / "zipelo.desktop")], check=True) | |
| 41 | 추가: docs = stage / "usr/share/doc/zipelo" | |
| 42 | 추가: docs.mkdir(parents=True) | |
| 43 | 추가: shutil.copyfile(ROOT / "LICENSE", docs / "copyright") | |
| 44 | 추가: control = stage / "DEBIAN" | |
| 45 | 추가: control.mkdir() | |
| 46 | 추가: (control / "control").write_text("""Package: zipelo | |
| 47 | 추가: Version: 0.1.0~dev1 | |
| 48 | 추가: Architecture: amd64 | |
| 49 | 추가: Maintainer: Zipelo contributors <[email protected]> | |
| 50 | 추가: Section: utils | |
| 51 | 추가: Priority: optional | |
| 52 | 추가: Depends: libc6 (>= 2.39), libgcc-s1, libx11-6, libxkbcommon0, libwayland-client0, libegl1, libgl1, libfontconfig1, fonts-noto-cjk, xdg-utils, desktop-file-utils | |
| 53 | 추가: Description: Lightweight Rust archive application | |
| 54 | 추가: ZIP, 7z, TAR, GZ and TAR.GZ archive application with a separate worker. | |
| 55 | 추가: """) | |
| 56 | 추가: for script in ("postinst", "postrm"): | |
| 57 | 추가: shutil.copyfile(Path(__file__).with_name(script), control / script) | |
| 58 | 추가: (control / script).chmod(0o755) | |
| 59 | 추가: package = output / "zipelo_0.1.0~dev1_amd64.deb" | |
| 60 | 추가: subprocess.run(["dpkg-deb", "--root-owner-group", "--build", str(stage), str(package)], check=True) | |
| 61 | 추가: print(package) | |
| 62 | 추가: print("SHA-256 " + hashlib.sha256(package.read_bytes()).hexdigest()) | |
| 63 | 추가: | |
| 64 | 추가: | |
| 65 | 추가: def main(): | |
| 66 | 추가: parser = argparse.ArgumentParser(description=__doc__) | |
| 67 | 추가: parser.add_argument("--output", required=True) | |
| 68 | 추가: parser.add_argument("--target-dir", required=True) | |
| 69 | 추가: parser.add_argument("--profile", choices=("dev", "release"), default="release") | |
| 70 | 추가: build(parser.parse_args()) | |
| 71 | 추가: | |
| 72 | 추가: | |
| 73 | 추가: if __name__ == "__main__": | |
| 74 | 추가: main() |
| @@ -0,0 +1,15 @@ | ||
| 1 | 추가: #!/bin/sh | |
| 2 | 추가: set -eu | |
| 3 | 추가: if command -v update-desktop-database >/dev/null 2>&1; then | |
| 4 | 추가: update-desktop-database /usr/share/applications | |
| 5 | 추가: fi | |
| 6 | 추가: if [ "$1" = configure ] && [ -z "${2:-}" ] && [ -n "${SUDO_USER:-}" ] && [ "$SUDO_USER" != root ]; then | |
| 7 | 추가: account=$(getent passwd "$SUDO_USER") | |
| 8 | 추가: uid=$(printf '%s' "$account" | cut -d: -f3) | |
| 9 | 추가: home_dir=$(printf '%s' "$account" | cut -d: -f6) | |
| 10 | 추가: if [ -n "$uid" ] && [ "$uid" -ge 1000 ] && [ -d "$home_dir" ]; then | |
| 11 | 추가: for mime in application/zip application/x-7z-compressed application/x-compressed-tar application/gzip application/x-tar; do | |
| 12 | 추가: runuser -u "$SUDO_USER" -- env HOME="$home_dir" xdg-mime default zipelo.desktop "$mime" | |
| 13 | 추가: done | |
| 14 | 추가: fi | |
| 15 | 추가: fi |
| @@ -0,0 +1,5 @@ | ||
| 1 | 추가: #!/bin/sh | |
| 2 | 추가: set -eu | |
| 3 | 추가: if command -v update-desktop-database >/dev/null 2>&1; then | |
| 4 | 추가: update-desktop-database /usr/share/applications | |
| 5 | 추가: fi |
| @@ -0,0 +1,10 @@ | ||
| 1 | 추가: [Desktop Entry] | |
| 2 | 추가: Type=Application | |
| 3 | 추가: Name=Zipelo | |
| 4 | 추가: Exec=/usr/bin/zipelo %f | |
| 5 | 추가: TryExec=/usr/bin/zipelo | |
| 6 | 추가: Icon=package-x-generic | |
| 7 | 추가: Terminal=false | |
| 8 | 추가: Categories=Utility;Archiving; | |
| 9 | 추가: MimeType=application/zip;application/x-7z-compressed;application/x-compressed-tar;application/gzip;application/x-tar; | |
| 10 | 추가: StartupNotify=true |
| @@ -27,12 +27,12 @@ Zipelo.exe, zipelo-archive-worker.exe, MIT LICENSE, BUILD-INFO.json과 제거 | ||
| 27 | 27 | 마지막 화면의 [적용]을 누르면 HKCU의 ZipeloDev.Archive ProgID와 RegisteredApplications에 |
| 28 | 28 | .zip, .tar, .gz, .tgz 연결 후보를 등록하고 ms-settings:defaultapps를 엽니다. |
| 29 | 29 | .tar.gz는 마지막 확장자 .gz로 연결됩니다. 기본 앱은 사용자가 Windows 설정에서 직접 선택합니다. |
| 30 | 삭제: JAR, RAR, 7z는 등록하지 않습니다. [마침]만 누르면 연결 후보를 등록하지 않습니다. | |
| 30 | 추가: 7z도 연결 후보에 포함하며 JAR와 RAR는 등록하지 않습니다. [마침]만 누르면 연결 후보를 등록하지 않습니다. | |
| 31 | 31 | 관리자 권한, HKLM, UserChoice 변경을 사용하지 않습니다. |
| 32 | 32 | 제거 시 알려진 앱 파일과 등록 값만 정리하며 폴더 전체를 재귀 삭제하지 않습니다. |
| 33 | 33 | 실행 파일 삭제 실패 시 등록과 제거 프로그램을 보존하여 재시도할 수 있습니다. |
| 34 | 34 | |
| 35 | 삭제: 현재는 개발 검증용입니다. PR62 화면의 실제 작업자 연결, Windows에서의 설치/제거와 설정 실행, | |
| 35 | 추가: 현재 main의 실제 작업자 연결 앱을 포함합니다. Windows에서의 설치/제거와 설정 실행, | |
| 36 | 36 | 지원 형식별 실제 파일 열기, 재설치/권한 실패/잠긴 파일 검증, 포함 의존성의 배포 고지 검토는 남아 있습니다. |
| 37 | 37 | 이번 EXE 생성만으로 해당 항목을 인증하거나 출시하지 않습니다. |
| 38 | 38 | Windows 실행 검증 전에는 README 다운로드 버튼이나 release에 배포하지 않습니다. |
| @@ -25,7 +25,7 @@ def pe_machine(path): | ||
| 25 | 25 | return struct.unpack_from("<H", signature, 4)[0] |
| 26 | 26 | |
| 27 | 27 | |
| 28 | 삭제: def build_binary(manifest, binary, target_dir, profile, features=()): | |
| 28 | 추가: def build_binary(manifest, binary, target_dir, profile, features=(), target=TARGET): | |
| 29 | 29 | manifest = Path(manifest).resolve(strict=True) |
| 30 | 30 | commit = subprocess.check_output( |
| 31 | 31 | ["git", "-C", str(manifest.parent), "rev-parse", "HEAD"], text=True |
| @@ -38,19 +38,20 @@ def build_binary(manifest, binary, target_dir, profile, features=()): | ||
| 38 | 38 | # 작업 복사본 간 mtime 기반 캐시 혼합을 방지함. |
| 39 | 39 | target_dir = target_dir / binary / commit |
| 40 | 40 | command = ["cargo", "+1.99.1", "build", "--locked", "--manifest-path", str(manifest), |
| 41 | 삭제: "--target", TARGET, "--target-dir", str(target_dir), "--profile", profile, | |
| 41 | 추가: "--target", target, "--target-dir", str(target_dir), "--profile", profile, | |
| 42 | 42 | "--bin", binary] |
| 43 | 43 | if features: |
| 44 | 44 | command += ["--features", ",".join(features)] |
| 45 | 45 | environment = dict(os.environ) |
| 46 | 46 | linker = environment.get("CARGO_TARGET_X86_64_PC_WINDOWS_GNU_LINKER") |
| 47 | 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): | |
| 48 | 추가: if target == TARGET and (not linker or not shutil.which(linker)): | |
| 49 | 49 | raise ValueError("MinGW-w64 교차 링커를 찾지 못함") |
| 50 | 삭제: environment["CARGO_TARGET_X86_64_PC_WINDOWS_GNU_LINKER"] = linker | |
| 50 | 추가: if target == TARGET: | |
| 51 | 추가: environment["CARGO_TARGET_X86_64_PC_WINDOWS_GNU_LINKER"] = linker | |
| 51 | 52 | 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: | |
| 53 | 추가: output = target_dir / target / ("debug" if profile == "dev" else profile) / (binary + (".exe" if target == TARGET else "")) | |
| 54 | 추가: if target == TARGET and pe_machine(output) != 0x8664: | |
| 54 | 55 | raise ValueError("x64 Windows 실행 파일이 아님") |
| 55 | 56 | current_commit = subprocess.check_output( |
| 56 | 57 | ["git", "-C", str(manifest.parent), "rev-parse", "HEAD"], text=True |
| @@ -181,6 +181,7 @@ Function ApplyAssociations | ||
| 181 | 181 | WriteRegStr HKCU "${APPKEY}\Capabilities" "ApplicationName" "Zipelo 개발판" |
| 182 | 182 | WriteRegStr HKCU "${APPKEY}\Capabilities" "ApplicationDescription" "압축파일 열기와 풀기" |
| 183 | 183 | WriteRegStr HKCU "${APPKEY}\Capabilities\FileAssociations" ".zip" "ZipeloDev.Archive" |
| 184 | 추가: WriteRegStr HKCU "${APPKEY}\Capabilities\FileAssociations" ".7z" "ZipeloDev.Archive" | |
| 184 | 185 | WriteRegStr HKCU "${APPKEY}\Capabilities\FileAssociations" ".tar" "ZipeloDev.Archive" |
| 185 | 186 | WriteRegStr HKCU "${APPKEY}\Capabilities\FileAssociations" ".gz" "ZipeloDev.Archive" |
| 186 | 187 | WriteRegStr HKCU "${APPKEY}\Capabilities\FileAssociations" ".tgz" "ZipeloDev.Archive" |
| @@ -233,6 +234,7 @@ Section "Uninstall" | ||
| 233 | 234 | DeleteRegValue HKCU "Software\RegisteredApplications" "Zipelo 개발판" |
| 234 | 235 | ${EndIf} |
| 235 | 236 | DeleteRegValue HKCU "${APPKEY}\Capabilities\FileAssociations" ".zip" |
| 237 | 추가: DeleteRegValue HKCU "${APPKEY}\Capabilities\FileAssociations" ".7z" | |
| 236 | 238 | DeleteRegValue HKCU "${APPKEY}\Capabilities\FileAssociations" ".tar" |
| 237 | 239 | DeleteRegValue HKCU "${APPKEY}\Capabilities\FileAssociations" ".gz" |
| 238 | 240 | DeleteRegValue HKCU "${APPKEY}\Capabilities\FileAssociations" ".tgz" |
| @@ -0,0 +1 @@ | ||
| 1 | 추가: runs/ |
| @@ -0,0 +1,15 @@ | ||
| 1 | 추가: # 패키지 검증 | |
| 2 | 추가: | |
| 3 | 추가: 저장소의 packaging/windows/rust/build.py와 packaging/ubuntu/rust/build.py로 두 플랫폼의 실제 앱과 작업자를 생성합니다. 기본 profile은 release이며 ui-fixture는 사용하지 않습니다. | |
| 4 | 추가: | |
| 5 | 추가: ```sh | |
| 6 | 추가: python3 tests/ci/run_rust.py local | |
| 7 | 추가: python3 -m unittest discover -s tests/release-packages -p "test_*.py" | |
| 8 | 추가: python3 tests/release-packages/ubuntu_smoke.py tests/release-packages/runs/ubuntu-release/zipelo_0.1.0~dev1_amd64.deb | |
| 9 | 추가: ``` | |
| 10 | 추가: | |
| 11 | 추가: Ubuntu 실기 스모크는 이 패키지를 sudo로 설치하고 ZIP, 7z, TAR.GZ의 기본 앱을 확인합니다. 별도 Xvfb 화면에서 공백이 있는 경로의 합성 ZIP을 실제 앱으로 열어 소유 창을 캡처합니다. 종료 후 패키지를 제거하고 기존 MIME 설정을 복원합니다. 설치나 제거가 실패해도 MIME 설정 복원을 시도하고 원래 실패와 정리 실패를 함께 보고합니다. 설치된 Zipelo나 같은 경로의 기존 파일이 있으면 중단합니다. 시험 중 다른 MIME 설정 변경이 감지되면 해당 파일을 덮어쓰지 않고 나머지 파일은 복원합니다. | |
| 12 | 추가: | |
| 13 | 추가: sudo 비대화형 권한, Xvfb, xdotool과 ImageMagick import가 필요합니다. 이 검사는 실제 시스템 패키지를 설치하고 사용자 기본 앱을 임시로 바꾸므로 실행 전에 해당 작업의 승인이 필요합니다. 출력은 runs/에 남고 Git에는 포함하지 않습니다. | |
| 14 | 추가: | |
| 15 | 추가: Windows 설치와 설정 화면, 제거의 실기 검증은 이 Linux 시험에 포함되지 않습니다. release 게시와 다운로드 버튼 갱신도 수행하지 않습니다. |
| @@ -0,0 +1,118 @@ | ||
| 1 | 추가: """기본 앱 보존과 설치 실패 정리를 격리 검증함.""" | |
| 2 | 추가: | |
| 3 | 추가: import importlib.util | |
| 4 | 추가: import os | |
| 5 | 추가: from pathlib import Path | |
| 6 | 추가: import subprocess | |
| 7 | 추가: import tempfile | |
| 8 | 추가: import unittest | |
| 9 | 추가: from unittest.mock import patch | |
| 10 | 추가: | |
| 11 | 추가: ROOT = Path(__file__).resolve().parents[2] | |
| 12 | 추가: SPEC = importlib.util.spec_from_file_location("ubuntu_smoke", Path(__file__).with_name("ubuntu_smoke.py")) | |
| 13 | 추가: SMOKE = importlib.util.module_from_spec(SPEC) | |
| 14 | 추가: SPEC.loader.exec_module(SMOKE) | |
| 15 | 추가: | |
| 16 | 추가: | |
| 17 | 추가: class LifecycleTests(unittest.TestCase): | |
| 18 | 추가: def setUp(self): | |
| 19 | 추가: (ROOT / "tests/release-packages/runs").mkdir(parents=True, exist_ok=True) | |
| 20 | 추가: temporary = tempfile.TemporaryDirectory(dir=ROOT / "tests/release-packages/runs") | |
| 21 | 추가: self.addCleanup(temporary.cleanup) | |
| 22 | 추가: self.directory = Path(temporary.name) | |
| 23 | 추가: self.previous = self.directory / "mimeapps.list" | |
| 24 | 추가: self.previous.write_bytes(b"previous-app.desktop\n") | |
| 25 | 추가: self.created = self.directory / "added-mimeapps.list" | |
| 26 | 추가: self.original = {self.previous: self.previous.read_bytes()} | |
| 27 | 추가: settings = patch.object(SMOKE, "CONFIGS", (self.directory,)) | |
| 28 | 추가: settings.start() | |
| 29 | 추가: self.addCleanup(settings.stop) | |
| 30 | 추가: | |
| 31 | 추가: def test_only_first_configuration_sets_defaults(self): | |
| 32 | 추가: commands = self.directory / "bin" | |
| 33 | 추가: commands.mkdir() | |
| 34 | 추가: log = self.directory / "calls" | |
| 35 | 추가: scripts = { | |
| 36 | 추가: "update-desktop-database": "#!/bin/sh\nexit 0\n", | |
| 37 | 추가: "getent": '#!/bin/sh\nprintf "tester:x:1000:1000::%s:/bin/sh\\n" "$TEST_HOME"\n', | |
| 38 | 추가: "runuser": '#!/bin/sh\nprintf "%s\\n" "$*" >> "$TEST_LOG"\n', | |
| 39 | 추가: } | |
| 40 | 추가: for name, content in scripts.items(): | |
| 41 | 추가: executable = commands / name | |
| 42 | 추가: executable.write_text(content) | |
| 43 | 추가: executable.chmod(0o755) | |
| 44 | 추가: env = { | |
| 45 | 추가: **os.environ, | |
| 46 | 추가: "PATH": str(commands) + os.pathsep + os.environ["PATH"], | |
| 47 | 추가: "SUDO_USER": "tester", | |
| 48 | 추가: "TEST_HOME": str(self.directory), | |
| 49 | 추가: "TEST_LOG": str(log), | |
| 50 | 추가: } | |
| 51 | 추가: for arguments, count in ((["configure"], 5), (["configure", "0.1.0"], 0), | |
| 52 | 추가: (["triggered", "desktop"], 0)): | |
| 53 | 추가: with self.subTest(arguments=arguments): | |
| 54 | 추가: log.write_text("") | |
| 55 | 추가: subprocess.run(["sh", str(ROOT / "packaging/ubuntu/rust/postinst"), *arguments], | |
| 56 | 추가: env=env, check=True) | |
| 57 | 추가: self.assertEqual(len(log.read_text().splitlines()), count) | |
| 58 | 추가: | |
| 59 | 추가: def check_smoke(self, install_fails=False, purge_fails=False, body_fails=False): | |
| 60 | 추가: calls = [] | |
| 61 | 추가: | |
| 62 | 추가: def command(arguments, **options): | |
| 63 | 추가: calls.append(arguments) | |
| 64 | 추가: if "-i" in arguments: | |
| 65 | 추가: self.previous.write_bytes(b"zipelo.desktop\n") | |
| 66 | 추가: self.created.write_bytes(b"zipelo.desktop\n") | |
| 67 | 추가: if install_fails: | |
| 68 | 추가: raise subprocess.CalledProcessError(1, arguments) | |
| 69 | 추가: elif purge_fails: | |
| 70 | 추가: raise subprocess.CalledProcessError(2, arguments) | |
| 71 | 추가: return subprocess.CompletedProcess(arguments, 0) | |
| 72 | 추가: | |
| 73 | 추가: def exercise(): | |
| 74 | 추가: with patch.object(SMOKE.subprocess, "run", side_effect=command): | |
| 75 | 추가: with SMOKE.installed_package(self.directory / "sample.deb"): | |
| 76 | 추가: self.assertFalse(install_fails) | |
| 77 | 추가: if body_fails: | |
| 78 | 추가: raise RuntimeError("창 실행 실패") | |
| 79 | 추가: | |
| 80 | 추가: if install_fails or purge_fails or body_fails: | |
| 81 | 추가: with self.assertRaises(ExceptionGroup) as raised: | |
| 82 | 추가: exercise() | |
| 83 | 추가: self.assertEqual(len(raised.exception.exceptions), | |
| 84 | 추가: int(install_fails) + int(purge_fails) + int(body_fails)) | |
| 85 | 추가: else: | |
| 86 | 추가: exercise() | |
| 87 | 추가: self.assertEqual(SMOKE.configs(), self.original) | |
| 88 | 추가: self.assertEqual(len(calls), 2) | |
| 89 | 추가: self.assertIn("-P", calls[1]) | |
| 90 | 추가: | |
| 91 | 추가: def test_success_restores_settings(self): | |
| 92 | 추가: self.check_smoke() | |
| 93 | 추가: | |
| 94 | 추가: def test_partial_install_failure_restores_settings(self): | |
| 95 | 추가: self.check_smoke(install_fails=True) | |
| 96 | 추가: | |
| 97 | 추가: def test_purge_failure_still_restores_settings(self): | |
| 98 | 추가: self.check_smoke(purge_fails=True) | |
| 99 | 추가: | |
| 100 | 추가: def test_both_failures_are_reported(self): | |
| 101 | 추가: self.check_smoke(install_fails=True, purge_fails=True) | |
| 102 | 추가: | |
| 103 | 추가: def test_window_failure_restores_settings(self): | |
| 104 | 추가: self.check_smoke(body_fails=True) | |
| 105 | 추가: | |
| 106 | 추가: def test_external_change_does_not_skip_other_restores(self): | |
| 107 | 추가: self.previous.write_bytes(b"zipelo.desktop\n") | |
| 108 | 추가: self.created.write_bytes(b"zipelo.desktop\n") | |
| 109 | 추가: after = SMOKE.configs() | |
| 110 | 추가: self.created.write_bytes(b"external-choice.desktop\n") | |
| 111 | 추가: with self.assertRaises(ExceptionGroup): | |
| 112 | 추가: SMOKE.restore_configs(self.original, after) | |
| 113 | 추가: self.assertEqual(self.previous.read_bytes(), self.original[self.previous]) | |
| 114 | 추가: self.assertEqual(self.created.read_bytes(), b"external-choice.desktop\n") | |
| 115 | 추가: | |
| 116 | 추가: | |
| 117 | 추가: if __name__ == "__main__": | |
| 118 | 추가: unittest.main() |
| @@ -0,0 +1,130 @@ | ||
| 1 | 추가: """현재 사용자 설정을 보존하고 실제 패키지 설치와 창 실행을 검증함.""" | |
| 2 | 추가: | |
| 3 | 추가: import argparse | |
| 4 | 추가: from contextlib import contextmanager | |
| 5 | 추가: import json | |
| 6 | 추가: import os | |
| 7 | 추가: from pathlib import Path | |
| 8 | 추가: import select | |
| 9 | 추가: import subprocess | |
| 10 | 추가: import time | |
| 11 | 추가: import zipfile | |
| 12 | 추가: | |
| 13 | 추가: ROOT = Path(__file__).resolve().parents[2] | |
| 14 | 추가: MIMES = ("application/zip", "application/x-7z-compressed", "application/x-compressed-tar") | |
| 15 | 추가: CONFIGS = (Path.home() / ".config", Path.home() / ".local/share/applications") | |
| 16 | 추가: | |
| 17 | 추가: | |
| 18 | 추가: def configs(): | |
| 19 | 추가: return {p: p.read_bytes() for directory in CONFIGS for p in directory.glob("*mimeapps.list")} | |
| 20 | 추가: | |
| 21 | 추가: | |
| 22 | 추가: def restore_configs(before, after): | |
| 23 | 추가: current = configs() | |
| 24 | 추가: failures = [] | |
| 25 | 추가: for path in set(before) | set(after): | |
| 26 | 추가: try: | |
| 27 | 추가: if current.get(path) != after.get(path): | |
| 28 | 추가: raise RuntimeError(f"다른 MIME 설정 변경이 있어 복원을 보류함: {path}") | |
| 29 | 추가: if path in before: | |
| 30 | 추가: path.write_bytes(before[path]) | |
| 31 | 추가: elif path.exists(): | |
| 32 | 추가: path.unlink() | |
| 33 | 추가: except Exception as error: | |
| 34 | 추가: failures.append(error) | |
| 35 | 추가: if failures: | |
| 36 | 추가: raise ExceptionGroup("MIME 설정 복원 실패", failures) | |
| 37 | 추가: if configs() != before: | |
| 38 | 추가: raise RuntimeError("기존 MIME 설정 복원 실패") | |
| 39 | 추가: | |
| 40 | 추가: | |
| 41 | 추가: @contextmanager | |
| 42 | 추가: def installed_package(package): | |
| 43 | 추가: before = configs() | |
| 44 | 추가: after = None | |
| 45 | 추가: failures = [] | |
| 46 | 추가: try: | |
| 47 | 추가: try: | |
| 48 | 추가: subprocess.run(["sudo", "-n", "dpkg", "-i", str(package)], check=True) | |
| 49 | 추가: finally: | |
| 50 | 추가: after = configs() | |
| 51 | 추가: yield | |
| 52 | 추가: except BaseException as error: | |
| 53 | 추가: failures.append(error) | |
| 54 | 추가: finally: | |
| 55 | 추가: try: | |
| 56 | 추가: subprocess.run(["sudo", "-n", "dpkg", "-P", "zipelo"], check=True) | |
| 57 | 추가: except BaseException as error: | |
| 58 | 추가: failures.append(error) | |
| 59 | 추가: try: | |
| 60 | 추가: if after is not None: | |
| 61 | 추가: restore_configs(before, after) | |
| 62 | 추가: except BaseException as error: | |
| 63 | 추가: failures.append(error) | |
| 64 | 추가: if failures: | |
| 65 | 추가: raise BaseExceptionGroup("패키지 시험 또는 정리 실패", failures) | |
| 66 | 추가: | |
| 67 | 추가: | |
| 68 | 추가: def main(): | |
| 69 | 추가: parser = argparse.ArgumentParser(description=__doc__) | |
| 70 | 추가: parser.add_argument("package", type=Path) | |
| 71 | 추가: args = parser.parse_args() | |
| 72 | 추가: package = args.package.resolve(strict=True) | |
| 73 | 추가: runs = ROOT / "tests/release-packages/runs/smoke" | |
| 74 | 추가: runs.mkdir(parents=True, exist_ok=False) | |
| 75 | 추가: assert subprocess.run(["dpkg-query", "-W", "-f=${db:Status-Status}", "zipelo"], | |
| 76 | 추가: capture_output=True).stdout != b"installed", "기존 설치를 보존해야 함" | |
| 77 | 추가: for name in ("/usr/lib/zipelo", "/usr/bin/zipelo", "/usr/share/applications/zipelo.desktop"): | |
| 78 | 추가: assert not Path(name).exists(), "기존 파일이 있어 설치를 중단함" | |
| 79 | 추가: app = None | |
| 80 | 추가: display = None | |
| 81 | 추가: with installed_package(package): | |
| 82 | 추가: try: | |
| 83 | 추가: for mime in MIMES: | |
| 84 | 추가: result = subprocess.check_output(["xdg-mime", "query", "default", mime], text=True).strip() | |
| 85 | 추가: assert result == "zipelo.desktop", f"연결 실패: {mime}" | |
| 86 | 추가: info = json.loads(Path("/usr/lib/zipelo/BUILD-INFO.json").read_text()) | |
| 87 | 추가: assert info["profile"] == "release" | |
| 88 | 추가: archive = runs / "sample archive.zip" | |
| 89 | 추가: with zipfile.ZipFile(archive, "w") as output: | |
| 90 | 추가: output.writestr("example.txt", "Zipelo package verification") | |
| 91 | 추가: display = subprocess.Popen( | |
| 92 | 추가: ["Xvfb", "-displayfd", "1", "-screen", "0", "1280x900x24", "-nolisten", "tcp"], | |
| 93 | 추가: stdout=subprocess.PIPE, stderr=subprocess.DEVNULL) | |
| 94 | 추가: assert select.select([display.stdout], [], [], 15)[0], "Xvfb 준비 실패" | |
| 95 | 추가: number = display.stdout.readline().decode().strip() | |
| 96 | 추가: assert number.isdecimal() | |
| 97 | 추가: env = {**os.environ, "DISPLAY": ":" + number, "WINIT_UNIX_BACKEND": "x11", "XDG_SESSION_TYPE": "x11"} | |
| 98 | 추가: env.pop("WAYLAND_DISPLAY", None) | |
| 99 | 추가: with (runs / "app.stdout").open("wb") as stdout, (runs / "app.stderr").open("wb") as stderr: | |
| 100 | 추가: app = subprocess.Popen(["/usr/bin/zipelo", str(archive)], env=env, stdout=stdout, stderr=stderr) | |
| 101 | 추가: deadline = time.monotonic() + 30 | |
| 102 | 추가: while True: | |
| 103 | 추가: assert app.poll() is None, "설치된 앱이 조기에 종료됨" | |
| 104 | 추가: window = subprocess.run(["xdotool", "search", "--all", "--pid", str(app.pid), "--name", "Zipelo"], | |
| 105 | 추가: env=env, capture_output=True, text=True) | |
| 106 | 추가: if window.returncode == 0: | |
| 107 | 추가: break | |
| 108 | 추가: assert time.monotonic() < deadline, "앱 창 표시 시간 초과" | |
| 109 | 추가: time.sleep(0.2) | |
| 110 | 추가: time.sleep(3) | |
| 111 | 추가: assert app.poll() is None | |
| 112 | 추가: subprocess.run(["import", "-window", window.stdout.splitlines()[0], | |
| 113 | 추가: str(runs / "installed-window.png")], env=env, check=True) | |
| 114 | 추가: print("PASS installed package, ZIP/7z/TAR.GZ defaults and native X11 window") | |
| 115 | 추가: finally: | |
| 116 | 추가: for process in (app, display): | |
| 117 | 추가: if process is not None and process.poll() is None: | |
| 118 | 추가: process.terminate() | |
| 119 | 추가: try: | |
| 120 | 추가: process.wait(timeout=10) | |
| 121 | 추가: except subprocess.TimeoutExpired: | |
| 122 | 추가: process.kill() | |
| 123 | 추가: process.wait() | |
| 124 | 추가: assert not Path("/usr/bin/zipelo").exists() | |
| 125 | 추가: assert not Path("/usr/lib/zipelo").exists() | |
| 126 | 추가: print("PASS package removed and previous MIME settings restored") | |
| 127 | 추가: | |
| 128 | 추가: | |
| 129 | 추가: if __name__ == "__main__": | |
| 130 | 추가: main() |
| @@ -0,0 +1,103 @@ | ||
| 1 | 추가: { | |
| 2 | 추가: "base_remote_main": "3b9b5910383295e5597be9b66edcfe444f9ff2ea", | |
| 3 | 추가: "package_source_local_commit": "10aad21", | |
| 4 | 추가: "tested_source_local_commit": "7048d97b20a3eaa903cbaa7e992ae3df1fcf7027", | |
| 5 | 추가: "tested_code_tree": "fb20221c8ec4bbf3e9cd86e1f048d3e6a77551d1", | |
| 6 | 추가: "product_code_unchanged_from_base": true, | |
| 7 | 추가: "build_profile": "release", | |
| 8 | 추가: "package_version": "0.1.0 development", | |
| 9 | 추가: "artifacts": { | |
| 10 | 추가: "ubuntu": { | |
| 11 | 추가: "path": "tests/release-packages/runs/ubuntu-release/zipelo_0.1.0~dev1_amd64.deb", | |
| 12 | 추가: "bytes": 4966530, | |
| 13 | 추가: "sha256": "b5824125075f957633ee8c1e08abccfa083027e4ba40a94281c76e397638cf15" | |
| 14 | 추가: }, | |
| 15 | 추가: "windows": { | |
| 16 | 추가: "path": "tests/release-packages/runs/windows-release/Zipelo-0.1.0-dev-windows-x64-setup.exe", | |
| 17 | 추가: "bytes": 5614970, | |
| 18 | 추가: "sha256": "8331b43b82349f6b7a65b8865bc5b40a899082f67b796528f7726d8009fe1dab" | |
| 19 | 추가: } | |
| 20 | 추가: }, | |
| 21 | 추가: "local": { | |
| 22 | 추가: "command": "python3 tests/ci/run_rust.py local", | |
| 23 | 추가: "exit_code": 0, | |
| 24 | 추가: "rust_tests_passed": 937, | |
| 25 | 추가: "runner_checks_passed": 34, | |
| 26 | 추가: "linux_build_targets_passed": 21, | |
| 27 | 추가: "linux_test_targets_passed": 21, | |
| 28 | 추가: "windows_cross_targets_passed": 21 | |
| 29 | 추가: }, | |
| 30 | 추가: "ubuntu": { | |
| 31 | 추가: "platform": "Ubuntu 26.04 amd64", | |
| 32 | 추가: "installed": true, | |
| 33 | 추가: "mime_defaults_verified": [ | |
| 34 | 추가: "application/zip", | |
| 35 | 추가: "application/x-7z-compressed", | |
| 36 | 추가: "application/x-compressed-tar" | |
| 37 | 추가: ], | |
| 38 | 추가: "native_window": "Xvfb X11, installed /usr/bin/zipelo with real worker", | |
| 39 | 추가: "list_screen_reviewed": "example.txt, 27 bytes, completed", | |
| 40 | 추가: "removed_and_purged": true, | |
| 41 | 추가: "previous_mime_settings_restored": true | |
| 42 | 추가: }, | |
| 43 | 추가: "windows": { | |
| 44 | 추가: "installer_compiled": true, | |
| 45 | 추가: "payload_pe_architecture": "x64", | |
| 46 | 추가: "runtime_tested": false | |
| 47 | 추가: }, | |
| 48 | 추가: "regression": { | |
| 49 | 추가: "initial_local_exit_code": 1, | |
| 50 | 추가: "initial_failure": "cancel_racing_child_exit_preserves_completed_result_before_poll: Cancelled instead of Completed after a fixed 2ms wait", | |
| 51 | 추가: "fix": "Wait for the real Exited event and buffer responses before model polling; product code unchanged", | |
| 52 | 추가: "focused_iterations": 100, | |
| 53 | 추가: "focused_passed": true, | |
| 54 | 추가: "full_local_after_fix_passed": true | |
| 55 | 추가: }, | |
| 56 | 추가: "limitations": [ | |
| 57 | 추가: "Automatic MIME defaults require SUDO_USER; GUI/service installs without user identity only register a candidate", | |
| 58 | 추가: "Windows runtime and native Wayland session not tested", | |
| 59 | 추가: "Rebuild final distribution after pending 7z/ZIP streaming integration" | |
| 60 | 추가: ], | |
| 61 | 추가: "local_evidence": [ | |
| 62 | 추가: "tests/release-packages/runs/ubuntu-release-build.log", | |
| 63 | 추가: "tests/release-packages/runs/windows-release-build.log", | |
| 64 | 추가: "tests/release-packages/runs/ubuntu-smoke.log", | |
| 65 | 추가: "tests/release-packages/runs/ubuntu-purge.log", | |
| 66 | 추가: "tests/release-packages/runs/cancel-regression.log", | |
| 67 | 추가: "tests/release-packages/runs/local.log", | |
| 68 | 추가: "tests/release-packages/runs/local-fixed.log", | |
| 69 | 추가: "tests/release-packages/runs/smoke/installed-window.png" | |
| 70 | 추가: ], | |
| 71 | 추가: "evidence_note": "Validation JSON added after tests; the tested code tree matches the remote code tree.", | |
| 72 | 추가: "lifecycle_fix": { | |
| 73 | 추가: "tested_source_local_commit": "64278d557270ceead65729a2a7484c90806cce97", | |
| 74 | 추가: "changes": [ | |
| 75 | 추가: "최초 configure에서만 기본 앱 적용, 업그레이드 및 재설정은 기존 선택 보존", | |
| 76 | 추가: "설치 시도 실패에도 purge 실행, purge 실패와 별개로 MIME 복원", | |
| 77 | 추가: "외부 MIME 변경은 보존하며 다른 파일 복원 지속, 원래 실패와 정리 실패 모두 보고" | |
| 78 | 추가: ], | |
| 79 | 추가: "regression_command": "python3 -m unittest discover -s tests/release-packages -p \"test_*.py\" -v", | |
| 80 | 추가: "regression_tests_passed": 7, | |
| 81 | 추가: "local": { | |
| 82 | 추가: "exit_code": 0, | |
| 83 | 추가: "rust_tests_passed": 937, | |
| 84 | 추가: "runner_checks_passed": 34, | |
| 85 | 추가: "linux_build_targets_passed": 21, | |
| 86 | 추가: "linux_test_targets_passed": 21, | |
| 87 | 추가: "windows_cross_targets_passed": 21 | |
| 88 | 추가: }, | |
| 89 | 추가: "ubuntu_repackaged": { | |
| 90 | 추가: "path": "tests/release-packages/runs/ubuntu-lifecycle/zipelo_0.1.0~dev1_amd64.deb", | |
| 91 | 추가: "bytes": 4966540, | |
| 92 | 추가: "sha256": "bbab8fcd97b004c6bbb62a3a3f76d519dc517d35f72b617f01f37f18e46ec97a", | |
| 93 | 추가: "payload_reused_from": "10aad21", | |
| 94 | 추가: "postinst_updated": true | |
| 95 | 추가: }, | |
| 96 | 추가: "actual_installation_rerun": false, | |
| 97 | 추가: "windows_runtime_tested": false, | |
| 98 | 추가: "logs": [ | |
| 99 | 추가: "tests/release-packages/runs/lifecycle-regression.log", | |
| 100 | 추가: "tests/release-packages/runs/local-lifecycle.log" | |
| 101 | 추가: ] | |
| 102 | 추가: } | |
| 103 | 추가: } |
| @@ -511,12 +511,50 @@ fn late_cancel_after_child_reap_keeps_the_original_terminal_result() { | ||
| 511 | 511 | |
| 512 | 512 | #[test] |
| 513 | 513 | fn cancel_racing_child_exit_preserves_completed_result_before_poll() { |
| 514 | 추가: struct CompletedFactory(ProcessFactory); | |
| 515 | 추가: struct BufferedConnection { | |
| 516 | 추가: inner: Box<dyn Connection>, | |
| 517 | 추가: pending: std::collections::VecDeque<HostEvent>, | |
| 518 | 추가: } | |
| 519 | 추가: impl Factory for CompletedFactory { | |
| 520 | 추가: fn connect(&mut self, job_id: u64) -> Result<Box<dyn Connection>, String> { | |
| 521 | 추가: Ok(Box::new(BufferedConnection { | |
| 522 | 추가: inner: self.0.connect(job_id)?, | |
| 523 | 추가: pending: Default::default(), | |
| 524 | 추가: })) | |
| 525 | 추가: } | |
| 526 | 추가: } | |
| 527 | 추가: impl Connection for BufferedConnection { | |
| 528 | 추가: fn send(&mut self, request: Request) -> Result<(), String> { | |
| 529 | 추가: let starting = matches!(&request.command, Command::Start(_)); | |
| 530 | 추가: self.inner.send(request)?; | |
| 531 | 추가: if starting { | |
| 532 | 추가: let deadline = Instant::now() + Duration::from_secs(20); | |
| 533 | 추가: loop { | |
| 534 | 추가: assert!(Instant::now() < deadline, "작업자 종료 대기 시간 초과"); | |
| 535 | 추가: if let Some(event) = self.inner.poll() { | |
| 536 | 추가: let exited = matches!(&event, HostEvent::Exited { .. }); | |
| 537 | 추가: self.pending.push_back(event); | |
| 538 | 추가: if exited { | |
| 539 | 추가: break; | |
| 540 | 추가: } | |
| 541 | 추가: } else { | |
| 542 | 추가: std::thread::sleep(Duration::from_millis(1)); | |
| 543 | 추가: } | |
| 544 | 추가: } | |
| 545 | 추가: } | |
| 546 | 추가: Ok(()) | |
| 547 | 추가: } | |
| 548 | 추가: fn poll(&mut self) -> Option<HostEvent> { | |
| 549 | 추가: self.pending.pop_front().or_else(|| self.inner.poll()) | |
| 550 | 추가: } | |
| 551 | 추가: } | |
| 514 | 552 | let archive = Path::new(env!("CARGO_MANIFEST_DIR")) |
| 515 | 553 | .join("../../tests/rust-app-real-worker/fixtures/sample.zip") |
| 516 | 554 | .canonicalize() |
| 517 | 555 | .unwrap(); |
| 518 | 556 | for iteration in 0..100 { |
| 519 | 삭제: let mut factory = ProcessFactory::new(binary("zipelo-archive-worker")); | |
| 557 | 추가: let mut factory = CompletedFactory(ProcessFactory::new(binary("zipelo-archive-worker"))); | |
| 520 | 558 | let mut model = Model::default(); |
| 521 | 559 | assert!(model.begin( |
| 522 | 560 | Start::List { |
| @@ -524,7 +562,7 @@ fn cancel_racing_child_exit_preserves_completed_result_before_poll() { | ||
| 524 | 562 | }, |
| 525 | 563 | &mut factory |
| 526 | 564 | )); |
| 527 | 삭제: std::thread::sleep(Duration::from_millis(2)); | |
| 565 | 추가: assert!(model.terminal.is_none()); | |
| 528 | 566 | model.cancel(); |
| 529 | 567 | wait(&mut model); |
| 530 | 568 | assert!(model.confirmed, "iteration={iteration}: {:?}", model.error); |