feat: support cleaning without removing artifacts

Signed-off-by: sisungo <[email protected]>
This commit is contained in:
2026-07-08 18:57:44 +08:00
parent 4f4ec0468a
commit e567c27db8
2 changed files with 21 additions and 5 deletions
+20 -4
View File
@@ -29,6 +29,7 @@ parser_build.add_argument("BUILD_PKGNAME")
parser_clean = subparsers.add_parser("clean")
parser_clean.add_argument("CLEAN_PKGNAME", nargs="*")
parser_clean.add_argument("--all", action="store_true")
parser_clean.add_argument("--no-artifacts", action="store_true")
parser_list = subparsers.add_parser("list")
parser_list.add_argument("ITEM", choices=("all", "built", "new"))
parser_repo_push = subparsers.add_parser("repo-push")
@@ -132,10 +133,21 @@ def cmd_build_package(package: str):
def cmd_clean_package(package: list[str]):
for i in package:
try:
shutil.rmtree(f"packages/{i}/target")
except Exception:
pass
targetdir = f"packages/{i}/target"
if not os.path.exists(targetdir):
continue
if args.no_artifacts:
for file in os.listdir(targetdir):
path = f"{targetdir}/{file}"
if file.endswith(".pkg") or file == "build-ok.tag":
continue
if os.path.isfile(path) or os.path.islink(path):
os.remove(path)
else:
shutil.rmtree(path)
else:
shutil.rmtree(targetdir)
def do_list(item: str):
@@ -204,6 +216,10 @@ def cmd_build_atom(pkgname: str):
except Exception:
pass
# Build success
with open(f"{target_dir}/build-ok.tag", "wt+") as file:
file.write("OK")
def cmd_repo_push(repo_dir: str, pkgname: list[str]):
for pkg in pkgname: