pkgmgr-kunrunic 0.1.2.dev4__tar.gz → 0.1.2.dev5__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 (43) hide show
  1. {pkgmgr_kunrunic-0.1.2.dev4 → pkgmgr_kunrunic-0.1.2.dev5}/PKG-INFO +1 -1
  2. {pkgmgr_kunrunic-0.1.2.dev4 → pkgmgr_kunrunic-0.1.2.dev5}/pkgmgr/__init__.py +1 -1
  3. {pkgmgr_kunrunic-0.1.2.dev4 → pkgmgr_kunrunic-0.1.2.dev5}/pkgmgr/release.py +35 -14
  4. {pkgmgr_kunrunic-0.1.2.dev4 → pkgmgr_kunrunic-0.1.2.dev5}/pkgmgr_kunrunic.egg-info/PKG-INFO +1 -1
  5. {pkgmgr_kunrunic-0.1.2.dev4 → pkgmgr_kunrunic-0.1.2.dev5}/pkgmgr_kunrunic.egg-info/SOURCES.txt +1 -0
  6. pkgmgr_kunrunic-0.1.2.dev5/tests/test_release_symlink.py +78 -0
  7. {pkgmgr_kunrunic-0.1.2.dev4 → pkgmgr_kunrunic-0.1.2.dev5}/LICENSE +0 -0
  8. {pkgmgr_kunrunic-0.1.2.dev4 → pkgmgr_kunrunic-0.1.2.dev5}/README.md +0 -0
  9. {pkgmgr_kunrunic-0.1.2.dev4 → pkgmgr_kunrunic-0.1.2.dev5}/pkgmgr/__main__.py +0 -0
  10. {pkgmgr_kunrunic-0.1.2.dev4 → pkgmgr_kunrunic-0.1.2.dev5}/pkgmgr/cli.py +0 -0
  11. {pkgmgr_kunrunic-0.1.2.dev4 → pkgmgr_kunrunic-0.1.2.dev5}/pkgmgr/collectors/__init__.py +0 -0
  12. {pkgmgr_kunrunic-0.1.2.dev4 → pkgmgr_kunrunic-0.1.2.dev5}/pkgmgr/collectors/base.py +0 -0
  13. {pkgmgr_kunrunic-0.1.2.dev4 → pkgmgr_kunrunic-0.1.2.dev5}/pkgmgr/collectors/checksums.py +0 -0
  14. {pkgmgr_kunrunic-0.1.2.dev4 → pkgmgr_kunrunic-0.1.2.dev5}/pkgmgr/config.py +0 -0
  15. {pkgmgr_kunrunic-0.1.2.dev4 → pkgmgr_kunrunic-0.1.2.dev5}/pkgmgr/detection.py +0 -0
  16. {pkgmgr_kunrunic-0.1.2.dev4 → pkgmgr_kunrunic-0.1.2.dev5}/pkgmgr/points.py +0 -0
  17. {pkgmgr_kunrunic-0.1.2.dev4 → pkgmgr_kunrunic-0.1.2.dev5}/pkgmgr/shell_integration.py +0 -0
  18. {pkgmgr_kunrunic-0.1.2.dev4 → pkgmgr_kunrunic-0.1.2.dev5}/pkgmgr/snapshot.py +0 -0
  19. {pkgmgr_kunrunic-0.1.2.dev4 → pkgmgr_kunrunic-0.1.2.dev5}/pkgmgr/templates/pkg.yaml.sample +0 -0
  20. {pkgmgr_kunrunic-0.1.2.dev4 → pkgmgr_kunrunic-0.1.2.dev5}/pkgmgr/templates/pkgmgr.yaml.sample +0 -0
  21. {pkgmgr_kunrunic-0.1.2.dev4 → pkgmgr_kunrunic-0.1.2.dev5}/pkgmgr/watch.py +0 -0
  22. {pkgmgr_kunrunic-0.1.2.dev4 → pkgmgr_kunrunic-0.1.2.dev5}/pkgmgr_kunrunic.egg-info/dependency_links.txt +0 -0
  23. {pkgmgr_kunrunic-0.1.2.dev4 → pkgmgr_kunrunic-0.1.2.dev5}/pkgmgr_kunrunic.egg-info/entry_points.txt +0 -0
  24. {pkgmgr_kunrunic-0.1.2.dev4 → pkgmgr_kunrunic-0.1.2.dev5}/pkgmgr_kunrunic.egg-info/not-zip-safe +0 -0
  25. {pkgmgr_kunrunic-0.1.2.dev4 → pkgmgr_kunrunic-0.1.2.dev5}/pkgmgr_kunrunic.egg-info/requires.txt +0 -0
  26. {pkgmgr_kunrunic-0.1.2.dev4 → pkgmgr_kunrunic-0.1.2.dev5}/pkgmgr_kunrunic.egg-info/top_level.txt +0 -0
  27. {pkgmgr_kunrunic-0.1.2.dev4 → pkgmgr_kunrunic-0.1.2.dev5}/plugin/export_cksum.py +0 -0
  28. {pkgmgr_kunrunic-0.1.2.dev4 → pkgmgr_kunrunic-0.1.2.dev5}/plugin/export_pkgstore.py +0 -0
  29. {pkgmgr_kunrunic-0.1.2.dev4 → pkgmgr_kunrunic-0.1.2.dev5}/plugin/export_source_review.py +0 -0
  30. {pkgmgr_kunrunic-0.1.2.dev4 → pkgmgr_kunrunic-0.1.2.dev5}/plugin/export_trivy_sbom.py +0 -0
  31. {pkgmgr_kunrunic-0.1.2.dev4 → pkgmgr_kunrunic-0.1.2.dev5}/pyproject.toml +0 -0
  32. {pkgmgr_kunrunic-0.1.2.dev4 → pkgmgr_kunrunic-0.1.2.dev5}/setup.cfg +0 -0
  33. {pkgmgr_kunrunic-0.1.2.dev4 → pkgmgr_kunrunic-0.1.2.dev5}/tests/test_cli_detect.py +0 -0
  34. {pkgmgr_kunrunic-0.1.2.dev4 → pkgmgr_kunrunic-0.1.2.dev5}/tests/test_cli_install.py +0 -0
  35. {pkgmgr_kunrunic-0.1.2.dev4 → pkgmgr_kunrunic-0.1.2.dev5}/tests/test_cli_telegram.py +0 -0
  36. {pkgmgr_kunrunic-0.1.2.dev4 → pkgmgr_kunrunic-0.1.2.dev5}/tests/test_config.py +0 -0
  37. {pkgmgr_kunrunic-0.1.2.dev4 → pkgmgr_kunrunic-0.1.2.dev5}/tests/test_detection.py +0 -0
  38. {pkgmgr_kunrunic-0.1.2.dev4 → pkgmgr_kunrunic-0.1.2.dev5}/tests/test_export_trivy_sbom.py +0 -0
  39. {pkgmgr_kunrunic-0.1.2.dev4 → pkgmgr_kunrunic-0.1.2.dev5}/tests/test_progress.py +0 -0
  40. {pkgmgr_kunrunic-0.1.2.dev4 → pkgmgr_kunrunic-0.1.2.dev5}/tests/test_release.py +0 -0
  41. {pkgmgr_kunrunic-0.1.2.dev4 → pkgmgr_kunrunic-0.1.2.dev5}/tests/test_snapshot.py +0 -0
  42. {pkgmgr_kunrunic-0.1.2.dev4 → pkgmgr_kunrunic-0.1.2.dev5}/tests/test_watch_notify.py +0 -0
  43. {pkgmgr_kunrunic-0.1.2.dev4 → pkgmgr_kunrunic-0.1.2.dev5}/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.dev4
