team-ljyzipelo

공개

ENOSPC 시험 오탐을 수정하고 main 변경을 통합함

작성자
시로사키 하나
작성 시각
커밋
d717ae55970a0ed4e4ac51f81f08fa2e451bb829
이 시점의 파일 보기

변경된 파일 16개

+548-12
추가packaging/ubuntu/rust/README.md+16-0
@@ -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 실기는 별도 확인이 필요합니다.
추가packaging/ubuntu/rust/build.py+74-0
@@ -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()
추가packaging/ubuntu/rust/postinst+15-0
@@ -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
추가packaging/ubuntu/rust/postrm+5-0
@@ -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
추가packaging/ubuntu/rust/zipelo.desktop+10-0
@@ -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
수정packaging/windows/rust/README.md+2-2
@@ -27,12 +27,12 @@ Zipelo.exe, zipelo-archive-worker.exe, MIT LICENSE, BUILD-INFO.json과 제거
2727마지막 화면의 [적용]을 누르면 HKCU의 ZipeloDev.Archive ProgID와 RegisteredApplications에
2828.zip, .tar, .gz, .tgz 연결 후보를 등록하고 ms-settings:defaultapps를 엽니다.
2929.tar.gz는 마지막 확장자 .gz로 연결됩니다. 기본 앱은 사용자가 Windows 설정에서 직접 선택합니다.
30삭제: JAR, RAR, 7z는 등록하지 않습니다. [마침]만 누르면 연결 후보를 등록하지 않습니다.
30추가: 7z도 연결 후보에 포함하며 JAR와 RAR는 등록하지 않습니다. [마침]만 누르면 연결 후보를 등록하지 않습니다.
3131관리자 권한, HKLM, UserChoice 변경을 사용하지 않습니다.
3232제거 시 알려진 앱 파일과 등록 값만 정리하며 폴더 전체를 재귀 삭제하지 않습니다.
3333실행 파일 삭제 실패 시 등록과 제거 프로그램을 보존하여 재시도할 수 있습니다.
3434
35삭제: 현재는 개발 검증용입니다. PR62 화면의 실제 작업자 연결, Windows에서의 설치/제거와 설정 실행,
35추가: 현재 main의 실제 작업자 연결 앱을 포함합니다. Windows에서의 설치/제거와 설정 실행,
3636지원 형식별 실제 파일 열기, 재설치/권한 실패/잠긴 파일 검증, 포함 의존성의 배포 고지 검토는 남아 있습니다.
3737이번 EXE 생성만으로 해당 항목을 인증하거나 출시하지 않습니다.
3838Windows 실행 검증 전에는 README 다운로드 버튼이나 release에 배포하지 않습니다.
수정packaging/windows/rust/build.py+7-6
@@ -25,7 +25,7 @@ def pe_machine(path):
2525 return struct.unpack_from("<H", signature, 4)[0]
2626
2727
28삭제: def build_binary(manifest, binary, target_dir, profile, features=()):
28추가: def build_binary(manifest, binary, target_dir, profile, features=(), target=TARGET):
2929 manifest = Path(manifest).resolve(strict=True)
3030 commit = subprocess.check_output(
3131 ["git", "-C", str(manifest.parent), "rev-parse", "HEAD"], text=True
@@ -38,19 +38,20 @@ def build_binary(manifest, binary, target_dir, profile, features=()):
3838 # 작업 복사본 간 mtime 기반 캐시 혼합을 방지함.
3939 target_dir = target_dir / binary / commit
4040 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,
4242 "--bin", binary]
4343 if features:
4444 command += ["--features", ",".join(features)]
4545 environment = dict(os.environ)
4646 linker = environment.get("CARGO_TARGET_X86_64_PC_WINDOWS_GNU_LINKER")
4747 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)):
4949 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
5152 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:
5455 raise ValueError("x64 Windows 실행 파일이 아님")
5556 current_commit = subprocess.check_output(
5657 ["git", "-C", str(manifest.parent), "rev-parse", "HEAD"], text=True
수정packaging/windows/rust/installer.nsi+2-0
@@ -181,6 +181,7 @@ Function ApplyAssociations
181181 WriteRegStr HKCU "${APPKEY}\Capabilities" "ApplicationName" "Zipelo 개발판"
182182 WriteRegStr HKCU "${APPKEY}\Capabilities" "ApplicationDescription" "압축파일 열기와 풀기"
183183 WriteRegStr HKCU "${APPKEY}\Capabilities\FileAssociations" ".zip" "ZipeloDev.Archive"
184추가: WriteRegStr HKCU "${APPKEY}\Capabilities\FileAssociations" ".7z" "ZipeloDev.Archive"
184185 WriteRegStr HKCU "${APPKEY}\Capabilities\FileAssociations" ".tar" "ZipeloDev.Archive"
185186 WriteRegStr HKCU "${APPKEY}\Capabilities\FileAssociations" ".gz" "ZipeloDev.Archive"
186187 WriteRegStr HKCU "${APPKEY}\Capabilities\FileAssociations" ".tgz" "ZipeloDev.Archive"
@@ -233,6 +234,7 @@ Section "Uninstall"
233234 DeleteRegValue HKCU "Software\RegisteredApplications" "Zipelo 개발판"
234235 ${EndIf}
235236 DeleteRegValue HKCU "${APPKEY}\Capabilities\FileAssociations" ".zip"
237추가: DeleteRegValue HKCU "${APPKEY}\Capabilities\FileAssociations" ".7z"
236238 DeleteRegValue HKCU "${APPKEY}\Capabilities\FileAssociations" ".tar"
237239 DeleteRegValue HKCU "${APPKEY}\Capabilities\FileAssociations" ".gz"
238240 DeleteRegValue HKCU "${APPKEY}\Capabilities\FileAssociations" ".tgz"
추가tests/release-packages/.gitignore+1-0
@@ -0,0 +1 @@
1추가: runs/
추가tests/release-packages/README.md+15-0
@@ -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 게시와 다운로드 버튼 갱신도 수행하지 않습니다.
추가tests/release-packages/test_ubuntu_lifecycle.py+118-0
@@ -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()
추가tests/release-packages/ubuntu_smoke.py+130-0
@@ -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()
추가tests/release-packages/validation.json+103-0
@@ -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추가: }
수정tests/rust-app-real-worker/flows.rs+40-2
@@ -511,12 +511,50 @@ fn late_cancel_after_child_reap_keeps_the_original_terminal_result() {
511511
512512#[test]
513513fn 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추가: }
514552 let archive = Path::new(env!("CARGO_MANIFEST_DIR"))
515553 .join("../../tests/rust-app-real-worker/fixtures/sample.zip")
516554 .canonicalize()
517555 .unwrap();
518556 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")));
520558 let mut model = Model::default();
521559 assert!(model.begin(
522560 Start::List {
@@ -524,7 +562,7 @@ fn cancel_racing_child_exit_preserves_completed_result_before_poll() {
524562 },
525563 &mut factory
526564 ));
527삭제: std::thread::sleep(Duration::from_millis(2));
565추가: assert!(model.terminal.is_none());
528566 model.cancel();
529567 wait(&mut model);
530568 assert!(model.confirmed, "iteration={iteration}: {:?}", model.error);
수정tests/rust-archive-worker/hardening.rs+6-1
@@ -670,7 +670,12 @@ mod linux {
670670 let s = Scratch::new();
671671 generate(&s, "store", 1024 * 1024);
672672 fs::write(s.0.join("preserve"), b"original").unwrap();
673삭제: let request = start(&s, false, Limits::default().output);
673추가: fs::create_dir(s.0.join("zipelo-source")).unwrap();
674추가: fs::rename(s.0.join("input"), s.0.join("zipelo-source/zipelo-input")).unwrap();
675추가: let mut request = start(&s, false, Limits::default().output);
676추가: if let Action::Extract { archive, .. } = &mut request.action {
677추가: *archive = s.path("zipelo-source/zipelo-input");
678추가: }
674679 let child = spawn(&s, request, Some(mode));
675680 assert_eq!(wait(child.id()).0, 0);
676681 let events = events(&s);
수정tests/rust-archive-worker/io_fault.c+4-1
@@ -63,8 +63,11 @@ int open64(const char *path, int flags, ...) {
6363 va_end(args);
6464 }
6565 const char *fault = getenv("ZIPELO_TEST_FAULT");
66추가: const char *name = strrchr(path, '/');
67추가: name = name ? name + 1 : path;
68추가: int named_temp = (flags & O_CREAT) && !strncmp(name, "zipelo-", 7);
6669 if (fault && !strcmp(fault, "temp-full")
67삭제: && (((flags & O_TMPFILE) == O_TMPFILE) || strstr(path, "/zipelo-"))) {
70추가: && (((flags & O_TMPFILE) == O_TMPFILE) || named_temp)) {
6871 errno = ENOSPC;
6972 return -1;
7073 }