build: stage immutable release files without duplicate copies
This commit is contained in:
1 parent
5aeddacfc9
commit
1340f6c233
3 files changed
+19
-2
No files matched your search
@@ -14,7 +14,7 @@ Extract the installer with an existing 7-Zip tool into a build-only directory. N
|
||||
python tools/build_self_extracting_release.py --source-dir dist/DxPartReplace --output-dir G:/dx-release-1.2.2 --version 1.2.2 --seven-zip build/7zip-2605/full/7z.exe --sfx-stub build/7zip-2605/full/7z.sfx --license build/7zip-2605/full/License.txt
|
||||
```
|
||||
|
||||
Use a fresh output directory. The tool rejects an existing directory, overlapping input/output paths and an application input containing `data`. It copies the complete input, includes the 7-Zip license, produces EXE + ZIP, and writes artifact and per-file SHA256 hashes. LZMA2 level 3 and bounded solid blocks keep decoding memory modest; tiny files still incur filesystem costs, so do not promise a fixed speedup across machines.
|
||||
Use a fresh output directory and keep the completed build input unchanged during packaging. The tool rejects an existing directory, overlapping input/output paths and an application input containing `data`. It stages the complete input using same-volume hardlinks (copying when links are unavailable), includes the 7-Zip license, produces independent EXE + ZIP archives, and writes artifact and per-file SHA256 hashes. LZMA2 level 3 and bounded solid blocks keep decoding memory modest; tiny files still incur filesystem costs, so do not promise a fixed speedup across machines.
|
||||
|
||||
Before publishing, run the self-extracting EXE itself with `-y -o<fresh directory>`, compare every resulting file and every ZIP member against the manifest, and run `tools/verify_packaged_runtime.py` and Qt/DSH UI acceptance on that extracted EXE. Neither merely listing the archive nor the source UI tests replaces this check.
|
||||
|
||||
|
||||
@@ -57,9 +57,13 @@ def test_actual_sfx_and_zip_extract_identical_unicode_and_empty_files(tmp_path):
|
||||
(source / '中文 目录').mkdir()
|
||||
(source / '中文 目录' / '空.txt').write_bytes(b'')
|
||||
(source / '中文 目录' / 'file.bin').write_bytes(bytes(range(256)) * 2048)
|
||||
(source / 'licenses').mkdir()
|
||||
original_license=source/'licenses'/'7-Zip-LICENSE.txt'
|
||||
original_license.write_text('original input must remain unchanged')
|
||||
output = tmp_path / 'release'
|
||||
manifest = build_release(source, output, version='1.2.2', seven_zip=tools/'7z.exe',
|
||||
sfx_stub=tools/'7z.sfx', license_path=tools/'License.txt')
|
||||
assert original_license.read_text() == 'original input must remain unchanged'
|
||||
destination = tmp_path / '解压 结果'
|
||||
result = verify(output/'release-manifest-1.2.2.json', destination)
|
||||
assert result['passed'] and result['files'] == 4
|
||||
|
||||
@@ -5,6 +5,7 @@ from __future__ import annotations
|
||||
import argparse
|
||||
import hashlib
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
from pathlib import Path
|
||||
import shutil
|
||||
@@ -32,6 +33,16 @@ def _zip_tree(source: Path, output: Path) -> int:
|
||||
return files
|
||||
|
||||
|
||||
def _stage_file(source, destination):
|
||||
# Release input is immutable during packaging. Same-volume links avoid a
|
||||
# second copy of tens of thousands of runtime files; archives are independent.
|
||||
try:
|
||||
os.link(source, destination)
|
||||
except OSError:
|
||||
shutil.copyfile(source, destination)
|
||||
return destination
|
||||
|
||||
|
||||
def build_release(source_dir: Path, output_dir: Path, *, version: str, seven_zip: Path, sfx_stub: Path,
|
||||
license_path: Path | None = None) -> dict:
|
||||
source_dir = Path(source_dir).resolve(strict=True)
|
||||
@@ -49,10 +60,12 @@ def build_release(source_dir: Path, output_dir: Path, *, version: str, seven_zip
|
||||
output_dir.mkdir(parents=True, exist_ok=False)
|
||||
|
||||
staging = output_dir / "staging" / "DxPartReplace"
|
||||
shutil.copytree(source_dir, staging)
|
||||
shutil.copytree(source_dir, staging, copy_function=_stage_file)
|
||||
if license_path is not None:
|
||||
license_target = staging / "licenses" / "7-Zip-LICENSE.txt"
|
||||
license_target.parent.mkdir(parents=True, exist_ok=True)
|
||||
# Break a possible staging hardlink before replacing a pre-existing notice.
|
||||
license_target.unlink(missing_ok=True)
|
||||
shutil.copyfile(Path(license_path).resolve(strict=True), license_target)
|
||||
|
||||
archive_7z = output_dir / f"DxPartReplace-{version}.7z"
|
||||
|
||||
Reference in new issue
Block a user