3
+ Version: 0.1.2.dev5
4
4
  Summary: Package management workflow scaffold.
5
5
  Author: pkgmgr maintainers
6
6
  License: MIT License
@@ -14,4 +14,4 @@ __all__ = [
14
14
  "detection",
15
15
  ]
16
16
 
17
- __version__ = "0.1.2.dev4"
17
+ __version__ = "0.1.2.dev5"
@@ -878,16 +878,37 @@ def _collect_release_sources(pkg_dir, pkg_cfg):
878
878
  return files
879
879
 
880
880
 
881
+ def _is_entry(path):
882
+ return os.path.islink(path) or os.path.isfile(path)
883
+
884
+
885
+ def _entry_hash(path):
886
+ # 링크는 대상 경로 문자열로 비교해야 lib 버전 체인이 대상 파일 변경에 끌려가지 않는다.
887
+ if os.path.islink(path):
888
+ return "symlink:" + os.readlink(path)
889
+ return checksums_module.sha256_of_file(path)
890
+
891
+
892
+ def _copy_entry(src, dest):
893
+ # 링크를 따라가 복사하면 release·tar·장비에서 링크가 실제 파일 사본으로 바뀐다.
894
+ if os.path.islink(dest) or os.path.exists(dest):
895
+ os.remove(dest)
896
+ if os.path.islink(src):
897
+ os.symlink(os.readlink(src), dest)
898
+ else:
899
+ shutil.copy2(src, dest)
900
+
901
+
881
902
  def _load_prev_hashes(prev_release_dir):
