pkgmgr-kunrunic 0.1.1.dev9__tar.gz → 0.1.2.dev1__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.dev1}/PKG-INFO +1 -1
- {pkgmgr_kunrunic-0.1.1.dev9 → pkgmgr_kunrunic-0.1.2.dev1}/pkgmgr/__init__.py +1 -1
- {pkgmgr_kunrunic-0.1.1.dev9 → pkgmgr_kunrunic-0.1.2.dev1}/pkgmgr/cli.py +97 -3
- {pkgmgr_kunrunic-0.1.1.dev9 → pkgmgr_kunrunic-0.1.2.dev1}/pkgmgr/config.py +10 -2
- {pkgmgr_kunrunic-0.1.1.dev9 → pkgmgr_kunrunic-0.1.2.dev1}/pkgmgr/release.py +275 -15
- {pkgmgr_kunrunic-0.1.1.dev9 → pkgmgr_kunrunic-0.1.2.dev1}/pkgmgr/templates/pkg.yaml.sample +1 -0
- {pkgmgr_kunrunic-0.1.1.dev9 → pkgmgr_kunrunic-0.1.2.dev1}/pkgmgr/templates/pkgmgr.yaml.sample +10 -0
- {pkgmgr_kunrunic-0.1.1.dev9 → pkgmgr_kunrunic-0.1.2.dev1/pkgmgr_kunrunic.egg-info}/PKG-INFO +1 -1
- {pkgmgr_kunrunic-0.1.1.dev9 → pkgmgr_kunrunic-0.1.2.dev1}/plugin/export_pkgstore.py +35 -8
- {pkgmgr_kunrunic-0.1.1.dev9 → pkgmgr_kunrunic-0.1.2.dev1}/LICENSE +0 -0
- {pkgmgr_kunrunic-0.1.1.dev9 → pkgmgr_kunrunic-0.1.2.dev1}/README.md +0 -0
- {pkgmgr_kunrunic-0.1.1.dev9 → pkgmgr_kunrunic-0.1.2.dev1}/pkgmgr/__main__.py +0 -0
- {pkgmgr_kunrunic-0.1.1.dev9 → pkgmgr_kunrunic-0.1.2.dev1}/pkgmgr/collectors/__init__.py +0 -0
- {pkgmgr_kunrunic-0.1.1.dev9 → pkgmgr_kunrunic-0.1.2.dev1}/pkgmgr/collectors/base.py +0 -0
- {pkgmgr_kunrunic-0.1.1.dev9 → pkgmgr_kunrunic-0.1.2.dev1}/pkgmgr/collectors/checksums.py +0 -0
- {pkgmgr_kunrunic-0.1.1.dev9 → pkgmgr_kunrunic-0.1.2.dev1}/pkgmgr/points.py +0 -0
- {pkgmgr_kunrunic-0.1.1.dev9 → pkgmgr_kunrunic-0.1.2.dev1}/pkgmgr/shell_integration.py +0 -0
- {pkgmgr_kunrunic-0.1.1.dev9 → pkgmgr_kunrunic-0.1.2.dev1}/pkgmgr/snapshot.py +0 -0
- {pkgmgr_kunrunic-0.1.1.dev9 → pkgmgr_kunrunic-0.1.2.dev1}/pkgmgr/watch.py +0 -0
- {pkgmgr_kunrunic-0.1.1.dev9 → pkgmgr_kunrunic-0.1.2.dev1}/pkgmgr_kunrunic.egg-info/SOURCES.txt +0 -0
- {pkgmgr_kunrunic-0.1.1.dev9 → pkgmgr_kunrunic-0.1.2.dev1}/pkgmgr_kunrunic.egg-info/dependency_links.txt +0 -0
- {pkgmgr_kunrunic-0.1.1.dev9 → pkgmgr_kunrunic-0.1.2.dev1}/pkgmgr_kunrunic.egg-info/entry_points.txt +0 -0
- {pkgmgr_kunrunic-0.1.1.dev9 → pkgmgr_kunrunic-0.1.2.dev1}/pkgmgr_kunrunic.egg-info/not-zip-safe +0 -0
- {pkgmgr_kunrunic-0.1.1.dev9 → pkgmgr_kunrunic-0.1.2.dev1}/pkgmgr_kunrunic.egg-info/requires.txt +0 -0
- {pkgmgr_kunrunic-0.1.1.dev9 → pkgmgr_kunrunic-0.1.2.dev1}/pkgmgr_kunrunic.egg-info/top_level.txt +0 -0
- {pkgmgr_kunrunic-0.1.1.dev9 → pkgmgr_kunrunic-0.1.2.dev1}/plugin/export_cksum.py +0 -0
- {pkgmgr_kunrunic-0.1.1.dev9 → pkgmgr_kunrunic-0.1.2.dev1}/plugin/export_source_review.py +0 -0
- {pkgmgr_kunrunic-0.1.1.dev9 → pkgmgr_kunrunic-0.1.2.dev1}/pyproject.toml +0 -0
- {pkgmgr_kunrunic-0.1.1.dev9 → pkgmgr_kunrunic-0.1.2.dev1}/setup.cfg +0 -0
- {pkgmgr_kunrunic-0.1.1.dev9 → pkgmgr_kunrunic-0.1.2.dev1}/tests/test_cli_install.py +0 -0
- {pkgmgr_kunrunic-0.1.1.dev9 → pkgmgr_kunrunic-0.1.2.dev1}/tests/test_config.py +0 -0
- {pkgmgr_kunrunic-0.1.1.dev9 → pkgmgr_kunrunic-0.1.2.dev1}/tests/test_progress.py +0 -0
- {pkgmgr_kunrunic-0.1.1.dev9 → pkgmgr_kunrunic-0.1.2.dev1}/tests/test_release.py +0 -0
- {pkgmgr_kunrunic-0.1.1.dev9 → pkgmgr_kunrunic-0.1.2.dev1}/tests/test_snapshot.py +0 -0
- {pkgmgr_kunrunic-0.1.1.dev9 → pkgmgr_kunrunic-0.1.2.dev1}/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__":
|
|
@@ -28,6 +28,7 @@ MAIN_TEMPLATE = """\
|
|
|
28
28
|
pkg_release_root: ~/PKG/RELEASE
|
|
29
29
|
git:
|
|
30
30
|
repo_url: "https://github.com/org/repo"
|
|
31
|
+
keyword_prefix: "DEV-CODE:"
|
|
31
32
|
sources:
|
|
32
33
|
- /path/to/source-A
|
|
33
34
|
- /path/to/source-B
|
|
@@ -106,7 +107,7 @@ collectors:
|
|
|
106
107
|
|
|
107
108
|
MAIN_DEFAULTS = {
|
|
108
109
|
"pkg_release_root": None,
|
|
109
|
-
"git": {"repo_url": None},
|
|
110
|
+
"git": {"repo_url": None, "keyword_prefix": None},
|
|
110
111
|
"sources": [],
|
|
111
112
|
"source": {"exclude": []},
|
|
112
113
|
"artifacts": {"root": None, "targets": [], "exclude": []},
|
|
@@ -117,6 +118,7 @@ MAIN_DEFAULTS = {
|
|
|
117
118
|
"create_pkg": [],
|
|
118
119
|
"update_pkg": [],
|
|
119
120
|
"update_pkg_release": [],
|
|
121
|
+
"cancel_pkg_release": [],
|
|
120
122
|
"close_pkg": [],
|
|
121
123
|
},
|
|
122
124
|
}
|
|
@@ -188,6 +190,7 @@ def _validate_auto_actions(auto_actions):
|
|
|
188
190
|
"create_pkg": _ensure_list_of_strings(cfg.get("create_pkg"), "auto_actions.create_pkg"),
|
|
189
191
|
"update_pkg": _ensure_list_of_strings(cfg.get("update_pkg"), "auto_actions.update_pkg"),
|
|
190
192
|
"update_pkg_release": _ensure_list_of_strings(cfg.get("update_pkg_release"), "auto_actions.update_pkg_release"),
|
|
193
|
+
"cancel_pkg_release": _ensure_list_of_strings(cfg.get("cancel_pkg_release"), "auto_actions.cancel_pkg_release"),
|
|
191
194
|
"close_pkg": _ensure_list_of_strings(cfg.get("close_pkg"), "auto_actions.close_pkg"),
|
|
192
195
|
}
|
|
193
196
|
|
|
@@ -204,7 +207,11 @@ def _validate_main_config(data):
|
|
|
204
207
|
|
|
205
208
|
git_cfg = cfg.get("git") if isinstance(cfg.get("git"), dict) else {}
|
|
206
209
|
repo_url = git_cfg.get("repo_url")
|
|
207
|
-
|
|
210
|
+
keyword_prefix = git_cfg.get("keyword_prefix")
|
|
211
|
+
cfg["git"] = {
|
|
212
|
+
"repo_url": str(repo_url) if repo_url else None,
|
|
213
|
+
"keyword_prefix": str(keyword_prefix) if keyword_prefix else None,
|
|
214
|
+
}
|
|
208
215
|
|
|
209
216
|
cfg["sources"] = _ensure_list_of_strings(cfg.get("sources"), "sources")
|
|
210
217
|
src = cfg.get("source") if isinstance(cfg.get("source"), dict) else {}
|
|
@@ -412,5 +419,6 @@ def describe_expected_fields():
|
|
|
412
419
|
- env: key/value env overrides for that command only (optional)
|
|
413
420
|
auto_actions: mapping of lifecycle events to action names (create_pkg/update_pkg/update_pkg_release/close_pkg)
|
|
414
421
|
git.repo_url: base repository URL for commit links (per system)
|
|
422
|
+
git.keyword_prefix: commit prefix used with git.keywords (e.g. "DEV-CODE:")
|
|
415
423
|
"""
|
|
416
424
|
).strip()
|
|
@@ -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
|
|
@@ -474,8 +475,9 @@ def _git_output_encoding(repo_root):
|
|
|
474
475
|
return "utf-8"
|
|
475
476
|
|
|
476
477
|
|
|
477
|
-
def _collect_git_hits(pkg_cfg, pkg_root):
|
|
478
|
+
def _collect_git_hits(pkg_cfg, pkg_root, main_git_cfg=None):
|
|
478
479
|
git_cfg = pkg_cfg.get("git") or {}
|
|
480
|
+
main_git_cfg = main_git_cfg or {}
|
|
479
481
|
keywords = [str(k) for k in (git_cfg.get("keywords") or []) if str(k).strip()]
|
|
480
482
|
result = {"keywords": keywords, "commits": []}
|
|
481
483
|
files = set()
|
|
@@ -492,14 +494,19 @@ def _collect_git_hits(pkg_cfg, pkg_root):
|
|
|
492
494
|
current = None
|
|
493
495
|
|
|
494
496
|
output_encoding = _git_output_encoding(repo_root)
|
|
497
|
+
prefix = str(main_git_cfg.get("keyword_prefix") or "").strip()
|
|
498
|
+
prefix_re = re.escape(prefix) if prefix else ""
|
|
495
499
|
for kw in keywords:
|
|
500
|
+
grep_kw = kw
|
|
501
|
+
if prefix_re:
|
|
502
|
+
grep_kw = "%s\\s*%s" % (prefix_re, re.escape(kw))
|
|
496
503
|
cmd = [
|
|
497
504
|
"git",
|
|
498
505
|
"--no-pager",
|
|
499
506
|
"log",
|
|
500
507
|
"--name-only",
|
|
501
508
|
"--pretty=format:%H\t%s",
|
|
502
|
-
"--grep=%s" %
|
|
509
|
+
"--grep=%s" % grep_kw,
|
|
503
510
|
"--regexp-ignore-case",
|
|
504
511
|
"--all",
|
|
505
512
|
"--",
|
|
@@ -1012,7 +1019,24 @@ def _finalize_release_root(root_dir):
|
|
|
1012
1019
|
return tar_path
|
|
1013
1020
|
|
|
1014
1021
|
|
|
1015
|
-
def
|
|
1022
|
+
def list_active_release_roots(cfg, pkg_id):
|
|
1023
|
+
pkg_dir = _pkg_dir(cfg, pkg_id)
|
|
1024
|
+
if not os.path.exists(pkg_dir):
|
|
1025
|
+
return []
|
|
1026
|
+
release_root = os.path.join(pkg_dir, "release")
|
|
1027
|
+
roots = []
|
|
1028
|
+
if not os.path.isdir(release_root):
|
|
1029
|
+
return roots
|
|
1030
|
+
for name in os.listdir(release_root):
|
|
1031
|
+
root_dir = os.path.join(release_root, name)
|
|
1032
|
+
if not os.path.isdir(root_dir) or name == "HISTORY":
|
|
1033
|
+
continue
|
|
1034
|
+
if _list_release_versions(root_dir, include_history=False):
|
|
1035
|
+
roots.append(name)
|
|
1036
|
+
return sorted(roots)
|
|
1037
|
+
|
|
1038
|
+
|
|
1039
|
+
def finalize_pkg_release(cfg, pkg_id, roots=None):
|
|
1016
1040
|
"""Finalize latest release bundle by moving to HISTORY and creating tar."""
|
|
1017
1041
|
pkg_dir = _pkg_dir(cfg, pkg_id)
|
|
1018
1042
|
if not os.path.exists(pkg_dir):
|
|
@@ -1020,18 +1044,11 @@ def finalize_pkg_release(cfg, pkg_id):
|
|
|
1020
1044
|
pkg_cfg_path = os.path.join(pkg_dir, "pkg.yaml")
|
|
1021
1045
|
pkg_cfg = config.load_pkg_config(pkg_cfg_path)
|
|
1022
1046
|
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:
|
|
1047
|
+
active_roots = list_active_release_roots(cfg, pkg_id)
|
|
1048
|
+
if not active_roots:
|
|
1033
1049
|
print("[update-pkg] no active release; run `pkgmgr update-pkg %s` first" % pkg_id)
|
|
1034
1050
|
return []
|
|
1051
|
+
roots_filter = set(roots) if roots else set(active_roots)
|
|
1035
1052
|
source_files = _collect_release_sources(pkg_dir, pkg_cfg)
|
|
1036
1053
|
grouped = {}
|
|
1037
1054
|
for src, rel in source_files:
|
|
@@ -1053,6 +1070,8 @@ def finalize_pkg_release(cfg, pkg_id):
|
|
|
1053
1070
|
continue
|
|
1054
1071
|
if name == "HISTORY":
|
|
1055
1072
|
continue
|
|
1073
|
+
if name not in roots_filter:
|
|
1074
|
+
continue
|
|
1056
1075
|
tar_path = _finalize_release_root(root_dir)
|
|
1057
1076
|
if tar_path:
|
|
1058
1077
|
release_name = os.path.basename(tar_path).rsplit(".tar", 1)[0]
|
|
@@ -1071,6 +1090,8 @@ def finalize_pkg_release(cfg, pkg_id):
|
|
|
1071
1090
|
continue
|
|
1072
1091
|
if name == "HISTORY":
|
|
1073
1092
|
continue
|
|
1093
|
+
if name not in roots_filter:
|
|
1094
|
+
continue
|
|
1074
1095
|
baseline_dir = os.path.join(root_dir, "HISTORY", "BASELINE")
|
|
1075
1096
|
if os.path.isdir(baseline_dir):
|
|
1076
1097
|
continue
|
|
@@ -1083,6 +1104,244 @@ def finalize_pkg_release(cfg, pkg_id):
|
|
|
1083
1104
|
return finalized
|
|
1084
1105
|
|
|
1085
1106
|
|
|
1107
|
+
def _normalize_release_name(release_name):
|
|
1108
|
+
name = (release_name or "").strip()
|
|
1109
|
+
if not name:
|
|
1110
|
+
raise RuntimeError("release_name required")
|
|
1111
|
+
if not name.startswith("release."):
|
|
1112
|
+
if not name.startswith("v"):
|
|
1113
|
+
name = "v" + name
|
|
1114
|
+
name = "release." + name
|
|
1115
|
+
return name
|
|
1116
|
+
|
|
1117
|
+
|
|
1118
|
+
def list_cancel_targets(cfg, pkg_id, release_name):
|
|
1119
|
+
pkg_dir = _pkg_dir(cfg, pkg_id)
|
|
1120
|
+
if not os.path.exists(pkg_dir):
|
|
1121
|
+
raise RuntimeError("pkg dir not found: %s" % pkg_dir)
|
|
1122
|
+
release_root = os.path.join(pkg_dir, "release")
|
|
1123
|
+
if not os.path.isdir(release_root):
|
|
1124
|
+
raise RuntimeError("release root missing: %s" % release_root)
|
|
1125
|
+
|
|
1126
|
+
name = _normalize_release_name(release_name)
|
|
1127
|
+
roots = []
|
|
1128
|
+
for root_name in os.listdir(release_root):
|
|
1129
|
+
root_dir = os.path.join(release_root, root_name)
|
|
1130
|
+
if not os.path.isdir(root_dir) or root_name == "HISTORY":
|
|
1131
|
+
continue
|
|
1132
|
+
history_dir = os.path.join(root_dir, "HISTORY", name)
|
|
1133
|
+
tar_path = os.path.join(root_dir, "%s.tar" % name)
|
|
1134
|
+
if os.path.isdir(history_dir) or os.path.exists(tar_path):
|
|
1135
|
+
roots.append(root_name)
|
|
1136
|
+
return name, roots
|
|
1137
|
+
|
|
1138
|
+
|
|
1139
|
+
def _release_history_dir_for_pkg(pkg_id):
|
|
1140
|
+
return os.path.join(config.DEFAULT_STATE_DIR, "pkg", str(pkg_id), "release")
|
|
1141
|
+
|
|
1142
|
+
|
|
1143
|
+
def _load_release_history_payload(path):
|
|
1144
|
+
payload = {}
|
|
1145
|
+
try:
|
|
1146
|
+
raw = open(path, "rb").read()
|
|
1147
|
+
except Exception:
|
|
1148
|
+
raw = None
|
|
1149
|
+
if raw:
|
|
1150
|
+
for enc in ("utf-8", "cp949", "euc-kr", "latin1"):
|
|
1151
|
+
try:
|
|
1152
|
+
payload = json.loads(raw.decode(enc))
|
|
1153
|
+
break
|
|
1154
|
+
except Exception:
|
|
1155
|
+
payload = {}
|
|
1156
|
+
return payload
|
|
1157
|
+
|
|
1158
|
+
|
|
1159
|
+
def _remove_release_history_entries(pkg_id, release_name, roots):
|
|
1160
|
+
history_dir = _release_history_dir_for_pkg(pkg_id)
|
|
1161
|
+
if not os.path.isdir(history_dir):
|
|
1162
|
+
return 0
|
|
1163
|
+
removed = 0
|
|
1164
|
+
for path in sorted(glob.glob(os.path.join(history_dir, "release-*.json"))):
|
|
1165
|
+
payload = _load_release_history_payload(path)
|
|
1166
|
+
bundles = payload.get("bundles") or []
|
|
1167
|
+
kept = []
|
|
1168
|
+
for bundle in bundles:
|
|
1169
|
+
if bundle.get("release_name") == release_name and bundle.get("root") in roots:
|
|
1170
|
+
removed += 1
|
|
1171
|
+
continue
|
|
1172
|
+
kept.append(bundle)
|
|
1173
|
+
if len(kept) != len(bundles):
|
|
1174
|
+
if kept:
|
|
1175
|
+
payload["bundles"] = kept
|
|
1176
|
+
payload["generated_at"] = _timestamp()
|
|
1177
|
+
with open(path, "w") as f:
|
|
1178
|
+
json.dump(payload, f, ensure_ascii=False, indent=2, sort_keys=True)
|
|
1179
|
+
else:
|
|
1180
|
+
os.remove(path)
|
|
1181
|
+
return removed
|
|
1182
|
+
|
|
1183
|
+
|
|
1184
|
+
def _find_release_bundles(pkg_id, release_name, roots):
|
|
1185
|
+
history_dir = _release_history_dir_for_pkg(pkg_id)
|
|
1186
|
+
bundles = []
|
|
1187
|
+
if not os.path.isdir(history_dir):
|
|
1188
|
+
return bundles
|
|
1189
|
+
for path in sorted(glob.glob(os.path.join(history_dir, "release-*.json"))):
|
|
1190
|
+
payload = _load_release_history_payload(path)
|
|
1191
|
+
for bundle in payload.get("bundles") or []:
|
|
1192
|
+
if bundle.get("release_name") != release_name:
|
|
1193
|
+
continue
|
|
1194
|
+
root = bundle.get("root") or "root"
|
|
1195
|
+
if root in roots:
|
|
1196
|
+
bundles.append(bundle)
|
|
1197
|
+
return bundles
|
|
1198
|
+
|
|
1199
|
+
|
|
1200
|
+
def _prune_empty_dirs(base_dir):
|
|
1201
|
+
for base, dirs, files in os.walk(base_dir, topdown=False):
|
|
1202
|
+
if files:
|
|
1203
|
+
continue
|
|
1204
|
+
if not dirs and base != base_dir:
|
|
1205
|
+
os.rmdir(base)
|
|
1206
|
+
|
|
1207
|
+
|
|
1208
|
+
def _reset_baseline_from_active(root_dir, release_name):
|
|
1209
|
+
baseline_dir = os.path.join(root_dir, "HISTORY", "BASELINE")
|
|
1210
|
+
active_dir = os.path.join(root_dir, release_name)
|
|
1211
|
+
if not os.path.isdir(active_dir):
|
|
1212
|
+
print("[cancel] active release missing; skip baseline reset for %s" % root_dir)
|
|
1213
|
+
return
|
|
1214
|
+
if os.path.isdir(baseline_dir):
|
|
1215
|
+
shutil.rmtree(baseline_dir)
|
|
1216
|
+
os.makedirs(baseline_dir, exist_ok=True)
|
|
1217
|
+
for base, dirs, files in os.walk(active_dir):
|
|
1218
|
+
rel_base = os.path.relpath(base, active_dir)
|
|
1219
|
+
dest_base = baseline_dir if rel_base == "." else os.path.join(baseline_dir, rel_base)
|
|
1220
|
+
if not os.path.exists(dest_base):
|
|
1221
|
+
os.makedirs(dest_base)
|
|
1222
|
+
for name in files:
|
|
1223
|
+
if name in (_PKG_NOTE_NAME, _PKG_LIST_NAME):
|
|
1224
|
+
continue
|
|
1225
|
+
src = os.path.join(base, name)
|
|
1226
|
+
dest = os.path.join(dest_base, name)
|
|
1227
|
+
shutil.copy2(src, dest)
|
|
1228
|
+
print("[cancel] baseline reset from active for %s" % root_dir)
|
|
1229
|
+
|
|
1230
|
+
|
|
1231
|
+
def _revert_baseline_for_bundles(release_root, bundles):
|
|
1232
|
+
by_root = {}
|
|
1233
|
+
for bundle in bundles:
|
|
1234
|
+
root = bundle.get("root") or "root"
|
|
1235
|
+
by_root.setdefault(root, []).append(bundle)
|
|
1236
|
+
for root, items in by_root.items():
|
|
1237
|
+
baseline_dir = os.path.join(release_root, root, "HISTORY", "BASELINE")
|
|
1238
|
+
if not os.path.isdir(baseline_dir):
|
|
1239
|
+
print("[cancel] baseline missing for %s; skip revert" % root)
|
|
1240
|
+
continue
|
|
1241
|
+
for bundle in items:
|
|
1242
|
+
prev_release = bundle.get("prev_release")
|
|
1243
|
+
release_name = bundle.get("release_name") or ""
|
|
1244
|
+
added = bundle.get("added") or []
|
|
1245
|
+
updated = bundle.get("updated") or []
|
|
1246
|
+
removed = bundle.get("removed") or []
|
|
1247
|
+
if prev_release and not os.path.isdir(prev_release):
|
|
1248
|
+
prev_release = None
|
|
1249
|
+
if not prev_release and release_name:
|
|
1250
|
+
_reset_baseline_from_active(os.path.join(release_root, root), release_name)
|
|
1251
|
+
continue
|
|
1252
|
+
for rel in added:
|
|
1253
|
+
target = os.path.join(baseline_dir, rel)
|
|
1254
|
+
if os.path.isfile(target):
|
|
1255
|
+
os.remove(target)
|
|
1256
|
+
if prev_release:
|
|
1257
|
+
for rel in list(set(updated + removed)):
|
|
1258
|
+
src = os.path.join(prev_release, rel)
|
|
1259
|
+
if not os.path.isfile(src):
|
|
1260
|
+
continue
|
|
1261
|
+
dest = os.path.join(baseline_dir, rel)
|
|
1262
|
+
dest_parent = os.path.dirname(dest)
|
|
1263
|
+
if dest_parent and not os.path.exists(dest_parent):
|
|
1264
|
+
os.makedirs(dest_parent)
|
|
1265
|
+
shutil.copy2(src, dest)
|
|
1266
|
+
_prune_empty_dirs(baseline_dir)
|
|
1267
|
+
print("[cancel] baseline reverted for %s" % root)
|
|
1268
|
+
|
|
1269
|
+
|
|
1270
|
+
def cancel_pkg_release(cfg, pkg_id, release_name, root_name=None, force=False, clean_history=False):
|
|
1271
|
+
pkg_dir = _pkg_dir(cfg, pkg_id)
|
|
1272
|
+
if not os.path.exists(pkg_dir):
|
|
1273
|
+
raise RuntimeError("pkg dir not found: %s" % pkg_dir)
|
|
1274
|
+
release_root = os.path.join(pkg_dir, "release")
|
|
1275
|
+
if not os.path.isdir(release_root):
|
|
1276
|
+
raise RuntimeError("release root missing: %s" % release_root)
|
|
1277
|
+
|
|
1278
|
+
name = _normalize_release_name(release_name)
|
|
1279
|
+
|
|
1280
|
+
found = False
|
|
1281
|
+
touched_roots = []
|
|
1282
|
+
if root_name:
|
|
1283
|
+
roots = [root_name]
|
|
1284
|
+
else:
|
|
1285
|
+
_, roots = list_cancel_targets(cfg, pkg_id, name)
|
|
1286
|
+
roots = sorted(set(roots))
|
|
1287
|
+
precheck_errors = {}
|
|
1288
|
+
for root in roots:
|
|
1289
|
+
root_dir = os.path.join(release_root, root)
|
|
1290
|
+
if not os.path.isdir(root_dir) or root == "HISTORY":
|
|
1291
|
+
continue
|
|
1292
|
+
active_versions = _list_release_versions(root_dir, include_history=False)
|
|
1293
|
+
if active_versions and not force:
|
|
1294
|
+
precheck_errors.setdefault(root, []).append("active release exists")
|
|
1295
|
+
history_dir = os.path.join(root_dir, "HISTORY", name)
|
|
1296
|
+
tar_path = os.path.join(root_dir, "%s.tar" % name)
|
|
1297
|
+
if not clean_history and not os.path.isdir(history_dir) and not os.path.exists(tar_path):
|
|
1298
|
+
precheck_errors.setdefault(root, []).append("cancel target missing")
|
|
1299
|
+
if precheck_errors:
|
|
1300
|
+
detail = "; ".join(
|
|
1301
|
+
["%s (%s)" % (root, ", ".join(sorted(set(reasons)))) for root, reasons in sorted(precheck_errors.items())]
|
|
1302
|
+
)
|
|
1303
|
+
raise RuntimeError(
|
|
1304
|
+
"cancel precheck failed: %s; use --cancel-force or --cancel-clean-history" % detail
|
|
1305
|
+
)
|
|
1306
|
+
for root in roots:
|
|
1307
|
+
root_dir = os.path.join(release_root, root)
|
|
1308
|
+
if not os.path.isdir(root_dir) or root == "HISTORY":
|
|
1309
|
+
continue
|
|
1310
|
+
active_versions = _list_release_versions(root_dir, include_history=False)
|
|
1311
|
+
history_dir = os.path.join(root_dir, "HISTORY", name)
|
|
1312
|
+
active_dir = os.path.join(root_dir, name)
|
|
1313
|
+
tar_path = os.path.join(root_dir, "%s.tar" % name)
|
|
1314
|
+
has_history = os.path.isdir(history_dir)
|
|
1315
|
+
has_tar = os.path.exists(tar_path)
|
|
1316
|
+
if active_versions and force and has_history:
|
|
1317
|
+
for _, active_path in active_versions:
|
|
1318
|
+
if os.path.isdir(active_path):
|
|
1319
|
+
shutil.rmtree(active_path)
|
|
1320
|
+
print("[cancel] removed active %s" % active_path)
|
|
1321
|
+
if os.path.isdir(history_dir):
|
|
1322
|
+
if os.path.exists(active_dir):
|
|
1323
|
+
raise RuntimeError("active release already exists: %s" % active_dir)
|
|
1324
|
+
shutil.move(history_dir, active_dir)
|
|
1325
|
+
print("[cancel] restored %s -> %s" % (history_dir, active_dir))
|
|
1326
|
+
found = True
|
|
1327
|
+
touched_roots.append(root)
|
|
1328
|
+
if has_tar:
|
|
1329
|
+
os.remove(tar_path)
|
|
1330
|
+
print("[cancel] removed tar %s" % tar_path)
|
|
1331
|
+
found = True
|
|
1332
|
+
|
|
1333
|
+
if not found:
|
|
1334
|
+
if not clean_history:
|
|
1335
|
+
raise RuntimeError("release not found: %s" % name)
|
|
1336
|
+
print("[cancel] nothing to restore; history cleanup only")
|
|
1337
|
+
if clean_history:
|
|
1338
|
+
bundles = _find_release_bundles(pkg_id, name, touched_roots or roots)
|
|
1339
|
+
if bundles:
|
|
1340
|
+
_revert_baseline_for_bundles(release_root, bundles)
|
|
1341
|
+
removed = _remove_release_history_entries(pkg_id, name, touched_roots or roots)
|
|
1342
|
+
print("[cancel] cleaned history bundles: %d" % removed)
|
|
1343
|
+
|
|
1344
|
+
|
|
1086
1345
|
def update_pkg(cfg, pkg_id):
|
|
1087
1346
|
"""Collect git keyword hits and release checksums into a timestamped history."""
|
|
1088
1347
|
pkg_dir = _pkg_dir(cfg, pkg_id)
|
|
@@ -1096,8 +1355,9 @@ def update_pkg(cfg, pkg_id):
|
|
|
1096
1355
|
if not os.path.exists(updates_dir):
|
|
1097
1356
|
os.makedirs(updates_dir)
|
|
1098
1357
|
|
|
1099
|
-
|
|
1100
|
-
|
|
1358
|
+
main_git_cfg = cfg.get("git") or {}
|
|
1359
|
+
git_info, git_files = _collect_git_hits(pkg_cfg, pkg_dir, main_git_cfg)
|
|
1360
|
+
repo_url = main_git_cfg.get("repo_url")
|
|
1101
1361
|
if repo_url:
|
|
1102
1362
|
git_info["repo_url"] = repo_url
|
|
1103
1363
|
release_files = _collect_release_files(pkg_dir, pkg_cfg)
|
{pkgmgr_kunrunic-0.1.1.dev9 → pkgmgr_kunrunic-0.1.2.dev1}/pkgmgr/templates/pkgmgr.yaml.sample
RENAMED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
pkg_release_root: ~/PKG/RELEASE
|
|
2
|
+
git:
|
|
3
|
+
repo_url: "https://github.com/org/repo"
|
|
4
|
+
keyword_prefix: "DEV-CODE:"
|
|
2
5
|
sources:
|
|
3
6
|
- /path/to/source-A
|
|
4
7
|
- /path/to/source-B
|
|
@@ -49,3 +52,10 @@ actions:
|
|
|
49
52
|
noti_email:
|
|
50
53
|
- cmd: sh noti_email.sh
|
|
51
54
|
cwd: /app/script
|
|
55
|
+
|
|
56
|
+
auto_actions:
|
|
57
|
+
create_pkg: []
|
|
58
|
+
update_pkg: []
|
|
59
|
+
update_pkg_release: []
|
|
60
|
+
cancel_pkg_release: []
|
|
61
|
+
close_pkg: []
|
|
@@ -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
|
{pkgmgr_kunrunic-0.1.1.dev9 → pkgmgr_kunrunic-0.1.2.dev1}/pkgmgr_kunrunic.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
{pkgmgr_kunrunic-0.1.1.dev9 → pkgmgr_kunrunic-0.1.2.dev1}/pkgmgr_kunrunic.egg-info/entry_points.txt
RENAMED
|
File without changes
|
{pkgmgr_kunrunic-0.1.1.dev9 → pkgmgr_kunrunic-0.1.2.dev1}/pkgmgr_kunrunic.egg-info/not-zip-safe
RENAMED
|
File without changes
|
{pkgmgr_kunrunic-0.1.1.dev9 → pkgmgr_kunrunic-0.1.2.dev1}/pkgmgr_kunrunic.egg-info/requires.txt
RENAMED
|
File without changes
|
{pkgmgr_kunrunic-0.1.1.dev9 → pkgmgr_kunrunic-0.1.2.dev1}/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
|