Improve VPN video routing, profile storage and authorization reuse
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Remove reproducible workspace artifacts, keeping tools, profiles and packages."""
|
||||
import argparse
|
||||
from pathlib import Path
|
||||
import shutil
|
||||
import subprocess
|
||||
|
||||
root = Path(__file__).resolve().parents[1]
|
||||
paths = [
|
||||
"target",
|
||||
"apps/meshport_lab/build",
|
||||
"apps/meshport_lab/.dart_tool",
|
||||
"apps/meshport_lab/android/.gradle",
|
||||
"apps/meshport_lab/android/.kotlin",
|
||||
"apps/meshport_lab/android/app/src/main/jniLibs",
|
||||
"work/cache",
|
||||
"work/bin",
|
||||
"work/android-validation",
|
||||
"work/ui-preview",
|
||||
"work/menubar-preview",
|
||||
"work/menubar-native-tests.xcresult",
|
||||
"work/menubar-native-tests-2.xcresult",
|
||||
"work/menubar-native-tests-3.xcresult",
|
||||
"work/video-tcp-core",
|
||||
"work/singbox-patched",
|
||||
"work/singbox-patched.go.mod",
|
||||
"work/singbox-patched.go.sum",
|
||||
"work/easytier-upstream.tar.gz",
|
||||
"work/toolchain/go-sdk.tar.gz",
|
||||
"work/toolchain/protoc.zip",
|
||||
"work/toolchain/rustup-init.sh",
|
||||
]
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument("--delete", action="store_true", help="Actually delete; default only lists paths")
|
||||
args = parser.parse_args()
|
||||
repository = subprocess.check_output(["git", "rev-parse", "--show-toplevel"], cwd=root, text=True).strip()
|
||||
if Path(repository).resolve() != root:
|
||||
raise SystemExit("Refusing cleanup outside the repository root")
|
||||
tracked = subprocess.check_output(["git", "ls-files", "-z", "--", *paths], cwd=root)
|
||||
if tracked:
|
||||
raise SystemExit("Refusing to remove tracked files under a cleanup path")
|
||||
# Check every parent before deleting anything. Leaf symlinks are unlinked only.
|
||||
for relative in paths:
|
||||
if not (root / relative).parent.resolve().is_relative_to(root):
|
||||
raise SystemExit(f"Refusing path with an external parent: {relative}")
|
||||
for relative in paths:
|
||||
path = root / relative
|
||||
if not path.exists() and not path.is_symlink():
|
||||
continue
|
||||
print(("Removing " if args.delete else "Would remove ") + relative, flush=True)
|
||||
if args.delete:
|
||||
if path.is_symlink() or path.is_file():
|
||||
path.unlink()
|
||||
else:
|
||||
shutil.rmtree(path)
|
||||
print("Kept toolchains, user configuration, Git history and outputs/android + outputs/macos")
|
||||
Reference in New Issue
Block a user