pkgmgr-kunrunic 0.1.2.dev1__tar.gz → 0.1.2.dev2__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.
Files changed (35) hide show
  1. {pkgmgr_kunrunic-0.1.2.dev1 → pkgmgr_kunrunic-0.1.2.dev2}/PKG-INFO +1 -1
  2. {pkgmgr_kunrunic-0.1.2.dev1 → pkgmgr_kunrunic-0.1.2.dev2}/pkgmgr/__init__.py +1 -1
  3. {pkgmgr_kunrunic-0.1.2.dev1 → pkgmgr_kunrunic-0.1.2.dev2}/pkgmgr/cli.py +19 -0
  4. {pkgmgr_kunrunic-0.1.2.dev1 → pkgmgr_kunrunic-0.1.2.dev2}/pkgmgr/config.py +20 -5
  5. {pkgmgr_kunrunic-0.1.2.dev1 → pkgmgr_kunrunic-0.1.2.dev2}/pkgmgr/release.py +162 -4
  6. {pkgmgr_kunrunic-0.1.2.dev1 → pkgmgr_kunrunic-0.1.2.dev2}/pkgmgr/templates/pkg.yaml.sample +1 -0
  7. {pkgmgr_kunrunic-0.1.2.dev1 → pkgmgr_kunrunic-0.1.2.dev2}/pkgmgr/templates/pkgmgr.yaml.sample +2 -0
  8. {pkgmgr_kunrunic-0.1.2.dev1 → pkgmgr_kunrunic-0.1.2.dev2}/pkgmgr_kunrunic.egg-info/PKG-INFO +1 -1
  9. {pkgmgr_kunrunic-0.1.2.dev1 → pkgmgr_kunrunic-0.1.2.dev2}/pkgmgr_kunrunic.egg-info/top_level.txt +0 -1
  10. {pkgmgr_kunrunic-0.1.2.dev1 → pkgmgr_kunrunic-0.1.2.dev2}/plugin/export_pkgstore.py +17 -1
  11. {pkgmgr_kunrunic-0.1.2.dev1 → pkgmgr_kunrunic-0.1.2.dev2}/LICENSE +0 -0
  12. {pkgmgr_kunrunic-0.1.2.dev1 → pkgmgr_kunrunic-0.1.2.dev2}/README.md +0 -0
  13. {pkgmgr_kunrunic-0.1.2.dev1 → pkgmgr_kunrunic-0.1.2.dev2}/pkgmgr/__main__.py +0 -0
  14. {pkgmgr_kunrunic-0.1.2.dev1 → pkgmgr_kunrunic-0.1.2.dev2}/pkgmgr/collectors/__init__.py +0 -0
  15. {pkgmgr_kunrunic-0.1.2.dev1 → pkgmgr_kunrunic-0.1.2.dev2}/pkgmgr/collectors/base.py +0 -0
  16. {pkgmgr_kunrunic-0.1.2.dev1 → pkgmgr_kunrunic-0.1.2.dev2}/pkgmgr/collectors/checksums.py +0 -0
  17. {pkgmgr_kunrunic-0.1.2.dev1 → pkgmgr_kunrunic-0.1.2.dev2}/pkgmgr/points.py +0 -0
  18. {pkgmgr_kunrunic-0.1.2.dev1 → pkgmgr_kunrunic-0.1.2.dev2}/pkgmgr/shell_integration.py +0 -0
  19. {pkgmgr_kunrunic-0.1.2.dev1 → pkgmgr_kunrunic-0.1.2.dev2}/pkgmgr/snapshot.py +0 -0
  20. {pkgmgr_kunrunic-0.1.2.dev1 → pkgmgr_kunrunic-0.1.2.dev2}/pkgmgr/watch.py +0 -0
  21. {pkgmgr_kunrunic-0.1.2.dev1 → pkgmgr_kunrunic-0.1.2.dev2}/pkgmgr_kunrunic.egg-info/SOURCES.txt +0 -0
  22. {pkgmgr_kunrunic-0.1.2.dev1 → pkgmgr_kunrunic-0.1.2.dev2}/pkgmgr_kunrunic.egg-info/dependency_links.txt +0 -0
  23. {pkgmgr_kunrunic-0.1.2.dev1 → pkgmgr_kunrunic-0.1.2.dev2}/pkgmgr_kunrunic.egg-info/entry_points.txt +0 -0
  24. {pkgmgr_kunrunic-0.1.2.dev1 → pkgmgr_kunrunic-0.1.2.dev2}/pkgmgr_kunrunic.egg-info/not-zip-safe +0 -0
  25. {pkgmgr_kunrunic-0.1.2.dev1 → pkgmgr_kunrunic-0.1.2.dev2}/pkgmgr_kunrunic.egg-info/requires.txt +0 -0
  26. {pkgmgr_kunrunic-0.1.2.dev1 → pkgmgr_kunrunic-0.1.2.dev2}/plugin/export_cksum.py +0 -0
  27. {pkgmgr_kunrunic-0.1.2.dev1 → pkgmgr_kunrunic-0.1.2.dev2}/plugin/export_source_review.py +0 -0
  28. {pkgmgr_kunrunic-0.1.2.dev1 → pkgmgr_kunrunic-0.1.2.dev2}/pyproject.toml +0 -0
  29. {pkgmgr_kunrunic-0.1.2.dev1 → pkgmgr_kunrunic-0.1.2.dev2}/setup.cfg +0 -0
  30. {pkgmgr_kunrunic-0.1.2.dev1 → pkgmgr_kunrunic-0.1.2.dev2}/tests/test_cli_install.py +0 -0
  31. {pkgmgr_kunrunic-0.1.2.dev1 → pkgmgr_kunrunic-0.1.2.dev2}/tests/test_config.py +0 -0
  32. {pkgmgr_kunrunic-0.1.2.dev1 → pkgmgr_kunrunic-0.1.2.dev2}/tests/test_progress.py +0 -0
  33. {pkgmgr_kunrunic-0.1.2.dev1 → pkgmgr_kunrunic-0.1.2.dev2}/tests/test_release.py +0 -0
  34. {pkgmgr_kunrunic-0.1.2.dev1 → pkgmgr_kunrunic-0.1.2.dev2}/tests/test_snapshot.py +0 -0
  35. {pkgmgr_kunrunic-0.1.2.dev1 → pkgmgr_kunrunic-0.1.2.dev2}/tools/echo_args.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pkgmgr-kunrunic
