This commit is contained in:
hashbro
2026-08-05 05:42:10 +08:00
parent d4fb538997
commit 22942f1a78
19 changed files with 986 additions and 164 deletions
+39 -10
View File
@@ -13,7 +13,9 @@ MODULE_HUNT = ONLINE_ROOT / "module_hunt"
if str(MODULE_HUNT) not in sys.path:
sys.path.insert(0, str(MODULE_HUNT))
CAMPAIGN_HASH = "34f5121f572d6742703eb84ec2f866a6"
# Campaign / channel id embedded in type-0x01 (also source/web/<id>/ dirname).
ORIGINAL_CHANNEL_ID = "34f5121f572d6742703eb84ec2f866a6"
CAMPAIGN_HASH = ORIGINAL_CHANNEL_ID # active campaign id (may be overridden)
# Campaign originals (current seeds embedded in type-0x01 + core)
ORIGINAL_DEPLOYMENT_SEED = "09d0b8d58a71653cd1c89c64c866f2e6"
@@ -27,6 +29,7 @@ OLD_REP = ORIGINAL_REPORTING_SEED.encode("ascii")
_TREE_ROOT = SOURCE_ROOT
CAMPAIGN_DIR = _TREE_ROOT / "web" / CAMPAIGN_HASH
SYNC_DIR = _TREE_ROOT / "sync"
SOURCE_CAMPAIGN_DIR = SOURCE_ROOT / "web" / ORIGINAL_CHANNEL_ID
C2_FETCH = ONLINE_ROOT / "c2_fetch"
CORE_DYLIB = (
@@ -53,25 +56,51 @@ def tree_root() -> Path:
return _TREE_ROOT
def set_tree_root(root: Path) -> Path:
"""Point CAMPAIGN_DIR / SYNC_DIR at root/web/... and root/sync."""
def campaign_id() -> str:
return CAMPAIGN_HASH
def set_campaign_id(channel: str) -> str:
"""Point CAMPAIGN_DIR at web/<channel>/ under the current tree root."""
global CAMPAIGN_HASH, CAMPAIGN_DIR
from _channel_patch import validate_channel_id
CAMPAIGN_HASH = validate_channel_id(channel, name="channel id")
CAMPAIGN_DIR = _TREE_ROOT / "web" / CAMPAIGN_HASH
return CAMPAIGN_HASH
def set_tree_root(root: Path, *, channel: str | None = None) -> Path:
"""Point CAMPAIGN_DIR / SYNC_DIR at root/web/<channel>/ and root/sync."""
global _TREE_ROOT, CAMPAIGN_DIR, SYNC_DIR
root = root.resolve()
_TREE_ROOT = root
CAMPAIGN_DIR = root / "web" / CAMPAIGN_HASH
if channel is not None:
set_campaign_id(channel)
else:
CAMPAIGN_DIR = root / "web" / CAMPAIGN_HASH
SYNC_DIR = root / "sync"
return root
def ensure_tree_layout(root: Path) -> None:
camp = root / "web" / CAMPAIGN_HASH
def ensure_tree_layout(
root: Path,
*,
channel: str | None = None,
require_campaign: bool = True,
) -> None:
cid = channel or CAMPAIGN_HASH
camp = root / "web" / cid
sync = root / "sync"
if not camp.is_dir() or not sync.is_dir():
missing = []
if require_campaign and not camp.is_dir():
missing.append(f"web/{cid}/")
if not sync.is_dir():
missing.append("sync/")
if missing:
raise SystemExit(
f"missing working tree under {root} (need web/{CAMPAIGN_HASH}/ and sync/).\n"
f"missing working tree under {root} (need {', '.join(missing)}).\n"
f"Run first:\n"
f" python3 tools/new_project.py --skip-patch\n"
f"or directly:\n"
f" python3 tools/new_project.py --deployment-domains '...' --reporting-domains '...'"
)