882
903
  hashes = {}
883
904
  for base, _, names in os.walk(prev_release_dir):
884
905
  for name in names:
885
906
  abspath = os.path.join(base, name)
886
- if not os.path.isfile(abspath):
907
+ if not _is_entry(abspath):
887
908
  continue
888
909
  rel = os.path.relpath(abspath, prev_release_dir)
889
910
  try:
890
- hashes[rel] = checksums_module.sha256_of_file(abspath)
911
+ hashes[rel] = _entry_hash(abspath)
891
912
  except Exception:
892
913
  continue
893
914
  return hashes
@@ -950,7 +971,7 @@ def _prepare_release(pkg_dir, pkg_cfg):
950
971
  if name in (_PKG_NOTE_NAME, _PKG_LIST_NAME):
951
972
  continue
952
973
  abspath = os.path.join(base, name)
953
- if not os.path.isfile(abspath):
974
+ if not _is_entry(abspath):
954
975
  continue
955
976
  rel = os.path.relpath(abspath, release_dir)
956
977
  existing.add(rel)
@@ -963,7 +984,7 @@ def _prepare_release(pkg_dir, pkg_cfg):
963
984
  if name in (_PKG_NOTE_NAME, _PKG_LIST_NAME):
964
985
  continue
965
986
  abspath = os.path.join(base, name)
966
- if not os.path.isfile(abspath):
987
+ if not _is_entry(abspath):
967
988
  continue
968
989
  rel = os.path.relpath(abspath, prev_dir)
969
990
  prev_existing.add(rel)
@@ -971,7 +992,7 @@ def _prepare_release(pkg_dir, pkg_cfg):
971
992
  for src, rel in entries:
972
993
  baseline_hash = baseline_hashes.get(rel)
973
994
  try:
974
- curr_hash = checksums_module.sha256_of_file(src)
995
+ curr_hash = _entry_hash(src)
975
996
  curr_hashes[rel] = curr_hash
976
997
  except Exception as e:
977
998
  print("[update-pkg] failed to hash %s: %s" % (src, str(e)))
@@ -1025,10 +1046,10 @@ def _prepare_release(pkg_dir, pkg_cfg):
1025
1046
  dest_parent = os.path.dirname(dest)
1026
1047
  if dest_parent and not os.path.exists(dest_parent):
1027
1048
  os.makedirs(dest_parent)
1028
- shutil.copy2(src, dest)
1049
+ _copy_entry(src, dest)
1029
1050
  for rel in sorted(removed):
1030
1051
  abspath = os.path.join(release_dir, rel)
1031
- if os.path.isfile(abspath):
1052
+ if _is_entry(abspath):
1032
1053
  os.remove(abspath)
1033
1054
  for base, dirs, files in os.walk(release_dir, topdown=False):
1034
1055
  if files:
@@ -1066,7 +1087,7 @@ def _prepare_release(pkg_dir, pkg_cfg):
1066
1087
  if name in (_PKG_NOTE_NAME, _PKG_LIST_NAME):
1067
1088
  continue
1068
1089
  abspath = os.path.join(base, name)
1069
- if not os.path.isfile(abspath):
1090
+ if not _is_entry(abspath):
1070
1091
  continue
1071
1092
  rel = os.path.relpath(abspath, release_dir)
1072
1093
  all_files.append(rel)
@@ -1133,12 +1154,12 @@ def _sync_baseline_root(root_dir, entries):
1133
1154
  dest_parent = os.path.dirname(dest)
1134
1155
  if dest_parent and not os.path.exists(dest_parent):
1135
1156
  os.makedirs(dest_parent)
1136
- shutil.copy2(src, dest)
1157
+ _copy_entry(src, dest)
1137
1158
 
1138
1159
  for base, _, names in os.walk(baseline_dir):
1139
1160
  for name in names:
1140
1161
  abspath = os.path.join(base, name)
1141
- if not os.path.isfile(abspath):
1162
+ if not _is_entry(abspath):
1142
1163
  continue
1143
1164
  rel = os.path.relpath(abspath, baseline_dir)
1144
1165
  if rel not in expected:
@@ -1379,7 +1400,7 @@ def _reset_baseline_from_active(root_dir, release_name):
1379
1400
  continue
1380
1401
  src = os.path.join(base, name)
1381
1402
  dest = os.path.join(dest_base, name)
1382
- shutil.copy2(src, dest)
1403
+ _copy_entry(src, dest)
1383
1404
  print("[cancel] baseline reset from active for %s" % root_dir)
1384
1405
 
1385
1406
 
@@ -1406,18 +1427,18 @@ def _revert_baseline_for_bundles(release_root, bundles):
1406
1427
  continue
1407
1428
  for rel in added:
1408
1429
  target = os.path.join(baseline_dir, rel)
1409
- if os.path.isfile(target):
1430
+ if _is_entry(target):
1410
1431
  os.remove(target)
1411
1432
  if prev_release:
1412
1433
  for rel in list(set(updated + removed)):
1413
1434
  src = os.path.join(prev_release, rel)
1414
- if not os.path.isfile(src):
1435
+ if not _is_entry(src):
1415
1436
  continue
1416
1437
  dest = os.path.join(baseline_dir, rel)
1417
1438
  dest_parent = os.path.dirname(dest)
1418
1439
  if dest_parent and not os.path.exists(dest_parent):
1419
1440
  os.makedirs(dest_parent)
1420
- shutil.copy2(src, dest)
1441
+ _copy_entry(src, dest)
1421
1442
  _prune_empty_dirs(baseline_dir)
1422
1443
  print("[cancel] baseline reverted for %s" % root)
1423
1444
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pkgmgr-kunrunic
3
- Version: 0.1.2.dev4
3
+ Version: 0.1.2.dev5
4
4
  Summary: Package management workflow scaffold.
5
5
  Author: pkgmgr maintainers
6
6
  License: MIT License
@@ -35,6 +35,7 @@ tests/test_detection.py
35
35
  tests/test_export_trivy_sbom.py
36
36
  tests/test_progress.py
37
37
  tests/test_release.py
38
+ tests/test_release_symlink.py
38
39
  tests/test_snapshot.py
39
40
  tests/test_watch_notify.py
40
41
  tools/echo_args.py
