pkgmgr-kunrunic 0.1.0.dev2__tar.gz → 0.1.0.dev3__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.0.dev2 → pkgmgr_kunrunic-0.1.0.dev3}/PKG-INFO +24 -15
- {pkgmgr_kunrunic-0.1.0.dev2 → pkgmgr_kunrunic-0.1.0.dev3}/README.md +23 -14
- {pkgmgr_kunrunic-0.1.0.dev2 → pkgmgr_kunrunic-0.1.0.dev3}/pkgmgr/__init__.py +1 -1
- {pkgmgr_kunrunic-0.1.0.dev2 → pkgmgr_kunrunic-0.1.0.dev3}/pkgmgr/cli.py +26 -9
- {pkgmgr_kunrunic-0.1.0.dev2 → pkgmgr_kunrunic-0.1.0.dev3}/pkgmgr/config.py +57 -14
- pkgmgr_kunrunic-0.1.0.dev3/pkgmgr/release.py +115 -0
- pkgmgr_kunrunic-0.1.0.dev3/pkgmgr/snapshot.py +153 -0
- {pkgmgr_kunrunic-0.1.0.dev2 → pkgmgr_kunrunic-0.1.0.dev3}/pkgmgr/templates/pkg.yaml.sample +1 -1
- pkgmgr_kunrunic-0.1.0.dev3/pkgmgr/templates/pkgmgr.yaml.sample +39 -0
- {pkgmgr_kunrunic-0.1.0.dev2 → pkgmgr_kunrunic-0.1.0.dev3}/pkgmgr_kunrunic.egg-info/PKG-INFO +24 -15
- pkgmgr_kunrunic-0.1.0.dev2/pkgmgr/release.py +0 -58
- pkgmgr_kunrunic-0.1.0.dev2/pkgmgr/snapshot.py +0 -27
- pkgmgr_kunrunic-0.1.0.dev2/pkgmgr/templates/pkgmgr.yaml.sample +0 -14
- {pkgmgr_kunrunic-0.1.0.dev2 → pkgmgr_kunrunic-0.1.0.dev3}/LICENSE +0 -0
- {pkgmgr_kunrunic-0.1.0.dev2 → pkgmgr_kunrunic-0.1.0.dev3}/pkgmgr/__main__.py +0 -0
- {pkgmgr_kunrunic-0.1.0.dev2 → pkgmgr_kunrunic-0.1.0.dev3}/pkgmgr/collectors/__init__.py +0 -0
- {pkgmgr_kunrunic-0.1.0.dev2 → pkgmgr_kunrunic-0.1.0.dev3}/pkgmgr/collectors/base.py +0 -0
- {pkgmgr_kunrunic-0.1.0.dev2 → pkgmgr_kunrunic-0.1.0.dev3}/pkgmgr/collectors/checksums.py +0 -0
- {pkgmgr_kunrunic-0.1.0.dev2 → pkgmgr_kunrunic-0.1.0.dev3}/pkgmgr/gitcollect.py +0 -0
- {pkgmgr_kunrunic-0.1.0.dev2 → pkgmgr_kunrunic-0.1.0.dev3}/pkgmgr/shell_integration.py +0 -0
- {pkgmgr_kunrunic-0.1.0.dev2 → pkgmgr_kunrunic-0.1.0.dev3}/pkgmgr/watch.py +0 -0
- {pkgmgr_kunrunic-0.1.0.dev2 → pkgmgr_kunrunic-0.1.0.dev3}/pkgmgr_kunrunic.egg-info/SOURCES.txt +0 -0
- {pkgmgr_kunrunic-0.1.0.dev2 → pkgmgr_kunrunic-0.1.0.dev3}/pkgmgr_kunrunic.egg-info/dependency_links.txt +0 -0
- {pkgmgr_kunrunic-0.1.0.dev2 → pkgmgr_kunrunic-0.1.0.dev3}/pkgmgr_kunrunic.egg-info/entry_points.txt +0 -0
- {pkgmgr_kunrunic-0.1.0.dev2 → pkgmgr_kunrunic-0.1.0.dev3}/pkgmgr_kunrunic.egg-info/not-zip-safe +0 -0
- {pkgmgr_kunrunic-0.1.0.dev2 → pkgmgr_kunrunic-0.1.0.dev3}/pkgmgr_kunrunic.egg-info/requires.txt +0 -0
- {pkgmgr_kunrunic-0.1.0.dev2 → pkgmgr_kunrunic-0.1.0.dev3}/pkgmgr_kunrunic.egg-info/top_level.txt +0 -0
- {pkgmgr_kunrunic-0.1.0.dev2 → pkgmgr_kunrunic-0.1.0.dev3}/pyproject.toml +0 -0
- {pkgmgr_kunrunic-0.1.0.dev2 → pkgmgr_kunrunic-0.1.0.dev3}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pkgmgr-kunrunic
|
|
3
|
-
Version: 0.1.0.
|
|
3
|
+
Version: 0.1.0.dev3
|
|
4
4
|
Summary: Package management workflow scaffold.
|
|
5
5
|
Author: pkgmgr maintainers
|
|
6
6
|
License: MIT License
|
|
@@ -62,7 +62,8 @@ Dynamic: license-file
|
|
|
62
62
|
- PyYAML 6.x (의존성에 포함되어 일반 설치 시 자동 설치)
|
|
63
63
|
|
|
64
64
|
## 기본 사용 흐름 (스캐폴드)
|
|
65
|
-
아래 명령은 `python -m pkgmgr.cli ...` 형태로 실행합니다.
|
|
65
|
+
아래 명령은 `python -m pkgmgr.cli ...` 형태로 실행합니다.
|
|
66
|
+
설정 파일 기본 경로는 `~/pkmgr/config/pkgmgr.yaml`이며, `--config`로 다른 경로를 지정할 수 있습니다.
|
|
66
67
|
|
|
67
68
|
1) 메인 설정 템플릿 생성
|
|
68
69
|
```
|
|
@@ -70,17 +71,18 @@ python -m pkgmgr.cli make-config -o pkgmgr.yaml
|
|
|
70
71
|
```
|
|
71
72
|
`pkgmgr.yaml`에서 소스 경로, 설치 타깃(bin/lib/data 등), release 루트, Git 키워드, 감시 주기, 기본 컬렉터 목록 등을 편집합니다. 기본 생성 위치는 `~/pkmgr/config/pkgmgr.yaml`이며, `--config`로 다른 경로를 지정할 수 있습니다. 상태/캐시 데이터는 추후 `~/pkmgr/local/state`, `~/pkmgr/cache`에 둘 예정입니다.
|
|
72
73
|
|
|
73
|
-
2) 환경 준비
|
|
74
|
+
2) 환경 준비 + 초기 베이스라인 수집
|
|
74
75
|
```
|
|
75
76
|
python -m pkgmgr.cli install
|
|
76
77
|
```
|
|
77
|
-
(
|
|
78
|
+
- 셸 PATH/alias 자동 등록 후, 기본 설정(`~/pkmgr/config/pkgmgr.yaml`)을 읽어 초기 베이스라인 스냅샷을 저장 (`~/pkmgr/local/state/baseline.json`).
|
|
79
|
+
- 추후 의존성/경로 체크 추가 예정.
|
|
78
80
|
|
|
79
|
-
3)
|
|
81
|
+
3) 스냅샷 갱신
|
|
80
82
|
```
|
|
81
|
-
python -m pkgmgr.cli
|
|
83
|
+
python -m pkgmgr.cli snapshot --config pkgmgr.yaml
|
|
82
84
|
```
|
|
83
|
-
설정된
|
|
85
|
+
설정된 소스/아티팩트/릴리스 루트를 기준으로 최신 스냅샷을 저장합니다 (`~/pkmgr/local/state/snapshot.json`). 이후 diff/감시에 사용할 예정입니다.
|
|
84
86
|
|
|
85
87
|
4) 패키지 생성
|
|
86
88
|
```
|
|
@@ -99,20 +101,26 @@ python -m pkgmgr.cli close-pkg <pkg-id> --config pkgmgr.yaml
|
|
|
99
101
|
python -m pkgmgr.cli watch --config pkgmgr.yaml
|
|
100
102
|
python -m pkgmgr.cli watch --config pkgmgr.yaml --once # 한 번만 폴링
|
|
101
103
|
```
|
|
102
|
-
설정된 interval로 변경을 감시하는 로직을 연결할 예정입니다.
|
|
104
|
+
설정된 interval로 변경을 감시하는 로직을 연결할 예정입니다. (현재는 스텁 로그만 출력)
|
|
103
105
|
|
|
104
106
|
7) 수집(컬렉터)
|
|
105
107
|
```
|
|
106
108
|
python -m pkgmgr.cli collect --pkg <pkg-id> --config pkgmgr.yaml
|
|
107
109
|
python -m pkgmgr.cli collect --pkg <pkg-id> --collector checksums --config pkgmgr.yaml
|
|
108
110
|
```
|
|
109
|
-
체크섬/정적/동적/EDR/백신 등 컬렉터를 플러그인 형태로 추가할 수 있도록 확장 예정입니다.
|
|
111
|
+
체크섬/정적/동적/EDR/백신 등 컬렉터를 플러그인 형태로 추가할 수 있도록 확장 예정입니다. (현재는 스텁 로그만 출력)
|
|
110
112
|
|
|
111
113
|
8) 내보내기
|
|
112
114
|
```
|
|
113
115
|
python -m pkgmgr.cli export --pkg <pkg-id> --format excel --config pkgmgr.yaml
|
|
114
116
|
```
|
|
115
|
-
엑셀/워드/JSON 등의 산출물을 생성하는 후크를 붙일 계획입니다.
|
|
117
|
+
엑셀/워드/JSON 등의 산출물을 생성하는 후크를 붙일 계획입니다. (현재는 스텁 로그만 출력)
|
|
118
|
+
|
|
119
|
+
9) 액션 실행
|
|
120
|
+
```
|
|
121
|
+
python -m pkgmgr.cli actions <action-name> [<action-name> ...] --config pkgmgr.yaml
|
|
122
|
+
```
|
|
123
|
+
`actions` 설정에 등록된 커맨드를 순서대로 실행합니다(`cmd` 필수, `cwd`/`env` 선택). (실제 실행 로직은 포함되어 있음)
|
|
116
124
|
|
|
117
125
|
## 설치·PATH/alias 자동 추가
|
|
118
126
|
- `python -m pip install .` 후 `python -m pkgmgr.cli install`을 실행하면 현재 파이썬의 `bin` 경로(예: venv/bin, ~/.local/bin 등)를 감지해 사용 중인 쉘의 rc 파일에 PATH/alias를 추가합니다.
|
|
@@ -132,17 +140,18 @@ python -m pkgmgr.cli export --pkg <pkg-id> --format excel --config pkgmgr.yaml
|
|
|
132
140
|
|
|
133
141
|
## 템플릿 개요
|
|
134
142
|
- `pkgmgr/templates/pkgmgr.yaml.sample` : 메인 설정 샘플
|
|
135
|
-
- `version`: 스키마 버전
|
|
136
143
|
- `pkg_release_root`: 패키지 릴리스 루트
|
|
137
144
|
- `sources`: 관리할 소스 경로 목록
|
|
138
|
-
- `
|
|
145
|
+
- `source.exclude`: 소스 스캔 제외 패턴 (glob 지원)
|
|
146
|
+
- `artifacts.targets` / `artifacts.exclude`: 배포 대상 포함/제외 규칙 (glob 지원: `tmp/**`, `*.bak`, `**/*.tmp` 등)
|
|
139
147
|
- `watch.interval_sec`: 감시 폴링 주기
|
|
140
|
-
- `
|
|
148
|
+
- `watch.on_change`: 변경 시 실행할 action 이름 리스트
|
|
141
149
|
- `collectors.enabled`: 기본 활성 컬렉터
|
|
150
|
+
- `actions`: action 이름 → 실행할 커맨드 목록 (각 항목에 `cmd` 필수, `cwd`/`env` 선택)
|
|
142
151
|
|
|
143
152
|
- `pkgmgr/templates/pkg.yaml.sample` : 패키지별 설정 샘플
|
|
144
153
|
- `pkg.id` / `pkg.root` / `pkg.status(open|closed)`
|
|
145
|
-
- `include.sources/
|
|
154
|
+
- `include.sources/artifacts/pkg_dir`: 포함 대상
|
|
146
155
|
- `git.keywords/since/until`: 커밋 수집 범위
|
|
147
156
|
- `collectors.enabled`: 패키지별 컬렉터 설정
|
|
148
157
|
|
|
@@ -150,7 +159,7 @@ python -m pkgmgr.cli export --pkg <pkg-id> --format excel --config pkgmgr.yaml
|
|
|
150
159
|
- 아직 핵심 로직(스냅샷/감시/수집/내보내기)은 스텁입니다. 추후 단계적으로 구현/교체 예정입니다.
|
|
151
160
|
|
|
152
161
|
## TODO (우선순위)
|
|
153
|
-
- 스냅샷/디프 구현: `pkgmgr/snapshot.py`에 해시/mtime/size 스캔, baseline/latest 저장(`state/...`), diff 작성. CLI `
|
|
162
|
+
- 스냅샷/디프 구현: `pkgmgr/snapshot.py`에 해시/mtime/size 스캔, baseline/latest 저장(`state/...`), diff 작성. CLI `snapshot`/`watch` 연결.
|
|
154
163
|
- 설정 스키마 검증: `pkgmgr/config.py` 필수 필드 확인, 기본값 주입, PyYAML 체크, 템플릿 필드 설명 보강.
|
|
155
164
|
- 패키지 라이프사이클: `release.py`에서 `create-pkg` 시 `pkg.yaml` 초기화, `close-pkg` 상태 저장, 상태 파일 표준화.
|
|
156
165
|
- Git 수집: `gitcollect.py`에 키워드/정규식 로그 수집, `state/pkg/<id>/commits.json` 저장, `collect_for_pkg`에서 호출.
|
|
@@ -14,7 +14,8 @@
|
|
|
14
14
|
- PyYAML 6.x (의존성에 포함되어 일반 설치 시 자동 설치)
|
|
15
15
|
|
|
16
16
|
## 기본 사용 흐름 (스캐폴드)
|
|
17
|
-
아래 명령은 `python -m pkgmgr.cli ...` 형태로 실행합니다.
|
|
17
|
+
아래 명령은 `python -m pkgmgr.cli ...` 형태로 실행합니다.
|
|
18
|
+
설정 파일 기본 경로는 `~/pkmgr/config/pkgmgr.yaml`이며, `--config`로 다른 경로를 지정할 수 있습니다.
|
|
18
19
|
|
|
19
20
|
1) 메인 설정 템플릿 생성
|
|
20
21
|
```
|
|
@@ -22,17 +23,18 @@ python -m pkgmgr.cli make-config -o pkgmgr.yaml
|
|
|
22
23
|
```
|
|
23
24
|
`pkgmgr.yaml`에서 소스 경로, 설치 타깃(bin/lib/data 등), release 루트, Git 키워드, 감시 주기, 기본 컬렉터 목록 등을 편집합니다. 기본 생성 위치는 `~/pkmgr/config/pkgmgr.yaml`이며, `--config`로 다른 경로를 지정할 수 있습니다. 상태/캐시 데이터는 추후 `~/pkmgr/local/state`, `~/pkmgr/cache`에 둘 예정입니다.
|
|
24
25
|
|
|
25
|
-
2) 환경 준비
|
|
26
|
+
2) 환경 준비 + 초기 베이스라인 수집
|
|
26
27
|
```
|
|
27
28
|
python -m pkgmgr.cli install
|
|
28
29
|
```
|
|
29
|
-
(
|
|
30
|
+
- 셸 PATH/alias 자동 등록 후, 기본 설정(`~/pkmgr/config/pkgmgr.yaml`)을 읽어 초기 베이스라인 스냅샷을 저장 (`~/pkmgr/local/state/baseline.json`).
|
|
31
|
+
- 추후 의존성/경로 체크 추가 예정.
|
|
30
32
|
|
|
31
|
-
3)
|
|
33
|
+
3) 스냅샷 갱신
|
|
32
34
|
```
|
|
33
|
-
python -m pkgmgr.cli
|
|
35
|
+
python -m pkgmgr.cli snapshot --config pkgmgr.yaml
|
|
34
36
|
```
|
|
35
|
-
설정된
|
|
37
|
+
설정된 소스/아티팩트/릴리스 루트를 기준으로 최신 스냅샷을 저장합니다 (`~/pkmgr/local/state/snapshot.json`). 이후 diff/감시에 사용할 예정입니다.
|
|
36
38
|
|
|
37
39
|
4) 패키지 생성
|
|
38
40
|
```
|
|
@@ -51,20 +53,26 @@ python -m pkgmgr.cli close-pkg <pkg-id> --config pkgmgr.yaml
|
|
|
51
53
|
python -m pkgmgr.cli watch --config pkgmgr.yaml
|
|
52
54
|
python -m pkgmgr.cli watch --config pkgmgr.yaml --once # 한 번만 폴링
|
|
53
55
|
```
|
|
54
|
-
설정된 interval로 변경을 감시하는 로직을 연결할 예정입니다.
|
|
56
|
+
설정된 interval로 변경을 감시하는 로직을 연결할 예정입니다. (현재는 스텁 로그만 출력)
|
|
55
57
|
|
|
56
58
|
7) 수집(컬렉터)
|
|
57
59
|
```
|
|
58
60
|
python -m pkgmgr.cli collect --pkg <pkg-id> --config pkgmgr.yaml
|
|
59
61
|
python -m pkgmgr.cli collect --pkg <pkg-id> --collector checksums --config pkgmgr.yaml
|
|
60
62
|
```
|
|
61
|
-
체크섬/정적/동적/EDR/백신 등 컬렉터를 플러그인 형태로 추가할 수 있도록 확장 예정입니다.
|
|
63
|
+
체크섬/정적/동적/EDR/백신 등 컬렉터를 플러그인 형태로 추가할 수 있도록 확장 예정입니다. (현재는 스텁 로그만 출력)
|
|
62
64
|
|
|
63
65
|
8) 내보내기
|
|
64
66
|
```
|
|
65
67
|
python -m pkgmgr.cli export --pkg <pkg-id> --format excel --config pkgmgr.yaml
|
|
66
68
|
```
|
|
67
|
-
엑셀/워드/JSON 등의 산출물을 생성하는 후크를 붙일 계획입니다.
|
|
69
|
+
엑셀/워드/JSON 등의 산출물을 생성하는 후크를 붙일 계획입니다. (현재는 스텁 로그만 출력)
|
|
70
|
+
|
|
71
|
+
9) 액션 실행
|
|
72
|
+
```
|
|
73
|
+
python -m pkgmgr.cli actions <action-name> [<action-name> ...] --config pkgmgr.yaml
|
|
74
|
+
```
|
|
75
|
+
`actions` 설정에 등록된 커맨드를 순서대로 실행합니다(`cmd` 필수, `cwd`/`env` 선택). (실제 실행 로직은 포함되어 있음)
|
|
68
76
|
|
|
69
77
|
## 설치·PATH/alias 자동 추가
|
|
70
78
|
- `python -m pip install .` 후 `python -m pkgmgr.cli install`을 실행하면 현재 파이썬의 `bin` 경로(예: venv/bin, ~/.local/bin 등)를 감지해 사용 중인 쉘의 rc 파일에 PATH/alias를 추가합니다.
|
|
@@ -84,17 +92,18 @@ python -m pkgmgr.cli export --pkg <pkg-id> --format excel --config pkgmgr.yaml
|
|
|
84
92
|
|
|
85
93
|
## 템플릿 개요
|
|
86
94
|
- `pkgmgr/templates/pkgmgr.yaml.sample` : 메인 설정 샘플
|
|
87
|
-
- `version`: 스키마 버전
|
|
88
95
|
- `pkg_release_root`: 패키지 릴리스 루트
|
|
89
96
|
- `sources`: 관리할 소스 경로 목록
|
|
90
|
-
- `
|
|
97
|
+
- `source.exclude`: 소스 스캔 제외 패턴 (glob 지원)
|
|
98
|
+
- `artifacts.targets` / `artifacts.exclude`: 배포 대상 포함/제외 규칙 (glob 지원: `tmp/**`, `*.bak`, `**/*.tmp` 등)
|
|
91
99
|
- `watch.interval_sec`: 감시 폴링 주기
|
|
92
|
-
- `
|
|
100
|
+
- `watch.on_change`: 변경 시 실행할 action 이름 리스트
|
|
93
101
|
- `collectors.enabled`: 기본 활성 컬렉터
|
|
102
|
+
- `actions`: action 이름 → 실행할 커맨드 목록 (각 항목에 `cmd` 필수, `cwd`/`env` 선택)
|
|
94
103
|
|
|
95
104
|
- `pkgmgr/templates/pkg.yaml.sample` : 패키지별 설정 샘플
|
|
96
105
|
- `pkg.id` / `pkg.root` / `pkg.status(open|closed)`
|
|
97
|
-
- `include.sources/
|
|
106
|
+
- `include.sources/artifacts/pkg_dir`: 포함 대상
|
|
98
107
|
- `git.keywords/since/until`: 커밋 수집 범위
|
|
99
108
|
- `collectors.enabled`: 패키지별 컬렉터 설정
|
|
100
109
|
|
|
@@ -102,7 +111,7 @@ python -m pkgmgr.cli export --pkg <pkg-id> --format excel --config pkgmgr.yaml
|
|
|
102
111
|
- 아직 핵심 로직(스냅샷/감시/수집/내보내기)은 스텁입니다. 추후 단계적으로 구현/교체 예정입니다.
|
|
103
112
|
|
|
104
113
|
## TODO (우선순위)
|
|
105
|
-
- 스냅샷/디프 구현: `pkgmgr/snapshot.py`에 해시/mtime/size 스캔, baseline/latest 저장(`state/...`), diff 작성. CLI `
|
|
114
|
+
- 스냅샷/디프 구현: `pkgmgr/snapshot.py`에 해시/mtime/size 스캔, baseline/latest 저장(`state/...`), diff 작성. CLI `snapshot`/`watch` 연결.
|
|
106
115
|
- 설정 스키마 검증: `pkgmgr/config.py` 필수 필드 확인, 기본값 주입, PyYAML 체크, 템플릿 필드 설명 보강.
|
|
107
116
|
- 패키지 라이프사이클: `release.py`에서 `create-pkg` 시 `pkg.yaml` 초기화, `close-pkg` 상태 저장, 상태 파일 표준화.
|
|
108
117
|
- Git 수집: `gitcollect.py`에 키워드/정규식 로그 수집, `state/pkg/<id>/commits.json` 저장, `collect_for_pkg`에서 호출.
|
|
@@ -4,7 +4,7 @@ from __future__ import print_function
|
|
|
4
4
|
import sys
|
|
5
5
|
|
|
6
6
|
try:
|
|
7
|
-
import argparse
|
|
7
|
+
import argparse
|
|
8
8
|
except Exception:
|
|
9
9
|
argparse = None
|
|
10
10
|
|
|
@@ -23,18 +23,26 @@ def _add_make_config(sub):
|
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
def _add_install(sub):
|
|
26
|
-
p = sub.add_parser("install", help="
|
|
26
|
+
p = sub.add_parser("install", help="prepare environment and collect initial baseline")
|
|
27
27
|
p.set_defaults(func=_handle_install)
|
|
28
28
|
|
|
29
29
|
|
|
30
|
-
def
|
|
30
|
+
def _add_snapshot(sub):
|
|
31
31
|
p = sub.add_parser(
|
|
32
|
-
"
|
|
32
|
+
"snapshot", help="take a snapshot (baseline update after install)"
|
|
33
33
|
)
|
|
34
34
|
p.add_argument(
|
|
35
35
|
"--config", default=config.DEFAULT_MAIN_CONFIG, help="config file path"
|
|
36
36
|
)
|
|
37
|
-
p.set_defaults(func=
|
|
37
|
+
p.set_defaults(func=_handle_snapshot)
|
|
38
|
+
|
|
39
|
+
def _add_actions(sub):
|
|
40
|
+
p = sub.add_parser("actions", help="run one or more configured actions")
|
|
41
|
+
p.add_argument("names", nargs="+", help="action names to run")
|
|
42
|
+
p.add_argument(
|
|
43
|
+
"--config", default=config.DEFAULT_MAIN_CONFIG, help="config file path"
|
|
44
|
+
)
|
|
45
|
+
p.set_defaults(func=_handle_actions)
|
|
38
46
|
|
|
39
47
|
|
|
40
48
|
def _add_create_pkg(sub):
|
|
@@ -95,18 +103,19 @@ def _add_export(sub):
|
|
|
95
103
|
|
|
96
104
|
def build_parser():
|
|
97
105
|
if argparse is None:
|
|
98
|
-
raise RuntimeError("argparse not available
|
|
106
|
+
raise RuntimeError("argparse not available; install argparse")
|
|
99
107
|
parser = argparse.ArgumentParser(prog="pkgmgr", description="Pkg manager CLI scaffold")
|
|
100
108
|
sub = parser.add_subparsers(dest="command")
|
|
101
109
|
|
|
102
110
|
_add_make_config(sub)
|
|
103
111
|
_add_install(sub)
|
|
104
|
-
|
|
112
|
+
_add_snapshot(sub)
|
|
105
113
|
_add_create_pkg(sub)
|
|
106
114
|
_add_close_pkg(sub)
|
|
107
115
|
_add_watch(sub)
|
|
108
116
|
_add_collect(sub)
|
|
109
117
|
_add_export(sub)
|
|
118
|
+
_add_actions(sub)
|
|
110
119
|
return parser
|
|
111
120
|
|
|
112
121
|
|
|
@@ -116,13 +125,15 @@ def _handle_make_config(args):
|
|
|
116
125
|
|
|
117
126
|
|
|
118
127
|
def _handle_install(args):
|
|
128
|
+
cfg = config.load_main(config.DEFAULT_MAIN_CONFIG)
|
|
119
129
|
release.ensure_environment()
|
|
130
|
+
snapshot.create_baseline(cfg)
|
|
120
131
|
return 0
|
|
121
132
|
|
|
122
133
|
|
|
123
|
-
def
|
|
134
|
+
def _handle_snapshot(args):
|
|
124
135
|
cfg = config.load_main(args.config)
|
|
125
|
-
snapshot.
|
|
136
|
+
snapshot.create_snapshot(cfg)
|
|
126
137
|
return 0
|
|
127
138
|
|
|
128
139
|
|
|
@@ -156,6 +167,12 @@ def _handle_export(args):
|
|
|
156
167
|
return 0
|
|
157
168
|
|
|
158
169
|
|
|
170
|
+
def _handle_actions(args):
|
|
171
|
+
cfg = config.load_main(args.config)
|
|
172
|
+
release.run_actions(cfg, args.names)
|
|
173
|
+
return 0
|
|
174
|
+
|
|
175
|
+
|
|
159
176
|
def main(argv=None):
|
|
160
177
|
argv = argv if argv is not None else sys.argv[1:]
|
|
161
178
|
parser = build_parser()
|
|
@@ -10,6 +10,8 @@ DEFAULT_CONFIG_DIR = os.path.join(BASE_DIR, "config")
|
|
|
10
10
|
DEFAULT_STATE_DIR = os.path.join(BASE_DIR, "local", "state")
|
|
11
11
|
DEFAULT_CACHE_DIR = os.path.join(BASE_DIR, "cache")
|
|
12
12
|
DEFAULT_MAIN_CONFIG = os.path.join(DEFAULT_CONFIG_DIR, "pkgmgr.yaml")
|
|
13
|
+
HERE = os.path.dirname(os.path.abspath(__file__))
|
|
14
|
+
TEMPLATE_DIR = os.path.join(HERE, "templates")
|
|
13
15
|
|
|
14
16
|
|
|
15
17
|
try:
|
|
@@ -19,25 +21,47 @@ except Exception:
|
|
|
19
21
|
|
|
20
22
|
|
|
21
23
|
MAIN_TEMPLATE = """\
|
|
22
|
-
version: 1
|
|
23
|
-
|
|
24
24
|
pkg_release_root: ~/PKG/RELEASE
|
|
25
25
|
sources:
|
|
26
26
|
- /path/to/source-A
|
|
27
27
|
- /path/to/source-B
|
|
28
|
+
source:
|
|
29
|
+
# glob patterns to exclude from source scanning
|
|
30
|
+
exclude:
|
|
31
|
+
- "**/build/**"
|
|
32
|
+
- "**/*.tmp"
|
|
28
33
|
|
|
29
|
-
|
|
34
|
+
artifacts:
|
|
30
35
|
targets: [bin, lib, data]
|
|
31
|
-
exclude
|
|
36
|
+
# glob patterns to exclude in artifacts area
|
|
37
|
+
exclude:
|
|
38
|
+
- log
|
|
39
|
+
- tmp/**
|
|
40
|
+
- "*.bak"
|
|
41
|
+
- "**/*.tmp"
|
|
32
42
|
|
|
33
43
|
watch:
|
|
34
44
|
interval_sec: 60
|
|
35
|
-
|
|
36
|
-
git:
|
|
37
|
-
keywords: ["FIX", "BUG", "SECURITY"]
|
|
45
|
+
on_change: [] # optional list of action names to run on change (poller)
|
|
38
46
|
|
|
39
47
|
collectors:
|
|
40
48
|
enabled: ["checksums"]
|
|
49
|
+
|
|
50
|
+
actions:
|
|
51
|
+
# action_name: list of commands (cmd required, cwd/env optional)
|
|
52
|
+
export_cksum:
|
|
53
|
+
- cmd: python cksum_excel.py
|
|
54
|
+
cwd: /app/script
|
|
55
|
+
env: { APP_ENV: dev }
|
|
56
|
+
export_world_dev:
|
|
57
|
+
- cmd: python dev_world.py
|
|
58
|
+
cwd: /app/script
|
|
59
|
+
export_world_security:
|
|
60
|
+
- cmd: python security_world.py
|
|
61
|
+
cwd: /app/script
|
|
62
|
+
noti_email:
|
|
63
|
+
- cmd: sh noti_email.sh
|
|
64
|
+
cwd: /app/script
|
|
41
65
|
"""
|
|
42
66
|
|
|
43
67
|
PKG_TEMPLATE = """\
|
|
@@ -48,7 +72,7 @@ pkg:
|
|
|
48
72
|
|
|
49
73
|
include:
|
|
50
74
|
sources: ["relative/path/from/source/root"]
|
|
51
|
-
|
|
75
|
+
artifacts: ["bin", "lib", "data"]
|
|
52
76
|
pkg_dir: ["docs", "notes"]
|
|
53
77
|
|
|
54
78
|
git:
|
|
@@ -61,6 +85,19 @@ collectors:
|
|
|
61
85
|
"""
|
|
62
86
|
|
|
63
87
|
|
|
88
|
+
def _load_template_file(filename, fallback):
|
|
89
|
+
"""Try loading a template file under pkgmgr/templates; fallback to inline default."""
|
|
90
|
+
path = os.path.join(TEMPLATE_DIR, filename)
|
|
91
|
+
try:
|
|
92
|
+
f = open(path, "r")
|
|
93
|
+
try:
|
|
94
|
+
return f.read()
|
|
95
|
+
finally:
|
|
96
|
+
f.close()
|
|
97
|
+
except Exception:
|
|
98
|
+
return fallback
|
|
99
|
+
|
|
100
|
+
|
|
64
101
|
def write_template(path=None):
|
|
65
102
|
"""Write the main pkgmgr.yaml template."""
|
|
66
103
|
path = path or DEFAULT_MAIN_CONFIG
|
|
@@ -68,8 +105,9 @@ def write_template(path=None):
|
|
|
68
105
|
parent = os.path.dirname(target)
|
|
69
106
|
if parent and not os.path.exists(parent):
|
|
70
107
|
os.makedirs(parent)
|
|
108
|
+
content = _load_template_file("pkgmgr.yaml.sample", MAIN_TEMPLATE)
|
|
71
109
|
with open(target, "w") as f:
|
|
72
|
-
f.write(
|
|
110
|
+
f.write(content)
|
|
73
111
|
print("[make-config] wrote template to %s" % target)
|
|
74
112
|
|
|
75
113
|
|
|
@@ -79,8 +117,9 @@ def write_pkg_template(path):
|
|
|
79
117
|
parent = os.path.dirname(target)
|
|
80
118
|
if parent and not os.path.exists(parent):
|
|
81
119
|
os.makedirs(parent)
|
|
120
|
+
content = _load_template_file("pkg.yaml.sample", PKG_TEMPLATE)
|
|
82
121
|
with open(target, "w") as f:
|
|
83
|
-
f.write(
|
|
122
|
+
f.write(content)
|
|
84
123
|
print("[create-pkg] wrote pkg template to %s" % target)
|
|
85
124
|
|
|
86
125
|
|
|
@@ -106,13 +145,17 @@ def describe_expected_fields():
|
|
|
106
145
|
"""Return a help string for the main config layout."""
|
|
107
146
|
return textwrap.dedent(
|
|
108
147
|
"""
|
|
109
|
-
version: schema version for future compatibility
|
|
110
148
|
pkg_release_root: root directory where pkg/<id> will live
|
|
111
149
|
sources: list of source roots to watch
|
|
112
|
-
|
|
113
|
-
|
|
150
|
+
source.exclude: glob patterns to skip under sources (supports **, *.ext)
|
|
151
|
+
artifacts.targets: top-level artifacts (bin/lib/data) to include
|
|
152
|
+
artifacts.exclude: glob patterns for dirs/files to skip (supports **, *.ext)
|
|
114
153
|
watch.interval_sec: poll interval for the watcher
|
|
115
|
-
|
|
154
|
+
watch.on_change: action names to run when changes are detected
|
|
116
155
|
collectors.enabled: default collectors to run per pkg
|
|
156
|
+
actions: mapping action_name -> list of command entries with:
|
|
157
|
+
- cmd: shell command string (required, often relative to cwd)
|
|
158
|
+
- cwd: working directory (optional)
|
|
159
|
+
- env: key/value env overrides for that command only (optional)
|
|
117
160
|
"""
|
|
118
161
|
).strip()
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
from __future__ import print_function
|
|
2
|
+
"""Release/package lifecycle scaffolding."""
|
|
3
|
+
|
|
4
|
+
import os
|
|
5
|
+
import sys
|
|
6
|
+
import subprocess
|
|
7
|
+
|
|
8
|
+
from . import config, snapshot, shell_integration
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def ensure_environment():
|
|
12
|
+
"""Prepare environment: update shell PATH/alias for current python scripts."""
|
|
13
|
+
script_dir = os.path.dirname(sys.executable)
|
|
14
|
+
shell_integration.ensure_path_and_alias(script_dir)
|
|
15
|
+
print("[install] ensured shell PATH/alias for script dir: %s" % script_dir)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def _pkg_dir(cfg, pkg_id):
|
|
19
|
+
root = os.path.expanduser(cfg.get("pkg_release_root", ""))
|
|
20
|
+
if not root:
|
|
21
|
+
raise RuntimeError("pkg_release_root missing in config")
|
|
22
|
+
return os.path.join(root, str(pkg_id))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def create_pkg(cfg, pkg_id):
|
|
26
|
+
"""Create pkg directory and write pkg.yaml template."""
|
|
27
|
+
dest = _pkg_dir(cfg, pkg_id)
|
|
28
|
+
if not os.path.exists(dest):
|
|
29
|
+
os.makedirs(dest)
|
|
30
|
+
template_path = os.path.join(dest, "pkg.yaml")
|
|
31
|
+
config.write_pkg_template(template_path)
|
|
32
|
+
# initial snapshot placeholder
|
|
33
|
+
snapshot.create_baseline(cfg)
|
|
34
|
+
print("[create-pkg] prepared %s" % dest)
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def close_pkg(cfg, pkg_id):
|
|
38
|
+
"""Mark pkg closed (stub)."""
|
|
39
|
+
dest = _pkg_dir(cfg, pkg_id)
|
|
40
|
+
if not os.path.exists(dest):
|
|
41
|
+
print("[close-pkg] pkg dir not found, nothing to close: %s" % dest)
|
|
42
|
+
return
|
|
43
|
+
marker = os.path.join(dest, ".closed")
|
|
44
|
+
with open(marker, "w") as f:
|
|
45
|
+
f.write("closed\n")
|
|
46
|
+
print("[close-pkg] marked closed: %s" % dest)
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def collect_for_pkg(cfg, pkg_id, collectors=None):
|
|
50
|
+
"""Run collector hooks (stub)."""
|
|
51
|
+
print(
|
|
52
|
+
"[collect] pkg=%s collectors=%s (stub; wire to collectors.checksums etc.)"
|
|
53
|
+
% (pkg_id, collectors or "default")
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def export_pkg(cfg, pkg_id, fmt):
|
|
58
|
+
"""Export pkg data placeholder."""
|
|
59
|
+
print("[export] pkg=%s format=%s (stub)" % (pkg_id, fmt))
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def run_actions(cfg, names):
|
|
63
|
+
"""Run configured actions by name."""
|
|
64
|
+
actions = cfg.get("actions", {}) or {}
|
|
65
|
+
if not names:
|
|
66
|
+
print("[actions] no action names provided")
|
|
67
|
+
return
|
|
68
|
+
for name in names:
|
|
69
|
+
entries = actions.get(name)
|
|
70
|
+
if not entries:
|
|
71
|
+
print("[actions] unknown action: %s" % name)
|
|
72
|
+
continue
|
|
73
|
+
if isinstance(entries, dict):
|
|
74
|
+
entries = [entries]
|
|
75
|
+
if not isinstance(entries, (list, tuple)):
|
|
76
|
+
print("[actions] invalid action format for %s" % name)
|
|
77
|
+
continue
|
|
78
|
+
print("[actions] running %s (%d command(s))" % (name, len(entries)))
|
|
79
|
+
for idx, entry in enumerate(entries):
|
|
80
|
+
cmd, cwd, env = _parse_action_entry(entry)
|
|
81
|
+
if not cmd:
|
|
82
|
+
print("[actions] skip empty cmd for %s #%d" % (name, idx + 1))
|
|
83
|
+
continue
|
|
84
|
+
_run_cmd(cmd, cwd=cwd, env=env, label="%s #%d" % (name, idx + 1))
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
def _parse_action_entry(entry):
|
|
88
|
+
if isinstance(entry, dict):
|
|
89
|
+
cmd = entry.get("cmd")
|
|
90
|
+
cwd = entry.get("cwd")
|
|
91
|
+
env = entry.get("env")
|
|
92
|
+
return cmd, cwd, env
|
|
93
|
+
return entry, None, None
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
def _run_cmd(cmd, cwd=None, env=None, label=None):
|
|
97
|
+
merged_env = os.environ.copy()
|
|
98
|
+
if env and isinstance(env, dict):
|
|
99
|
+
for k, v in env.items():
|
|
100
|
+
if v is None:
|
|
101
|
+
continue
|
|
102
|
+
merged_env[str(k)] = str(v)
|
|
103
|
+
try:
|
|
104
|
+
p = subprocess.Popen(cmd, shell=True, cwd=cwd, env=merged_env)
|
|
105
|
+
rc = p.wait()
|
|
106
|
+
prefix = "[actions]"
|
|
107
|
+
tag = " (%s)" % label if label else ""
|
|
108
|
+
if rc == 0:
|
|
109
|
+
print("%s command ok%s" % (prefix, tag))
|
|
110
|
+
else:
|
|
111
|
+
print("%s command failed%s (rc=%s)" % (prefix, tag, rc))
|
|
112
|
+
except Exception as e:
|
|
113
|
+
prefix = "[actions]"
|
|
114
|
+
tag = " (%s)" % label if label else ""
|
|
115
|
+
print("%s error%s: %s" % (prefix, tag, str(e)))
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
from __future__ import print_function
|
|
2
|
+
"""Snapshot utilities: hashing and state persistence."""
|
|
3
|
+
|
|
4
|
+
import os
|
|
5
|
+
import hashlib
|
|
6
|
+
import json
|
|
7
|
+
import fnmatch
|
|
8
|
+
import time
|
|
9
|
+
|
|
10
|
+
from . import config
|
|
11
|
+
|
|
12
|
+
STATE_DIR = config.DEFAULT_STATE_DIR
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def _ensure_state_dir():
|
|
16
|
+
if not os.path.exists(STATE_DIR):
|
|
17
|
+
os.makedirs(STATE_DIR)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def _sha256(path, chunk=1024 * 1024):
|
|
21
|
+
h = hashlib.sha256()
|
|
22
|
+
f = open(path, "rb")
|
|
23
|
+
try:
|
|
24
|
+
while True:
|
|
25
|
+
b = f.read(chunk)
|
|
26
|
+
if not b:
|
|
27
|
+
break
|
|
28
|
+
h.update(b)
|
|
29
|
+
finally:
|
|
30
|
+
f.close()
|
|
31
|
+
return h.hexdigest()
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def _should_skip(relpath, patterns):
|
|
35
|
+
for p in patterns or []:
|
|
36
|
+
if fnmatch.fnmatch(relpath, p):
|
|
37
|
+
return True
|
|
38
|
+
return False
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def _scan(root, exclude):
|
|
42
|
+
res = {}
|
|
43
|
+
root_abs = os.path.abspath(os.path.expanduser(root))
|
|
44
|
+
if not os.path.exists(root_abs):
|
|
45
|
+
print("[snap] skip missing root: %s" % root_abs)
|
|
46
|
+
return res
|
|
47
|
+
for base, _, files in os.walk(root_abs):
|
|
48
|
+
for name in files:
|
|
49
|
+
abspath = os.path.join(base, name)
|
|
50
|
+
rel = os.path.relpath(abspath, root_abs).replace("\\", "/")
|
|
51
|
+
if _should_skip(rel, exclude):
|
|
52
|
+
continue
|
|
53
|
+
try:
|
|
54
|
+
st = os.stat(abspath)
|
|
55
|
+
res[rel] = {
|
|
56
|
+
"hash": _sha256(abspath),
|
|
57
|
+
"size": int(st.st_size),
|
|
58
|
+
"mtime": int(st.st_mtime),
|
|
59
|
+
}
|
|
60
|
+
except Exception as e:
|
|
61
|
+
print("[snap] warn skip %s: %s" % (abspath, str(e)))
|
|
62
|
+
return res
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def create_baseline(cfg):
|
|
66
|
+
"""
|
|
67
|
+
Collect initial baseline snapshot.
|
|
68
|
+
For now scans sources only; artifacts can be added when roots are available.
|
|
69
|
+
"""
|
|
70
|
+
_ensure_state_dir()
|
|
71
|
+
sources = cfg.get("sources", []) or []
|
|
72
|
+
src_exclude = (cfg.get("source") or {}).get("exclude", []) or []
|
|
73
|
+
|
|
74
|
+
snapshot_data = {
|
|
75
|
+
"meta": {
|
|
76
|
+
"ts": time.strftime("%Y-%m-%dT%H:%M:%S", time.localtime()),
|
|
77
|
+
"type": "baseline",
|
|
78
|
+
},
|
|
79
|
+
"sources": {},
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
for root in sources:
|
|
83
|
+
snapshot_data["sources"][root] = _scan(root, src_exclude)
|
|
84
|
+
|
|
85
|
+
path = os.path.join(STATE_DIR, "baseline.json")
|
|
86
|
+
f = open(path, "w")
|
|
87
|
+
try:
|
|
88
|
+
json.dump(snapshot_data, f, ensure_ascii=False, indent=2, sort_keys=True)
|
|
89
|
+
finally:
|
|
90
|
+
f.close()
|
|
91
|
+
print("[baseline] saved to %s" % path)
|
|
92
|
+
return snapshot_data
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
def create_snapshot(cfg):
|
|
96
|
+
"""
|
|
97
|
+
Collect a fresh snapshot (for updates).
|
|
98
|
+
"""
|
|
99
|
+
_ensure_state_dir()
|
|
100
|
+
sources = cfg.get("sources", []) or []
|
|
101
|
+
src_exclude = (cfg.get("source") or {}).get("exclude", []) or []
|
|
102
|
+
|
|
103
|
+
snapshot_data = {
|
|
104
|
+
"meta": {
|
|
105
|
+
"ts": time.strftime("%Y-%m-%dT%H:%M:%S", time.localtime()),
|
|
106
|
+
"type": "snapshot",
|
|
107
|
+
},
|
|
108
|
+
"sources": {},
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
for root in sources:
|
|
112
|
+
snapshot_data["sources"][root] = _scan(root, src_exclude)
|
|
113
|
+
|
|
114
|
+
path = os.path.join(STATE_DIR, "snapshot.json")
|
|
115
|
+
f = open(path, "w")
|
|
116
|
+
try:
|
|
117
|
+
json.dump(snapshot_data, f, ensure_ascii=False, indent=2, sort_keys=True)
|
|
118
|
+
finally:
|
|
119
|
+
f.close()
|
|
120
|
+
print("[snap] snapshot saved to %s" % path)
|
|
121
|
+
return snapshot_data
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
def diff_snapshots(base, latest):
|
|
125
|
+
"""Diff two snapshot dicts."""
|
|
126
|
+
added = []
|
|
127
|
+
modified = []
|
|
128
|
+
deleted = []
|
|
129
|
+
|
|
130
|
+
def _diff_map(a, b):
|
|
131
|
+
a_keys = set(a.keys())
|
|
132
|
+
b_keys = set(b.keys())
|
|
133
|
+
for k in b_keys - a_keys:
|
|
134
|
+
added.append(k)
|
|
135
|
+
for k in a_keys - b_keys:
|
|
136
|
+
deleted.append(k)
|
|
137
|
+
for k in a_keys & b_keys:
|
|
138
|
+
if a[k].get("hash") != b[k].get("hash"):
|
|
139
|
+
modified.append(k)
|
|
140
|
+
|
|
141
|
+
# flatten per-root
|
|
142
|
+
def _flatten(snap):
|
|
143
|
+
flat = {}
|
|
144
|
+
for root, entries in (snap or {}).items():
|
|
145
|
+
for rel, meta in (entries or {}).items():
|
|
146
|
+
flat[root + "/" + rel] = meta
|
|
147
|
+
return flat
|
|
148
|
+
|
|
149
|
+
a_flat = _flatten(base.get("sources") if base else {})
|
|
150
|
+
b_flat = _flatten(latest.get("sources") if latest else {})
|
|
151
|
+
_diff_map(a_flat, b_flat)
|
|
152
|
+
|
|
153
|
+
return {"added": sorted(added), "modified": sorted(modified), "deleted": sorted(deleted)}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
pkg_release_root: ~/PKG/RELEASE
|
|
2
|
+
sources:
|
|
3
|
+
- /path/to/source-A
|
|
4
|
+
- /path/to/source-B
|
|
5
|
+
source:
|
|
6
|
+
# 소스 스캔 제외 (glob 지원)
|
|
7
|
+
exclude:
|
|
8
|
+
- "**/build/**"
|
|
9
|
+
- "**/*.tmp"
|
|
10
|
+
|
|
11
|
+
artifacts:
|
|
12
|
+
targets: [bin, lib, data]
|
|
13
|
+
# 배포/설치 영역 제외 (glob/패턴)
|
|
14
|
+
exclude:
|
|
15
|
+
- log # 정확히 log 디렉터리
|
|
16
|
+
- tmp/** # tmp 이하 전체
|
|
17
|
+
- "*.bak" # 확장자 패턴
|
|
18
|
+
- "**/*.tmp" # 모든 하위에서 .tmp
|
|
19
|
+
watch:
|
|
20
|
+
interval_sec: 60
|
|
21
|
+
on_change: [] # 변경 발생 시 실행할 action 이름 리스트
|
|
22
|
+
collectors:
|
|
23
|
+
enabled: ["checksums"]
|
|
24
|
+
actions:
|
|
25
|
+
# 각 액션은 하나 이상의 커맨드를 가질 수 있음.
|
|
26
|
+
# 필드: cmd (필수, 보통 cwd 기준 경로), cwd(선택), env(선택; 이 커맨드에만 적용)
|
|
27
|
+
export_cksum:
|
|
28
|
+
- cmd: python cksum_excel.py # cwd 기준 실행
|
|
29
|
+
cwd: /app/script # 선택: 작업 디렉터리
|
|
30
|
+
env: { APP_ENV: dev } # 선택: 이 명령에만 적용할 환경변수
|
|
31
|
+
export_world_dev:
|
|
32
|
+
- cmd: python dev_world.py
|
|
33
|
+
cwd: /app/script
|
|
34
|
+
export_world_security:
|
|
35
|
+
- cmd: python security_world.py
|
|
36
|
+
cwd: /app/script
|
|
37
|
+
noti_email:
|
|
38
|
+
- cmd: sh noti_email.sh
|
|
39
|
+
cwd: /app/script
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pkgmgr-kunrunic
|
|
3
|
-
Version: 0.1.0.
|
|
3
|
+
Version: 0.1.0.dev3
|
|
4
4
|
Summary: Package management workflow scaffold.
|
|
5
5
|
Author: pkgmgr maintainers
|
|
6
6
|
License: MIT License
|
|
@@ -62,7 +62,8 @@ Dynamic: license-file
|
|
|
62
62
|
- PyYAML 6.x (의존성에 포함되어 일반 설치 시 자동 설치)
|
|
63
63
|
|
|
64
64
|
## 기본 사용 흐름 (스캐폴드)
|
|
65
|
-
아래 명령은 `python -m pkgmgr.cli ...` 형태로 실행합니다.
|
|
65
|
+
아래 명령은 `python -m pkgmgr.cli ...` 형태로 실행합니다.
|
|
66
|
+
설정 파일 기본 경로는 `~/pkmgr/config/pkgmgr.yaml`이며, `--config`로 다른 경로를 지정할 수 있습니다.
|
|
66
67
|
|
|
67
68
|
1) 메인 설정 템플릿 생성
|
|
68
69
|
```
|
|
@@ -70,17 +71,18 @@ python -m pkgmgr.cli make-config -o pkgmgr.yaml
|
|
|
70
71
|
```
|
|
71
72
|
`pkgmgr.yaml`에서 소스 경로, 설치 타깃(bin/lib/data 등), release 루트, Git 키워드, 감시 주기, 기본 컬렉터 목록 등을 편집합니다. 기본 생성 위치는 `~/pkmgr/config/pkgmgr.yaml`이며, `--config`로 다른 경로를 지정할 수 있습니다. 상태/캐시 데이터는 추후 `~/pkmgr/local/state`, `~/pkmgr/cache`에 둘 예정입니다.
|
|
72
73
|
|
|
73
|
-
2) 환경 준비
|
|
74
|
+
2) 환경 준비 + 초기 베이스라인 수집
|
|
74
75
|
```
|
|
75
76
|
python -m pkgmgr.cli install
|
|
76
77
|
```
|
|
77
|
-
(
|
|
78
|
+
- 셸 PATH/alias 자동 등록 후, 기본 설정(`~/pkmgr/config/pkgmgr.yaml`)을 읽어 초기 베이스라인 스냅샷을 저장 (`~/pkmgr/local/state/baseline.json`).
|
|
79
|
+
- 추후 의존성/경로 체크 추가 예정.
|
|
78
80
|
|
|
79
|
-
3)
|
|
81
|
+
3) 스냅샷 갱신
|
|
80
82
|
```
|
|
81
|
-
python -m pkgmgr.cli
|
|
83
|
+
python -m pkgmgr.cli snapshot --config pkgmgr.yaml
|
|
82
84
|
```
|
|
83
|
-
설정된
|
|
85
|
+
설정된 소스/아티팩트/릴리스 루트를 기준으로 최신 스냅샷을 저장합니다 (`~/pkmgr/local/state/snapshot.json`). 이후 diff/감시에 사용할 예정입니다.
|
|
84
86
|
|
|
85
87
|
4) 패키지 생성
|
|
86
88
|
```
|
|
@@ -99,20 +101,26 @@ python -m pkgmgr.cli close-pkg <pkg-id> --config pkgmgr.yaml
|
|
|
99
101
|
python -m pkgmgr.cli watch --config pkgmgr.yaml
|
|
100
102
|
python -m pkgmgr.cli watch --config pkgmgr.yaml --once # 한 번만 폴링
|
|
101
103
|
```
|
|
102
|
-
설정된 interval로 변경을 감시하는 로직을 연결할 예정입니다.
|
|
104
|
+
설정된 interval로 변경을 감시하는 로직을 연결할 예정입니다. (현재는 스텁 로그만 출력)
|
|
103
105
|
|
|
104
106
|
7) 수집(컬렉터)
|
|
105
107
|
```
|
|
106
108
|
python -m pkgmgr.cli collect --pkg <pkg-id> --config pkgmgr.yaml
|
|
107
109
|
python -m pkgmgr.cli collect --pkg <pkg-id> --collector checksums --config pkgmgr.yaml
|
|
108
110
|
```
|
|
109
|
-
체크섬/정적/동적/EDR/백신 등 컬렉터를 플러그인 형태로 추가할 수 있도록 확장 예정입니다.
|
|
111
|
+
체크섬/정적/동적/EDR/백신 등 컬렉터를 플러그인 형태로 추가할 수 있도록 확장 예정입니다. (현재는 스텁 로그만 출력)
|
|
110
112
|
|
|
111
113
|
8) 내보내기
|
|
112
114
|
```
|
|
113
115
|
python -m pkgmgr.cli export --pkg <pkg-id> --format excel --config pkgmgr.yaml
|
|
114
116
|
```
|
|
115
|
-
엑셀/워드/JSON 등의 산출물을 생성하는 후크를 붙일 계획입니다.
|
|
117
|
+
엑셀/워드/JSON 등의 산출물을 생성하는 후크를 붙일 계획입니다. (현재는 스텁 로그만 출력)
|
|
118
|
+
|
|
119
|
+
9) 액션 실행
|
|
120
|
+
```
|
|
121
|
+
python -m pkgmgr.cli actions <action-name> [<action-name> ...] --config pkgmgr.yaml
|
|
122
|
+
```
|
|
123
|
+
`actions` 설정에 등록된 커맨드를 순서대로 실행합니다(`cmd` 필수, `cwd`/`env` 선택). (실제 실행 로직은 포함되어 있음)
|
|
116
124
|
|
|
117
125
|
## 설치·PATH/alias 자동 추가
|
|
118
126
|
- `python -m pip install .` 후 `python -m pkgmgr.cli install`을 실행하면 현재 파이썬의 `bin` 경로(예: venv/bin, ~/.local/bin 등)를 감지해 사용 중인 쉘의 rc 파일에 PATH/alias를 추가합니다.
|
|
@@ -132,17 +140,18 @@ python -m pkgmgr.cli export --pkg <pkg-id> --format excel --config pkgmgr.yaml
|
|
|
132
140
|
|
|
133
141
|
## 템플릿 개요
|
|
134
142
|
- `pkgmgr/templates/pkgmgr.yaml.sample` : 메인 설정 샘플
|
|
135
|
-
- `version`: 스키마 버전
|
|
136
143
|
- `pkg_release_root`: 패키지 릴리스 루트
|
|
137
144
|
- `sources`: 관리할 소스 경로 목록
|
|
138
|
-
- `
|
|
145
|
+
- `source.exclude`: 소스 스캔 제외 패턴 (glob 지원)
|
|
146
|
+
- `artifacts.targets` / `artifacts.exclude`: 배포 대상 포함/제외 규칙 (glob 지원: `tmp/**`, `*.bak`, `**/*.tmp` 등)
|
|
139
147
|
- `watch.interval_sec`: 감시 폴링 주기
|
|
140
|
-
- `
|
|
148
|
+
- `watch.on_change`: 변경 시 실행할 action 이름 리스트
|
|
141
149
|
- `collectors.enabled`: 기본 활성 컬렉터
|
|
150
|
+
- `actions`: action 이름 → 실행할 커맨드 목록 (각 항목에 `cmd` 필수, `cwd`/`env` 선택)
|
|
142
151
|
|
|
143
152
|
- `pkgmgr/templates/pkg.yaml.sample` : 패키지별 설정 샘플
|
|
144
153
|
- `pkg.id` / `pkg.root` / `pkg.status(open|closed)`
|
|
145
|
-
- `include.sources/
|
|
154
|
+
- `include.sources/artifacts/pkg_dir`: 포함 대상
|
|
146
155
|
- `git.keywords/since/until`: 커밋 수집 범위
|
|
147
156
|
- `collectors.enabled`: 패키지별 컬렉터 설정
|
|
148
157
|
|
|
@@ -150,7 +159,7 @@ python -m pkgmgr.cli export --pkg <pkg-id> --format excel --config pkgmgr.yaml
|
|
|
150
159
|
- 아직 핵심 로직(스냅샷/감시/수집/내보내기)은 스텁입니다. 추후 단계적으로 구현/교체 예정입니다.
|
|
151
160
|
|
|
152
161
|
## TODO (우선순위)
|
|
153
|
-
- 스냅샷/디프 구현: `pkgmgr/snapshot.py`에 해시/mtime/size 스캔, baseline/latest 저장(`state/...`), diff 작성. CLI `
|
|
162
|
+
- 스냅샷/디프 구현: `pkgmgr/snapshot.py`에 해시/mtime/size 스캔, baseline/latest 저장(`state/...`), diff 작성. CLI `snapshot`/`watch` 연결.
|
|
154
163
|
- 설정 스키마 검증: `pkgmgr/config.py` 필수 필드 확인, 기본값 주입, PyYAML 체크, 템플릿 필드 설명 보강.
|
|
155
164
|
- 패키지 라이프사이클: `release.py`에서 `create-pkg` 시 `pkg.yaml` 초기화, `close-pkg` 상태 저장, 상태 파일 표준화.
|
|
156
165
|
- Git 수집: `gitcollect.py`에 키워드/정규식 로그 수집, `state/pkg/<id>/commits.json` 저장, `collect_for_pkg`에서 호출.
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
from __future__ import print_function
|
|
2
|
-
"""Release/package lifecycle scaffolding."""
|
|
3
|
-
|
|
4
|
-
import os
|
|
5
|
-
import sys
|
|
6
|
-
|
|
7
|
-
from . import config, snapshot, shell_integration
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
def ensure_environment():
|
|
11
|
-
"""Prepare environment: update shell PATH/alias for current python scripts."""
|
|
12
|
-
script_dir = os.path.dirname(sys.executable)
|
|
13
|
-
shell_integration.ensure_path_and_alias(script_dir)
|
|
14
|
-
print("[install] ensured shell PATH/alias for script dir: %s" % script_dir)
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
def _pkg_dir(cfg, pkg_id):
|
|
18
|
-
root = os.path.expanduser(cfg.get("pkg_release_root", ""))
|
|
19
|
-
if not root:
|
|
20
|
-
raise RuntimeError("pkg_release_root missing in config")
|
|
21
|
-
return os.path.join(root, str(pkg_id))
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
def create_pkg(cfg, pkg_id):
|
|
25
|
-
"""Create pkg directory and write pkg.yaml template."""
|
|
26
|
-
dest = _pkg_dir(cfg, pkg_id)
|
|
27
|
-
if not os.path.exists(dest):
|
|
28
|
-
os.makedirs(dest)
|
|
29
|
-
template_path = os.path.join(dest, "pkg.yaml")
|
|
30
|
-
config.write_pkg_template(template_path)
|
|
31
|
-
# initial snapshot placeholder
|
|
32
|
-
snapshot.create_baseline(cfg)
|
|
33
|
-
print("[create-pkg] prepared %s" % dest)
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
def close_pkg(cfg, pkg_id):
|
|
37
|
-
"""Mark pkg closed (stub)."""
|
|
38
|
-
dest = _pkg_dir(cfg, pkg_id)
|
|
39
|
-
if not os.path.exists(dest):
|
|
40
|
-
print("[close-pkg] pkg dir not found, nothing to close: %s" % dest)
|
|
41
|
-
return
|
|
42
|
-
marker = os.path.join(dest, ".closed")
|
|
43
|
-
with open(marker, "w") as f:
|
|
44
|
-
f.write("closed\n")
|
|
45
|
-
print("[close-pkg] marked closed: %s" % dest)
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
def collect_for_pkg(cfg, pkg_id, collectors=None):
|
|
49
|
-
"""Run collector hooks (stub)."""
|
|
50
|
-
print(
|
|
51
|
-
"[collect] pkg=%s collectors=%s (stub; wire to collectors.checksums etc.)"
|
|
52
|
-
% (pkg_id, collectors or "default")
|
|
53
|
-
)
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
def export_pkg(cfg, pkg_id, fmt):
|
|
57
|
-
"""Export pkg data placeholder."""
|
|
58
|
-
print("[export] pkg=%s format=%s (stub)" % (pkg_id, fmt))
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
from __future__ import print_function
|
|
2
|
-
"""Snapshot scaffolding.
|
|
3
|
-
|
|
4
|
-
This module will house hash/mtime scanning for sources/install/pkg dirs.
|
|
5
|
-
"""
|
|
6
|
-
|
|
7
|
-
import os
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
def create_baseline(cfg):
|
|
11
|
-
"""
|
|
12
|
-
Placeholder for baseline snapshot creation.
|
|
13
|
-
Will use cfg['sources'], cfg['install'], cfg['pkg_release_root'].
|
|
14
|
-
"""
|
|
15
|
-
roots = {
|
|
16
|
-
"sources": cfg.get("sources", []),
|
|
17
|
-
"install": cfg.get("install", {}).get("targets", []),
|
|
18
|
-
"release": cfg.get("pkg_release_root"),
|
|
19
|
-
}
|
|
20
|
-
print("[init-snap] baseline placeholder. roots=%s" % roots)
|
|
21
|
-
# TODO: implement hashing and storage under pkgmgr/state
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
def diff_snapshots(base, latest):
|
|
25
|
-
"""Placeholder diff helper."""
|
|
26
|
-
print("[snapshot] diff placeholder: base=%s latest=%s" % (base, latest))
|
|
27
|
-
return {}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
version: 1
|
|
2
|
-
pkg_release_root: ~/PKG/RELEASE
|
|
3
|
-
sources:
|
|
4
|
-
- /path/to/source-A
|
|
5
|
-
- /path/to/source-B
|
|
6
|
-
install:
|
|
7
|
-
targets: [bin, lib, data]
|
|
8
|
-
exclude: [log, tmp, cache]
|
|
9
|
-
watch:
|
|
10
|
-
interval_sec: 60
|
|
11
|
-
git:
|
|
12
|
-
keywords: ["FIX", "BUG", "SECURITY"]
|
|
13
|
-
collectors:
|
|
14
|
-
enabled: ["checksums"]
|
|
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.0.dev2 → pkgmgr_kunrunic-0.1.0.dev3}/pkgmgr_kunrunic.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
{pkgmgr_kunrunic-0.1.0.dev2 → pkgmgr_kunrunic-0.1.0.dev3}/pkgmgr_kunrunic.egg-info/entry_points.txt
RENAMED
|
File without changes
|
{pkgmgr_kunrunic-0.1.0.dev2 → pkgmgr_kunrunic-0.1.0.dev3}/pkgmgr_kunrunic.egg-info/not-zip-safe
RENAMED
|
File without changes
|
{pkgmgr_kunrunic-0.1.0.dev2 → pkgmgr_kunrunic-0.1.0.dev3}/pkgmgr_kunrunic.egg-info/requires.txt
RENAMED
|
File without changes
|
{pkgmgr_kunrunic-0.1.0.dev2 → pkgmgr_kunrunic-0.1.0.dev3}/pkgmgr_kunrunic.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|