Merge pull request #82 from Team-LJY/features/third-party-licenses
전체 의존성 라이선스 고지를 두 패키지에 동봉
- 작성자
- LeeJunyoung
- 작성 시각
- 커밋
b10c7eedddd202f83766aa8f001142cdfdb4097c
변경된 파일 13개
+719-14| @@ -1,11 +1,6 @@ | ||
| 1 | 삭제: Zipelo 합성 메모리 UI 후보 | |
| 2 | 삭제: 자체 코드: MIT. LICENSE에 원문을 포함함. | |
| 3 | 삭제: 직접 의존성: 고정 PR42의 zipelo-app-core-memory와 선택적 eframe 0.37.0임. | |
| 4 | 삭제: eframe feature: accesskit, clipboard, glow, system_fonts, wayland, x11임. | |
| 5 | 삭제: 기존 PR34 및 PR42 lock에 있는 package/version/checksum만 사용함. | |
| 6 | 삭제: 플랫폼별 선택 feature, SPDX license, 캐시 archive checksum, 라이선스 파일의 상대 경로와 SHA256은 tests/rust-ui-memory-app/dependencies.json에 기록함. | |
| 7 | 삭제: 원문 출처는 해당 checksum의 crates.io crate archive와 그 archive에서 풀린 registry source임. | |
| 8 | 삭제: Linux headless/GUI 빌드만 수행함. Windows GNU/MSVC는 선택 그래프 분석이며 빌드/실행을 뜻하지 않음. | |
| 9 | 삭제: 설치된 Noto CJK 폰트는 런타임 경로에서 읽으며 이 후보에 재배포하지 않음. | |
| 10 | 삭제: 이 기록은 최종 설치기/배포용 전체 고지를 완료했다는 뜻이 아님. | |
| 11 | 삭제: crate에 원문이 없는 GUI package의 고정 upstream 보충 원문은 기존 PR34에서 보존한 tests/rust-ui-memory-app/license-supplement.json을 사용함. 원래 URL과 원문을 그대로 보존하며 새로운 네트워크 조회를 하지 않음. | |
| 1 | 추가: Zipelo 의존성 고지 생성 안내 | |
| 2 | 추가: | |
| 3 | 추가: 최종 배포 고지는 packaging/licenses.py가 빌드할 때 생성하는 THIRD-PARTY-LICENSES.txt임. | |
| 4 | 추가: 앱과 작업자의 Cargo.lock 전체 항목을 오프라인 cargo metadata와 대조함. | |
| 5 | 추가: 로컬 registry의 원문과 잠금 체크섬을 확인하며 누락 시 패키지 생성을 중단함. | |
| 6 | 추가: 이 안내 파일과 과거 시험용 보충 원문은 최종 배포 고지를 대신하지 않음. |
Diff가 표시 한도를 넘어서 생략했어요.
Raw로 열기| @@ -0,0 +1,231 @@ | ||
| 1 | 추가: """잠금 의존성의 로컬 원문을 모으고 누락 시 배포를 중단함.""" | |
| 2 | 추가: | |
| 3 | 추가: import argparse | |
| 4 | 추가: import hashlib | |
| 5 | 추가: import json | |
| 6 | 추가: import re | |
| 7 | 추가: from pathlib import Path | |
| 8 | 추가: import subprocess | |
| 9 | 추가: import tarfile | |
| 10 | 추가: import tomllib | |
| 11 | 추가: | |
| 12 | 추가: ROOT = Path(__file__).resolve().parents[1] | |
| 13 | 추가: | |
| 14 | 추가: | |
| 15 | 추가: def identity(package): | |
| 16 | 추가: return package["name"], package["version"], package.get("source") or "workspace" | |
| 17 | 추가: | |
| 18 | 추가: | |
| 19 | 추가: def metadata(manifest): | |
| 20 | 추가: result = subprocess.run( | |
| 21 | 추가: ["cargo", "+1.99.1", "metadata", "--format-version", "1", "--locked", "--offline", | |
| 22 | 추가: "--all-features", "--manifest-path", str(manifest)], | |
| 23 | 추가: check=True, capture_output=True, text=True, | |
| 24 | 추가: ) | |
| 25 | 추가: return json.loads(result.stdout)["packages"] | |
| 26 | 추가: | |
| 27 | 추가: | |
| 28 | 추가: def is_license(path): | |
| 29 | 추가: path = Path(path) | |
| 30 | 추가: name = path.name.upper() | |
| 31 | 추가: return ( | |
| 32 | 추가: name.startswith(("LICENSE", "LICENCE", "COPYING", "COPYRIGHT", "NOTICE", "UNLICENSE", "OFL")) | |
| 33 | 추가: or any(part.lower() in {"license", "licenses", "licence", "licences"} for part in path.parts[:-1]) | |
| 34 | 추가: ) and path.suffix.lower() not in {".rs", ".c", ".h", ".cpp", ".py", ".json"} | |
| 35 | 추가: | |
| 36 | 추가: | |
| 37 | 추가: def registry_files(package, locked): | |
| 38 | 추가: root = Path(package["manifest_path"]).parent.resolve() | |
| 39 | 추가: archive = root.parents[2] / "cache" / root.parent.name / (root.name + ".crate") | |
| 40 | 추가: if hashlib.sha256(archive.read_bytes()).hexdigest() != locked["checksum"]: | |
| 41 | 추가: raise ValueError(f"crate 체크섬 불일치: {root.name}") | |
| 42 | 추가: explicit = package.get("license_file") | |
| 43 | 추가: if explicit: | |
| 44 | 추가: explicit = Path(explicit) | |
| 45 | 추가: if not explicit.is_absolute(): | |
| 46 | 추가: explicit = root / explicit | |
| 47 | 추가: explicit = explicit.resolve().relative_to(root).as_posix() | |
| 48 | 추가: records = [] | |
| 49 | 추가: with tarfile.open(archive, "r:gz") as source: | |
| 50 | 추가: for member in sorted(source.getmembers(), key=lambda member: member.name): | |
| 51 | 추가: name = Path(member.name) | |
| 52 | 추가: if name.parts[0] != root.name or ".." in name.parts: | |
| 53 | 추가: raise ValueError(f"crate 경로 오류: {root.name}") | |
| 54 | 추가: relative = Path(*name.parts[1:]) | |
| 55 | 추가: if not (is_license(relative) or relative.as_posix() == explicit): | |
| 56 | 추가: continue | |
| 57 | 추가: if not member.isfile(): | |
| 58 | 추가: if member.isdir(): | |
| 59 | 추가: continue | |
| 60 | 추가: raise ValueError(f"라이선스가 일반 파일이 아님: {member.name}") | |
| 61 | 추가: local = root / relative | |
| 62 | 추가: if local.is_symlink() or not local.resolve().is_relative_to(root): | |
| 63 | 추가: raise ValueError(f"라이선스 경로 이탈: {relative}") | |
| 64 | 추가: content = local.read_bytes() | |
| 65 | 추가: if content != source.extractfile(member).read(): | |
| 66 | 추가: raise ValueError(f"라이선스 원문 변경: {root.name}/{relative}") | |
| 67 | 추가: records.append({ | |
| 68 | 추가: "path": relative.as_posix(), | |
| 69 | 추가: "sha256": hashlib.sha256(content).hexdigest(), | |
| 70 | 추가: "text": content.decode("utf-8"), | |
| 71 | 추가: }) | |
| 72 | 추가: return records | |
| 73 | 추가: | |
| 74 | 추가: | |
| 75 | 추가: def supplemental_files(package, supplement_path): | |
| 76 | 추가: data = json.loads(Path(supplement_path).read_text(encoding="utf-8")) | |
| 77 | 추가: candidates = [row for row in data["packages"] | |
| 78 | 추가: if (row["name"], row["version"]) == (package["name"], package["version"])] | |
| 79 | 추가: if not candidates: | |
| 80 | 추가: return [] | |
| 81 | 추가: if len(candidates) != 1: | |
| 82 | 추가: raise ValueError("보충 항목 중복") | |
| 83 | 추가: row = candidates[0] | |
| 84 | 추가: if row["license"] != package["license"]: | |
| 85 | 추가: raise ValueError(f"보충 SPDX 불일치: {package['name']}") | |
| 86 | 추가: root = Path(package["manifest_path"]).parent.resolve() | |
| 87 | 추가: archive = root.parents[2] / "cache" / root.parent.name / (root.name + ".crate") | |
| 88 | 추가: with tarfile.open(archive, "r:gz") as source: | |
| 89 | 추가: vcs = json.load(source.extractfile(root.name + "/.cargo_vcs_info.json")) | |
| 90 | 추가: manifest_bytes = source.extractfile(root.name + "/Cargo.toml").read() | |
| 91 | 추가: if vcs["git"]["sha1"] != row["rev"]: | |
| 92 | 추가: raise ValueError(f"보충 버전 커밋 불일치: {package['name']}") | |
| 93 | 추가: def checked_file(url): | |
| 94 | 추가: file = data["files"][url] | |
| 95 | 추가: if file["url"] != url or hashlib.sha256(file["text"].encode("utf-8")).hexdigest() != file["sha256"]: | |
| 96 | 추가: raise ValueError(f"보충 원문 해시 불일치: {url}") | |
| 97 | 추가: return file | |
| 98 | 추가: | |
| 99 | 추가: if row.get("standard_license"): | |
| 100 | 추가: chosen = row["standard_license"] | |
| 101 | 추가: alternatives = package["license"].split(" OR ") | |
| 102 | 추가: if chosen != "MIT" or chosen not in alternatives: | |
| 103 | 추가: raise ValueError("표준 원문 SPDX 선택 불일치") | |
| 104 | 추가: url = data["standards"][chosen] | |
| 105 | 추가: if not re.fullmatch(r"https://raw\.githubusercontent\.com/spdx/license-list-data/v[0-9]+\.[0-9]+\.[0-9]+/text/MIT\.txt", url): | |
| 106 | 추가: raise ValueError("표준 원문 출처 고정 오류") | |
| 107 | 추가: standard = checked_file(url) | |
| 108 | 추가: attribution_url = row["attribution_source"] | |
| 109 | 추가: attribution = checked_file(attribution_url) | |
| 110 | 추가: manifest = tomllib.loads(attribution["text"]) | |
| 111 | 추가: if attribution_url.startswith("crate:"): | |
| 112 | 추가: if (attribution_url != "crate:" + root.name + "/Cargo.toml" | |
| 113 | 추가: or attribution["text"].encode("utf-8") != manifest_bytes): | |
| 114 | 추가: raise ValueError("게시 crate 저자 원문 불일치") | |
| 115 | 추가: authors = manifest["package"].get("authors") | |
| 116 | 추가: else: | |
| 117 | 추가: expected = "https://raw.githubusercontent.com/madsmtm/objc2/" + row["rev"] + "/Cargo.toml" | |
| 118 | 추가: if attribution_url != expected or manifest["workspace"]["package"]["version"] != row["version"]: | |
| 119 | 추가: raise ValueError("upstream 저자 출처 불일치") | |
| 120 | 추가: authors = manifest["workspace"]["package"].get("authors") | |
| 121 | 추가: if not authors or authors != row["authors"]: | |
| 122 | 추가: raise ValueError("저자 고지 불일치") | |
| 123 | 추가: note = ("upstream에 원문이 없어 표준 원문으로 보충함\n" | |
| 124 | 추가: + "Selected license: " + chosen + "\n" | |
| 125 | 추가: + "Authors (Cargo.toml): " + ", ".join(authors) + "\n" | |
| 126 | 추가: + "Attribution source: " + attribution_url + "\n" | |
| 127 | 추가: + "Attribution SHA-256: " + attribution["sha256"]) | |
| 128 | 추가: return [{"path": url, "sha256": standard["sha256"], "text": standard["text"], "note": note}] | |
| 129 | 추가: | |
| 130 | 추가: records = [] | |
| 131 | 추가: for url in row["files"]: | |
| 132 | 추가: file = data["files"][url] | |
| 133 | 추가: parts = url.split("/") | |
| 134 | 추가: if (len(parts) < 7 or parts[:3] != ["https:", "", "raw.githubusercontent.com"] | |
| 135 | 추가: or parts[5] != row["upstream_ref"] | |
| 136 | 추가: or row["upstream_ref"] not in {row["rev"], row["version"]}): | |
| 137 | 추가: raise ValueError(f"보충 출처 고정 오류: {url}") | |
| 138 | 추가: content = file["text"].encode("utf-8") | |
| 139 | 추가: if file["url"] != url or hashlib.sha256(content).hexdigest() != file["sha256"]: | |
| 140 | 추가: raise ValueError(f"보충 원문 해시 불일치: {url}") | |
| 141 | 추가: records.append({"path": url, "sha256": file["sha256"], "text": file["text"]}) | |
| 142 | 추가: return records | |
| 143 | 추가: | |
| 144 | 추가: | |
| 145 | 추가: def repository_root(manifest): | |
| 146 | 추가: result = subprocess.run( | |
| 147 | 추가: ["git", "-C", str(manifest.parent), "rev-parse", "--show-toplevel"], | |
| 148 | 추가: check=True, capture_output=True, text=True, | |
| 149 | 추가: ) | |
| 150 | 추가: return Path(result.stdout.strip()).resolve(strict=True) | |
| 151 | 추가: | |
| 152 | 추가: | |
| 153 | 추가: def inventory(manifests, project_root=None, supplement_path=ROOT / "packaging/license-supplements.json"): | |
| 154 | 추가: records = {} | |
| 155 | 추가: for manifest in manifests: | |
| 156 | 추가: manifest = Path(manifest).resolve(strict=True) | |
| 157 | 추가: lock = tomllib.loads(manifest.with_name("Cargo.lock").read_text()) | |
| 158 | 추가: locked = {identity(package): package for package in lock["package"]} | |
| 159 | 추가: packages = {identity(package): package for package in metadata(manifest)} | |
| 160 | 추가: if set(locked) != set(packages): | |
| 161 | 추가: raise ValueError(f"Cargo.lock/metadata 불일치: 누락 {sorted(set(locked) - set(packages))}, " | |
| 162 | 추가: f"추가 {sorted(set(packages) - set(locked))}") | |
| 163 | 추가: root = None | |
| 164 | 추가: for key, package in sorted(packages.items()): | |
| 165 | 추가: if package.get("source"): | |
| 166 | 추가: if not package["source"].startswith("registry+"): | |
| 167 | 추가: raise ValueError(f"지원하지 않는 원문 저장소: {key}") | |
| 168 | 추가: files = registry_files(package, locked[key]) | |
| 169 | 추가: if not files and Path(supplement_path).is_file(): | |
| 170 | 추가: files = supplemental_files(package, supplement_path) | |
| 171 | 추가: else: | |
| 172 | 추가: if root is None: | |
| 173 | 추가: root = Path(project_root).resolve() if project_root else repository_root(manifest) | |
| 174 | 추가: if (package["license"] != "MIT" | |
| 175 | 추가: or not Path(package["manifest_path"]).resolve().is_relative_to(root)): | |
| 176 | 추가: raise ValueError(f"프로젝트 라이선스 범위 확인 필요: {key}") | |
| 177 | 추가: content = (root / "LICENSE").read_bytes() | |
| 178 | 추가: files = [{"path": "project/LICENSE", "sha256": hashlib.sha256(content).hexdigest(), | |
| 179 | 추가: "text": content.decode("utf-8")}] | |
| 180 | 추가: if key in records: | |
| 181 | 추가: if records[key]["license"] != package["license"]: | |
| 182 | 추가: raise ValueError(f"입력 저장소 간 SPDX 불일치: {key}") | |
| 183 | 추가: for file in files: | |
| 184 | 추가: if file not in records[key]["files"]: | |
| 185 | 추가: records[key]["files"].append(file) | |
| 186 | 추가: else: | |
| 187 | 추가: records[key] = {"name": key[0], "version": key[1], "source": key[2], | |
| 188 | 추가: "license": package["license"], "files": files} | |
| 189 | 추가: return [records[key] for key in sorted(records)] | |
| 190 | 추가: | |
| 191 | 추가: | |
| 192 | 추가: def render(records): | |
| 193 | 추가: missing = [f'{record["name"]}@{record["version"]}' for record in records if not record["files"]] | |
| 194 | 추가: if missing: | |
| 195 | 추가: raise ValueError(f"라이선스 원문 누락 {len(missing)}개: " + ", ".join(missing)) | |
| 196 | 추가: lines = ["Zipelo third-party licenses", "Cargo.lock 전체 의존성의 원문 고지 (로컬 registry 및 고정 upstream 보충)", ""] | |
| 197 | 추가: for record in records: | |
| 198 | 추가: lines.extend(["=" * 72, f'Crate: {record["name"]} {record["version"]}', | |
| 199 | 추가: f'Source: {record["source"]}', f'License: {record["license"]}', f'Version: {record["version"]}', ""]) | |
| 200 | 추가: for file in record["files"]: | |
| 201 | 추가: lines.extend([f'File: {file["path"]}', f'SHA-256: {file["sha256"]}']) | |
| 202 | 추가: if file.get("note"): | |
| 203 | 추가: lines.append(file["note"]) | |
| 204 | 추가: lines.extend(["", file["text"], ""]) | |
| 205 | 추가: return "\n".join(lines) | |
| 206 | 추가: | |
| 207 | 추가: | |
| 208 | 추가: def generate(manifests, output, audit=None): | |
| 209 | 추가: records = inventory(manifests) | |
| 210 | 추가: if audit: | |
| 211 | 추가: Path(audit).write_text(json.dumps(records, ensure_ascii=False, indent=4) + "\n", encoding="utf-8") | |
| 212 | 추가: text = render(records) | |
| 213 | 추가: Path(output).write_text(text, encoding="utf-8", newline="") | |
| 214 | 추가: return records | |
| 215 | 추가: | |
| 216 | 추가: | |
| 217 | 추가: def main(): | |
| 218 | 추가: parser = argparse.ArgumentParser(description=__doc__) | |
| 219 | 추가: parser.add_argument("--manifest", type=Path, action="append", required=True) | |
| 220 | 추가: parser.add_argument("--output", type=Path, required=True) | |
| 221 | 추가: parser.add_argument("--audit", type=Path) | |
| 222 | 추가: args = parser.parse_args() | |
| 223 | 추가: try: | |
| 224 | 추가: records = generate(args.manifest, args.output, args.audit) | |
| 225 | 추가: except (ValueError, OSError, subprocess.CalledProcessError) as error: | |
| 226 | 추가: parser.exit(1, str(error) + "\n") | |
| 227 | 추가: print(f"라이선스 {len(records)}개, 누락 0개") | |
| 228 | 추가: | |
| 229 | 추가: | |
| 230 | 추가: if __name__ == "__main__": | |
| 231 | 추가: main() |
| @@ -14,3 +14,12 @@ Rust 1.99.1, dpkg-deb와 desktop-file-validate가 필요합니다. 출력은 새 | ||
| 14 | 14 | sudo로 처음 설치하면 postinst가 SUDO_USER의 ZIP, 7z, TAR.GZ, GZ, TAR 기본 앱을 xdg-mime으로 적용합니다. 최초 설치에서 기존 기본 앱 선택을 바꿉니다. 업그레이드와 재설정에서는 사용자의 기본 앱 선택을 유지합니다. 다른 패키지 관리자로 설치해 SUDO_USER가 없으면 사용자 설정을 추측하지 않고 연결 후보만 등록합니다. 이 경우 사용자 계정에서 xdg-mime default zipelo.desktop application/zip 등을 실행해야 합니다. 제거는 사용자 MIME 설정을 지우지 않으며 다른 앱을 기본 앱으로 다시 선택할 수 있습니다. |
| 15 | 15 | |
| 16 | 16 | 이 패키지의 검사 범위는 Ubuntu 26.04입니다. 다른 Ubuntu 버전과 Windows 실기는 별도 확인이 필요합니다. |
| 17 | 추가: | |
| 18 | 추가: | |
| 19 | 추가: 앱과 작업자의 Cargo.lock 전체 항목을 cargo metadata --locked --offline --all-features와 대조한 뒤 packaging/licenses.py로 THIRD-PARTY-LICENSES.txt를 생성합니다. 로컬 registry 원문과 캐시 crate의 잠금 체크섬을 확인하며 LICENSE, COPYING, NOTICE 등의 원문을 함께 보존합니다. 원문이 없거나 변조됐거나 metadata 대조에서 누락되면 패키지 생성을 중단합니다. | |
| 20 | 추가: | |
| 21 | 추가: 처음 준비할 때 각 manifest에 cargo +1.99.1 fetch --locked --manifest-path 명령으로 모든 플랫폼의 의존성을 캐시에 받아 두어야 합니다. 고지 생성 중에는 네트워크를 사용하지 않습니다. Windows에는 설치 폴더에, Ubuntu에는 /usr/share/doc/zipelo/THIRD-PARTY-LICENSES.txt에 포함합니다. 파일 동봉 자체가 별도 라이선스 준수 검토를 대신하지는 않습니다. | |
| 22 | 추가: | |
| 23 | 추가: 로컬 crate에 원문이 없으면 packaging/license-supplements.json의 해당 버전 공식 upstream 원문을 사용합니다. 보충 파일에는 고정 출처 URL, crate 버전과 VCS 커밋, Cargo SPDX 식, UTF-8 원문과 SHA-256이 들어 있습니다. 생성기는 SPDX와 게시된 crate 커밋 및 원문 해시를 오프라인으로 검증합니다. 승인된 표준 보충도 없는 항목은 링크 설명만으로 대체하지 않고 계속 빌드를 차단합니다. | |
| 24 | 추가: | |
| 25 | 추가: upstream에도 원문이 없는 승인된 12개 항목은 SPDX의 MIT 표준 원문과 해당 버전 Cargo.toml의 저자 고지로 보충합니다. 고지에 표준 원문 보충 사유, 선택한 라이선스, 원문과 저자 고지의 출처 및 SHA-256을 표시합니다. Cargo 메타데이터의 전체 라이선스 식은 그대로 보존합니다. |
| @@ -22,6 +22,12 @@ def build(args): | ||
| 22 | 22 | lib = stage / "usr/lib/zipelo" |
| 23 | 23 | lib.mkdir(parents=True) |
| 24 | 24 | records = {} |
| 25 | 추가: docs = stage / "usr/share/doc/zipelo" | |
| 26 | 추가: docs.mkdir(parents=True) | |
| 27 | 추가: WINDOWS.LICENSES.generate( | |
| 28 | 추가: [ROOT / "experiments/rust-ui-memory-app/Cargo.toml", ROOT / "experiments/rust-archive-worker/Cargo.toml"], | |
| 29 | 추가: docs / "THIRD-PARTY-LICENSES.txt", | |
| 30 | 추가: ) | |
| 25 | 31 | for name, manifest, binary, features in ( |
| 26 | 32 | ("Zipelo", ROOT / "experiments/rust-ui-memory-app/Cargo.toml", "zipelo-ui-memory-app", ("ui",)), |
| 27 | 33 | ("zipelo-archive-worker", ROOT / "experiments/rust-archive-worker/Cargo.toml", "zipelo-archive-worker", ()), |
| @@ -38,8 +44,6 @@ def build(args): | ||
| 38 | 44 | desktop.mkdir(parents=True) |
| 39 | 45 | shutil.copyfile(Path(__file__).with_name("zipelo.desktop"), desktop / "zipelo.desktop") |
| 40 | 46 | subprocess.run(["desktop-file-validate", str(desktop / "zipelo.desktop")], check=True) |
| 41 | 삭제: docs = stage / "usr/share/doc/zipelo" | |
| 42 | 삭제: docs.mkdir(parents=True) | |
| 43 | 47 | shutil.copyfile(ROOT / "LICENSE", docs / "copyright") |
| 44 | 48 | control = stage / "DEBIAN" |
| 45 | 49 | control.mkdir() |
| @@ -45,3 +45,14 @@ Windows 실행 검증 전에는 README 다운로드 버튼이나 release에 배 | ||
| 45 | 45 | Capabilities/RegisteredApplications 구조를 사용하며, |
| 46 | 46 | [Windows 기본 앱 설정 열기](https://learn.microsoft.com/en-us/windows/apps/develop/launch/launch-default-apps-settings)의 |
| 47 | 47 | ms-settings URI를 사용합니다. |
| 48 | 추가: | |
| 49 | 추가: | |
| 50 | 추가: 앱과 작업자의 Cargo.lock 전체 항목을 cargo metadata --locked --offline --all-features와 대조한 뒤 packaging/licenses.py로 THIRD-PARTY-LICENSES.txt를 생성합니다. 로컬 registry 원문과 캐시 crate의 잠금 체크섬을 확인하며 LICENSE, COPYING, NOTICE 등의 원문을 함께 보존합니다. 원문이 없거나 변조됐거나 metadata 대조에서 누락되면 패키지 생성을 중단합니다. | |
| 51 | 추가: | |
| 52 | 추가: 별도 체크아웃을 입력하면 각 manifest가 속한 Git 저장소의 LICENSE와 로컬 패키지의 MIT 선언 및 경로 범위를 따로 검증합니다. 두 입력의 Cargo.lock과 metadata도 각각 대조한 뒤 고지를 합치며, 같은 이름과 버전의 패키지라도 서로 다른 저작권 고지는 모두 보존합니다. | |
| 53 | 추가: | |
| 54 | 추가: 처음 준비할 때 각 manifest에 cargo +1.99.1 fetch --locked --manifest-path 명령으로 모든 플랫폼의 의존성을 캐시에 받아 두어야 합니다. 고지 생성 중에는 네트워크를 사용하지 않습니다. Windows에는 설치 폴더에, Ubuntu에는 /usr/share/doc/zipelo/THIRD-PARTY-LICENSES.txt에 포함합니다. 파일 동봉 자체가 별도 라이선스 준수 검토를 대신하지는 않습니다. | |
| 55 | 추가: | |
| 56 | 추가: 로컬 crate에 원문이 없으면 packaging/license-supplements.json의 해당 버전 공식 upstream 원문을 사용합니다. 보충 파일에는 고정 출처 URL, crate 버전과 VCS 커밋, Cargo SPDX 식, UTF-8 원문과 SHA-256이 들어 있습니다. 생성기는 SPDX와 게시된 crate 커밋 및 원문 해시를 오프라인으로 검증합니다. 승인된 표준 보충도 없는 항목은 링크 설명만으로 대체하지 않고 계속 빌드를 차단합니다. | |
| 57 | 추가: | |
| 58 | 추가: upstream에도 원문이 없는 승인된 12개 항목은 SPDX의 MIT 표준 원문과 해당 버전 Cargo.toml의 저자 고지로 보충합니다. 고지에 표준 원문 보충 사유, 선택한 라이선스, 원문과 저자 고지의 출처 및 SHA-256을 표시합니다. Cargo 메타데이터의 전체 라이선스 식은 그대로 보존합니다. |
| @@ -2,6 +2,7 @@ | ||
| 2 | 2 | |
| 3 | 3 | import argparse |
| 4 | 4 | import hashlib |
| 5 | 추가: import importlib.util | |
| 5 | 6 | import json |
| 6 | 7 | import os |
| 7 | 8 | from pathlib import Path |
| @@ -11,6 +12,9 @@ import subprocess | ||
| 11 | 12 | |
| 12 | 13 | ROOT = Path(__file__).resolve().parents[3] |
| 13 | 14 | TARGET = "x86_64-pc-windows-gnu" |
| 15 | 추가: SPEC = importlib.util.spec_from_file_location("licenses", ROOT / "packaging/licenses.py") | |
| 16 | 추가: LICENSES = importlib.util.module_from_spec(SPEC) | |
| 17 | 추가: SPEC.loader.exec_module(LICENSES) | |
| 14 | 18 | |
| 15 | 19 | |
| 16 | 20 | def pe_machine(path): |
| @@ -72,6 +76,7 @@ def build(args): | ||
| 72 | 76 | records = {} |
| 73 | 77 | payload = output / "payload" |
| 74 | 78 | payload.mkdir() |
| 79 | 추가: LICENSES.generate([args.app_manifest, args.worker_manifest], payload / "THIRD-PARTY-LICENSES.txt") | |
| 75 | 80 | for name, manifest, binary, features in ( |
| 76 | 81 | ("Zipelo.exe", args.app_manifest, "zipelo-ui-memory-app", ("ui",)), |
| 77 | 82 | ("zipelo-archive-worker.exe", args.worker_manifest, "zipelo-archive-worker", ()), |
| @@ -99,6 +99,7 @@ Section "Zipelo" | ||
| 99 | 99 | File "payload\Zipelo.exe" |
| 100 | 100 | File "payload\zipelo-archive-worker.exe" |
| 101 | 101 | File "payload\LICENSE" |
| 102 | 추가: File "payload\THIRD-PARTY-LICENSES.txt" | |
| 102 | 103 | File "payload\BUILD-INFO.json" |
| 103 | 104 | IfErrors failed |
| 104 | 105 | WriteUninstaller "$INSTDIR\Uninstall.exe" |
| @@ -141,6 +142,7 @@ Function Rollback | ||
| 141 | 142 | Delete "$INSTDIR\Zipelo.exe" |
| 142 | 143 | Delete "$INSTDIR\zipelo-archive-worker.exe" |
| 143 | 144 | Delete "$INSTDIR\LICENSE" |
| 145 | 추가: Delete "$INSTDIR\THIRD-PARTY-LICENSES.txt" | |
| 144 | 146 | Delete "$INSTDIR\BUILD-INFO.json" |
| 145 | 147 | Delete "$INSTDIR\install.ini" |
| 146 | 148 | Delete "$INSTDIR\Uninstall.exe" |
| @@ -225,6 +227,7 @@ Section "Uninstall" | ||
| 225 | 227 | Delete "$INSTDIR\zipelo-archive-worker.exe" |
| 226 | 228 | IfErrors uninstall_failed |
| 227 | 229 | Delete "$INSTDIR\LICENSE" |
| 230 | 추가: Delete "$INSTDIR\THIRD-PARTY-LICENSES.txt" | |
| 228 | 231 | Delete "$INSTDIR\BUILD-INFO.json" |
| 229 | 232 | Delete "$SMPROGRAMS\Zipelo 개발판.lnk" |
| 230 | 233 | IfErrors uninstall_failed |
| @@ -57,7 +57,7 @@ class InstallerInputTests(unittest.TestCase): | ||
| 57 | 57 | def test_nsis_compiles_payloads_and_finish_callbacks(self): |
| 58 | 58 | payload = self.root / "payload" |
| 59 | 59 | payload.mkdir() |
| 60 | 삭제: for name in ("Zipelo.exe", "zipelo-archive-worker.exe", "LICENSE", "BUILD-INFO.json"): | |
| 60 | 추가: for name in ("Zipelo.exe", "zipelo-archive-worker.exe", "LICENSE", "BUILD-INFO.json", "THIRD-PARTY-LICENSES.txt"): | |
| 61 | 61 | (payload / name).write_bytes(b"compile-only test fixture") |
| 62 | 62 | shutil.copyfile(ROOT / "packaging/windows/rust/installer.nsi", self.root / "installer.nsi") |
| 63 | 63 | completed = subprocess.run(["makensis", "-WX", "installer.nsi"], cwd=self.root, |
| @@ -13,3 +13,17 @@ Ubuntu 실기 스모크는 이 패키지를 sudo로 설치하고 ZIP, 7z, TAR.GZ | ||
| 13 | 13 | sudo 비대화형 권한, Xvfb, xdotool과 ImageMagick import가 필요합니다. 이 검사는 실제 시스템 패키지를 설치하고 사용자 기본 앱을 임시로 바꾸므로 실행 전에 해당 작업의 승인이 필요합니다. 출력은 runs/에 남고 Git에는 포함하지 않습니다. |
| 14 | 14 | |
| 15 | 15 | Windows 설치와 설정 화면, 제거의 실기 검증은 이 Linux 시험에 포함되지 않습니다. release 게시와 다운로드 버튼 갱신도 수행하지 않습니다. |
| 16 | 추가: | |
| 17 | 추가: | |
| 18 | 추가: ## 라이선스 대조 | |
| 19 | 추가: | |
| 20 | 추가: ```sh | |
| 21 | 추가: python3 -m unittest discover -s tests/release-packages -p "test_*.py" | |
| 22 | 추가: python3 packaging/licenses.py --manifest experiments/rust-ui-memory-app/Cargo.toml --manifest experiments/rust-archive-worker/Cargo.toml --output tests/release-packages/runs/THIRD-PARTY-LICENSES.txt --audit tests/release-packages/runs/license-inventory.json | |
| 23 | 추가: ``` | |
| 24 | 추가: | |
| 25 | 추가: 고지의 crate 목록은 두 Cargo.lock과 metadata의 합집합을 기준으로 합니다. 플랫폼이나 활성 기능을 기준으로 항목을 줄이지 않습니다. 원문 파일이 없는 crate는 라이선스 식만으로 대체하지 않으며 최종 파일을 생성하지 않습니다. audit JSON은 누락 원인 확인용이며 배포 고지가 아닙니다. 대조 시험은 원문 보존, 변경된 캐시 거부, metadata 누락과 두 패키지의 조기 중단을 검증합니다. | |
| 26 | 추가: | |
| 27 | 추가: 로컬 crate에 원문이 없으면 packaging/license-supplements.json의 해당 버전 공식 upstream 원문을 사용합니다. 보충 파일에는 고정 출처 URL, crate 버전과 VCS 커밋, Cargo SPDX 식, UTF-8 원문과 SHA-256이 들어 있습니다. 생성기는 SPDX와 게시된 crate 커밋 및 원문 해시를 오프라인으로 검증합니다. 승인된 표준 보충도 없는 항목은 링크 설명만으로 대체하지 않고 계속 빌드를 차단합니다. | |
| 28 | 추가: | |
| 29 | 추가: upstream에도 원문이 없는 승인된 12개 항목은 SPDX의 MIT 표준 원문과 해당 버전 Cargo.toml의 저자 고지로 보충합니다. 고지에 표준 원문 보충 사유, 선택한 라이선스, 원문과 저자 고지의 출처 및 SHA-256을 표시합니다. Cargo 메타데이터의 전체 라이선스 식은 그대로 보존합니다. |
| @@ -0,0 +1,74 @@ | ||
| 1 | 추가: """실제 두 패키지의 고지 원문과 Cargo 항목 일치를 확인함.""" | |
| 2 | 추가: | |
| 3 | 추가: import argparse | |
| 4 | 추가: import hashlib | |
| 5 | 추가: import json | |
| 6 | 추가: from pathlib import Path | |
| 7 | 추가: import subprocess | |
| 8 | 추가: import tarfile | |
| 9 | 추가: | |
| 10 | 추가: ROOT = Path(__file__).resolve().parents[2] | |
| 11 | 추가: | |
| 12 | 추가: | |
| 13 | 추가: def deb_notice(path): | |
| 14 | 추가: matches = [] | |
| 15 | 추가: with subprocess.Popen(["dpkg-deb", "--fsys-tarfile", str(path)], stdout=subprocess.PIPE) as process: | |
| 16 | 추가: with tarfile.open(fileobj=process.stdout, mode="r|") as archive: | |
| 17 | 추가: for member in archive: | |
| 18 | 추가: if member.name.removeprefix("./") == "usr/share/doc/zipelo/THIRD-PARTY-LICENSES.txt": | |
| 19 | 추가: if not member.isfile(): | |
| 20 | 추가: raise ValueError("deb 고지가 일반 파일이 아님") | |
| 21 | 추가: matches.append(archive.extractfile(member).read()) | |
| 22 | 추가: if process.wait() != 0: | |
| 23 | 추가: raise ValueError("deb 읽기 실패") | |
| 24 | 추가: if len(matches) != 1: | |
| 25 | 추가: raise ValueError("deb 고지 누락 또는 중복") | |
| 26 | 추가: return matches[0] | |
| 27 | 추가: | |
| 28 | 추가: | |
| 29 | 추가: def windows_notice(path, sevenzip): | |
| 30 | 추가: listing = subprocess.check_output([sevenzip, "l", "-slt", "-ba", str(path)], text=True) | |
| 31 | 추가: paths = [line.removeprefix("Path = ") for line in listing.splitlines() if line.startswith("Path = ")] | |
| 32 | 추가: matches = [name for name in paths if name.replace("\\", "/").split("/")[-1] == "THIRD-PARTY-LICENSES.txt"] | |
| 33 | 추가: if len(matches) != 1: | |
| 34 | 추가: raise ValueError("NSIS 고지 누락 또는 중복") | |
| 35 | 추가: return subprocess.check_output([sevenzip, "x", "-so", str(path), matches[0]]) | |
| 36 | 추가: | |
| 37 | 추가: | |
| 38 | 추가: def main(): | |
| 39 | 추가: parser = argparse.ArgumentParser(description=__doc__) | |
| 40 | 추가: for name in ["windows", "ubuntu", "notice", "inventory", "output"]: | |
| 41 | 추가: parser.add_argument("--" + name, type=Path, required=True) | |
| 42 | 추가: parser.add_argument("--sevenzip", required=True) | |
| 43 | 추가: args = parser.parse_args() | |
| 44 | 추가: if not args.output.resolve().is_relative_to(ROOT / "tests"): | |
| 45 | 추가: raise ValueError("검증 결과는 tests 안에 저장해야 함") | |
| 46 | 추가: expected = args.notice.read_bytes() | |
| 47 | 추가: inventory = json.loads(args.inventory.read_text()) | |
| 48 | 추가: headings = {line.removeprefix("Crate: ") for line in expected.decode("utf-8").splitlines() | |
| 49 | 추가: if line.startswith("Crate: ")} | |
| 50 | 추가: expected_headings = {row["name"] + " " + row["version"] for row in inventory} | |
| 51 | 추가: if headings != expected_headings or not all(row["files"] for row in inventory): | |
| 52 | 추가: raise ValueError("고지 항목과 inventory 불일치") | |
| 53 | 추가: if expected.count(b"\nCrate: ") != len(inventory): | |
| 54 | 추가: raise ValueError("고지 항목 중복") | |
| 55 | 추가: for label, actual in [("windows", windows_notice(args.windows, args.sevenzip)), | |
| 56 | 추가: ("ubuntu", deb_notice(args.ubuntu))]: | |
| 57 | 추가: if actual != expected: | |
| 58 | 추가: raise ValueError(label + " 패키지 고지 원문 불일치") | |
| 59 | 추가: report = { | |
| 60 | 추가: "crates": len(inventory), | |
| 61 | 추가: "missing": 0, | |
| 62 | 추가: "notice_sha256": hashlib.sha256(expected).hexdigest(), | |
| 63 | 추가: "notice_bytes": len(expected), | |
| 64 | 추가: "standard_supplements": expected.decode("utf-8").count("upstream에 원문이 없어 표준 원문으로 보충함"), | |
| 65 | 추가: "packages": {label: {"path": str(path), "sha256": hashlib.sha256(path.read_bytes()).hexdigest(), | |
| 66 | 추가: "bytes": path.stat().st_size} | |
| 67 | 추가: for label, path in [("windows", args.windows), ("ubuntu", args.ubuntu)]}, | |
| 68 | 추가: } | |
| 69 | 추가: args.output.write_text(json.dumps(report, ensure_ascii=False, indent=4) + "\n") | |
| 70 | 추가: print(json.dumps(report, ensure_ascii=False)) | |
| 71 | 추가: | |
| 72 | 추가: | |
| 73 | 추가: if __name__ == "__main__": | |
| 74 | 추가: main() |
| @@ -0,0 +1,293 @@ | ||
| 1 | 추가: """원문 무결성과 고지 누락 시 패키지 생성 차단을 검증함.""" | |
| 2 | 추가: | |
| 3 | 추가: import hashlib | |
| 4 | 추가: import importlib.util | |
| 5 | 추가: import io | |
| 6 | 추가: import json | |
| 7 | 추가: from pathlib import Path | |
| 8 | 추가: import subprocess | |
| 9 | 추가: import tarfile | |
| 10 | 추가: import tempfile | |
| 11 | 추가: import unittest | |
| 12 | 추가: from types import SimpleNamespace | |
| 13 | 추가: from unittest.mock import patch | |
| 14 | 추가: | |
| 15 | 추가: ROOT = Path(__file__).resolve().parents[2] | |
| 16 | 추가: | |
| 17 | 추가: | |
| 18 | 추가: def load(name, path): | |
| 19 | 추가: spec = importlib.util.spec_from_file_location(name, ROOT / path) | |
| 20 | 추가: module = importlib.util.module_from_spec(spec) | |
| 21 | 추가: spec.loader.exec_module(module) | |
| 22 | 추가: return module | |
| 23 | 추가: | |
| 24 | 추가: | |
| 25 | 추가: LICENSES = load("license_tests", "packaging/licenses.py") | |
| 26 | 추가: WINDOWS = load("windows_license_tests", "packaging/windows/rust/build.py") | |
| 27 | 추가: UBUNTU = load("ubuntu_license_tests", "packaging/ubuntu/rust/build.py") | |
| 28 | 추가: | |
| 29 | 추가: | |
| 30 | 추가: class LicenseTests(unittest.TestCase): | |
| 31 | 추가: def setUp(self): | |
| 32 | 추가: runs = ROOT / "tests/release-packages/runs" | |
| 33 | 추가: runs.mkdir(parents=True, exist_ok=True) | |
| 34 | 추가: temporary = tempfile.TemporaryDirectory(dir=runs) | |
| 35 | 추가: self.addCleanup(temporary.cleanup) | |
| 36 | 추가: self.root = Path(temporary.name) | |
| 37 | 추가: self.manifest = self.root / "Cargo.toml" | |
| 38 | 추가: self.manifest.write_text("") | |
| 39 | 추가: (self.root / "LICENSE").write_text("Project fixture license\n") | |
| 40 | 추가: self.registry = self.root / "registry/src/index/sample-1.0.0" | |
| 41 | 추가: self.registry.mkdir(parents=True) | |
| 42 | 추가: self.package = { | |
| 43 | 추가: "name": "sample", "version": "1.0.0", "source": "registry+https://example.invalid/index", | |
| 44 | 추가: "license": "MIT", "license_file": None, "manifest_path": str(self.registry / "Cargo.toml"), | |
| 45 | 추가: } | |
| 46 | 추가: self.archive = self.root / "registry/cache/index/sample-1.0.0.crate" | |
| 47 | 추가: self.archive.parent.mkdir(parents=True) | |
| 48 | 추가: | |
| 49 | 추가: def fixture(self, files): | |
| 50 | 추가: with tarfile.open(self.archive, "w:gz") as archive: | |
| 51 | 추가: for relative, content in files.items(): | |
| 52 | 추가: destination = self.registry / relative | |
| 53 | 추가: destination.parent.mkdir(parents=True, exist_ok=True) | |
| 54 | 추가: destination.write_bytes(content) | |
| 55 | 추가: member = tarfile.TarInfo("sample-1.0.0/" + relative) | |
| 56 | 추가: member.size = len(content) | |
| 57 | 추가: archive.addfile(member, io.BytesIO(content)) | |
| 58 | 추가: checksum = hashlib.sha256(self.archive.read_bytes()).hexdigest() | |
| 59 | 추가: self.manifest.with_name("Cargo.lock").write_text( | |
| 60 | 추가: 'version = 4\n[[package]]\nname = "sample"\nversion = "1.0.0"\n' | |
| 61 | 추가: 'source = "registry+https://example.invalid/index"\n' + f'checksum = "{checksum}"\n' | |
| 62 | 추가: ) | |
| 63 | 추가: return {"checksum": checksum} | |
| 64 | 추가: | |
| 65 | 추가: def test_inventory_matches_metadata_and_preserves_all_texts(self): | |
| 66 | 추가: originals = {"LICENSE-MIT": b"Fixture MIT text\r\n", "data/NOTICE": b"Fixture attribution\n"} | |
| 67 | 추가: self.fixture(originals) | |
| 68 | 추가: with patch.object(LICENSES, "metadata", return_value=[self.package]): | |
| 69 | 추가: records = LICENSES.inventory([self.manifest], self.root) | |
| 70 | 추가: text = LICENSES.render(records) | |
| 71 | 추가: self.assertEqual([(r["name"], r["version"]) for r in records], [("sample", "1.0.0")]) | |
| 72 | 추가: self.assertEqual(text.count("Crate: sample 1.0.0\n"), 1) | |
| 73 | 추가: for content in originals.values(): | |
| 74 | 추가: self.assertIn(content.decode(), text) | |
| 75 | 추가: self.assertIn(hashlib.sha256(content).hexdigest(), text) | |
| 76 | 추가: | |
| 77 | 추가: def test_missing_license_prevents_output(self): | |
| 78 | 추가: self.fixture({"README.md": b"No license text in fixture"}) | |
| 79 | 추가: output = self.root / "THIRD-PARTY-LICENSES.txt" | |
| 80 | 추가: with patch.object(LICENSES, "metadata", return_value=[self.package]): | |
| 81 | 추가: with self.assertRaisesRegex(ValueError, "원문 누락 1개"): | |
| 82 | 추가: LICENSES.generate([self.manifest], output) | |
| 83 | 추가: self.assertFalse(output.exists()) | |
| 84 | 추가: | |
| 85 | 추가: def test_metadata_omission_is_not_silently_ignored(self): | |
| 86 | 추가: self.fixture({"LICENSE": b"Fixture license"}) | |
| 87 | 추가: with patch.object(LICENSES, "metadata", return_value=[]): | |
| 88 | 추가: with self.assertRaisesRegex(ValueError, "Cargo.lock/metadata 불일치"): | |
| 89 | 추가: LICENSES.inventory([self.manifest], self.root) | |
| 90 | 추가: | |
| 91 | 추가: def checkout_fixture(self, name, license_text): | |
| 92 | 추가: checkout = self.root / name | |
| 93 | 추가: crate = checkout / "experiments" / "shared" | |
| 94 | 추가: crate.mkdir(parents=True) | |
| 95 | 추가: subprocess.run(["git", "init", "-q", str(checkout)], check=True) | |
| 96 | 추가: (checkout / "LICENSE").write_text(license_text) | |
| 97 | 추가: (crate / "Cargo.toml").write_text( | |
| 98 | 추가: '[workspace]\n[package]\nname = "shared"\nversion = "1.0.0"\nlicense = "MIT"\n' | |
| 99 | 추가: ) | |
| 100 | 추가: (crate / "src").mkdir() | |
| 101 | 추가: (crate / "src/lib.rs").write_text("") | |
| 102 | 추가: (crate / "Cargo.lock").write_text( | |
| 103 | 추가: 'version = 4\n[[package]]\nname = "shared"\nversion = "1.0.0"\n' | |
| 104 | 추가: ) | |
| 105 | 추가: return crate / "Cargo.toml" | |
| 106 | 추가: | |
| 107 | 추가: def test_separate_checkouts_preserve_each_repository_license(self): | |
| 108 | 추가: app = self.checkout_fixture("app-checkout", "App copyright\n") | |
| 109 | 추가: worker = self.checkout_fixture("worker-checkout", "Worker copyright\n") | |
| 110 | 추가: records = LICENSES.inventory([app, worker]) | |
| 111 | 추가: self.assertEqual(len(records), 1) | |
| 112 | 추가: self.assertEqual( | |
| 113 | 추가: {file["text"] for file in records[0]["files"]}, | |
| 114 | 추가: {"App copyright\n", "Worker copyright\n"}, | |
| 115 | 추가: ) | |
| 116 | 추가: args = SimpleNamespace(output=self.root / "windows", target_dir=self.root / "target", | |
| 117 | 추가: profile="release", app_manifest=app, worker_manifest=worker) | |
| 118 | 추가: with patch.object(WINDOWS, "build_binary", side_effect=RuntimeError("compile reached")) as build: | |
| 119 | 추가: with self.assertRaisesRegex(RuntimeError, "compile reached"): | |
| 120 | 추가: WINDOWS.build(args) | |
| 121 | 추가: self.assertEqual(build.call_args.args[0], app) | |
| 122 | 추가: notice = (args.output / "payload/THIRD-PARTY-LICENSES.txt").read_text() | |
| 123 | 추가: self.assertIn("App copyright", notice) | |
| 124 | 추가: self.assertIn("Worker copyright", notice) | |
| 125 | 추가: | |
| 126 | 추가: def test_second_checkout_license_is_validated_before_deduplication(self): | |
| 127 | 추가: app = self.checkout_fixture("app-checkout", "App copyright\n") | |
| 128 | 추가: worker = self.checkout_fixture("worker-checkout", "Worker copyright\n") | |
| 129 | 추가: worker.write_text(worker.read_text().replace('license = "MIT"', 'license = "Apache-2.0"')) | |
| 130 | 추가: with self.assertRaisesRegex(ValueError, "프로젝트 라이선스 범위"): | |
| 131 | 추가: LICENSES.inventory([app, worker]) | |
| 132 | 추가: | |
| 133 | 추가: def test_external_path_dependency_is_not_covered_by_input_license(self): | |
| 134 | 추가: app = self.checkout_fixture("app-checkout", "App copyright\n") | |
| 135 | 추가: foreign = self.checkout_fixture("foreign-checkout", "Foreign copyright\n") | |
| 136 | 추가: package = LICENSES.metadata(app)[0] | |
| 137 | 추가: package["manifest_path"] = str(foreign) | |
| 138 | 추가: with patch.object(LICENSES, "metadata", return_value=[package]): | |
| 139 | 추가: with self.assertRaisesRegex(ValueError, "프로젝트 라이선스 범위"): | |
| 140 | 추가: LICENSES.inventory([app]) | |
| 141 | 추가: | |
| 142 | 추가: def test_each_input_lock_is_checked_before_merging(self): | |
| 143 | 추가: app = self.checkout_fixture("app-checkout", "App copyright\n") | |
| 144 | 추가: worker = self.checkout_fixture("worker-checkout", "Worker copyright\n") | |
| 145 | 추가: package = LICENSES.metadata(app)[0] | |
| 146 | 추가: with patch.object(LICENSES, "metadata", side_effect=[[package], []]): | |
| 147 | 추가: with self.assertRaisesRegex(ValueError, "Cargo.lock/metadata 불일치"): | |
| 148 | 추가: LICENSES.inventory([app, worker]) | |
| 149 | 추가: | |
| 150 | 추가: def test_modified_registry_license_is_rejected(self): | |
| 151 | 추가: locked = self.fixture({"LICENSE": b"Fixture license"}) | |
| 152 | 추가: (self.registry / "LICENSE").write_bytes(b"Modified license") | |
| 153 | 추가: with self.assertRaisesRegex(ValueError, "원문 변경"): | |
| 154 | 추가: LICENSES.registry_files(self.package, locked) | |
| 155 | 추가: | |
| 156 | 추가: def test_wrong_archive_checksum_is_rejected(self): | |
| 157 | 추가: self.fixture({"LICENSE": b"Fixture license"}) | |
| 158 | 추가: with self.assertRaisesRegex(ValueError, "체크섬 불일치"): | |
| 159 | 추가: LICENSES.registry_files(self.package, {"checksum": "0" * 64}) | |
| 160 | 추가: | |
| 161 | 추가: def test_license_file_cannot_escape_package(self): | |
| 162 | 추가: locked = self.fixture({"LICENSE": b"Fixture license"}) | |
| 163 | 추가: self.package["license_file"] = str(self.root / "LICENSE") | |
| 164 | 추가: with self.assertRaises(ValueError): | |
| 165 | 추가: LICENSES.registry_files(self.package, locked) | |
| 166 | 추가: | |
| 167 | 추가: def test_metadata_command_is_locked_and_offline(self): | |
| 168 | 추가: with patch.object(LICENSES.subprocess, "run", return_value=subprocess.CompletedProcess([], 0, '{"packages": []}')) as run: | |
| 169 | 추가: self.assertEqual(LICENSES.metadata(self.manifest), []) | |
| 170 | 추가: command = run.call_args.args[0] | |
| 171 | 추가: self.assertIn("--locked", command) | |
| 172 | 추가: self.assertIn("--offline", command) | |
| 173 | 추가: self.assertIn("--all-features", command) | |
| 174 | 추가: | |
| 175 | 추가: def supplement_fixture(self, license="MIT", revision="a" * 40): | |
| 176 | 추가: self.fixture({".cargo_vcs_info.json": json.dumps({"git": {"sha1": "a" * 40}}).encode(), | |
| 177 | 추가: "Cargo.toml": b'[package]\nname = "sample"\nversion = "1.0.0"\nauthors = ["Fixture author"]\n'}) | |
| 178 | 추가: url = "https://raw.githubusercontent.com/example/sample/" + revision + "/LICENSE" | |
| 179 | 추가: original = "Fixture permission text\\r\\n" | |
| 180 | 추가: data = {"packages": [{"name": "sample", "version": "1.0.0", "license": license, | |
| 181 | 추가: "rev": revision, "upstream_ref": revision, "files": [url]}], | |
| 182 | 추가: "files": {url: {"url": url, "text": original, | |
| 183 | 추가: "sha256": hashlib.sha256(original.encode()).hexdigest()}}} | |
| 184 | 추가: path = self.root / "supplements.json" | |
| 185 | 추가: path.write_text(json.dumps(data)) | |
| 186 | 추가: return path, data, url | |
| 187 | 추가: | |
| 188 | 추가: def test_supplement_preserves_fixed_source_and_original(self): | |
| 189 | 추가: path, data, url = self.supplement_fixture() | |
| 190 | 추가: records = LICENSES.supplemental_files(self.package, path) | |
| 191 | 추가: self.assertEqual(records[0]["path"], url) | |
| 192 | 추가: self.assertEqual(records[0]["text"], data["files"][url]["text"]) | |
| 193 | 추가: | |
| 194 | 추가: def test_supplement_spdx_must_match_metadata(self): | |
| 195 | 추가: path, _, _ = self.supplement_fixture(license="Apache-2.0") | |
| 196 | 추가: with self.assertRaisesRegex(ValueError, "SPDX 불일치"): | |
| 197 | 추가: LICENSES.supplemental_files(self.package, path) | |
| 198 | 추가: | |
| 199 | 추가: def test_supplement_revision_must_match_published_crate(self): | |
| 200 | 추가: path, _, _ = self.supplement_fixture(revision="b" * 40) | |
| 201 | 추가: with self.assertRaisesRegex(ValueError, "커밋 불일치"): | |
| 202 | 추가: LICENSES.supplemental_files(self.package, path) | |
| 203 | 추가: | |
| 204 | 추가: def test_supplement_content_hash_is_verified(self): | |
| 205 | 추가: path, data, url = self.supplement_fixture() | |
| 206 | 추가: data["files"][url]["text"] += "changed" | |
| 207 | 추가: path.write_text(json.dumps(data)) | |
| 208 | 추가: with self.assertRaisesRegex(ValueError, "해시 불일치"): | |
| 209 | 추가: LICENSES.supplemental_files(self.package, path) | |
| 210 | 추가: | |
| 211 | 추가: def test_supplement_requires_fixed_upstream_url(self): | |
| 212 | 추가: path, data, _ = self.supplement_fixture() | |
| 213 | 추가: data["packages"][0]["upstream_ref"] = "main" | |
| 214 | 추가: path.write_text(json.dumps(data)) | |
| 215 | 추가: with self.assertRaisesRegex(ValueError, "출처 고정 오류"): | |
| 216 | 추가: LICENSES.supplemental_files(self.package, path) | |
| 217 | 추가: | |
| 218 | 추가: def test_real_supplement_spdx_matches_offline_metadata(self): | |
| 219 | 추가: manifests = [ROOT / "experiments" / crate / "Cargo.toml" | |
| 220 | 추가: for crate in ["rust-ui-memory-app", "rust-archive-worker"]] | |
| 221 | 추가: records = LICENSES.inventory(manifests) | |
| 222 | 추가: declared = {LICENSES.identity(p): p["license"] | |
| 223 | 추가: for manifest in manifests for p in LICENSES.metadata(manifest)} | |
| 224 | 추가: self.assertEqual({(r["name"], r["version"], r["source"]): r["license"] | |
| 225 | 추가: for r in records}, declared) | |
| 226 | 추가: supplement = json.loads((ROOT / "packaging/license-supplements.json").read_text()) | |
| 227 | 추가: for row in supplement["packages"]: | |
| 228 | 추가: matches = [r for r in records if (r["name"], r["version"]) == (row["name"], row["version"])] | |
| 229 | 추가: self.assertEqual(len(matches), 1) | |
| 230 | 추가: self.assertEqual(matches[0]["license"], row["license"]) | |
| 231 | 추가: self.assertTrue(matches[0]["files"]) | |
| 232 | 추가: | |
| 233 | 추가: def standard_fixture(self): | |
| 234 | 추가: path, data, _ = self.supplement_fixture() | |
| 235 | 추가: source = "crate:sample-1.0.0/Cargo.toml" | |
| 236 | 추가: content = (self.registry / "Cargo.toml").read_text() | |
| 237 | 추가: url = "https://raw.githubusercontent.com/spdx/license-list-data/v3.26.0/text/MIT.txt" | |
| 238 | 추가: data["standards"] = {"MIT": url} | |
| 239 | 추가: for location, text in [(source, content), (url, "Fixture standard MIT text")]: | |
| 240 | 추가: data["files"][location] = {"url": location, "text": text, | |
| 241 | 추가: "sha256": hashlib.sha256(text.encode()).hexdigest()} | |
| 242 | 추가: data["packages"][0].update(standard_license="MIT", attribution_source=source, | |
| 243 | 추가: authors=["Fixture author"]) | |
| 244 | 추가: path.write_text(json.dumps(data)) | |
| 245 | 추가: return path, data | |
| 246 | 추가: | |
| 247 | 추가: def test_standard_supplement_records_authors_source_and_reason(self): | |
| 248 | 추가: path, _ = self.standard_fixture() | |
| 249 | 추가: files = LICENSES.supplemental_files(self.package, path) | |
| 250 | 추가: self.assertIn("upstream에 원문이 없어 표준 원문으로 보충함", files[0]["note"]) | |
| 251 | 추가: self.assertIn("Fixture author", files[0]["note"]) | |
| 252 | 추가: self.assertIn("crate:sample-1.0.0/Cargo.toml", files[0]["note"]) | |
| 253 | 추가: | |
| 254 | 추가: def test_standard_supplement_rejects_wrong_license_choice(self): | |
| 255 | 추가: path, data = self.standard_fixture() | |
| 256 | 추가: data["packages"][0]["standard_license"] = "Apache-2.0" | |
| 257 | 추가: path.write_text(json.dumps(data)) | |
| 258 | 추가: with self.assertRaisesRegex(ValueError, "SPDX 선택 불일치"): | |
| 259 | 추가: LICENSES.supplemental_files(self.package, path) | |
| 260 | 추가: | |
| 261 | 추가: def test_standard_supplement_rejects_changed_attribution(self): | |
| 262 | 추가: path, data = self.standard_fixture() | |
| 263 | 추가: data["packages"][0]["authors"] = ["Invented author"] | |
| 264 | 추가: path.write_text(json.dumps(data)) | |
| 265 | 추가: with self.assertRaisesRegex(ValueError, "저자 고지 불일치"): | |
| 266 | 추가: LICENSES.supplemental_files(self.package, path) | |
| 267 | 추가: | |
| 268 | 추가: def test_complete_notice_has_zero_omissions_against_metadata(self): | |
| 269 | 추가: manifests = [ROOT / "experiments" / crate / "Cargo.toml" | |
| 270 | 추가: for crate in ["rust-ui-memory-app", "rust-archive-worker"]] | |
| 271 | 추가: records = LICENSES.inventory(manifests) | |
| 272 | 추가: expected = {LICENSES.identity(p) for manifest in manifests for p in LICENSES.metadata(manifest)} | |
| 273 | 추가: self.assertEqual({(r["name"], r["version"], r["source"]) for r in records}, expected) | |
| 274 | 추가: text = LICENSES.render(records) | |
| 275 | 추가: self.assertEqual(text.count("\nCrate: "), len(expected)) | |
| 276 | 추가: self.assertTrue(all(r["files"] for r in records)) | |
| 277 | 추가: self.assertEqual(text.count("upstream에 원문이 없어 표준 원문으로 보충함"), 12) | |
| 278 | 추가: | |
| 279 | 추가: def test_both_packagers_stop_before_build_on_missing_licenses(self): | |
| 280 | 추가: for builder, binaries in [(WINDOWS, WINDOWS), (UBUNTU, UBUNTU.WINDOWS)]: | |
| 281 | 추가: with self.subTest(builder=builder.__name__): | |
| 282 | 추가: output = self.root / builder.__name__ | |
| 283 | 추가: args = SimpleNamespace(output=output, target_dir=self.root / "target", profile="release", | |
| 284 | 추가: app_manifest=self.manifest, worker_manifest=self.manifest) | |
| 285 | 추가: with patch.object(binaries.LICENSES, "generate", side_effect=ValueError("원문 누락")): | |
| 286 | 추가: with patch.object(binaries, "build_binary") as build_binary: | |
| 287 | 추가: with self.assertRaisesRegex(ValueError, "원문 누락"): | |
| 288 | 추가: builder.build(args) | |
| 289 | 추가: build_binary.assert_not_called() | |
| 290 | 추가: | |
| 291 | 추가: | |
| 292 | 추가: if __name__ == "__main__": | |
| 293 | 추가: unittest.main() |
| @@ -99,5 +99,71 @@ | ||
| 99 | 99 | "tests/release-packages/runs/lifecycle-regression.log", |
| 100 | 100 | "tests/release-packages/runs/local-lifecycle.log" |
| 101 | 101 | ] |
| 102 | 추가: }, | |
| 103 | 추가: "third_party_licenses": { | |
| 104 | 추가: "status": "passed", | |
| 105 | 추가: "base_remote_main": "8bfa25456b936346b4f1808233afb4551e769718", | |
| 106 | 추가: "tested_source_local_commit": "6e0cfdb2ce00acc0b703c29a078234066493ed91", | |
| 107 | 추가: "tested_code_tree": "f29a148a8b6ef035f90140d143fa0e4f80b5eea5", | |
| 108 | 추가: "metadata_locked_crates": 403, | |
| 109 | 추가: "metadata_lock_mismatches": 0, | |
| 110 | 추가: "missing_originals": [], | |
| 111 | 추가: "source_counts": { | |
| 112 | 추가: "upstream_supplement": 46, | |
| 113 | 추가: "registry": 339, | |
| 114 | 추가: "standard_supplement": 12, | |
| 115 | 추가: "workspace": 6 | |
| 116 | 추가: }, | |
| 117 | 추가: "notice_source_files": 745, | |
| 118 | 추가: "supplement_catalog_sha256": "519f306f6d7affe127b762d82df99ca025ffcbb5a5db628884112e4b88c73084", | |
| 119 | 추가: "source_policy": "로컬 registry와 잠금 .crate를 대조함. 누락 46개는 해당 버전 공식 upstream 원문을 사용함. upstream에도 원문이 없는 승인된 12개는 SPDX MIT 표준 원문과 버전별 Cargo.toml 저자 고지를 출처 및 해시와 함께 표시함. 생성 단계는 오프라인임.", | |
| 120 | 추가: "unit_command": "python3 -m unittest discover -s tests/release-packages -p \"test_*.py\" -v", | |
| 121 | 추가: "package_unit_tests_passed": 25, | |
| 122 | 추가: "license_tests_passed": 18, | |
| 123 | 추가: "local_command": "python3 tests/ci/run_rust.py local", | |
| 124 | 추가: "local_exit_code": 0, | |
| 125 | 추가: "rust_tests_passed": 953, | |
| 126 | 추가: "runner_tests_passed": 34, | |
| 127 | 추가: "local_phase_counts": { | |
| 128 | 추가: "build": 21, | |
| 129 | 추가: "test": 21, | |
| 130 | 추가: "cross-build": 21 | |
| 131 | 추가: }, | |
| 132 | 추가: "windows_builder_exit_code": 0, | |
| 133 | 추가: "ubuntu_builder_exit_code": 0, | |
| 134 | 추가: "package_profile": "release", | |
| 135 | 추가: "final_packages_created": true, | |
| 136 | 추가: "package_contents_verified": true, | |
| 137 | 추가: "verification": "NSIS 설치 EXE와 .deb 내부에서 고지를 읽어 생성 원문과 바이트 단위로 대조함. metadata/잠금 목록과 고지 항목 누락 0개 및 중복 없음.", | |
| 138 | 추가: "package_contents": { | |
| 139 | 추가: "crates": 403, | |
| 140 | 추가: "missing": 0, | |
| 141 | 추가: "notice_sha256": "69c07f1cf2943b28931834c7a97fd201b6fbfd56bc623b22c78d7880b0e0f096", | |
| 142 | 추가: "notice_bytes": 3847431, | |
| 143 | 추가: "standard_supplements": 12, | |
| 144 | 추가: "packages": { | |
| 145 | 추가: "windows": { | |
| 146 | 추가: "path": "tests/release-packages/runs/licenses/windows-final/Zipelo-0.1.0-dev-windows-x64-setup.exe", | |
| 147 | 추가: "sha256": "e3fc9a259c13aadcc399263bb844a989b4d493456505590109dc2a4c12678e9e", | |
| 148 | 추가: "bytes": 7523507 | |
| 149 | 추가: }, | |
| 150 | 추가: "ubuntu": { | |
| 151 | 추가: "path": "tests/release-packages/runs/licenses/ubuntu-final/zipelo_0.1.0~dev1_amd64.deb", | |
| 152 | 추가: "sha256": "19014ebafac2e9d4dbf5ec6cc9f54c21f82484d1dfdb7c182c5923b512829be2", | |
| 153 | 추가: "bytes": 5015432 | |
| 154 | 추가: } | |
| 155 | 추가: } | |
| 156 | 추가: }, | |
| 157 | 추가: "windows_runtime_tested": false, | |
| 158 | 추가: "ubuntu_installation_tested": false, | |
| 159 | 추가: "release_published": false, | |
| 160 | 추가: "local_logs": [ | |
| 161 | 추가: "tests/release-packages/runs/licenses/final-unit.log", | |
| 162 | 추가: "tests/release-packages/runs/licenses/final-local.log", | |
| 163 | 추가: "tests/release-packages/runs/licenses/windows-final.log", | |
| 164 | 추가: "tests/release-packages/runs/licenses/ubuntu-final.log", | |
| 165 | 추가: "tests/release-packages/runs/licenses/package-contents.json" | |
| 166 | 추가: ], | |
| 167 | 추가: "evidence_note": "코드와 패키지 검증을 완료한 뒤 이 검증 JSON만 갱신함. 실제 설치와 별도 법적 준수 심사는 이번 범위가 아님." | |
| 102 | 168 | } |
| 103 | 169 | } |