@@ -0,0 +1,78 @@
1
+ import json
2
+ import tarfile
3
+ import os
4
+ import sys
5
+ import tempfile
6
+ import shlex
7
+ from importlib import import_module, reload
8
+ from pathlib import Path
9
+
10
+ ROOT = Path(__file__).resolve().parents[1]
11
+ if str(ROOT) not in sys.path:
12
+ sys.path.insert(0, str(ROOT))
13
+
14
+ config = import_module("pkgmgr.config")
15
+ release = import_module("pkgmgr.release")
16
+ snapshot = import_module("pkgmgr.snapshot")
17
+ reload(config)
18
+ reload(release)
19
+ reload(snapshot)
20
+
21
+
22
+ def _setup_state_dir(monkeypatch, base_dir):
23
+ state_dir = Path(base_dir) / "state"
24
+ monkeypatch.setattr(config, "DEFAULT_STATE_DIR", str(state_dir))
25
+ monkeypatch.setattr(snapshot, "STATE_DIR", str(state_dir))
26
+ return state_dir
27
+
28
+
29
+ def _write_pkg_yaml(pkg_dir, pkg_id, include_releases):
30
+ config.write_pkg_template(
31
+ os.path.join(pkg_dir, "pkg.yaml"),
32
+ pkg_id=pkg_id,
33
+ pkg_root=pkg_dir,
34
+ include_releases=include_releases,
35
+ git_cfg={"keywords": []},
36
+ collectors_enabled=["checksums"],
37
+ )
38
+
39
+ def test_update_pkg_keeps_symlinks_in_release_tar_and_baseline(monkeypatch):
40
+ with tempfile.TemporaryDirectory() as tmp:
41
+ base = Path(tmp)
42
+ _setup_state_dir(monkeypatch, base)
43
+ pkg_root = base / "pkgs"
44
+ pkg_id = "20240120"
45
+ pkg_dir = pkg_root / pkg_id
46
+ lib_dir = pkg_dir / "sys" / "lib"
47
+ lib_dir.mkdir(parents=True)
48
+ (lib_dir / "libx-1.0.0.so").write_text("v1")
49
+ os.symlink("libx-1.0.0.so", str(lib_dir / "libx-1.0.so"))
50
+ os.symlink("libx-1.0.so", str(lib_dir / "libx.so"))
51
+
52
+ _write_pkg_yaml(str(pkg_dir), pkg_id, ["sys/lib"])
53
+ cfg = {"pkg_release_root": str(pkg_root)}
54
+ release.update_pkg(cfg, pkg_id)
55
+
56
+ rel_lib = pkg_dir / "release" / "sys" / "release.v0.0.1" / "lib"
57
+ assert os.path.islink(str(rel_lib / "libx-1.0.so"))
58
+ assert os.readlink(str(rel_lib / "libx.so")) == "libx-1.0.so"
59
+ assert not os.path.islink(str(rel_lib / "libx-1.0.0.so"))
60
+
61
+ release.finalize_pkg_release(cfg, pkg_id)
62
+ root = pkg_dir / "release" / "sys"
63
+ with tarfile.open(str(root / "release.v0.0.1.tar"), "r") as tar:
64
+ member = tar.getmember("release.v0.0.1/lib/libx.so")
65
+ assert member.issym() and member.linkname == "libx-1.0.so"
66
+ assert os.path.islink(str(root / "HISTORY" / "BASELINE" / "lib" / "libx.so"))
67
+
68
+ # 대상 파일만 바뀌면 링크는 v0.0.2 에 들어가지 않는다
69
+ (lib_dir / "libx-1.0.0.so").write_text("v2")
70
+ release.update_pkg(cfg, pkg_id)
71
+ v002 = root / "release.v0.0.2" / "lib"
72
+ assert sorted(os.listdir(str(v002))) == ["libx-1.0.0.so"]
73
+
74
+ # 링크 대상이 바뀌면 링크만 변경으로 잡힌다
75
+ os.remove(str(lib_dir / "libx.so"))
76
+ os.symlink("libx-1.0.0.so", str(lib_dir / "libx.so"))
77
+ release.update_pkg(cfg, pkg_id)
78
+ assert os.readlink(str(v002 / "libx.so")) == "libx-1.0.0.so"