3
- Version: 0.1.2.dev1
3
+ Version: 0.1.2.dev2
4
4
  Summary: Package management workflow scaffold.
5
5
  Author: pkgmgr maintainers
6
6
  License: MIT License
@@ -13,4 +13,4 @@ __all__ = [
13
13
  "points",
14
14
  ]
15
15
 
16
- __version__ = "0.1.2.dev1"
16
+ __version__ = "0.1.2.dev2"
@@ -111,6 +111,17 @@ def _add_close_pkg(sub):
111
111
  p.set_defaults(func=_handle_close_pkg)
112
112
 
113
113
 
114
+ def _add_delete_pkg(sub):
115
+ p = sub.add_parser("delete-pkg", help="delete a closed pkg from local state")
116
+ p.add_argument("pkg_id", help="package identifier to delete (closed only)")
117
+ p.add_argument(
118
+ "--config",
119
+ default=None,
120
+ help="config file path (default: auto-discover under %s)" % config.BASE_DIR,
121
+ )
122
+ p.set_defaults(func=_handle_delete_pkg)
123
+
124
+
114
125
  def _add_watch(sub):
115
126
  p = sub.add_parser("watch", help="start watcher/daemon to monitor pkgs")
116
127
  p.add_argument(
@@ -196,6 +207,7 @@ def build_parser():
196
207
  _add_create_pkg(sub)
197
208
  _add_update_pkg(sub)
198
209
  _add_close_pkg(sub)
210
+ _add_delete_pkg(sub)
199
211
  _add_actions(sub)
200
212
  return parser
201
213
 
@@ -331,6 +343,13 @@ def _handle_close_pkg(args):
331
343
  return 0
332
344
 
333
345
 
346
+ def _handle_delete_pkg(args):
347
+ cfg = config.load_main(args.config)
348
+ release.delete_pkg(cfg, args.pkg_id)
349
+ _run_auto_actions(cfg, "delete_pkg", config_path=args.config, context={"pkg_id": args.pkg_id, "event": "delete_pkg"})
350
+ return 0
351
+
352
+
334
353
  def _handle_watch(args):
335
354
  cfg = config.load_main(args.config)
336
355
  watch.run(
@@ -27,6 +27,7 @@ except Exception:
27
27
  MAIN_TEMPLATE = """\
28
28
  pkg_release_root: ~/PKG/RELEASE
29
29
  git:
30
+ repo_root: null # optional override; default is git rev-parse from cwd
30
31
  repo_url: "https://github.com/org/repo"
31
32
  keyword_prefix: "DEV-CODE:"
32
33
  sources:
@@ -107,7 +108,7 @@ collectors:
107
108
 
108
109
  MAIN_DEFAULTS = {
109
110
  "pkg_release_root": None,
110
- "git": {"repo_url": None, "keyword_prefix": None},
111
+ "git": {"repo_root": None, "repo_url": None, "keyword_prefix": None},
111
112
  "sources": [],
112
113
  "source": {"exclude": []},
113
114
  "artifacts": {"root": None, "targets": [], "exclude": []},
@@ -120,6 +121,7 @@ MAIN_DEFAULTS = {
120
121
  "update_pkg_release": [],
121
122
  "cancel_pkg_release": [],
122
123
  "close_pkg": [],
124
+ "delete_pkg": [],
123
125
  },
124
126
  }
125
127
 
@@ -192,6 +194,7 @@ def _validate_auto_actions(auto_actions):
192
194
  "update_pkg_release": _ensure_list_of_strings(cfg.get("update_pkg_release"), "auto_actions.update_pkg_release"),
193
195
  "cancel_pkg_release": _ensure_list_of_strings(cfg.get("cancel_pkg_release"), "auto_actions.cancel_pkg_release"),
194
196
  "close_pkg": _ensure_list_of_strings(cfg.get("close_pkg"), "auto_actions.close_pkg"),
197
+ "delete_pkg": _ensure_list_of_strings(cfg.get("delete_pkg"), "auto_actions.delete_pkg"),
195
198
  }
196
199
 
197
200
 
@@ -206,9 +209,11 @@ def _validate_main_config(data):
206
209
  cfg["pkg_release_root"] = str(pkg_root)
207
210
 
208
211
  git_cfg = cfg.get("git") if isinstance(cfg.get("git"), dict) else {}
212
+ repo_root = git_cfg.get("repo_root")
209
213
  repo_url = git_cfg.get("repo_url")
210
214
  keyword_prefix = git_cfg.get("keyword_prefix")
211
215
  cfg["git"] = {
216
+ "repo_root": str(repo_root) if repo_root else None,
212
217
  "repo_url": str(repo_url) if repo_url else None,
213
218
  "keyword_prefix": str(keyword_prefix) if keyword_prefix else None,
214
219
  }
@@ -280,7 +285,7 @@ def write_pkg_template(path, pkg_id=None, pkg_root=None, include_releases=None,
280
285
 
281
286
  if pkg_id is None or pkg_root is None or yaml is None:
282
287
  content = _load_template_file("pkg.yaml.sample", PKG_TEMPLATE)
283
- with open(target, "w") as f:
288
+ with open(target, "w", encoding="euc-kr") as f:
284
289
  f.write(content)
285
290
  else:
286
291
  data = {
@@ -294,8 +299,17 @@ def write_pkg_template(path, pkg_id=None, pkg_root=None, include_releases=None,
294
299
  },
295
300
  "collectors": {"enabled": collectors_enabled or ["checksums"]},
296
301
  }
297
- with open(target, "w") as f:
298
- yaml.safe_dump(data, f, allow_unicode=True, sort_keys=True)
302
+ dumped = yaml.safe_dump(data, allow_unicode=True, sort_keys=True)
303
+ lines = dumped.splitlines()
304
+ out_lines = []
305
+ for line in lines:
306
+ out_lines.append(line)
307
+ if line.strip().startswith("repo_root:"):
308
+ out_lines.append(" # pkgmgr.yaml 의 repo_root 값으로 자동 생성됩니다.")
309
+ if line.strip().startswith("releases:"):
310
+ out_lines.append(" # update-pkg 실행 시 추가 항목은 수동으로 include.releases에 입력 필요")
311
+ with open(target, "w", encoding="euc-kr") as f:
312
+ f.write("\n".join(out_lines) + "\n")
299
313
  print("[create-pkg] wrote pkg config to %s" % target)
300
314
 
301
315
 
@@ -417,7 +431,8 @@ def describe_expected_fields():
417
431
  - cmd: shell command string (required, often relative to cwd)
418
432
  - cwd: working directory (optional)
419
433
  - env: key/value env overrides for that command only (optional)
420
- auto_actions: mapping of lifecycle events to action names (create_pkg/update_pkg/update_pkg_release/close_pkg)
434
+ auto_actions: mapping of lifecycle events to action names (create_pkg/update_pkg/update_pkg_release/close_pkg/delete_pkg)
435
+ git.repo_root: override repo root for git scanning (optional)
421
436
  git.repo_url: base repository URL for commit links (per system)
422
437
  git.keyword_prefix: commit prefix used with git.keywords (e.g. "DEV-CODE:")
423
438
  """
@@ -84,6 +84,24 @@ def _write_pkg_state(pkg_id, status, extra=None):
84
84
  return state
85
85
 
86
86
 
87
+ def _touch_pkg_state_updated(pkg_id, updated_at=None):
88
+ now = updated_at or _timestamp()
89
+ existing = _load_pkg_state(pkg_id) or {}
90
+ state = {
91
+ "pkg_id": str(pkg_id),
92
+ "status": existing.get("status") or "unknown",
93
+ "opened_at": existing.get("opened_at"),
94
+ "updated_at": now,
95
+ "closed_at": existing.get("closed_at"),
96
+ }
97
+ state_dir = _pkg_state_dir(pkg_id)
98
+ if not os.path.exists(state_dir):
99
+ os.makedirs(state_dir)
100
+ with open(_pkg_state_path(pkg_id), "w") as f:
101
+ json.dump(state, f, ensure_ascii=False, indent=2, sort_keys=True)
102
+ return state
103
+
104
+
87
105
  def _parse_ts(value):
88
106
  if not value:
89
107
  return 0
@@ -109,6 +127,27 @@ def _load_pkg_summary():
109
127
  return {"generated_at": _timestamp(), "pkgs": []}
110
128
 
111
129
 
130
+ def _remove_pkg_summary_entry(pkg_id):
131
+ data = _load_pkg_summary()
132
+ pkgs = data.get("pkgs") or []
133
+ cleaned = []
134
+ for entry in pkgs:
135
+ if not isinstance(entry, dict):
136
+ continue
137
+ if entry.get("pkg_id") == str(pkg_id):
138
+ continue
139
+ cleaned.append(entry)
140
+ data = {
141
+ "generated_at": _timestamp(),
142
+ "pkgs": cleaned,
143
+ }
144
+ path = _pkg_summary_path()
145
+ if not os.path.exists(os.path.dirname(path)):
146
+ os.makedirs(os.path.dirname(path))
147
+ with open(path, "w") as f:
148
+ json.dump(data, f, ensure_ascii=False, indent=2, sort_keys=True)
149
+
150
+
112
151
  def _find_latest_update(pkg_id):
113
152
  updates_dir = os.path.join(config.DEFAULT_STATE_DIR, "pkg", str(pkg_id), "updates")
114
153
  if not os.path.isdir(updates_dir):
@@ -218,6 +257,47 @@ def pkg_state(pkg_id):
218
257
  return _load_pkg_state(pkg_id)
219
258
 
220
259
 
260
+ def _skip_release_entry(name):
261
+ upper = str(name or "").upper()
262
+ if not upper:
263
+ return True
264
+ if upper.startswith("BACKUP"):
265
+ return True
266
+ if upper in ("HISTORY",):
267
+ return True
268
+ if str(name).startswith("."):
269
+ return True
270
+ return False
271
+
272
+
273
+ def _discover_release_includes(pkg_root):
274
+ if not os.path.isdir(pkg_root):
275
+ return []
276
+ includes = []
277
+ for entry in sorted(os.listdir(pkg_root)):
278
+ if _skip_release_entry(entry):
279
+ continue
280
+ abspath = os.path.join(pkg_root, entry)
281
+ if os.path.isfile(abspath):
282
+ includes.append(entry)
283
+ continue
284
+ if not os.path.isdir(abspath):
285
+ continue
286
+ try:
287
+ children = sorted(os.listdir(abspath))
288
+ except Exception:
289
+ continue
290
+ added = False
291
+ for child in children:
292
+ if _skip_release_entry(child):
293
+ continue
294
+ includes.append(os.path.join(entry, child))
295
+ added = True
296
+ if not added:
297
+ includes.append(entry)
298
+ return includes
299
+
300
+
221
301
  def create_pkg(cfg, pkg_id):
222
302
  """Create pkg directory and write pkg.yaml template."""
223
303
  dest = _pkg_dir(cfg, pkg_id)
@@ -225,6 +305,13 @@ def create_pkg(cfg, pkg_id):
225
305
  os.makedirs(dest)
226
306
  template_path = os.path.join(dest, "pkg.yaml")
227
307
 
308
+ def _existing_pkg_status(path):
309
+ data = _read_yaml_path(path) or {}
310
+ if not isinstance(data, dict):
311
+ return None
312
+ pkg_info = data.get("pkg") if isinstance(data.get("pkg"), dict) else {}
313
+ return pkg_info.get("status")
314
+
228
315
  def _should_write_template(path):
229
316
  if not os.path.exists(path):
230
317
  return True
@@ -235,17 +322,34 @@ def create_pkg(cfg, pkg_id):
235
322
  ans = input(prompt).strip().lower()
236
323
  return ans in ("y", "yes")
237
324
 
238
- if not _should_write_template(template_path):
239
- print("[create-pkg] kept existing pkg.yaml; no changes made")
240
- return
325
+ if os.path.exists(template_path):
326
+ status = _existing_pkg_status(template_path)
327
+ if status == "deleted":
328
+ prompt = "[create-pkg] pkg.yaml is deleted; reopen and set status=open? [Y/n]: "
329
+ if not sys.stdin.isatty():
330
+ print(prompt + "non-tty -> keeping deleted")
331
+ return
332
+ ans = input(prompt).strip().lower()
333
+ if ans in ("", "y", "yes"):
334
+ _update_pkg_yaml_status(dest, "open")
335
+ _write_pkg_state(pkg_id, "open")
336
+ _update_pkg_summary(pkg_id)
337
+ print("[create-pkg] reopened %s (status=open)" % dest)
338
+ else:
339
+ print("[create-pkg] kept deleted status for %s" % dest)
340
+ return
341
+ if not _should_write_template(template_path):
342
+ print("[create-pkg] kept existing pkg.yaml; no changes made")
343
+ return
241
344
 
242
345
  git_cfg = cfg.get("git") or {}
243
346
  collectors_enabled = (cfg.get("collectors") or {}).get("enabled") or ["checksums"]
347
+ include_releases = _discover_release_includes(dest)
244
348
  config.write_pkg_template(
245
349
  template_path,
246
350
  pkg_id=pkg_id,
247
351
  pkg_root=dest,
248
- include_releases=[],
352
+ include_releases=include_releases,
249
353
  git_cfg=git_cfg,
250
354
  collectors_enabled=collectors_enabled,
251
355
  )
@@ -270,10 +374,26 @@ def close_pkg(cfg, pkg_id):
270
374
  with open(marker, "w") as f:
271
375
  f.write("closed\n")
272
376
  _write_pkg_state(pkg_id, "closed")
377
+ _update_pkg_yaml_status(dest, "closed")
273
378
  _update_pkg_summary(pkg_id)
274
379
  print("[close-pkg] marked closed: %s" % dest)
275
380
 
276
381
 
382
+ def delete_pkg(cfg, pkg_id):
383
+ """Delete pkg state data (closed only)."""
384
+ state = _load_pkg_state(pkg_id) or {}
385
+ status = state.get("status")
386
+ if status != "closed":
387
+ raise RuntimeError("delete-pkg requires closed status; run close-pkg first")
388
+ pkg_dir = _pkg_dir(cfg, pkg_id)
389
+ pkg_state_dir = _pkg_state_dir(pkg_id)
390
+ if os.path.isdir(pkg_state_dir):
391
+ shutil.rmtree(pkg_state_dir)
392
+ _remove_pkg_summary_entry(pkg_id)
393
+ _update_pkg_yaml_status(pkg_dir, "deleted")
394
+ print("[delete-pkg] removed state for %s" % pkg_id)
395
+
396
+
277
397
  def collect_for_pkg(cfg, pkg_id, collectors=None):
278
398
  """Run collector hooks (stub)."""
279
399
  if pkg_id and pkg_is_closed(pkg_id):
@@ -621,6 +741,43 @@ def _read_json_path(path):
621
741
  return None
622
742
 
623
743
 
744
+ def _read_yaml_path(path):
745
+ if config.yaml is None:
746
+ return None
747
+ for enc in ("utf-8", "euc-kr", "cp949"):
748
+ try:
749
+ with open(path, "r", encoding=enc) as f:
750
+ return config.yaml.safe_load(f) or {}
751
+ except Exception:
752
+ continue
753
+ return None
754
+
755
+
756
+ def _write_yaml_path(path, data):
757
+ if config.yaml is None:
758
+ return False
759
+ try:
760
+ dumped = config.yaml.safe_dump(data, allow_unicode=True, sort_keys=True)
761
+ with open(path, "w", encoding="euc-kr") as f:
762
+ f.write(dumped)
763
+ return True
764
+ except Exception:
765
+ return False
766
+
767
+
768
+ def _update_pkg_yaml_status(pkg_dir, status):
769
+ cfg_path = os.path.join(pkg_dir, "pkg.yaml")
770
+ if not os.path.isfile(cfg_path):
771
+ return False
772
+ data = _read_yaml_path(cfg_path)
773
+ if not isinstance(data, dict):
774
+ return False
775
+ pkg = data.get("pkg") if isinstance(data.get("pkg"), dict) else {}
776
+ pkg["status"] = status
777
+ data["pkg"] = pkg
778
+ return _write_yaml_path(cfg_path, data)
779
+
780
+
624
781
  def _read_note_text(path):
625
782
  try:
626
783
  with open(path, "r", encoding="utf-8") as f:
@@ -1379,6 +1536,7 @@ def update_pkg(cfg, pkg_id):
1379
1536
  with open(out_path, "w") as f:
1380
1537
  json.dump(data, f, ensure_ascii=False, indent=2, sort_keys=True)
1381
1538
  print("[update-pkg] wrote %s" % out_path)
1539
+ _touch_pkg_state_updated(pkg_id)
1382
1540
  _write_release_history(pkg_id, ts, release_bundle)
1383
1541
  _update_pkg_summary(pkg_id)
1384
1542
  return out_path
@@ -8,6 +8,7 @@ include:
8
8
 
9
9
  git:
10
10
  repo_root: null # optional override; default is git rev-parse from cwd
11
+ # pkgmgr.yaml 의 repo_root 값으로 자동 생성됩니다.
11
12
  # keywords are matched against commit messages; prefix is configurable in pkgmgr.yaml (git.keyword_prefix)
12
13
  keywords: []
13
14
  since: null
@@ -1,5 +1,6 @@
1
1
  pkg_release_root: ~/PKG/RELEASE
2
2
  git:
3
+ repo_root: null # 입력하는 경우 create-pkg 시 해당 정보로 자동 설정됩니다.
3
4
  repo_url: "https://github.com/org/repo"
4
5
  keyword_prefix: "DEV-CODE:"
5
6
  sources:
@@ -58,4 +59,5 @@ auto_actions:
58
59
  update_pkg: []
59
60
  update_pkg_release: []
60
61
  cancel_pkg_release: []
62
+ delete_pkg: []
61
63
  close_pkg: []
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pkgmgr-kunrunic
3
- Version: 0.1.2.dev1
3
+ Version: 0.1.2.dev2
4
4
  Summary: Package management workflow scaffold.
5
5
  Author: pkgmgr maintainers
6
6
  License: MIT License
@@ -2,5 +2,4 @@ design
2
2
  dist
3
3
  pkgmgr
4
4
  plugin
5
- test_data
6
5
  tools
@@ -61,6 +61,21 @@ 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_removed_pkgs(dest_state_root, allowed_pkg_ids):
65
+ if allowed_pkg_ids is None:
66
+ return
67
+ pkg_root = os.path.join(dest_state_root, "pkg")
68
+ if not os.path.isdir(pkg_root):
69
+ return
70
+ for name in os.listdir(pkg_root):
71
+ pkg_dir = os.path.join(pkg_root, name)
72
+ if not os.path.isdir(pkg_dir):
73
+ continue
74
+ if name in allowed_pkg_ids:
75
+ continue
76
+ shutil.rmtree(pkg_dir)
77
+
78
+
64
79
  def _prune_empty_dirs(root_dir):
65
80
  for base, dirs, files in os.walk(root_dir, topdown=False):
66
81
  if files:
@@ -162,11 +177,12 @@ def export_pkgstore(src, dest, clean=False, release_root=None, system_name=None)
162
177
  if not os.path.exists(dest):
163
178
  os.makedirs(dest)
164
179
  _copy_tree(src, dest)
180
+ allowed_pkg_ids = _list_pkg_ids(src)
165
181
  if release_root:
166
- allowed_pkg_ids = _list_pkg_ids(src)
167
182
  _copy_export_dirs(release_root, dest, allowed_pkg_ids=allowed_pkg_ids)
168
183
  _copy_release_tars(release_root, dest, allowed_pkg_ids=allowed_pkg_ids)
169
184
  _copy_readme_files(release_root, dest, system_name, allowed_pkg_ids=allowed_pkg_ids)
185
+ _prune_removed_pkgs(dest, allowed_pkg_ids)
170
186
 
171
187
 
172
188
  def main(argv=None):