Merge pull request 'feat: support cleaning without removing artifacts' (#114) from sisungo/semios-packages:clean-no-artifacts into master

Reviewed-on: semios/semios-packages#114
This commit is contained in:
2026-07-08 20:19:26 +08:00
2 changed files with 21 additions and 5 deletions
+1 -1
View File
@@ -20,7 +20,7 @@ def build():
shutil.rmtree("../cpp_install")
except Exception:
pass
cpp.make_install(["PREFIX=../cpp_install" + makevars], chdir=False)
cpp.make_install(["PREFIX=../cpp_install"] + makevars, chdir=False)
shutil.copy2(
f"libbz2.so.{upstream_version}",
f"../cpp_install/lib/libbz2.so.{upstream_version}",
+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: