pkgmgr-kunrunic 0.1.1.dev9__tar.gz → 0.1.2.dev0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pkgmgr_kunrunic-0.1.1.dev9/pkgmgr_kunrunic.egg-info → pkgmgr_kunrunic-0.1.2.dev0}/PKG-INFO +1 -1
- {pkgmgr_kunrunic-0.1.1.dev9 → pkgmgr_kunrunic-0.1.2.dev0}/pkgmgr/__init__.py +1 -1
- {pkgmgr_kunrunic-0.1.1.dev9 → pkgmgr_kunrunic-0.1.2.dev0}/pkgmgr/cli.py +97 -3
- {pkgmgr_kunrunic-0.1.1.dev9 → pkgmgr_kunrunic-0.1.2.dev0}/pkgmgr/config.py +2 -0
- {pkgmgr_kunrunic-0.1.1.dev9 → pkgmgr_kunrunic-0.1.2.dev0}/pkgmgr/release.py +264 -11
- {pkgmgr_kunrunic-0.1.1.dev9 → pkgmgr_kunrunic-0.1.2.dev0}/pkgmgr/templates/pkgmgr.yaml.sample +7 -0
- {pkgmgr_kunrunic-0.1.1.dev9 → pkgmgr_kunrunic-0.1.2.dev0/pkgmgr_kunrunic.egg-info}/PKG-INFO +1 -1
- {pkgmgr_kunrunic-0.1.1.dev9 → pkgmgr_kunrunic-0.1.2.dev0}/plugin/export_pkgstore.py +35 -8
- {pkgmgr_kunrunic-0.1.1.dev9 → pkgmgr_kunrunic-0.1.2.dev0}/LICENSE +0 -0
- {pkgmgr_kunrunic-0.1.1.dev9 → pkgmgr_kunrunic-0.1.2.dev0}/README.md +0 -0
- {pkgmgr_kunrunic-0.1.1.dev9 → pkgmgr_kunrunic-0.1.2.dev0}/pkgmgr/__main__.py +0 -0
- {pkgmgr_kunrunic-0.1.1.dev9 → pkgmgr_kunrunic-0.1.2.dev0}/pkgmgr/collectors/__init__.py +0 -0
- {pkgmgr_kunrunic-0.1.1.dev9 → pkgmgr_kunrunic-0.1.2.dev0}/pkgmgr/collectors/base.py +0 -0
- {pkgmgr_kunrunic-0.1.1.dev9 → pkgmgr_kunrunic-0.1.2.dev0}/pkgmgr/collectors/checksums.py +0 -0
- {pkgmgr_kunrunic-0.1.1.dev9 → pkgmgr_kunrunic-0.1.2.dev0}/pkgmgr/points.py +0 -0
- {pkgmgr_kunrunic-0.1.1.dev9 → pkgmgr_kunrunic-0.1.2.dev0}/pkgmgr/shell_integration.py +0 -0
- {pkgmgr_kunrunic-0.1.1.dev9 → pkgmgr_kunrunic-0.1.2.dev0}/pkgmgr/snapshot.py +0 -0
- {pkgmgr_kunrunic-0.1.1.dev9 → pkgmgr_kunrunic-0.1.2.dev0}/pkgmgr/templates/pkg.yaml.sample +0 -0
- {pkgmgr_kunrunic-0.1.1.dev9 → pkgmgr_kunrunic-0.1.2.dev0}/pkgmgr/watch.py +0 -0
- {pkgmgr_kunrunic-0.1.1.dev9 → pkgmgr_kunrunic-0.1.2.dev0}/pkgmgr_kunrunic.egg-info/SOURCES.txt +0 -0
- {pkgmgr_kunrunic-0.1.1.dev9 → pkgmgr_kunrunic-0.1.2.dev0}/pkgmgr_kunrunic.egg-info/dependency_links.txt +0 -0
- {pkgmgr_kunrunic-0.1.1.dev9 → pkgmgr_kunrunic-0.1.2.dev0}/pkgmgr_kunrunic.egg-info/entry_points.txt +0 -0
- {pkgmgr_kunrunic-0.1.1.dev9 → pkgmgr_kunrunic-0.1.2.dev0}/pkgmgr_kunrunic.egg-info/not-zip-safe +0 -0
- {pkgmgr_kunrunic-0.1.1.dev9 → pkgmgr_kunrunic-0.1.2.dev0}/pkgmgr_kunrunic.egg-info/requires.txt +0 -0
- {pkgmgr_kunrunic-0.1.1.dev9 → pkgmgr_kunrunic-0.1.2.dev0}/pkgmgr_kunrunic.egg-info/top_level.txt +0 -0
- {pkgmgr_kunrunic-0.1.1.dev9 → pkgmgr_kunrunic-0.1.2.dev0}/plugin/export_cksum.py +0 -0
- {pkgmgr_kunrunic-0.1.1.dev9 → pkgmgr_kunrunic-0.1.2.dev0}/plugin/export_source_review.py +0 -0
- {pkgmgr_kunrunic-0.1.1.dev9 → pkgmgr_kunrunic-0.1.2.dev0}/pyproject.toml +0 -0
- {pkgmgr_kunrunic-0.1.1.dev9 → pkgmgr_kunrunic-0.1.2.dev0}/setup.cfg +0 -0
- {pkgmgr_kunrunic-0.1.1.dev9 → pkgmgr_kunrunic-0.1.2.dev0}/tests/test_cli_install.py +0 -0
- {pkgmgr_kunrunic-0.1.1.dev9 → pkgmgr_kunrunic-0.1.2.dev0}/tests/test_config.py +0 -0
- {pkgmgr_kunrunic-0.1.1.dev9 → pkgmgr_kunrunic-0.1.2.dev0}/tests/test_progress.py +0 -0
- {pkgmgr_kunrunic-0.1.1.dev9 → pkgmgr_kunrunic-0.1.2.dev0}/tests/test_release.py +0 -0
- {pkgmgr_kunrunic-0.1.1.dev9 → pkgmgr_kunrunic-0.1.2.dev0}/tests/test_snapshot.py +0 -0
- {pkgmgr_kunrunic-0.1.1.dev9 → pkgmgr_kunrunic-0.1.2.dev0}/tools/echo_args.py +0 -0
|
@@ -70,11 +70,28 @@ def _add_update_pkg(sub):
|
|
|
70
70
|
p = sub.add_parser("update-pkg", help="collect git keyword hits and checksums for a pkg")
|
|
71
71
|
p.add_argument("pkg_id", help="package identifier to update")
|
|
72
72
|
p.add_argument(
|
|
73
|
-
"-release",
|
|
74
73
|
"--release",
|
|
75
74
|
action="store_true",
|
|
76
75
|
help="finalize the latest release bundle (tar + move to HISTORY)",
|
|
77
76
|
)
|
|
77
|
+
p.add_argument(
|
|
78
|
+
"--cancel",
|
|
79
|
+
help="cancel a finalized release and restore it to active (e.g. v0.0.2 or release.v0.0.2)",
|
|
80
|
+
)
|
|
81
|
+
p.add_argument(
|
|
82
|
+
"--root",
|
|
83
|
+
help="scope release/cancel to a specific release root (e.g. SYS_2)",
|
|
84
|
+
)
|
|
85
|
+
p.add_argument(
|
|
86
|
+
"--cancel-force",
|
|
87
|
+
action="store_true",
|
|
88
|
+
help="remove active release dirs before canceling",
|
|
89
|
+
)
|
|
90
|
+
p.add_argument(
|
|
91
|
+
"--cancel-clean-history",
|
|
92
|
+
action="store_true",
|
|
93
|
+
help="remove release history entries after cancel (implies --cancel-force)",
|
|
94
|
+
)
|
|
78
95
|
p.add_argument(
|
|
79
96
|
"--config",
|
|
80
97
|
default=None,
|
|
@@ -225,8 +242,81 @@ def _handle_create_pkg(args):
|
|
|
225
242
|
|
|
226
243
|
def _handle_update_pkg(args):
|
|
227
244
|
cfg = config.load_main(args.config)
|
|
245
|
+
if args.cancel_clean_history and not args.cancel:
|
|
246
|
+
raise RuntimeError("--cancel-clean-history requires --cancel")
|
|
247
|
+
if args.cancel:
|
|
248
|
+
if args.release:
|
|
249
|
+
raise RuntimeError("cannot use --release with --cancel")
|
|
250
|
+
cancel_force = bool(args.cancel_force)
|
|
251
|
+
if args.cancel_clean_history:
|
|
252
|
+
cancel_force = True
|
|
253
|
+
name, roots = release.list_cancel_targets(cfg, args.pkg_id, args.cancel)
|
|
254
|
+
if not roots and not args.cancel_clean_history:
|
|
255
|
+
raise RuntimeError("release not found: %s" % name)
|
|
256
|
+
if not args.cancel_clean_history:
|
|
257
|
+
prompt = (
|
|
258
|
+
"[cancel] history will remain in web. Use --cancel-clean-history to remove it.\n"
|
|
259
|
+
"[cancel] continue without cleaning history? [y/N]: "
|
|
260
|
+
)
|
|
261
|
+
answer = input(prompt).strip().lower()
|
|
262
|
+
if answer not in ("y", "yes"):
|
|
263
|
+
print("[cancel] skipped; example:")
|
|
264
|
+
print("[cancel] pkgmgr update-pkg %s --cancel %s --root %s --cancel-clean-history" % (args.pkg_id, name, (args.root or roots[0])))
|
|
265
|
+
return 0
|
|
266
|
+
if args.root:
|
|
267
|
+
if args.root not in roots and not args.cancel_clean_history:
|
|
268
|
+
raise RuntimeError("release not found for root %s: %s" % (args.root, name))
|
|
269
|
+
elif len(roots) > 1:
|
|
270
|
+
prompt = "[cancel] release %s found in roots: %s. Proceed cancel all? [y/N]: " % (name, ", ".join(roots))
|
|
271
|
+
answer = input(prompt).strip().lower()
|
|
272
|
+
if answer not in ("y", "yes"):
|
|
273
|
+
print("[cancel] skipped")
|
|
274
|
+
print("[cancel] single root cancel example")
|
|
275
|
+
print("[cancel] pkgmgr update-pkg %s --cancel %s --root %s" % (args.pkg_id, name, roots[0]))
|
|
276
|
+
if len(roots) > 1:
|
|
277
|
+
print("[cancel] pkgmgr update-pkg %s --cancel %s --root %s" % (args.pkg_id, name, roots[1]))
|
|
278
|
+
print("[cancel] history cleanup example")
|
|
279
|
+
print("[cancel] pkgmgr update-pkg %s --cancel %s --root %s --cancel-clean-history" % (args.pkg_id, name, roots[0]))
|
|
280
|
+
return 0
|
|
281
|
+
release.cancel_pkg_release(
|
|
282
|
+
cfg,
|
|
283
|
+
args.pkg_id,
|
|
284
|
+
args.cancel,
|
|
285
|
+
root_name=args.root,
|
|
286
|
+
force=cancel_force,
|
|
287
|
+
clean_history=bool(args.cancel_clean_history),
|
|
288
|
+
)
|
|
289
|
+
if not args.cancel_clean_history:
|
|
290
|
+
print("[cancel] history not cleaned; use --cancel-clean-history to remove release history entries")
|
|
291
|
+
_run_auto_actions(
|
|
292
|
+
cfg,
|
|
293
|
+
"cancel_pkg_release",
|
|
294
|
+
config_path=args.config,
|
|
295
|
+
context={"pkg_id": args.pkg_id, "event": "cancel_pkg_release", "release": args.cancel},
|
|
296
|
+
)
|
|
297
|
+
return 0
|
|
228
298
|
if args.release:
|
|
229
|
-
release.
|
|
299
|
+
active_roots = release.list_active_release_roots(cfg, args.pkg_id)
|
|
300
|
+
if not active_roots:
|
|
301
|
+
print("[update-pkg] no active release; run `pkgmgr update-pkg %s` first" % args.pkg_id)
|
|
302
|
+
return 0
|
|
303
|
+
if args.root:
|
|
304
|
+
if args.root not in active_roots:
|
|
305
|
+
raise RuntimeError("active release not found for root %s" % args.root)
|
|
306
|
+
roots = [args.root]
|
|
307
|
+
else:
|
|
308
|
+
roots = active_roots
|
|
309
|
+
if len(active_roots) > 1:
|
|
310
|
+
prompt = "[release] active roots: %s. Proceed finalize all? [y/N]: " % ", ".join(active_roots)
|
|
311
|
+
answer = input(prompt).strip().lower()
|
|
312
|
+
if answer not in ("y", "yes"):
|
|
313
|
+
print("[release] skipped; use --root to finalize a single root")
|
|
314
|
+
print("[release] single root release example")
|
|
315
|
+
print("[release] pkgmgr update-pkg %s --release --root %s" % (args.pkg_id, active_roots[0]))
|
|
316
|
+
if len(active_roots) > 1:
|
|
317
|
+
print("[release] pkgmgr update-pkg %s --release --root %s" % (args.pkg_id, active_roots[1]))
|
|
318
|
+
return 0
|
|
319
|
+
release.finalize_pkg_release(cfg, args.pkg_id, roots=roots)
|
|
230
320
|
_run_auto_actions(cfg, "update_pkg_release", config_path=args.config, context={"pkg_id": args.pkg_id, "event": "update_pkg_release"})
|
|
231
321
|
return 0
|
|
232
322
|
release.update_pkg(cfg, args.pkg_id)
|
|
@@ -313,7 +403,11 @@ def main(argv=None):
|
|
|
313
403
|
if not hasattr(args, "func"):
|
|
314
404
|
parser.print_help()
|
|
315
405
|
return 0
|
|
316
|
-
|
|
406
|
+
try:
|
|
407
|
+
return args.func(args)
|
|
408
|
+
except RuntimeError as exc:
|
|
409
|
+
print(str(exc), file=sys.stderr)
|
|
410
|
+
return 1
|
|
317
411
|
|
|
318
412
|
|
|
319
413
|
if __name__ == "__main__":
|
|
@@ -117,6 +117,7 @@ MAIN_DEFAULTS = {
|
|
|
117
117
|
"create_pkg": [],
|
|
118
118
|
"update_pkg": [],
|
|
119
119
|
"update_pkg_release": [],
|
|
120
|
+
"cancel_pkg_release": [],
|
|
120
121
|
"close_pkg": [],
|
|
121
122
|
},
|
|
122
123
|
}
|
|
@@ -188,6 +189,7 @@ def _validate_auto_actions(auto_actions):
|
|
|
188
189
|
"create_pkg": _ensure_list_of_strings(cfg.get("create_pkg"), "auto_actions.create_pkg"),
|
|
189
190
|
"update_pkg": _ensure_list_of_strings(cfg.get("update_pkg"), "auto_actions.update_pkg"),
|
|
190
191
|
"update_pkg_release": _ensure_list_of_strings(cfg.get("update_pkg_release"), "auto_actions.update_pkg_release"),
|
|
192
|
+
"cancel_pkg_release": _ensure_list_of_strings(cfg.get("cancel_pkg_release"), "auto_actions.cancel_pkg_release"),
|
|
191
193
|
"close_pkg": _ensure_list_of_strings(cfg.get("close_pkg"), "auto_actions.close_pkg"),
|
|
192
194
|
}
|
|
193
195
|
|
|
@@ -10,6 +10,7 @@ import sys
|
|
|
10
10
|
import time
|
|
11
11
|
import tarfile
|
|
12
12
|
import subprocess
|
|
13
|
+
import glob
|
|
13
14
|
|
|
14
15
|
from . import config, snapshot, shell_integration, points
|
|
15
16
|
from .collectors import checksums as checksums_module
|
|
@@ -1012,7 +1013,24 @@ def _finalize_release_root(root_dir):
|
|
|
1012
1013
|
return tar_path
|
|
1013
1014
|
|
|
1014
1015
|
|
|
1015
|
-
def
|
|
1016
|
+
def list_active_release_roots(cfg, pkg_id):
|
|
1017
|
+
pkg_dir = _pkg_dir(cfg, pkg_id)
|
|
1018
|
+
if not os.path.exists(pkg_dir):
|
|
1019
|
+
return []
|
|
1020
|
+
release_root = os.path.join(pkg_dir, "release")
|
|
1021
|
+
roots = []
|
|
1022
|
+
if not os.path.isdir(release_root):
|
|
1023
|
+
return roots
|
|
1024
|
+
for name in os.listdir(release_root):
|
|
1025
|
+
root_dir = os.path.join(release_root, name)
|
|
1026
|
+
if not os.path.isdir(root_dir) or name == "HISTORY":
|
|
1027
|
+
continue
|
|
1028
|
+
if _list_release_versions(root_dir, include_history=False):
|
|
1029
|
+
roots.append(name)
|
|
1030
|
+
return sorted(roots)
|
|
1031
|
+
|
|
1032
|
+
|
|
1033
|
+
def finalize_pkg_release(cfg, pkg_id, roots=None):
|
|
1016
1034
|
"""Finalize latest release bundle by moving to HISTORY and creating tar."""
|
|
1017
1035
|
pkg_dir = _pkg_dir(cfg, pkg_id)
|
|
1018
1036
|
if not os.path.exists(pkg_dir):
|
|
@@ -1020,18 +1038,11 @@ def finalize_pkg_release(cfg, pkg_id):
|
|
|
1020
1038
|
pkg_cfg_path = os.path.join(pkg_dir, "pkg.yaml")
|
|
1021
1039
|
pkg_cfg = config.load_pkg_config(pkg_cfg_path)
|
|
1022
1040
|
release_root = os.path.join(pkg_dir, "release")
|
|
1023
|
-
|
|
1024
|
-
if
|
|
1025
|
-
for name in os.listdir(release_root):
|
|
1026
|
-
root_dir = os.path.join(release_root, name)
|
|
1027
|
-
if not os.path.isdir(root_dir) or name == "HISTORY":
|
|
1028
|
-
continue
|
|
1029
|
-
if _list_release_versions(root_dir, include_history=False):
|
|
1030
|
-
active_release_found = True
|
|
1031
|
-
break
|
|
1032
|
-
if not active_release_found:
|
|
1041
|
+
active_roots = list_active_release_roots(cfg, pkg_id)
|
|
1042
|
+
if not active_roots:
|
|
1033
1043
|
print("[update-pkg] no active release; run `pkgmgr update-pkg %s` first" % pkg_id)
|
|
1034
1044
|
return []
|
|
1045
|
+
roots_filter = set(roots) if roots else set(active_roots)
|
|
1035
1046
|
source_files = _collect_release_sources(pkg_dir, pkg_cfg)
|
|
1036
1047
|
grouped = {}
|
|
1037
1048
|
for src, rel in source_files:
|
|
@@ -1053,6 +1064,8 @@ def finalize_pkg_release(cfg, pkg_id):
|
|
|
1053
1064
|
continue
|
|
1054
1065
|
if name == "HISTORY":
|
|
1055
1066
|
continue
|
|
1067
|
+
if name not in roots_filter:
|
|
1068
|
+
continue
|
|
1056
1069
|
tar_path = _finalize_release_root(root_dir)
|
|
1057
1070
|
if tar_path:
|
|
1058
1071
|
release_name = os.path.basename(tar_path).rsplit(".tar", 1)[0]
|
|
@@ -1071,6 +1084,8 @@ def finalize_pkg_release(cfg, pkg_id):
|
|
|
1071
1084
|
continue
|
|
1072
1085
|
if name == "HISTORY":
|
|
1073
1086
|
continue
|
|
1087
|
+
if name not in roots_filter:
|
|
1088
|
+
continue
|
|
1074
1089
|
baseline_dir = os.path.join(root_dir, "HISTORY", "BASELINE")
|
|
1075
1090
|
if os.path.isdir(baseline_dir):
|
|
1076
1091
|
continue
|
|
@@ -1083,6 +1098,244 @@ def finalize_pkg_release(cfg, pkg_id):
|
|
|
1083
1098
|
return finalized
|
|
1084
1099
|
|
|
1085
1100
|
|
|
1101
|
+
def _normalize_release_name(release_name):
|
|
1102
|
+
name = (release_name or "").strip()
|
|
1103
|
+
if not name:
|
|
1104
|
+
raise RuntimeError("release_name required")
|
|
1105
|
+
if not name.startswith("release."):
|
|
1106
|
+
if not name.startswith("v"):
|
|
1107
|
+
name = "v" + name
|
|
1108
|
+
name = "release." + name
|
|
1109
|
+
return name
|
|
1110
|
+
|
|
1111
|
+
|
|
1112
|
+
def list_cancel_targets(cfg, pkg_id, release_name):
|
|
1113
|
+
pkg_dir = _pkg_dir(cfg, pkg_id)
|
|
1114
|
+
if not os.path.exists(pkg_dir):
|
|
1115
|
+
raise RuntimeError("pkg dir not found: %s" % pkg_dir)
|
|
1116
|
+
release_root = os.path.join(pkg_dir, "release")
|
|
1117
|
+
if not os.path.isdir(release_root):
|
|
1118
|
+
raise RuntimeError("release root missing: %s" % release_root)
|
|
1119
|
+
|
|
1120
|
+
name = _normalize_release_name(release_name)
|
|
1121
|
+
roots = []
|
|
1122
|
+
for root_name in os.listdir(release_root):
|
|
1123
|
+
root_dir = os.path.join(release_root, root_name)
|
|
1124
|
+
if not os.path.isdir(root_dir) or root_name == "HISTORY":
|
|
1125
|
+
continue
|
|
1126
|
+
history_dir = os.path.join(root_dir, "HISTORY", name)
|
|
1127
|
+
tar_path = os.path.join(root_dir, "%s.tar" % name)
|
|
1128
|
+
if os.path.isdir(history_dir) or os.path.exists(tar_path):
|
|
1129
|
+
roots.append(root_name)
|
|
1130
|
+
return name, roots
|
|
1131
|
+
|
|
1132
|
+
|
|
1133
|
+
def _release_history_dir_for_pkg(pkg_id):
|
|
1134
|
+
return os.path.join(config.DEFAULT_STATE_DIR, "pkg", str(pkg_id), "release")
|
|
1135
|
+
|
|
1136
|
+
|
|
1137
|
+
def _load_release_history_payload(path):
|
|
1138
|
+
payload = {}
|
|
1139
|
+
try:
|
|
1140
|
+
raw = open(path, "rb").read()
|
|
1141
|
+
except Exception:
|
|
1142
|
+
raw = None
|
|
1143
|
+
if raw:
|
|
1144
|
+
for enc in ("utf-8", "cp949", "euc-kr", "latin1"):
|
|
1145
|
+
try:
|
|
1146
|
+
payload = json.loads(raw.decode(enc))
|
|
1147
|
+
break
|
|
1148
|
+
except Exception:
|
|
1149
|
+
payload = {}
|
|
1150
|
+
return payload
|
|
1151
|
+
|
|
1152
|
+
|
|
1153
|
+
def _remove_release_history_entries(pkg_id, release_name, roots):
|
|
1154
|
+
history_dir = _release_history_dir_for_pkg(pkg_id)
|
|
1155
|
+
if not os.path.isdir(history_dir):
|
|
1156
|
+
return 0
|
|
1157
|
+
removed = 0
|
|
1158
|
+
for path in sorted(glob.glob(os.path.join(history_dir, "release-*.json"))):
|
|
1159
|
+
payload = _load_release_history_payload(path)
|
|
1160
|
+
bundles = payload.get("bundles") or []
|
|
1161
|
+
kept = []
|
|
1162
|
+
for bundle in bundles:
|
|
1163
|
+
if bundle.get("release_name") == release_name and bundle.get("root") in roots:
|
|
1164
|
+
removed += 1
|
|
1165
|
+
continue
|
|
1166
|
+
kept.append(bundle)
|
|
1167
|
+
if len(kept) != len(bundles):
|
|
1168
|
+
if kept:
|
|
1169
|
+
payload["bundles"] = kept
|
|
1170
|
+
payload["generated_at"] = _timestamp()
|
|
1171
|
+
with open(path, "w") as f:
|
|
1172
|
+
json.dump(payload, f, ensure_ascii=False, indent=2, sort_keys=True)
|
|
1173
|
+
else:
|
|
1174
|
+
os.remove(path)
|
|
1175
|
+
return removed
|
|
1176
|
+
|
|
1177
|
+
|
|
1178
|
+
def _find_release_bundles(pkg_id, release_name, roots):
|
|
1179
|
+
history_dir = _release_history_dir_for_pkg(pkg_id)
|
|
1180
|
+
bundles = []
|
|
1181
|
+
if not os.path.isdir(history_dir):
|
|
1182
|
+
return bundles
|
|
1183
|
+
for path in sorted(glob.glob(os.path.join(history_dir, "release-*.json"))):
|
|
1184
|
+
payload = _load_release_history_payload(path)
|
|
1185
|
+
for bundle in payload.get("bundles") or []:
|
|
1186
|
+
if bundle.get("release_name") != release_name:
|
|
1187
|
+
continue
|
|
1188
|
+
root = bundle.get("root") or "root"
|
|
1189
|
+
if root in roots:
|
|
1190
|
+
bundles.append(bundle)
|
|
1191
|
+
return bundles
|
|
1192
|
+
|
|
1193
|
+
|
|
1194
|
+
def _prune_empty_dirs(base_dir):
|
|
1195
|
+
for base, dirs, files in os.walk(base_dir, topdown=False):
|
|
1196
|
+
if files:
|
|
1197
|
+
continue
|
|
1198
|
+
if not dirs and base != base_dir:
|
|
1199
|
+
os.rmdir(base)
|
|
1200
|
+
|
|
1201
|
+
|
|
1202
|
+
def _reset_baseline_from_active(root_dir, release_name):
|
|
1203
|
+
baseline_dir = os.path.join(root_dir, "HISTORY", "BASELINE")
|
|
1204
|
+
active_dir = os.path.join(root_dir, release_name)
|
|
1205
|
+
if not os.path.isdir(active_dir):
|
|
1206
|
+
print("[cancel] active release missing; skip baseline reset for %s" % root_dir)
|
|
1207
|
+
return
|
|
1208
|
+
if os.path.isdir(baseline_dir):
|
|
1209
|
+
shutil.rmtree(baseline_dir)
|
|
1210
|
+
os.makedirs(baseline_dir, exist_ok=True)
|
|
1211
|
+
for base, dirs, files in os.walk(active_dir):
|
|
1212
|
+
rel_base = os.path.relpath(base, active_dir)
|
|
1213
|
+
dest_base = baseline_dir if rel_base == "." else os.path.join(baseline_dir, rel_base)
|
|
1214
|
+
if not os.path.exists(dest_base):
|
|
1215
|
+
os.makedirs(dest_base)
|
|
1216
|
+
for name in files:
|
|
1217
|
+
if name in (_PKG_NOTE_NAME, _PKG_LIST_NAME):
|
|
1218
|
+
continue
|
|
1219
|
+
src = os.path.join(base, name)
|
|
1220
|
+
dest = os.path.join(dest_base, name)
|
|
1221
|
+
shutil.copy2(src, dest)
|
|
1222
|
+
print("[cancel] baseline reset from active for %s" % root_dir)
|
|
1223
|
+
|
|
1224
|
+
|
|
1225
|
+
def _revert_baseline_for_bundles(release_root, bundles):
|
|
1226
|
+
by_root = {}
|
|
1227
|
+
for bundle in bundles:
|
|
1228
|
+
root = bundle.get("root") or "root"
|
|
1229
|
+
by_root.setdefault(root, []).append(bundle)
|
|
1230
|
+
for root, items in by_root.items():
|
|
1231
|
+
baseline_dir = os.path.join(release_root, root, "HISTORY", "BASELINE")
|
|
1232
|
+
if not os.path.isdir(baseline_dir):
|
|
1233
|
+
print("[cancel] baseline missing for %s; skip revert" % root)
|
|
1234
|
+
continue
|
|
1235
|
+
for bundle in items:
|
|
1236
|
+
prev_release = bundle.get("prev_release")
|
|
1237
|
+
release_name = bundle.get("release_name") or ""
|
|
1238
|
+
added = bundle.get("added") or []
|
|
1239
|
+
updated = bundle.get("updated") or []
|
|
1240
|
+
removed = bundle.get("removed") or []
|
|
1241
|
+
if prev_release and not os.path.isdir(prev_release):
|
|
1242
|
+
prev_release = None
|
|
1243
|
+
if not prev_release and release_name:
|
|
1244
|
+
_reset_baseline_from_active(os.path.join(release_root, root), release_name)
|
|
1245
|
+
continue
|
|
1246
|
+
for rel in added:
|
|
1247
|
+
target = os.path.join(baseline_dir, rel)
|
|
1248
|
+
if os.path.isfile(target):
|
|
1249
|
+
os.remove(target)
|
|
1250
|
+
if prev_release:
|
|
1251
|
+
for rel in list(set(updated + removed)):
|
|
1252
|
+
src = os.path.join(prev_release, rel)
|
|
1253
|
+
if not os.path.isfile(src):
|
|
1254
|
+
continue
|
|
1255
|
+
dest = os.path.join(baseline_dir, rel)
|
|
1256
|
+
dest_parent = os.path.dirname(dest)
|
|
1257
|
+
if dest_parent and not os.path.exists(dest_parent):
|
|
1258
|
+
os.makedirs(dest_parent)
|
|
1259
|
+
shutil.copy2(src, dest)
|
|
1260
|
+
_prune_empty_dirs(baseline_dir)
|
|
1261
|
+
print("[cancel] baseline reverted for %s" % root)
|
|
1262
|
+
|
|
1263
|
+
|
|
1264
|
+
def cancel_pkg_release(cfg, pkg_id, release_name, root_name=None, force=False, clean_history=False):
|
|
1265
|
+
pkg_dir = _pkg_dir(cfg, pkg_id)
|
|
1266
|
+
if not os.path.exists(pkg_dir):
|
|
1267
|
+
raise RuntimeError("pkg dir not found: %s" % pkg_dir)
|
|
1268
|
+
release_root = os.path.join(pkg_dir, "release")
|
|
1269
|
+
if not os.path.isdir(release_root):
|
|
1270
|
+
raise RuntimeError("release root missing: %s" % release_root)
|
|
1271
|
+
|
|
1272
|
+
name = _normalize_release_name(release_name)
|
|
1273
|
+
|
|
1274
|
+
found = False
|
|
1275
|
+
touched_roots = []
|
|
1276
|
+
if root_name:
|
|
1277
|
+
roots = [root_name]
|
|
1278
|
+
else:
|
|
1279
|
+
_, roots = list_cancel_targets(cfg, pkg_id, name)
|
|
1280
|
+
roots = sorted(set(roots))
|
|
1281
|
+
precheck_errors = {}
|
|
1282
|
+
for root in roots:
|
|
1283
|
+
root_dir = os.path.join(release_root, root)
|
|
1284
|
+
if not os.path.isdir(root_dir) or root == "HISTORY":
|
|
1285
|
+
continue
|
|
1286
|
+
active_versions = _list_release_versions(root_dir, include_history=False)
|
|
1287
|
+
if active_versions and not force:
|
|
1288
|
+
precheck_errors.setdefault(root, []).append("active release exists")
|
|
1289
|
+
history_dir = os.path.join(root_dir, "HISTORY", name)
|
|
1290
|
+
tar_path = os.path.join(root_dir, "%s.tar" % name)
|
|
1291
|
+
if not clean_history and not os.path.isdir(history_dir) and not os.path.exists(tar_path):
|
|
1292
|
+
precheck_errors.setdefault(root, []).append("cancel target missing")
|
|
1293
|
+
if precheck_errors:
|
|
1294
|
+
detail = "; ".join(
|
|
1295
|
+
["%s (%s)" % (root, ", ".join(sorted(set(reasons)))) for root, reasons in sorted(precheck_errors.items())]
|
|
1296
|
+
)
|
|
1297
|
+
raise RuntimeError(
|
|
1298
|
+
"cancel precheck failed: %s; use --cancel-force or --cancel-clean-history" % detail
|
|
1299
|
+
)
|
|
1300
|
+
for root in roots:
|
|
1301
|
+
root_dir = os.path.join(release_root, root)
|
|
1302
|
+
if not os.path.isdir(root_dir) or root == "HISTORY":
|
|
1303
|
+
continue
|
|
1304
|
+
active_versions = _list_release_versions(root_dir, include_history=False)
|
|
1305
|
+
history_dir = os.path.join(root_dir, "HISTORY", name)
|
|
1306
|
+
active_dir = os.path.join(root_dir, name)
|
|
1307
|
+
tar_path = os.path.join(root_dir, "%s.tar" % name)
|
|
1308
|
+
has_history = os.path.isdir(history_dir)
|
|
1309
|
+
has_tar = os.path.exists(tar_path)
|
|
1310
|
+
if active_versions and force and has_history:
|
|
1311
|
+
for _, active_path in active_versions:
|
|
1312
|
+
if os.path.isdir(active_path):
|
|
1313
|
+
shutil.rmtree(active_path)
|
|
1314
|
+
print("[cancel] removed active %s" % active_path)
|
|
1315
|
+
if os.path.isdir(history_dir):
|
|
1316
|
+
if os.path.exists(active_dir):
|
|
1317
|
+
raise RuntimeError("active release already exists: %s" % active_dir)
|
|
1318
|
+
shutil.move(history_dir, active_dir)
|
|
1319
|
+
print("[cancel] restored %s -> %s" % (history_dir, active_dir))
|
|
1320
|
+
found = True
|
|
1321
|
+
touched_roots.append(root)
|
|
1322
|
+
if has_tar:
|
|
1323
|
+
os.remove(tar_path)
|
|
1324
|
+
print("[cancel] removed tar %s" % tar_path)
|
|
1325
|
+
found = True
|
|
1326
|
+
|
|
1327
|
+
if not found:
|
|
1328
|
+
if not clean_history:
|
|
1329
|
+
raise RuntimeError("release not found: %s" % name)
|
|
1330
|
+
print("[cancel] nothing to restore; history cleanup only")
|
|
1331
|
+
if clean_history:
|
|
1332
|
+
bundles = _find_release_bundles(pkg_id, name, touched_roots or roots)
|
|
1333
|
+
if bundles:
|
|
1334
|
+
_revert_baseline_for_bundles(release_root, bundles)
|
|
1335
|
+
removed = _remove_release_history_entries(pkg_id, name, touched_roots or roots)
|
|
1336
|
+
print("[cancel] cleaned history bundles: %d" % removed)
|
|
1337
|
+
|
|
1338
|
+
|
|
1086
1339
|
def update_pkg(cfg, pkg_id):
|
|
1087
1340
|
"""Collect git keyword hits and release checksums into a timestamped history."""
|
|
1088
1341
|
pkg_dir = _pkg_dir(cfg, pkg_id)
|
|
@@ -61,6 +61,26 @@ def _copy_export_dirs(release_root, dest_state_root, allowed_pkg_ids=None):
|
|
|
61
61
|
_copy_tree(export_dir, dest_export)
|
|
62
62
|
|
|
63
63
|
|
|
64
|
+
def _prune_empty_dirs(root_dir):
|
|
65
|
+
for base, dirs, files in os.walk(root_dir, topdown=False):
|
|
66
|
+
if files:
|
|
67
|
+
continue
|
|
68
|
+
if not dirs and base != root_dir:
|
|
69
|
+
os.rmdir(base)
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def _list_release_tars(release_dir):
|
|
73
|
+
items = []
|
|
74
|
+
for base, _, files in os.walk(release_dir):
|
|
75
|
+
for fname in files:
|
|
76
|
+
if not fname.endswith(".tar"):
|
|
77
|
+
continue
|
|
78
|
+
src = os.path.join(base, fname)
|
|
79
|
+
rel = os.path.relpath(src, release_dir)
|
|
80
|
+
items.append((src, rel))
|
|
81
|
+
return items
|
|
82
|
+
|
|
83
|
+
|
|
64
84
|
def _copy_release_tars(release_root, dest_state_root, allowed_pkg_ids=None):
|
|
65
85
|
if not os.path.isdir(release_root):
|
|
66
86
|
return
|
|
@@ -74,19 +94,26 @@ def _copy_release_tars(release_root, dest_state_root, allowed_pkg_ids=None):
|
|
|
74
94
|
if allowed_pkg_ids is not None and name not in allowed_pkg_ids:
|
|
75
95
|
continue
|
|
76
96
|
release_dir = os.path.join(pkg_dir, "release")
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
if not fname.endswith(".tar"):
|
|
82
|
-
continue
|
|
83
|
-
src = os.path.join(base, fname)
|
|
84
|
-
rel = os.path.relpath(src, release_dir)
|
|
97
|
+
expected = set()
|
|
98
|
+
if os.path.isdir(release_dir):
|
|
99
|
+
for src, rel in _list_release_tars(release_dir):
|
|
100
|
+
expected.add(rel)
|
|
85
101
|
dest_tar = os.path.join(pkg_root, name, "release_artifacts", rel)
|
|
86
102
|
dest_parent = os.path.dirname(dest_tar)
|
|
87
103
|
if not os.path.exists(dest_parent):
|
|
88
104
|
os.makedirs(dest_parent)
|
|
89
105
|
shutil.copy2(src, dest_tar)
|
|
106
|
+
dest_artifacts = os.path.join(pkg_root, name, "release_artifacts")
|
|
107
|
+
if os.path.isdir(dest_artifacts):
|
|
108
|
+
for base, _, files in os.walk(dest_artifacts):
|
|
109
|
+
for fname in files:
|
|
110
|
+
if not fname.endswith(".tar"):
|
|
111
|
+
continue
|
|
112
|
+
rel = os.path.relpath(os.path.join(base, fname), dest_artifacts)
|
|
113
|
+
if rel in expected:
|
|
114
|
+
continue
|
|
115
|
+
os.remove(os.path.join(base, fname))
|
|
116
|
+
_prune_empty_dirs(dest_artifacts)
|
|
90
117
|
|
|
91
118
|
|
|
92
119
|
def _list_readmes(pkg_dir):
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pkgmgr_kunrunic-0.1.1.dev9 → pkgmgr_kunrunic-0.1.2.dev0}/pkgmgr_kunrunic.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
{pkgmgr_kunrunic-0.1.1.dev9 → pkgmgr_kunrunic-0.1.2.dev0}/pkgmgr_kunrunic.egg-info/entry_points.txt
RENAMED
|
File without changes
|
{pkgmgr_kunrunic-0.1.1.dev9 → pkgmgr_kunrunic-0.1.2.dev0}/pkgmgr_kunrunic.egg-info/not-zip-safe
RENAMED
|
File without changes
|
{pkgmgr_kunrunic-0.1.1.dev9 → pkgmgr_kunrunic-0.1.2.dev0}/pkgmgr_kunrunic.egg-info/requires.txt
RENAMED
|
File without changes
|
{pkgmgr_kunrunic-0.1.1.dev9 → pkgmgr_kunrunic-0.1.2.dev0}/pkgmgr_kunrunic.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|