최신 main의 제거 안내와 검증을 통합한다
- 작성자
- 호시노 히나타
- 작성 시각
- 커밋
8fe41cc7fcd1ee3414d59b52f95c06ec065ce2fa
변경된 파일 14개
+712-23| @@ -74,6 +74,10 @@ cargo +1.99.1 build --locked --manifest-path experiments/rust-ui-memory-app/Carg | ||
| 74 | 74 | - create-error: ZIP 만들기 실패. 디스크 여유 공간 안내를 확인한다. |
| 75 | 75 | - password-create: 암호 ZIP 생성 중 작업자 암호 요청. 암호와 암호 확인 입력 배치를 확인한다. |
| 76 | 76 | - close-confirm: 진행 중 창 닫기 확인. 작업 취소와 유지 선택지를 확인한다. |
| 77 | 추가: - uninstall-windows: Windows 제거 전 다른 기본 앱 선택 안내와 설정 열기 버튼 문구를 확인한다. | |
| 78 | 추가: - uninstall-settings-error: Windows 설정 실행 실패 시 수동 설정 경로를 확인한다. | |
| 79 | 추가: - uninstall-ubuntu-missing: 이전 앱이 없어 복원하지 못한 경우의 터미널 안내 문구를 확인한다. | |
| 80 | 추가: - uninstall-ubuntu-unknown-user: 제거 사용자를 확인하지 못해 설정을 유지하는 안내 문구를 확인한다. | |
| 77 | 81 | |
| 78 | 82 | --ui-scenario에는 이름 하나만 지정한다. 없는 이름, 누락된 이름, 다른 옵션이나 경로와의 혼합은 사용 가능한 목록을 출력하고 실패로 끝난다. --list-ui-scenarios도 단독으로 사용한다. 기존 파일 연결 실행과 --ui-fixture의 인자 해석은 유지한다. |
| 79 | 83 | |
| @@ -136,3 +140,10 @@ Enter만으로 허용하지 않습니다. 기존 작업자로 자동 재시도 | ||
| 136 | 140 | 한도 초과 결과는 별도 운영체제 창 대신 주 창 안의 모달로 표시합니다. Wayland에서도 파일 경로로 실행한 직후 Alt+Tab 없이 결과와 재시도 버튼이 보여야 합니다. "확인"으로 닫으며, 일부 출력이 남은 경우 확대 재시도는 제공하지 않습니다. |
| 137 | 141 | |
| 138 | 142 | 큰 작업을 허용한 뒤 파일 충돌이 발견되면 승인 창을 닫고 충돌 선택 창을 표시합니다. 승인과 충돌 질문은 동시에 표시하지 않으며, 같은 작업의 질문 번호를 이어서 검증합니다. |
| 143 | 추가: ## 설치 프로그램의 제거 안내 | |
| 144 | 추가: | |
| 145 | 추가: Windows NSIS 제거 프로그램은 앱과 별도의 실행 파일입니다. 이번 제거 안내는 Uninstall.exe 실행 후 확인 화면 앞에 표시되며 [기본 앱 설정 열기]로 Windows 설정을 엽니다. --ui-scenario uninstall-windows와 uninstall-settings-error로 안내 문구를 확인합니다. Ubuntu 터미널 안내는 uninstall-ubuntu-missing과 uninstall-ubuntu-unknown-user로 확인합니다. 이 네 상황은 외부 설치 프로그램과 터미널의 문구를 egui에 재현한 읽기 전용 미리보기이며, NSIS의 실제 배치나 운영체제 창 모양을 재현하지 않습니다. 버튼은 설정을 열거나 제거를 실행하지 않습니다. 다른 운영체제에서도 같은 안내를 확인할 수 있습니다. | |
| 146 | 추가: | |
| 147 | 추가: 실제 검증은 전용 Windows VM에서 설치와 기본 앱 지정 후 Uninstall.exe를 실행합니다. 설정에서 ZIP의 다른 기본 앱을 선택하고 제거한 뒤 ZIP을 열어야 합니다. 설정을 열지 않고 제거한 경우의 [연결 프로그램] 경로, 취소 시 앱 유지, /S 무인 제거의 창 생략, 사용자가 바꾼 등록 값 보존도 확인합니다. NSIS 컴파일 시험은 이 운영체제 화면 검증을 대신하지 않습니다. | |
| 148 | 추가: | |
| 149 | 추가: Ubuntu 제거 안내는 패키지 관리자 터미널 출력입니다. 이전 기본 앱이 있는 경우, 삭제된 경우, 기록이 없는 경우, 설치 후 다른 앱으로 바꾼 경우와 다른 사용자의 제거를 구분해 확인합니다. 사용자 홈 전체나 MIME 설정 파일 전체를 초기화하지 않습니다. |
| @@ -112,7 +112,8 @@ fn run() -> eframe::Result { | ||
| 112 | 112 | zipelo_ui_memory_app::archive_screen::scenarios::Preview::new( |
| 113 | 113 | app, |
| 114 | 114 | &cc.egui_ctx, |
| 115 | 삭제: ), | |
| 115 | 추가: ) | |
| 116 | 추가: .with_scenario(scenario), | |
| 116 | 117 | ) as Box<dyn eframe::App>); |
| 117 | 118 | } |
| 118 | 119 | let factory: Box<dyn zipelo_ui_memory_app::archive_ui::Factory> = if fixture { |
| @@ -11,7 +11,11 @@ sudo dpkg -r zipelo | ||
| 11 | 11 | |
| 12 | 12 | Rust 1.99.1, dpkg-deb와 desktop-file-validate가 필요합니다. 출력은 새 경로여야 하며 기본은 release 빌드입니다. 개발 검증은 --profile dev를 명시합니다. 앱과 작업자는 같은 커밋에서 빌드하며 BUILD-INFO.json에 커밋과 SHA-256을 기록합니다. |
| 13 | 13 | |
| 14 | 삭제: sudo로 처음 설치하면 postinst가 SUDO_USER의 ZIP, 7z, TAR.GZ, GZ, TAR 기본 앱을 xdg-mime으로 적용합니다. 최초 설치에서 기존 기본 앱 선택을 바꿉니다. 업그레이드와 재설정에서는 사용자의 기본 앱 선택을 유지합니다. 다른 패키지 관리자로 설치해 SUDO_USER가 없으면 사용자 설정을 추측하지 않고 연결 후보만 등록합니다. 이 경우 사용자 계정에서 xdg-mime default zipelo.desktop application/zip 등을 실행해야 합니다. 제거는 사용자 MIME 설정을 지우지 않으며 다른 앱을 기본 앱으로 다시 선택할 수 있습니다. | |
| 14 | 추가: sudo로 처음 설치하면 postinst가 SUDO_USER의 ZIP, 7z, TAR.GZ, GZ, TAR 기본 앱을 xdg-mime으로 적용합니다. 최초 설치에서 기존 기본 앱 선택을 바꿉니다. 업그레이드와 재설정에서는 사용자의 기본 앱 선택을 유지합니다. 다른 패키지 관리자로 설치해 SUDO_USER가 없으면 사용자 설정을 추측하지 않고 연결 후보만 등록합니다. 이 경우 사용자 계정에서 xdg-mime default zipelo.desktop application/zip 등을 실행해야 합니다. 최초 적용 전에 이전 기본 앱 ID를 해당 사용자의 ~/.local/state/zipelo-default-apps-v1에 기록합니다. 같은 사용자가 sudo로 제거하면 prerm이 현재 선택이 여전히 Zipelo인지 확인하고, 이전 데스크톱 파일이 존재하며 숨김 상태가 아닐 때만 이전 앱으로 복원합니다. 설치 후 선택한 다른 앱과 다른 사용자의 설정은 건드리지 않습니다. | |
| 15 | 추가: | |
| 16 | 추가: 이전 버전에서 설치해 기록이 없거나 이전 앱이 삭제된 경우에는 자동 복원하지 않습니다. 그래픽 패키지 관리자처럼 SUDO_USER를 제공하지 않는 제거도 사용자를 추측하지 않습니다. 사용자 지정 XDG 설정 경로와 하위 디렉터리 데스크톱 ID는 자동 복원 대상으로 보장하지 않습니다. 제거 전에 ZIP 파일을 오른쪽 클릭하고 [다른 프로그램으로 열기]에서 사용할 앱을 선택하세요. 다른 앱이 없다면 먼저 설치하세요. 제거 명령도 이 안내를 출력합니다. 사용자 MIME 설정 파일 전체를 지우거나 다른 사용자 홈을 순회하지 않습니다. | |
| 17 | 추가: | |
| 18 | 추가: 제거된 desktop 파일을 가리키는 선택은 [freedesktop 기본 앱 규격](https://specifications.freedesktop.org/mime-apps/1.0/default.html)에 따라 다음 유효한 후보로 넘어갑니다. 기존 기록이 없을 때 임의의 앱을 새 기본값으로 강제하지 않습니다. 자동 복원은 이전 기본 앱 ID 한 개를 대상으로 하며 MIME 설정 파일 전체의 과거 내용을 되돌리지 않습니다. | |
| 15 | 19 | |
| 16 | 20 | 이 패키지의 검사 범위는 Ubuntu 26.04입니다. 다른 Ubuntu 버전과 Windows 실기는 별도 확인이 필요합니다. |
| 17 | 21 | |
| @@ -23,3 +27,5 @@ sudo로 처음 설치하면 postinst가 SUDO_USER의 ZIP, 7z, TAR.GZ, GZ, TAR | ||
| 23 | 27 | 로컬 crate에 원문이 없으면 packaging/license-supplements.json의 해당 버전 공식 upstream 원문을 사용합니다. 보충 파일에는 고정 출처 URL, crate 버전과 VCS 커밋, Cargo SPDX 식, UTF-8 원문과 SHA-256이 들어 있습니다. 생성기는 SPDX와 게시된 crate 커밋 및 원문 해시를 오프라인으로 검증합니다. 승인된 표준 보충도 없는 항목은 링크 설명만으로 대체하지 않고 계속 빌드를 차단합니다. |
| 24 | 28 | |
| 25 | 29 | upstream에도 원문이 없는 승인된 12개 항목은 SPDX의 MIT 표준 원문과 해당 버전 Cargo.toml의 저자 고지로 보충합니다. 고지에 표준 원문 보충 사유, 선택한 라이선스, 원문과 저자 고지의 출처 및 SHA-256을 표시합니다. Cargo 메타데이터의 전체 라이선스 식은 그대로 보존합니다. |
| 30 | 추가: | |
| 31 | 추가: 제거 회귀 시험은 python3 -m unittest discover -s tests/ci -p test_default_apps.py와 python3 -m unittest discover -s tests/release-packages -p test_ubuntu_lifecycle.py로 실행합니다. 실제 패키지 검증은 python3 tests/release-packages/uninstall_defaults_smoke.py <deb 경로>입니다. 기존 Zipelo 설치가 있으면 중단하며, 호스트 기본 앱은 바꾸지 않고 별도 설정 공간에서 이전 앱 복원과 xdg-open을 통한 unzip 실행을 확인합니다. 그래픽 데스크톱 창 조작이나 실제 SUDO_USER 홈의 복원까지 검증하는 명령은 아닙니다. |
| @@ -21,6 +21,8 @@ def build(args): | ||
| 21 | 21 | stage = output / "stage" |
| 22 | 22 | lib = stage / "usr/lib/zipelo" |
| 23 | 23 | lib.mkdir(parents=True) |
| 24 | 추가: shutil.copyfile(Path(__file__).with_name("default-apps"), lib / "default-apps") | |
| 25 | 추가: (lib / "default-apps").chmod(0o755) | |
| 24 | 26 | records = {} |
| 25 | 27 | docs = stage / "usr/share/doc/zipelo" |
| 26 | 28 | docs.mkdir(parents=True) |
| @@ -60,7 +62,7 @@ Depends: libc6 (>= 2.39), libgcc-s1, libx11-6, libxkbcommon0, libxkbcommon-x11-0 | ||
| 60 | 62 | Description: Lightweight Rust archive application |
| 61 | 63 | ZIP, 7z, TAR, GZ and TAR.GZ archive application with a separate worker. |
| 62 | 64 | """) |
| 63 | 삭제: for script in ("postinst", "postrm"): | |
| 65 | 추가: for script in ("postinst", "prerm", "postrm"): | |
| 64 | 66 | shutil.copyfile(Path(__file__).with_name(script), control / script) |
| 65 | 67 | (control / script).chmod(0o755) |
| 66 | 68 | package = output / "zipelo_0.1.0_amd64.deb" |
| @@ -0,0 +1,131 @@ | ||
| 1 | 추가: #!/bin/sh | |
| 2 | 추가: # 로그인 사용자 권한으로만 이전 선택을 기록하고 조건부 복원함. | |
| 3 | 추가: set -eu | |
| 4 | 추가: case "${1:-}" in | |
| 5 | 추가: install|remove) action=$1 ;; | |
| 6 | 추가: *) exit 2 ;; | |
| 7 | 추가: esac | |
| 8 | 추가: if [ "$(id -u)" -eq 0 ]; then | |
| 9 | 추가: echo "기본 앱 처리는 일반 사용자 계정에서 실행해야 합니다." >&2 | |
| 10 | 추가: exit 1 | |
| 11 | 추가: fi | |
| 12 | 추가: state="${XDG_STATE_HOME:-$HOME/.local/state}/zipelo-default-apps-v1" | |
| 13 | 추가: case "$state" in /*) ;; *) exit 1 ;; esac | |
| 14 | 추가: umask 077 | |
| 15 | 추가: if [ "$action" = install ] && [ ! -e "$state" ] && [ ! -L "$state" ]; then | |
| 16 | 추가: mkdir -p "$(dirname "$state")" | |
| 17 | 추가: mkdir "$state" | |
| 18 | 추가: fi | |
| 19 | 추가: if [ -L "$state" ] || [ ! -d "$state" ] || [ ! -O "$state" ]; then | |
| 20 | 추가: echo "이전 기본 앱 기록이 없습니다. 파일을 오른쪽 클릭해 [다른 프로그램으로 열기]에서 앱을 선택하세요." >&2 | |
| 21 | 추가: exit 0 | |
| 22 | 추가: fi | |
| 23 | 추가: | |
| 24 | 추가: # 주 그룹의 키만 읽고 값의 이스케이프를 해석함. 파일 내용을 실행하지 않음. | |
| 25 | 추가: desktop_value() { | |
| 26 | 추가: awk -v key="$2" ' | |
| 27 | 추가: /^\[/ { entry = ($0 == "[Desktop Entry]"); next } | |
| 28 | 추가: entry && /^[^#=]+=/ { | |
| 29 | 추가: name = substr($0, 1, index($0, "=") - 1) | |
| 30 | 추가: gsub(/^[ \t]+|[ \t]+$/, "", name) | |
| 31 | 추가: if (name != key) next | |
| 32 | 추가: value = substr($0, index($0, "=") + 1) | |
| 33 | 추가: gsub(/^[ \t]+|[ \t]+$/, "", value) | |
| 34 | 추가: result = "" | |
| 35 | 추가: for (i = 1; i <= length(value); i++) { | |
| 36 | 추가: c = substr(value, i, 1) | |
| 37 | 추가: if (c == "\\") { | |
| 38 | 추가: c = substr(value, ++i, 1) | |
| 39 | 추가: if (c == "s") c = " " | |
| 40 | 추가: else if (c == "n") c = "\n" | |
| 41 | 추가: else if (c == "t") c = "\t" | |
| 42 | 추가: else if (c == "r") c = "\r" | |
| 43 | 추가: else if (c != "\\") exit 1 | |
| 44 | 추가: } | |
| 45 | 추가: result = result c | |
| 46 | 추가: } | |
| 47 | 추가: print result | |
| 48 | 추가: exit | |
| 49 | 추가: } | |
| 50 | 추가: ' "$1" | |
| 51 | 추가: } | |
| 52 | 추가: | |
| 53 | 추가: executable_available() ( | |
| 54 | 추가: case "$1" in | |
| 55 | 추가: /*) [ -f "$1" ] && [ -x "$1" ]; exit $? ;; | |
| 56 | 추가: esac | |
| 57 | 추가: # 내장 명령이나 셸 구문이 아닌 PATH 안의 실행 파일만 검사함. | |
| 58 | 추가: search_path=${PATH:-} | |
| 59 | 추가: while :; do | |
| 60 | 추가: directory=${search_path%%:*} | |
| 61 | 추가: if [ -f "${directory:-.}/$1" ] && [ -x "${directory:-.}/$1" ]; then | |
| 62 | 추가: exit 0 | |
| 63 | 추가: fi | |
| 64 | 추가: case "$search_path" in | |
| 65 | 추가: *:*) search_path=${search_path#*:} ;; | |
| 66 | 추가: *) exit 1 ;; | |
| 67 | 추가: esac | |
| 68 | 추가: done | |
| 69 | 추가: ) | |
| 70 | 추가: | |
| 71 | 추가: available() { | |
| 72 | 추가: case "$1" in | |
| 73 | 추가: ""|zipelo.desktop|*/*|*\\*|*";"*|*"="*) return 1 ;; | |
| 74 | 추가: *.desktop) ;; | |
| 75 | 추가: *) return 1 ;; | |
| 76 | 추가: esac | |
| 77 | 추가: # 기본 데스크톱 파일만 복원하며 모호한 ID는 수동 선택으로 남김. | |
| 78 | 추가: old_ifs=$IFS | |
| 79 | 추가: IFS=: | |
| 80 | 추가: for directory in "${XDG_DATA_HOME:-$HOME/.local/share}" ${XDG_DATA_DIRS:-/usr/local/share:/usr/share}; do | |
| 81 | 추가: if [ -f "$directory/applications/$1" ]; then | |
| 82 | 추가: IFS=$old_ifs | |
| 83 | 추가: desktop="$directory/applications/$1" | |
| 84 | 추가: hidden=$(desktop_value "$desktop" Hidden) || return 1 | |
| 85 | 추가: [ "$hidden" != true ] || return 1 | |
| 86 | 추가: try_exec=$(desktop_value "$desktop" TryExec) || return 1 | |
| 87 | 추가: if [ -n "$try_exec" ]; then | |
| 88 | 추가: executable_available "$try_exec" || return 1 | |
| 89 | 추가: fi | |
| 90 | 추가: return 0 | |
| 91 | 추가: fi | |
| 92 | 추가: done | |
| 93 | 추가: IFS=$old_ifs | |
| 94 | 추가: return 1 | |
| 95 | 추가: } | |
| 96 | 추가: | |
| 97 | 추가: for item in zip:application/zip seven:application/x-7z-compressed targz:application/x-compressed-tar gzip:application/gzip tar:application/x-tar; do | |
| 98 | 추가: key=${item%%:*} | |
| 99 | 추가: mime=${item#*:} | |
| 100 | 추가: record="$state/$key" | |
| 101 | 추가: if [ -L "$record" ]; then | |
| 102 | 추가: continue | |
| 103 | 추가: fi | |
| 104 | 추가: current=$(xdg-mime query default "$mime") || continue | |
| 105 | 추가: if [ "$action" = install ]; then | |
| 106 | 추가: # 미완료 기록이나 재설치의 기존 기록을 덮어쓰지 않음. | |
| 107 | 추가: if [ -e "$record" ]; then | |
| 108 | 추가: continue | |
| 109 | 추가: fi | |
| 110 | 추가: (set -C; printf '%s\n' "$current" > "$record") || continue | |
| 111 | 추가: xdg-mime default zipelo.desktop "$mime" || echo "기본 앱 적용 실패: $mime" >&2 | |
| 112 | 추가: elif [ -f "$record" ] && [ -O "$record" ]; then | |
| 113 | 추가: previous=$(cat "$record") | |
| 114 | 추가: if [ "$current" = zipelo.desktop ]; then | |
| 115 | 추가: if available "$previous"; then | |
| 116 | 추가: if ! xdg-mime default "$previous" "$mime"; then | |
| 117 | 추가: echo "기본 앱 복원 실패: $mime" >&2 | |
| 118 | 추가: continue | |
| 119 | 추가: fi | |
| 120 | 추가: else | |
| 121 | 추가: echo "이전 앱을 복원할 수 없습니다: $mime. 파일을 오른쪽 클릭해 [다른 프로그램으로 열기]에서 앱을 선택하세요." >&2 | |
| 122 | 추가: # 이전 앱이 없던 빈 기록은 재시도 대상이 아님. | |
| 123 | 추가: [ -n "$previous" ] && continue | |
| 124 | 추가: fi | |
| 125 | 추가: fi | |
| 126 | 추가: rm -- "$record" | |
| 127 | 추가: fi | |
| 128 | 추가: done | |
| 129 | 추가: if [ "$action" = remove ]; then | |
| 130 | 추가: rmdir "$state" 2>/dev/null || : | |
| 131 | 추가: fi |
| @@ -11,8 +11,10 @@ if [ "$1" = configure ] && [ -z "${2:-}" ] && [ -n "${SUDO_USER:-}" ] && [ "$SUD | ||
| 11 | 11 | uid=$(printf '%s' "$account" | cut -d: -f3) |
| 12 | 12 | home_dir=$(printf '%s' "$account" | cut -d: -f6) |
| 13 | 13 | if [ -n "$uid" ] && [ "$uid" -ge 1000 ] && [ -d "$home_dir" ]; then |
| 14 | 삭제: for mime in application/zip application/x-7z-compressed application/x-compressed-tar application/gzip application/x-tar; do | |
| 15 | 삭제: runuser -u "$SUDO_USER" -- env HOME="$home_dir" xdg-mime default zipelo.desktop "$mime" | |
| 16 | 삭제: done | |
| 14 | 추가: runuser -u "$SUDO_USER" -- env HOME="$home_dir" \ | |
| 15 | 추가: XDG_CONFIG_HOME="$home_dir/.config" XDG_DATA_HOME="$home_dir/.local/share" \ | |
| 16 | 추가: XDG_STATE_HOME="$home_dir/.local/state" XDG_DATA_DIRS="/usr/local/share:/usr/share" \ | |
| 17 | 추가: /usr/lib/zipelo/default-apps install || \ | |
| 18 | 추가: echo "기본 앱 기록 또는 적용에 실패했습니다. 파일의 [다른 프로그램으로 열기]에서 직접 선택하세요." >&2 | |
| 17 | 19 | fi |
| 18 | 20 | fi |
| @@ -0,0 +1,21 @@ | ||
| 1 | 추가: #!/bin/sh | |
| 2 | 추가: set -eu | |
| 3 | 추가: # 업그레이드에서는 사용자 선택과 최초 설치 기록을 유지함. | |
| 4 | 추가: if [ "$1" != remove ]; then | |
| 5 | 추가: exit 0 | |
| 6 | 추가: fi | |
| 7 | 추가: echo "Zipelo를 제거합니다. 파일이 열리지 않으면 파일을 오른쪽 클릭하고 [다른 프로그램으로 열기]에서 다른 앱을 선택하세요." | |
| 8 | 추가: if [ -n "${SUDO_USER:-}" ] && [ "$SUDO_USER" != root ]; then | |
| 9 | 추가: account=$(getent passwd "$SUDO_USER") || exit 0 | |
| 10 | 추가: uid=$(printf '%s' "$account" | cut -d: -f3) | |
| 11 | 추가: home_dir=$(printf '%s' "$account" | cut -d: -f6) | |
| 12 | 추가: if [ -n "$uid" ] && [ "$uid" -ge 1000 ] && [ -d "$home_dir" ]; then | |
| 13 | 추가: runuser -u "$SUDO_USER" -- env HOME="$home_dir" \ | |
| 14 | 추가: XDG_CONFIG_HOME="$home_dir/.config" XDG_DATA_HOME="$home_dir/.local/share" \ | |
| 15 | 추가: XDG_STATE_HOME="$home_dir/.local/state" XDG_DATA_DIRS="/usr/local/share:/usr/share" \ | |
| 16 | 추가: /usr/lib/zipelo/default-apps remove || \ | |
| 17 | 추가: echo "기본 앱 복원이 끝나지 않았습니다. 다른 앱을 직접 선택하세요." >&2 | |
| 18 | 추가: fi | |
| 19 | 추가: else | |
| 20 | 추가: echo "제거를 요청한 사용자를 확인할 수 없어 사용자 기본 앱 설정은 변경하지 않습니다." | |
| 21 | 추가: fi |
| @@ -31,7 +31,9 @@ Zipelo.exe, zipelo-archive-worker.exe, MIT LICENSE, BUILD-INFO.json과 제거 | ||
| 31 | 31 | .tar.gz는 마지막 확장자 .gz로 연결됩니다. 기본 앱은 사용자가 Windows 설정에서 직접 선택합니다. |
| 32 | 32 | 7z도 연결 후보에 포함하며 JAR와 RAR는 등록하지 않습니다. [마침]만 누르면 연결 후보를 등록하지 않습니다. |
| 33 | 33 | 관리자 권한, HKLM, UserChoice 변경을 사용하지 않습니다. |
| 34 | 삭제: 제거 시 알려진 앱 파일과 등록 값만 정리하며 폴더 전체를 재귀 삭제하지 않습니다. | |
| 34 | 추가: 제거 시작 화면의 [기본 앱 설정 열기]에서 .zip, .7z, .tar, .gz, .tgz를 검색해 다른 앱을 선택할 수 있습니다. 제거 후 파일이 열리지 않으면 오른쪽 클릭 > 연결 프로그램에서도 다른 앱을 선택할 수 있습니다. 다른 앱이 없으면 먼저 설치하세요. 무인 제거(/S)는 안내 창을 표시하지 않으므로 제거 전에 기본 앱을 바꾸세요. | |
| 35 | 추가: | |
| 36 | 추가: 제거 시 알려진 앱 파일만 정리하며 폴더 전체를 재귀 삭제하지 않습니다. 연결 등록 값은 설치 시 쓴 값과 현재 값이 같은 항목만 지우고, 다른 값이나 비어 있지 않은 키는 유지합니다. UserChoice는 읽거나 쓰지 않으며 운영체제의 보호된 사용자 선택을 강제로 삭제하지 않습니다. | |
| 35 | 37 | 실행 파일 삭제 실패 시 등록과 제거 프로그램을 보존하여 재시도할 수 있습니다. |
| 36 | 38 | |
| 37 | 39 | 현재 main의 실제 작업자 연결 앱을 포함합니다. Windows에서의 설치/제거와 설정 실행, |
| @@ -20,6 +20,7 @@ ShowInstDetails show | ||
| 20 | 20 | !insertmacro MUI_PAGE_WELCOME |
| 21 | 21 | !insertmacro MUI_PAGE_INSTFILES |
| 22 | 22 | Page custom FinishCreate |
| 23 | 추가: UninstPage custom un.AssociationsCreate | |
| 23 | 24 | !insertmacro MUI_UNPAGE_CONFIRM |
| 24 | 25 | !insertmacro MUI_UNPAGE_INSTFILES |
| 25 | 26 | !insertmacro MUI_LANGUAGE "Korean" |
| @@ -383,6 +384,39 @@ settings_failed: | ||
| 383 | 384 | MessageBox MB_OK "Windows 설정을 열지 못했습니다. 설정에서 앱 > 기본 앱을 직접 열어주세요." |
| 384 | 385 | FunctionEnd |
| 385 | 386 | |
| 387 | 추가: ; 현재 값이 설치 시 기록한 값과 같은 경우에만 지움. | |
| 388 | 추가: !macro RemoveOwnedValue KEY NAME EXPECTED | |
| 389 | 추가: ReadRegStr $0 HKCU "${KEY}" "${NAME}" | |
| 390 | 추가: ${If} $0 S== "${EXPECTED}" | |
| 391 | 추가: DeleteRegValue HKCU "${KEY}" "${NAME}" | |
| 392 | 추가: ${EndIf} | |
| 393 | 추가: !macroend | |
| 394 | 추가: | |
| 395 | 추가: Function un.AssociationsCreate | |
| 396 | 추가: nsDialogs::Create 1018 | |
| 397 | 추가: Pop $Dialog | |
| 398 | 추가: ${If} $Dialog == error | |
| 399 | 추가: Abort | |
| 400 | 추가: ${EndIf} | |
| 401 | 추가: ${NSD_CreateLabel} 0 0 100% 62u "Zipelo를 기본 앱으로 사용했다면 제거 전에 다른 앱을 선택하세요. [기본 앱 설정 열기]에서 .zip, .7z, .tar, .gz, .tgz를 검색해 사용할 앱을 고를 수 있습니다. 다른 앱이 없으면 먼저 설치하세요." | |
| 402 | 추가: Pop $0 | |
| 403 | 추가: ${NSD_CreateLabel} 0 66u 100% 38u "직접 고른 기본 앱은 자동으로 바꾸지 않습니다. 제거 후 파일이 열리지 않으면 파일을 오른쪽 클릭하고 [연결 프로그램]에서 다른 앱을 선택하세요." | |
| 404 | 추가: Pop $0 | |
| 405 | 추가: ${NSD_CreateButton} 0 112u 100% 24u "기본 앱 설정 열기" | |
| 406 | 추가: Pop $ApplyButton | |
| 407 | 추가: ${NSD_OnClick} $ApplyButton un.OpenDefaultApps | |
| 408 | 추가: nsDialogs::Show | |
| 409 | 추가: FunctionEnd | |
| 410 | 추가: | |
| 411 | 추가: Function un.OpenDefaultApps | |
| 412 | 추가: Pop $0 | |
| 413 | 추가: ClearErrors | |
| 414 | 추가: ExecShell "open" "ms-settings:defaultapps" | |
| 415 | 추가: ${If} ${Errors} | |
| 416 | 추가: MessageBox MB_OK "Windows 설정을 열지 못했습니다. 설정 > 앱 > 기본 앱에서 확장자를 검색해 다른 앱을 선택하세요." | |
| 417 | 추가: ${EndIf} | |
| 418 | 추가: FunctionEnd | |
| 419 | 추가: | |
| 386 | 420 | Function un.onInit |
| 387 | 421 | SetShellVarContext current |
| 388 | 422 | SetRegView 64 |
| @@ -419,20 +453,20 @@ Section "Uninstall" | ||
| 419 | 453 | ${If} $0 == "${APPKEY}\Capabilities" |
| 420 | 454 | DeleteRegValue HKCU "Software\RegisteredApplications" "Zipelo" |
| 421 | 455 | ${EndIf} |
| 422 | 삭제: DeleteRegValue HKCU "${APPKEY}\Capabilities\FileAssociations" ".zip" | |
| 423 | 삭제: DeleteRegValue HKCU "${APPKEY}\Capabilities\FileAssociations" ".7z" | |
| 424 | 삭제: DeleteRegValue HKCU "${APPKEY}\Capabilities\FileAssociations" ".tar" | |
| 425 | 삭제: DeleteRegValue HKCU "${APPKEY}\Capabilities\FileAssociations" ".gz" | |
| 426 | 삭제: DeleteRegValue HKCU "${APPKEY}\Capabilities\FileAssociations" ".tgz" | |
| 427 | 삭제: DeleteRegValue HKCU "${APPKEY}\Capabilities" "ApplicationName" | |
| 428 | 삭제: DeleteRegValue HKCU "${APPKEY}\Capabilities" "ApplicationDescription" | |
| 456 | 추가: !insertmacro RemoveOwnedValue "${APPKEY}\Capabilities\FileAssociations" ".zip" "Zipelo.Archive" | |
| 457 | 추가: !insertmacro RemoveOwnedValue "${APPKEY}\Capabilities\FileAssociations" ".7z" "Zipelo.Archive" | |
| 458 | 추가: !insertmacro RemoveOwnedValue "${APPKEY}\Capabilities\FileAssociations" ".tar" "Zipelo.Archive" | |
| 459 | 추가: !insertmacro RemoveOwnedValue "${APPKEY}\Capabilities\FileAssociations" ".gz" "Zipelo.Archive" | |
| 460 | 추가: !insertmacro RemoveOwnedValue "${APPKEY}\Capabilities\FileAssociations" ".tgz" "Zipelo.Archive" | |
| 461 | 추가: !insertmacro RemoveOwnedValue "${APPKEY}\Capabilities" "ApplicationName" "Zipelo" | |
| 462 | 추가: !insertmacro RemoveOwnedValue "${APPKEY}\Capabilities" "ApplicationDescription" "압축파일 열기와 풀기" | |
| 429 | 463 | DeleteRegKey /ifempty HKCU "${APPKEY}\Capabilities\FileAssociations" |
| 430 | 464 | DeleteRegKey /ifempty HKCU "${APPKEY}\Capabilities" |
| 431 | 465 | DeleteRegKey /ifempty HKCU "${APPKEY}" |
| 432 | 삭제: DeleteRegValue HKCU "${PROGKEY}\shell\open\command" "" | |
| 433 | 삭제: DeleteRegValue HKCU "${PROGKEY}\DefaultIcon" "" | |
| 466 | 추가: !insertmacro RemoveOwnedValue "${PROGKEY}\shell\open\command" "" '$\"$INSTDIR\Zipelo.exe$\" $\"%1$\"' | |
| 467 | 추가: !insertmacro RemoveOwnedValue "${PROGKEY}\DefaultIcon" "" '$\"$INSTDIR\Zipelo.exe$\",0' | |
| 434 | 468 | DeleteRegKey /ifempty HKCU "${PROGKEY}\DefaultIcon" |
| 435 | 삭제: DeleteRegValue HKCU "${PROGKEY}" "" | |
| 469 | 추가: !insertmacro RemoveOwnedValue "${PROGKEY}" "" "Zipelo 압축파일" | |
| 436 | 470 | DeleteRegKey /ifempty HKCU "${PROGKEY}\shell\open\command" |
| 437 | 471 | DeleteRegKey /ifempty HKCU "${PROGKEY}\shell\open" |
| 438 | 472 | DeleteRegKey /ifempty HKCU "${PROGKEY}\shell" |
| @@ -0,0 +1,236 @@ | ||
| 1 | 추가: """제거 시 기존 기본 앱과 사용자의 새 선택 보존을 검증함.""" | |
| 2 | 추가: | |
| 3 | 추가: import json | |
| 4 | 추가: import os | |
| 5 | 추가: from pathlib import Path | |
| 6 | 추가: import subprocess | |
| 7 | 추가: import tempfile | |
| 8 | 추가: import unittest | |
| 9 | 추가: | |
| 10 | 추가: ROOT = Path(__file__).resolve().parents[2] | |
| 11 | 추가: HELPER = ROOT / "packaging/ubuntu/rust/default-apps" | |
| 12 | 추가: | |
| 13 | 추가: | |
| 14 | 추가: class DefaultAppsTests(unittest.TestCase): | |
| 15 | 추가: def setUp(self): | |
| 16 | 추가: work = ROOT / "tests/work" | |
| 17 | 추가: work.mkdir(exist_ok=True) | |
| 18 | 추가: self.temporary = tempfile.TemporaryDirectory(dir=work) | |
| 19 | 추가: self.addCleanup(self.temporary.cleanup) | |
| 20 | 추가: self.root = Path(self.temporary.name) | |
| 21 | 추가: self.bin = self.root / "bin" | |
| 22 | 추가: self.bin.mkdir() | |
| 23 | 추가: self.data = self.root / "data/applications" | |
| 24 | 추가: self.data.mkdir(parents=True) | |
| 25 | 추가: for name in ("before.desktop", "changed.desktop"): | |
| 26 | 추가: (self.data / name).write_text("[Desktop Entry]\nType=Application\nName=Archive\nExec=true %f\n") | |
| 27 | 추가: self.db = self.root / "choices.json" | |
| 28 | 추가: self.db.write_text(json.dumps({"application/zip": "before.desktop"})) | |
| 29 | 추가: executable = self.bin / "xdg-mime" | |
| 30 | 추가: executable.write_text("""#!/usr/bin/python3 | |
| 31 | 추가: import json, os, sys | |
| 32 | 추가: from pathlib import Path | |
| 33 | 추가: p = Path(os.environ["CHOICES"]) | |
| 34 | 추가: d = json.loads(p.read_text()) | |
| 35 | 추가: if sys.argv[1] == "query": | |
| 36 | 추가: print(d.get(sys.argv[3], "")) | |
| 37 | 추가: elif sys.argv[1] == "default": | |
| 38 | 추가: if os.environ.get("FAIL_RESTORE") and sys.argv[2] != "zipelo.desktop": | |
| 39 | 추가: sys.exit(1) | |
| 40 | 추가: d[sys.argv[3]] = sys.argv[2] | |
| 41 | 추가: p.write_text(json.dumps(d)) | |
| 42 | 추가: """) | |
| 43 | 추가: executable.chmod(0o755) | |
| 44 | 추가: self.env = dict(os.environ, HOME=str(self.root), | |
| 45 | 추가: XDG_STATE_HOME=str(self.root / "state"), | |
| 46 | 추가: XDG_DATA_HOME=str(self.root / "data"), | |
| 47 | 추가: XDG_DATA_DIRS=str(self.root / "empty"), | |
| 48 | 추가: CHOICES=str(self.db), PATH=str(self.bin) + ":" + os.environ["PATH"]) | |
| 49 | 추가: self.state = self.root / "state/zipelo-default-apps-v1" | |
| 50 | 추가: | |
| 51 | 추가: def run_helper(self, action): | |
| 52 | 추가: return subprocess.run(["sh", str(HELPER), action], env=self.env, check=True, | |
| 53 | 추가: capture_output=True, text=True) | |
| 54 | 추가: | |
| 55 | 추가: def choice(self): | |
| 56 | 추가: return json.loads(self.db.read_text())["application/zip"] | |
| 57 | 추가: | |
| 58 | 추가: def test_previous_app_is_restored(self): | |
| 59 | 추가: self.run_helper("install") | |
| 60 | 추가: self.assertEqual(self.choice(), "zipelo.desktop") | |
| 61 | 추가: self.run_helper("remove") | |
| 62 | 추가: self.assertEqual(self.choice(), "before.desktop") | |
| 63 | 추가: self.assertFalse(self.state.exists()) | |
| 64 | 추가: | |
| 65 | 추가: def test_nodisplay_previous_app_is_restored(self): | |
| 66 | 추가: with (self.data / "before.desktop").open("a") as desktop: | |
| 67 | 추가: desktop.write("NoDisplay=true\n") | |
| 68 | 추가: self.run_helper("install") | |
| 69 | 추가: self.run_helper("remove") | |
| 70 | 추가: self.assertEqual(self.choice(), "before.desktop") | |
| 71 | 추가: self.assertFalse(self.state.exists()) | |
| 72 | 추가: | |
| 73 | 추가: def test_nodisplay_failed_restore_keeps_record_for_retry(self): | |
| 74 | 추가: with (self.data / "before.desktop").open("a") as desktop: | |
| 75 | 추가: desktop.write("NoDisplay=true\n") | |
| 76 | 추가: self.run_helper("install") | |
| 77 | 추가: self.env["FAIL_RESTORE"] = "1" | |
| 78 | 추가: self.run_helper("remove") | |
| 79 | 추가: self.assertEqual((self.state / "zip").read_text(), "before.desktop\n") | |
| 80 | 추가: self.assertEqual(self.choice(), "zipelo.desktop") | |
| 81 | 추가: del self.env["FAIL_RESTORE"] | |
| 82 | 추가: self.run_helper("remove") | |
| 83 | 추가: self.assertEqual(self.choice(), "before.desktop") | |
| 84 | 추가: self.assertFalse(self.state.exists()) | |
| 85 | 추가: | |
| 86 | 추가: def test_nodisplay_restore_with_real_xdg_mime(self): | |
| 87 | 추가: (self.bin / "xdg-mime").unlink() | |
| 88 | 추가: (self.data / "before.desktop").write_text( | |
| 89 | 추가: "[Desktop Entry]\nType=Application\nName=Archive\n" | |
| 90 | 추가: "Exec=/usr/bin/true %f\nNoDisplay=true\nMimeType=application/zip;\n" | |
| 91 | 추가: ) | |
| 92 | 추가: (self.data / "zipelo.desktop").write_text( | |
| 93 | 추가: "[Desktop Entry]\nType=Application\nName=Zipelo\n" | |
| 94 | 추가: "Exec=/usr/bin/true %f\nMimeType=application/zip;\n" | |
| 95 | 추가: ) | |
| 96 | 추가: (self.root / "config").mkdir() | |
| 97 | 추가: self.env.update( | |
| 98 | 추가: XDG_CONFIG_HOME=str(self.root / "config"), | |
| 99 | 추가: XDG_CONFIG_DIRS=str(self.root / "system-config"), | |
| 100 | 추가: XDG_CURRENT_DESKTOP="X-Generic", | |
| 101 | 추가: DE="generic", | |
| 102 | 추가: ) | |
| 103 | 추가: for key in ("DISPLAY", "WAYLAND_DISPLAY", "DBUS_SESSION_BUS_ADDRESS"): | |
| 104 | 추가: self.env.pop(key, None) | |
| 105 | 추가: subprocess.run( | |
| 106 | 추가: ["xdg-mime", "default", "before.desktop", "application/zip"], | |
| 107 | 추가: env=self.env, check=True, | |
| 108 | 추가: ) | |
| 109 | 추가: | |
| 110 | 추가: def selected(): | |
| 111 | 추가: return subprocess.check_output( | |
| 112 | 추가: ["xdg-mime", "query", "default", "application/zip"], | |
| 113 | 추가: env=self.env, text=True, | |
| 114 | 추가: ).strip() | |
| 115 | 추가: | |
| 116 | 추가: self.assertEqual(selected(), "before.desktop") | |
| 117 | 추가: self.run_helper("install") | |
| 118 | 추가: self.assertEqual(selected(), "zipelo.desktop") | |
| 119 | 추가: self.run_helper("remove") | |
| 120 | 추가: self.assertEqual(selected(), "before.desktop") | |
| 121 | 추가: self.assertFalse(self.state.exists()) | |
| 122 | 추가: | |
| 123 | 추가: def test_changed_choice_is_preserved(self): | |
| 124 | 추가: self.run_helper("install") | |
| 125 | 추가: self.db.write_text(json.dumps({"application/zip": "changed.desktop"})) | |
| 126 | 추가: self.run_helper("remove") | |
| 127 | 추가: self.assertEqual(self.choice(), "changed.desktop") | |
| 128 | 추가: | |
| 129 | 추가: def test_missing_previous_app_has_guidance(self): | |
| 130 | 추가: self.run_helper("install") | |
| 131 | 추가: (self.data / "before.desktop").unlink() | |
| 132 | 추가: result = self.run_helper("remove") | |
| 133 | 추가: self.assertEqual(self.choice(), "zipelo.desktop") | |
| 134 | 추가: self.assertIn("다른 프로그램으로 열기", result.stderr) | |
| 135 | 추가: self.assertEqual((self.state / "zip").read_text(), "before.desktop\n") | |
| 136 | 추가: | |
| 137 | 추가: def assert_unavailable_keeps_record(self): | |
| 138 | 추가: result = self.run_helper("remove") | |
| 139 | 추가: self.assertEqual(self.choice(), "zipelo.desktop") | |
| 140 | 추가: self.assertEqual((self.state / "zip").read_text(), "before.desktop\n") | |
| 141 | 추가: self.assertIn("다른 프로그램으로 열기", result.stderr) | |
| 142 | 추가: | |
| 143 | 추가: def test_hidden_with_whitespace_keeps_record(self): | |
| 144 | 추가: self.run_helper("install") | |
| 145 | 추가: with (self.data / "before.desktop").open("a") as desktop: | |
| 146 | 추가: desktop.write("Hidden = true\n") | |
| 147 | 추가: self.assert_unavailable_keeps_record() | |
| 148 | 추가: | |
| 149 | 추가: def test_deleted_tryexec_keeps_record(self): | |
| 150 | 추가: executable = self.bin / "previous-app" | |
| 151 | 추가: executable.write_text("#!/bin/sh\nexit 0\n") | |
| 152 | 추가: executable.chmod(0o755) | |
| 153 | 추가: with (self.data / "before.desktop").open("a") as desktop: | |
| 154 | 추가: desktop.write(f"TryExec = {executable}\n") | |
| 155 | 추가: self.run_helper("install") | |
| 156 | 추가: executable.unlink() | |
| 157 | 추가: self.assert_unavailable_keeps_record() | |
| 158 | 추가: | |
| 159 | 추가: def test_tryexec_requires_executable_file_and_keeps_record_until_fixed(self): | |
| 160 | 추가: executable = self.bin / "previous-app" | |
| 161 | 추가: executable.write_text("#!/bin/sh\nexit 0\n") | |
| 162 | 추가: with (self.data / "before.desktop").open("a") as desktop: | |
| 163 | 추가: desktop.write("TryExec=previous-app\n") | |
| 164 | 추가: self.run_helper("install") | |
| 165 | 추가: self.assert_unavailable_keeps_record() | |
| 166 | 추가: executable.chmod(0o755) | |
| 167 | 추가: self.run_helper("remove") | |
| 168 | 추가: self.assertEqual(self.choice(), "before.desktop") | |
| 169 | 추가: self.assertFalse((self.state / "zip").exists()) | |
| 170 | 추가: | |
| 171 | 추가: def test_tryexec_absolute_escaped_space_is_available(self): | |
| 172 | 추가: executable = self.bin / "previous app" | |
| 173 | 추가: executable.write_text("#!/bin/sh\nexit 0\n") | |
| 174 | 추가: executable.chmod(0o755) | |
| 175 | 추가: value = str(executable).replace(" ", r"\s") | |
| 176 | 추가: with (self.data / "before.desktop").open("a") as desktop: | |
| 177 | 추가: desktop.write(f"TryExec={value}\n") | |
| 178 | 추가: self.run_helper("install") | |
| 179 | 추가: self.run_helper("remove") | |
| 180 | 추가: self.assertEqual(self.choice(), "before.desktop") | |
| 181 | 추가: | |
| 182 | 추가: def test_action_group_does_not_override_application_availability(self): | |
| 183 | 추가: with (self.data / "before.desktop").open("a") as desktop: | |
| 184 | 추가: desktop.write("[Desktop Action Other]\nHidden=true\nTryExec=missing-app\n") | |
| 185 | 추가: self.run_helper("install") | |
| 186 | 추가: self.run_helper("remove") | |
| 187 | 추가: self.assertEqual(self.choice(), "before.desktop") | |
| 188 | 추가: | |
| 189 | 추가: def test_missing_record_does_not_change_defaults(self): | |
| 190 | 추가: before = self.db.read_bytes() | |
| 191 | 추가: self.run_helper("remove") | |
| 192 | 추가: self.assertEqual(self.db.read_bytes(), before) | |
| 193 | 추가: | |
| 194 | 추가: def test_repeated_install_does_not_replace_first_record(self): | |
| 195 | 추가: self.run_helper("install") | |
| 196 | 추가: original = (self.state / "zip").read_bytes() | |
| 197 | 추가: self.run_helper("install") | |
| 198 | 추가: self.assertEqual((self.state / "zip").read_bytes(), original) | |
| 199 | 추가: self.run_helper("remove") | |
| 200 | 추가: self.assertEqual(self.choice(), "before.desktop") | |
| 201 | 추가: | |
| 202 | 추가: def test_symlinked_state_is_untouched(self): | |
| 203 | 추가: self.state.parent.mkdir() | |
| 204 | 추가: self.state.symlink_to(self.data, target_is_directory=True) | |
| 205 | 추가: before = self.db.read_bytes() | |
| 206 | 추가: self.run_helper("install") | |
| 207 | 추가: self.assertEqual(self.db.read_bytes(), before) | |
| 208 | 추가: self.assertEqual(len(list(self.data.iterdir())), 2) | |
| 209 | 추가: | |
| 210 | 추가: def test_failed_restore_retains_record_for_retry(self): | |
| 211 | 추가: self.run_helper("install") | |
| 212 | 추가: self.env["FAIL_RESTORE"] = "1" | |
| 213 | 추가: self.run_helper("remove") | |
| 214 | 추가: self.assertTrue((self.state / "zip").exists()) | |
| 215 | 추가: self.assertEqual(self.choice(), "zipelo.desktop") | |
| 216 | 추가: del self.env["FAIL_RESTORE"] | |
| 217 | 추가: self.run_helper("remove") | |
| 218 | 추가: self.assertEqual(self.choice(), "before.desktop") | |
| 219 | 추가: | |
| 220 | 추가: def test_hidden_user_entry_does_not_fall_through_to_system_copy(self): | |
| 221 | 추가: self.run_helper("install") | |
| 222 | 추가: (self.data / "before.desktop").write_text("[Desktop Entry]\nHidden=true\n") | |
| 223 | 추가: system = self.root / "system/applications" | |
| 224 | 추가: system.mkdir(parents=True) | |
| 225 | 추가: (system / "before.desktop").write_text("[Desktop Entry]\nType=Application\n") | |
| 226 | 추가: self.env["XDG_DATA_DIRS"] = str(system.parent) | |
| 227 | 추가: self.assert_unavailable_keeps_record() | |
| 228 | 추가: | |
| 229 | 추가: def test_hidden_previous_app_is_not_restored(self): | |
| 230 | 추가: self.run_helper("install") | |
| 231 | 추가: (self.data / "before.desktop").write_text("[Desktop Entry]\nHidden=true\n") | |
| 232 | 추가: self.assert_unavailable_keeps_record() | |
| 233 | 추가: | |
| 234 | 추가: | |
| 235 | 추가: if __name__ == "__main__": | |
| 236 | 추가: unittest.main() |
| @@ -49,7 +49,7 @@ class LifecycleTests(unittest.TestCase): | ||
| 49 | 49 | "TEST_HOME": str(self.directory), |
| 50 | 50 | "TEST_LOG": str(log), |
| 51 | 51 | } |
| 52 | 삭제: for arguments, count in ((["configure"], 5), (["configure", "0.1.0"], 0), | |
| 52 | 추가: for arguments, count in ((["configure"], 1), (["configure", "0.1.0"], 0), | |
| 53 | 53 | (["triggered", "desktop"], 0)): |
| 54 | 54 | with self.subTest(arguments=arguments): |
| 55 | 55 | log.write_text("") |
| @@ -57,6 +57,36 @@ class LifecycleTests(unittest.TestCase): | ||
| 57 | 57 | env=env, check=True) |
| 58 | 58 | self.assertEqual(len(log.read_text().splitlines()), count) |
| 59 | 59 | |
| 60 | 추가: def test_prerm_restores_only_on_remove_for_known_user(self): | |
| 61 | 추가: commands = self.directory / "bin" | |
| 62 | 추가: commands.mkdir() | |
| 63 | 추가: log = self.directory / "calls" | |
| 64 | 추가: for name, content in { | |
| 65 | 추가: "getent": '#!/bin/sh\nprintf "tester:x:1000:1000::%s:/bin/sh\\n" "$TEST_HOME"\n', | |
| 66 | 추가: "runuser": '#!/bin/sh\nprintf "%s\\n" "$*" >> "$TEST_LOG"\n', | |
| 67 | 추가: }.items(): | |
| 68 | 추가: executable = commands / name | |
| 69 | 추가: executable.write_text(content) | |
| 70 | 추가: executable.chmod(0o755) | |
| 71 | 추가: env = {**os.environ, "PATH": str(commands) + os.pathsep + os.environ["PATH"], | |
| 72 | 추가: "SUDO_USER": "tester", "TEST_HOME": str(self.directory), "TEST_LOG": str(log)} | |
| 73 | 추가: for action, count in (("upgrade", 0), ("failed-upgrade", 0), ("remove", 1)): | |
| 74 | 추가: with self.subTest(action=action): | |
| 75 | 추가: log.write_text("") | |
| 76 | 추가: subprocess.run(["sh", str(ROOT / "packaging/ubuntu/rust/prerm"), action], | |
| 77 | 추가: env=env, check=True, capture_output=True) | |
| 78 | 추가: calls = log.read_text().splitlines() | |
| 79 | 추가: self.assertEqual(len(calls), count) | |
| 80 | 추가: if count: | |
| 81 | 추가: self.assertIn("HOME=" + str(self.directory), calls[0]) | |
| 82 | 추가: self.assertTrue(calls[0].endswith("/usr/lib/zipelo/default-apps remove")) | |
| 83 | 추가: env.pop("SUDO_USER") | |
| 84 | 추가: log.write_text("") | |
| 85 | 추가: result = subprocess.run(["sh", str(ROOT / "packaging/ubuntu/rust/prerm"), "remove"], | |
| 86 | 추가: env=env, check=True, capture_output=True, text=True) | |
| 87 | 추가: self.assertEqual(log.read_text(), "") | |
| 88 | 추가: self.assertIn("사용자를 확인할 수 없어", result.stdout) | |
| 89 | 추가: | |
| 60 | 90 | def check_smoke(self, install_fails=False, purge_fails=False, body_fails=False): |
| 61 | 91 | calls = [] |
| 62 | 92 |
| @@ -0,0 +1,82 @@ | ||
| 1 | 추가: """실제 Ubuntu 패키지와 격리된 사용자 설정으로 제거 후 ZIP 열기를 검증함.""" | |
| 2 | 추가: | |
| 3 | 추가: import argparse | |
| 4 | 추가: import os | |
| 5 | 추가: from pathlib import Path | |
| 6 | 추가: import subprocess | |
| 7 | 추가: import tempfile | |
| 8 | 추가: import zipfile | |
| 9 | 추가: | |
| 10 | 추가: ROOT = Path(__file__).resolve().parents[2] | |
| 11 | 추가: | |
| 12 | 추가: | |
| 13 | 추가: def run(*args, **kwargs): | |
| 14 | 추가: return subprocess.run(args, check=True, **kwargs) | |
| 15 | 추가: | |
| 16 | 추가: | |
| 17 | 추가: def main(): | |
| 18 | 추가: parser = argparse.ArgumentParser(description=__doc__) | |
| 19 | 추가: parser.add_argument("package", type=Path) | |
| 20 | 추가: args = parser.parse_args() | |
| 21 | 추가: package = args.package.resolve(strict=True) | |
| 22 | 추가: status = subprocess.run(["dpkg-query", "-W", "-f=${db:Status-Status}", "zipelo"], | |
| 23 | 추가: capture_output=True, text=True) | |
| 24 | 추가: if status.returncode == 0 and status.stdout not in ("not-installed", "config-files"): | |
| 25 | 추가: raise RuntimeError("기존 Zipelo 패키지가 있어 검증을 중단함") | |
| 26 | 추가: for name in ("/usr/lib/zipelo", "/usr/bin/zipelo", "/usr/share/applications/zipelo.desktop"): | |
| 27 | 추가: if Path(name).exists() or Path(name).is_symlink(): | |
| 28 | 추가: raise RuntimeError("기존 설치 파일이 있어 검증을 중단함") | |
| 29 | 추가: work = ROOT / "tests/work" | |
| 30 | 추가: work.mkdir(exist_ok=True) | |
| 31 | 추가: with tempfile.TemporaryDirectory(dir=work) as temporary: | |
| 32 | 추가: root = Path(temporary) | |
| 33 | 추가: config = root / "config" | |
| 34 | 추가: data = root / "data" | |
| 35 | 추가: config.mkdir() | |
| 36 | 추가: apps = data / "applications" | |
| 37 | 추가: apps.mkdir(parents=True) | |
| 38 | 추가: output = root / "opened.txt" | |
| 39 | 추가: opener = root / "open-zip" | |
| 40 | 추가: opener.write_text("#!/bin/sh\n/usr/bin/unzip -p \"$1\" proof.txt > '" + str(output) + "'\n") | |
| 41 | 추가: opener.chmod(0o755) | |
| 42 | 추가: (apps / "previous.desktop").write_text( | |
| 43 | 추가: "[Desktop Entry]\nType=Application\nName=Previous archive app\n" | |
| 44 | 추가: f"Exec={opener} %f\nMimeType=application/zip;\nTerminal=false\n") | |
| 45 | 추가: archive = root / "proof.zip" | |
| 46 | 추가: with zipfile.ZipFile(archive, "w") as zipped: | |
| 47 | 추가: zipped.writestr("proof.txt", "opened by another app") | |
| 48 | 추가: env = dict(os.environ, HOME=str(root), XDG_CONFIG_HOME=str(config), | |
| 49 | 추가: XDG_DATA_HOME=str(data), XDG_STATE_HOME=str(root / "state"), | |
| 50 | 추가: XDG_DATA_DIRS="/usr/local/share:/usr/share", | |
| 51 | 추가: XDG_CONFIG_DIRS=str(root / "system-config"), XDG_CURRENT_DESKTOP="X-Generic", | |
| 52 | 추가: DE="generic", DISPLAY=":987", BROWSER="") | |
| 53 | 추가: env.pop("WAYLAND_DISPLAY", None) | |
| 54 | 추가: env.pop("DBUS_SESSION_BUS_ADDRESS", None) | |
| 55 | 추가: helper = "/usr/lib/zipelo/default-apps" | |
| 56 | 추가: attempted = False | |
| 57 | 추가: try: | |
| 58 | 추가: # 호스트 기본 앱은 건드리지 않고 등록 후보만 실제 설치함. | |
| 59 | 추가: attempted = True | |
| 60 | 추가: run("sudo", "-n", "env", "-u", "SUDO_USER", "dpkg", "-i", str(package)) | |
| 61 | 추가: run("xdg-mime", "default", "previous.desktop", "application/zip", env=env) | |
| 62 | 추가: run("sh", helper, "install", env=env) | |
| 63 | 추가: selected = subprocess.check_output( | |
| 64 | 추가: ["xdg-mime", "query", "default", "application/zip"], env=env, text=True).strip() | |
| 65 | 추가: assert selected == "zipelo.desktop", selected | |
| 66 | 추가: run("sh", helper, "remove", env=env) | |
| 67 | 추가: selected = subprocess.check_output( | |
| 68 | 추가: ["xdg-mime", "query", "default", "application/zip"], env=env, text=True).strip() | |
| 69 | 추가: assert selected == "previous.desktop", selected | |
| 70 | 추가: finally: | |
| 71 | 추가: if attempted: | |
| 72 | 추가: run("sudo", "-n", "env", "-u", "SUDO_USER", "dpkg", "-P", "zipelo") | |
| 73 | 추가: assert not Path(helper).exists() | |
| 74 | 추가: assert not Path("/usr/share/applications/zipelo.desktop").exists() | |
| 75 | 추가: run("xdg-open", str(archive), env=env) | |
| 76 | 추가: assert output.read_text() == "opened by another app" | |
| 77 | 추가: print("PASS actual package install/remove, isolated default restore and ZIP open via unzip") | |
| 78 | 추가: print("LIMIT no native desktop UI; SUDO_USER dispatch is covered separately") | |
| 79 | 추가: | |
| 80 | 추가: | |
| 81 | 추가: if __name__ == "__main__": | |
| 82 | 추가: main() |
| @@ -82,7 +82,7 @@ fn every_listed_scenario_draws_and_keeps_its_expected_screen() { | ||
| 82 | 82 | screen_rect: Some(egui::Rect::from_min_size(egui::Pos2::ZERO, size)), |
| 83 | 83 | ..Default::default() |
| 84 | 84 | }, |
| 85 | 삭제: |ui| app.show(ui), | |
| 85 | 추가: |ui| scenario.show(&mut app, ui), | |
| 86 | 86 | ); |
| 87 | 87 | assert!(!output.shapes.is_empty(), "{}", scenario.name); |
| 88 | 88 | labels = text(&output.shapes); |
| @@ -100,6 +100,10 @@ fn every_listed_scenario_draws_and_keeps_its_expected_screen() { | ||
| 100 | 100 | "resource-ratio" => "압축률이 매우 높습니다", |
| 101 | 101 | "resource-retry" => "한도를 늘려 다시 시도", |
| 102 | 102 | "resource-partial" => "저장 위치를 확인하세요", |
| 103 | 추가: "uninstall-windows" => "제거 전에 다른 앱을 선택하세요", | |
| 104 | 추가: "uninstall-settings-error" => "Windows 설정을 열지 못했습니다", | |
| 105 | 추가: "uninstall-ubuntu-missing" => "이전 앱을 복원할 수 없습니다", | |
| 106 | 추가: "uninstall-ubuntu-unknown-user" => "사용자 기본 앱 설정은 변경하지 않습니다", | |
| 103 | 107 | "conflict-choice" | "conflict-apply" | "gzip-conflict-choice" => { |
| 104 | 108 | "나머지 파일에도 같게 적용" |
| 105 | 109 | } |
| @@ -212,6 +216,62 @@ fn preview_ignores_password_submission() { | ||
| 212 | 216 | assert!(preview.0.model.busy()); |
| 213 | 217 | } |
| 214 | 218 | |
| 219 | 추가: #[test] | |
| 220 | 추가: fn uninstall_previews_match_packaged_notices_and_do_not_start_jobs() { | |
| 221 | 추가: let installer = include_str!("../../packaging/windows/rust/installer.nsi"); | |
| 222 | 추가: let prerm = include_str!("../../packaging/ubuntu/rust/prerm"); | |
| 223 | 추가: let helper = include_str!("../../packaging/ubuntu/rust/default-apps"); | |
| 224 | 추가: for (name, source, expected) in [ | |
| 225 | 추가: ( | |
| 226 | 추가: "uninstall-windows", | |
| 227 | 추가: installer, | |
| 228 | 추가: "직접 고른 기본 앱은 자동으로 바꾸지 않습니다.", | |
| 229 | 추가: ), | |
| 230 | 추가: ( | |
| 231 | 추가: "uninstall-settings-error", | |
| 232 | 추가: installer, | |
| 233 | 추가: "Windows 설정을 열지 못했습니다.", | |
| 234 | 추가: ), | |
| 235 | 추가: ( | |
| 236 | 추가: "uninstall-ubuntu-missing", | |
| 237 | 추가: helper, | |
| 238 | 추가: "이전 앱을 복원할 수 없습니다:", | |
| 239 | 추가: ), | |
| 240 | 추가: ( | |
| 241 | 추가: "uninstall-ubuntu-unknown-user", | |
| 242 | 추가: prerm, | |
| 243 | 추가: "제거를 요청한 사용자를 확인할 수 없어 사용자 기본 앱 설정은 변경하지 않습니다.", | |
| 244 | 추가: ), | |
| 245 | 추가: ] { | |
| 246 | 추가: assert!(source.contains(expected)); | |
| 247 | 추가: let scenario = scenarios::parse(name).unwrap(); | |
| 248 | 추가: let ctx = egui::Context::default(); | |
| 249 | 추가: let mut preview = scenarios::Preview::new(scenario.build(), &ctx).with_scenario(scenario); | |
| 250 | 추가: let mut output = ctx.run_ui( | |
| 251 | 추가: egui::RawInput { | |
| 252 | 추가: screen_rect: Some(egui::Rect::from_min_size( | |
| 253 | 추가: egui::Pos2::ZERO, | |
| 254 | 추가: egui::vec2(760.0, 540.0), | |
| 255 | 추가: )), | |
| 256 | 추가: events: vec![egui::Event::Key { | |
| 257 | 추가: key: egui::Key::Enter, | |
| 258 | 추가: physical_key: None, | |
| 259 | 추가: pressed: true, | |
| 260 | 추가: repeat: false, | |
| 261 | 추가: modifiers: egui::Modifiers::NONE, | |
| 262 | 추가: }], | |
| 263 | 추가: ..Default::default() | |
| 264 | 추가: }, | |
| 265 | 추가: |ui| preview.show(ui), | |
| 266 | 추가: ); | |
| 267 | 추가: assert!(text(&output.shapes).contains(expected), "{name}"); | |
| 268 | 추가: assert!(!preview.0.model.busy()); | |
| 269 | 추가: assert!(preview.0.model.archive.is_none()); | |
| 270 | 추가: assert!(output.platform_output.commands.is_empty()); | |
| 271 | 추가: output.textures_delta.clear(); | |
| 272 | 추가: } | |
| 273 | 추가: } | |
| 274 | 추가: | |
| 215 | 275 | fn result_labels( |
| 216 | 276 | app: &mut zipelo_ui_memory_app::archive_screen::ArchiveApp, |
| 217 | 277 | size: egui::Vec2, |
| @@ -64,6 +64,10 @@ catalog! { | ||
| 64 | 64 | "create-error" => "ZIP 만들기 중 디스크 공간 부족", |
| 65 | 65 | "password-create" => "암호 ZIP 생성의 작업자 암호 요청", |
| 66 | 66 | "close-confirm" => "진행 중 창 닫기 확인", |
| 67 | 추가: "uninstall-windows" => "Windows 제거 전 기본 앱 선택 안내", | |
| 68 | 추가: "uninstall-settings-error" => "Windows 기본 앱 설정 실행 실패", | |
| 69 | 추가: "uninstall-ubuntu-missing" => "Ubuntu 이전 기본 앱 복원 불가 안내", | |
| 70 | 추가: "uninstall-ubuntu-unknown-user" => "Ubuntu 제거 사용자 확인 불가 안내", | |
| 67 | 71 | } |
| 68 | 72 | |
| 69 | 73 | pub fn listing() -> String { |
| @@ -161,6 +165,60 @@ fn entries(many: bool) -> Vec<Entry> { | ||
| 161 | 165 | } |
| 162 | 166 | |
| 163 | 167 | impl Scenario { |
| 168 | 추가: /// 제거 안내는 외부 설치 화면의 문구만 재현하며 OS 동작은 실행하지 않음. | |
| 169 | 추가: pub fn show(self, app: &mut ArchiveApp, ui: &mut egui::Ui) { | |
| 170 | 추가: let (title, messages, button): (&str, Vec<&str>, Option<&str>) = match self.name { | |
| 171 | 추가: "uninstall-windows" => ( | |
| 172 | 추가: "제거 전 기본 앱 선택", | |
| 173 | 추가: vec![ | |
| 174 | 추가: "Zipelo를 기본 앱으로 사용했다면 제거 전에 다른 앱을 선택하세요. [기본 앱 설정 열기]에서 .zip, .7z, .tar, .gz, .tgz를 검색해 사용할 앱을 고를 수 있습니다. 다른 앱이 없으면 먼저 설치하세요.", | |
| 175 | 추가: "직접 고른 기본 앱은 자동으로 바꾸지 않습니다. 제거 후 파일이 열리지 않으면 파일을 오른쪽 클릭하고 [연결 프로그램]에서 다른 앱을 선택하세요.", | |
| 176 | 추가: ], | |
| 177 | 추가: Some("기본 앱 설정 열기"), | |
| 178 | 추가: ), | |
| 179 | 추가: "uninstall-settings-error" => ( | |
| 180 | 추가: "기본 앱 설정 실행 실패", | |
| 181 | 추가: vec![ | |
| 182 | 추가: "Windows 설정을 열지 못했습니다. 설정 > 앱 > 기본 앱에서 확장자를 검색해 다른 앱을 선택하세요.", | |
| 183 | 추가: ], | |
| 184 | 추가: Some("확인"), | |
| 185 | 추가: ), | |
| 186 | 추가: "uninstall-ubuntu-missing" => ( | |
| 187 | 추가: "Ubuntu 제거 안내", | |
| 188 | 추가: vec![ | |
| 189 | 추가: "Zipelo를 제거합니다. 파일이 열리지 않으면 파일을 오른쪽 클릭하고 [다른 프로그램으로 열기]에서 다른 앱을 선택하세요.", | |
| 190 | 추가: "이전 앱을 복원할 수 없습니다: application/zip. 파일을 오른쪽 클릭해 [다른 프로그램으로 열기]에서 앱을 선택하세요.", | |
| 191 | 추가: ], | |
| 192 | 추가: None, | |
| 193 | 추가: ), | |
| 194 | 추가: "uninstall-ubuntu-unknown-user" => ( | |
| 195 | 추가: "Ubuntu 제거 안내", | |
| 196 | 추가: vec![ | |
| 197 | 추가: "Zipelo를 제거합니다. 파일이 열리지 않으면 파일을 오른쪽 클릭하고 [다른 프로그램으로 열기]에서 다른 앱을 선택하세요.", | |
| 198 | 추가: "제거를 요청한 사용자를 확인할 수 없어 사용자 기본 앱 설정은 변경하지 않습니다.", | |
| 199 | 추가: ], | |
| 200 | 추가: None, | |
| 201 | 추가: ), | |
| 202 | 추가: _ => { | |
| 203 | 추가: app.show(ui); | |
| 204 | 추가: return; | |
| 205 | 추가: } | |
| 206 | 추가: }; | |
| 207 | 추가: egui::CentralPanel::default().show_inside(ui, |ui| { | |
| 208 | 추가: ui.add_space(16.0); | |
| 209 | 추가: ui.heading(title); | |
| 210 | 추가: ui.add_space(16.0); | |
| 211 | 추가: for message in messages { | |
| 212 | 추가: ui.label(message); | |
| 213 | 추가: ui.add_space(16.0); | |
| 214 | 추가: } | |
| 215 | 추가: if let Some(button) = button { | |
| 216 | 추가: // 미리보기에서는 설정 열기와 제거를 실행하지 않음. | |
| 217 | 추가: let _ = ui.button(button); | |
| 218 | 추가: } | |
| 219 | 추가: }); | |
| 220 | 추가: } | |
| 221 | 추가: | |
| 164 | 222 | /// 실제 파일과 작업자를 사용하지 않고 기존 화면 상태를 준비함. |
| 165 | 223 | pub fn build(self) -> ArchiveApp { |
| 166 | 224 | let factory = FakeFactory::manual(); |
| @@ -171,7 +229,7 @@ impl Scenario { | ||
| 171 | 229 | app.automatic_destination = false; |
| 172 | 230 | app.zip_folder = base.clone(); |
| 173 | 231 | app.zip_name = "여행 자료.zip".into(); |
| 174 | 삭제: if self.name == "empty" { | |
| 232 | 추가: if self.name == "empty" || self.name.starts_with("uninstall-") { | |
| 175 | 233 | return app; |
| 176 | 234 | } |
| 177 | 235 | let archive = base.join(match self.name { |
| @@ -557,8 +615,21 @@ impl Scenario { | ||
| 557 | 615 | } |
| 558 | 616 | |
| 559 | 617 | /// 화면을 고정하고 실제 파일 조작을 막는 미리보기임. |
| 560 | 삭제: pub struct Preview(pub ArchiveApp); | |
| 618 | 추가: pub struct Preview(pub ArchiveApp, Option<Scenario>); | |
| 561 | 619 | impl Preview { |
| 620 | 추가: pub fn with_scenario(mut self, scenario: Scenario) -> Self { | |
| 621 | 추가: self.1 = Some(scenario); | |
| 622 | 추가: self | |
| 623 | 추가: } | |
| 624 | 추가: | |
| 625 | 추가: pub fn show(&mut self, ui: &mut egui::Ui) { | |
| 626 | 추가: if let Some(scenario) = self.1 { | |
| 627 | 추가: scenario.show(&mut self.0, ui); | |
| 628 | 추가: } else { | |
| 629 | 추가: self.0.show(ui); | |
| 630 | 추가: } | |
| 631 | 추가: } | |
| 632 | 추가: | |
| 562 | 633 | pub fn new(app: ArchiveApp, ctx: &egui::Context) -> Self { |
| 563 | 634 | ctx.on_begin_pass( |
| 564 | 635 | "ui-scenario-readonly", |
| @@ -573,7 +644,7 @@ impl Preview { | ||
| 573 | 644 | }); |
| 574 | 645 | }), |
| 575 | 646 | ); |
| 576 | 삭제: Self(app) | |
| 647 | 추가: Self(app, None) | |
| 577 | 648 | } |
| 578 | 649 | } |
| 579 | 650 | impl eframe::App for Preview { |
| @@ -582,6 +653,6 @@ impl eframe::App for Preview { | ||
| 582 | 653 | root.ctx().send_viewport_cmd(egui::ViewportCommand::Close); |
| 583 | 654 | return; |
| 584 | 655 | } |
| 585 | 삭제: self.0.show(root); | |
| 656 | 추가: self.show(root); | |
| 586 | 657 | } |
| 587 | 658 | } |