team-ljyzipelo

공개

Ubuntu 패키지와 Windows 설치 파일을 준비함

작성자
호시노 히나타
작성 시각
커밋
a569bc9f828cc06d3404717b7d806b732b12b017
부모
3b9b591
이 시점의 파일 보기

변경된 파일 11개

+245-8
추가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 ] && [ -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+14-0
@@ -0,0 +1,14 @@
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 tests/release-packages/ubuntu_smoke.py tests/release-packages/runs/ubuntu-release/zipelo_0.1.0~dev1_amd64.deb
8추가: ```
9추가:
10추가: Ubuntu 실기 스모크는 이 패키지를 sudo로 설치하고 ZIP, 7z, TAR.GZ의 기본 앱을 확인합니다. 별도 Xvfb 화면에서 공백이 있는 경로의 합성 ZIP을 실제 앱으로 열어 소유 창을 캡처합니다. 종료 후 패키지를 제거하고 기존 MIME 설정을 복원합니다. 설치된 Zipelo나 같은 경로의 기존 파일이 있으면 중단합니다. 시험 중 다른 MIME 설정 변경이 감지되면 덮어쓰지 않고 복원을 보류합니다.
11추가:
12추가: sudo 비대화형 권한, Xvfb, xdotool과 ImageMagick import가 필요합니다. 이 검사는 실제 시스템 패키지를 설치하고 사용자 기본 앱을 임시로 바꾸므로 실행 전에 해당 작업의 승인이 필요합니다. 출력은 runs/에 남고 Git에는 포함하지 않습니다.
13추가:
14추가: Windows 설치와 설정 화면, 제거의 실기 검증은 이 Linux 시험에 포함되지 않습니다. release 게시와 다운로드 버튼 갱신도 수행하지 않습니다.
추가tests/release-packages/ubuntu_smoke.py+99-0
@@ -0,0 +1,99 @@
1추가: """현재 사용자 설정을 보존하고 실제 패키지 설치와 창 실행을 검증함."""
2추가:
3추가: import argparse
4추가: import json
5추가: import os
6추가: from pathlib import Path
7추가: import select
8추가: import subprocess
9추가: import time
10추가: import zipfile
11추가:
12추가: ROOT = Path(__file__).resolve().parents[2]
13추가: MIMES = ("application/zip", "application/x-7z-compressed", "application/x-compressed-tar")
14추가: CONFIGS = (Path.home() / ".config", Path.home() / ".local/share/applications")
15추가:
16추가:
17추가: def configs():
18추가: return {p: p.read_bytes() for directory in CONFIGS for p in directory.glob("*mimeapps.list")}
19추가:
20추가:
21추가: def main():
22추가: parser = argparse.ArgumentParser(description=__doc__)
23추가: parser.add_argument("package", type=Path)
24추가: args = parser.parse_args()
25추가: package = args.package.resolve(strict=True)
26추가: runs = ROOT / "tests/release-packages/runs/smoke"
27추가: runs.mkdir(parents=True, exist_ok=False)
28추가: assert subprocess.run(["dpkg-query", "-W", "-f=${db:Status-Status}", "zipelo"],
29추가: capture_output=True).stdout != b"installed", "기존 설치를 보존해야 함"
30추가: for name in ("/usr/lib/zipelo", "/usr/bin/zipelo", "/usr/share/applications/zipelo.desktop"):
31추가: assert not Path(name).exists(), "기존 파일이 있어 설치를 중단함"
32추가: before = configs()
33추가: after = None
34추가: app = None
35추가: display = None
36추가: installed = False
37추가: try:
38추가: subprocess.run(["sudo", "-n", "dpkg", "-i", str(package)], check=True)
39추가: installed = True
40추가: after = configs()
41추가: for mime in MIMES:
42추가: result = subprocess.check_output(["xdg-mime", "query", "default", mime], text=True).strip()
43추가: assert result == "zipelo.desktop", f"연결 실패: {mime}"
44추가: info = json.loads(Path("/usr/lib/zipelo/BUILD-INFO.json").read_text())
45추가: assert info["profile"] == "release"
46추가: archive = runs / "sample archive.zip"
47추가: with zipfile.ZipFile(archive, "w") as output:
48추가: output.writestr("example.txt", "Zipelo package verification")
49추가: display = subprocess.Popen(
50추가: ["Xvfb", "-displayfd", "1", "-screen", "0", "1280x900x24", "-nolisten", "tcp"],
51추가: stdout=subprocess.PIPE, stderr=subprocess.DEVNULL)
52추가: assert select.select([display.stdout], [], [], 15)[0], "Xvfb 준비 실패"
53추가: number = display.stdout.readline().decode().strip()
54추가: assert number.isdecimal()
55추가: env = {**os.environ, "DISPLAY": ":" + number, "WINIT_UNIX_BACKEND": "x11", "XDG_SESSION_TYPE": "x11"}
56추가: env.pop("WAYLAND_DISPLAY", None)
57추가: with (runs / "app.stdout").open("wb") as stdout, (runs / "app.stderr").open("wb") as stderr:
58추가: app = subprocess.Popen(["/usr/bin/zipelo", str(archive)], env=env, stdout=stdout, stderr=stderr)
59추가: deadline = time.monotonic() + 30
60추가: while True:
61추가: assert app.poll() is None, "설치된 앱이 조기에 종료됨"
62추가: window = subprocess.run(["xdotool", "search", "--all", "--pid", str(app.pid), "--name", "Zipelo"],
63추가: env=env, capture_output=True, text=True)
64추가: if window.returncode == 0:
65추가: break
66추가: assert time.monotonic() < deadline, "앱 창 표시 시간 초과"
67추가: time.sleep(0.2)
68추가: time.sleep(3)
69추가: assert app.poll() is None
70추가: subprocess.run(["import", "-window", window.stdout.splitlines()[0],
71추가: str(runs / "installed-window.png")], env=env, check=True)
72추가: print("PASS installed package, ZIP/7z/TAR.GZ defaults and native X11 window")
73추가: finally:
74추가: for process in (app, display):
75추가: if process is not None and process.poll() is None:
76추가: process.terminate()
77추가: try:
78추가: process.wait(timeout=10)
79추가: except subprocess.TimeoutExpired:
80추가: process.kill()
81추가: process.wait()
82추가: if installed:
83추가: subprocess.run(["sudo", "-n", "dpkg", "-P", "zipelo"], check=True)
84추가: current = configs()
85추가: if after is not None:
86추가: for path in set(before) | set(after):
87추가: assert current.get(path) == after.get(path), "시험 중 다른 MIME 설정 변경이 있어 복원을 보류함"
88추가: if path in before:
89추가: path.write_bytes(before[path])
90추가: elif path.exists():
91추가: path.unlink()
92추가: assert not Path("/usr/bin/zipelo").exists()
93추가: assert not Path("/usr/lib/zipelo").exists()
94추가: assert configs() == before, "기존 MIME 설정 복원 실패"
95추가: print("PASS package removed and previous MIME settings restored")
96추가:
97추가:
98추가: if __name__ == "__main__":
99추가: main()