93 lines
3.2 KiB
Bash
Executable File
93 lines
3.2 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
|
cd "$ROOT"
|
|
python3 - <<'PY'
|
|
from pathlib import Path
|
|
import subprocess, zipfile, fnmatch, os
|
|
|
|
root = Path.cwd()
|
|
submit = root / 'submit'
|
|
submit.mkdir(exist_ok=True)
|
|
|
|
source_zip = submit / 'source_code_oh-mcpstack.zip'
|
|
evidence_zip = submit / 'evidence_reports.zip'
|
|
submit_zip = submit / 'OH-MCPStack_final_submit.zip'
|
|
ascii_zip = submit / 'OH-MCPStack_final_submit_ascii.zip'
|
|
|
|
for p in [source_zip, evidence_zip, submit_zip, ascii_zip]:
|
|
if p.exists():
|
|
p.unlink()
|
|
|
|
# 1) Clean source archive from git tracked files only.
|
|
tracked = subprocess.check_output(['git', 'ls-files'], text=True).splitlines()
|
|
exclude_patterns = [
|
|
'submit/*.zip', 'submit/*.mp4', 'submit/*.pdf',
|
|
'scripts/video_workflow/*', 'local_tts/*', 'local_video/*',
|
|
'*.mp3', '*.aiff',
|
|
'.DS_Store', '*/.DS_Store',
|
|
'*__pycache__*', '*.pyc',
|
|
]
|
|
|
|
def excluded(path: str) -> bool:
|
|
return any(fnmatch.fnmatch(path, pat) for pat in exclude_patterns)
|
|
|
|
with zipfile.ZipFile(source_zip, 'w', zipfile.ZIP_DEFLATED) as z:
|
|
for rel in tracked:
|
|
if excluded(rel):
|
|
continue
|
|
p = root / rel
|
|
if p.is_file():
|
|
z.write(p, rel)
|
|
|
|
# 2) Evidence archive: selected raw reports and server build logs.
|
|
report_patterns = [
|
|
'reports/*.json', 'reports/*.csv', 'reports/*.prom', 'reports/*.ndjson',
|
|
'reports/server/*.log',
|
|
'reports/edge_docker/**/*.json', 'reports/edge_docker/**/*.ndjson',
|
|
'reports/trip_demo/*.json',
|
|
'reports/latest/*.json',
|
|
]
|
|
seen = set()
|
|
with zipfile.ZipFile(evidence_zip, 'w', zipfile.ZIP_DEFLATED) as z:
|
|
for pat in report_patterns:
|
|
for p in root.glob(pat):
|
|
if not p.is_file():
|
|
continue
|
|
rel = p.relative_to(root).as_posix()
|
|
if rel in seen or rel.endswith('.pid'):
|
|
continue
|
|
seen.add(rel)
|
|
z.write(p, rel)
|
|
|
|
# 3) Full submit package with Chinese filenames.
|
|
submit_files = [p for p in submit.iterdir() if p.is_file() and p.name != '.DS_Store']
|
|
with zipfile.ZipFile(submit_zip, 'w', zipfile.ZIP_DEFLATED) as z:
|
|
for p in sorted(submit_files, key=lambda x: x.name):
|
|
if p.name == submit_zip.name or p.name == ascii_zip.name:
|
|
continue
|
|
z.write(p, f'submit/{p.name}')
|
|
|
|
# 4) ASCII-compatible package for upload systems with filename encoding issues.
|
|
ascii_map = {
|
|
'00_提交文件清单.md': '00_manifest.md',
|
|
'01_方案设计文档.md': '01_design.md',
|
|
'02_测试报告.md': '02_test_report.md',
|
|
'03_部署复现说明.md': '03_reproduce.md',
|
|
'04_作品展示PPT.pptx': '04_presentation.pptx',
|
|
'04_作品展示PPT_大纲.md': '04_presentation_outline.md',
|
|
'06_源码仓库链接.txt': '06_repository_links.txt',
|
|
'README_提交说明.md': 'README_submit.md',
|
|
'source_code_oh-mcpstack.zip': 'source_code_oh-mcpstack.zip',
|
|
'evidence_reports.zip': 'evidence_reports.zip',
|
|
}
|
|
with zipfile.ZipFile(ascii_zip, 'w', zipfile.ZIP_DEFLATED) as z:
|
|
for zh, ascii_name in ascii_map.items():
|
|
p = submit / zh
|
|
if p.exists() and p.is_file():
|
|
z.write(p, f'submit/{ascii_name}')
|
|
|
|
for p in [source_zip, evidence_zip, submit_zip, ascii_zip]:
|
|
print(f'{p}: {p.stat().st_size/1024:.1f} KiB')
|
|
PY
|