autopkg-wrapper 0.2.0__tar.gz → 2024.2.2__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.
- autopkg_wrapper-2024.2.2/PKG-INFO +57 -0
- autopkg_wrapper-2024.2.2/README.md +34 -0
- autopkg_wrapper-2024.2.2/autopkg_wrapper/__init__.py +1 -0
- {autopkg_wrapper-0.2.0 → autopkg_wrapper-2024.2.2}/autopkg_wrapper/autopkg_wrapper.py +16 -21
- autopkg_wrapper-2024.2.2/autopkg_wrapper/notifier/__init__.py +1 -0
- autopkg_wrapper-2024.2.2/autopkg_wrapper/utils/__init__.py +1 -0
- {autopkg_wrapper-0.2.0 → autopkg_wrapper-2024.2.2}/autopkg_wrapper/utils/args.py +14 -14
- {autopkg_wrapper-0.2.0 → autopkg_wrapper-2024.2.2}/pyproject.toml +4 -3
- autopkg_wrapper-0.2.0/PKG-INFO +0 -24
- autopkg_wrapper-0.2.0/README.md +0 -1
- autopkg_wrapper-0.2.0/autopkg_wrapper/__init__.py +0 -1
- autopkg_wrapper-0.2.0/autopkg_wrapper/notifier/__init__.py +0 -0
- autopkg_wrapper-0.2.0/autopkg_wrapper/utils/__init__.py +0 -0
- {autopkg_wrapper-0.2.0 → autopkg_wrapper-2024.2.2}/LICENSE +0 -0
- {autopkg_wrapper-0.2.0 → autopkg_wrapper-2024.2.2}/autopkg_wrapper/notifier/slack.py +0 -0
- {autopkg_wrapper-0.2.0 → autopkg_wrapper-2024.2.2}/autopkg_wrapper/utils/git_functions.py +0 -0
- {autopkg_wrapper-0.2.0 → autopkg_wrapper-2024.2.2}/autopkg_wrapper/utils/logging.py +0 -0
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: autopkg-wrapper
|
|
3
|
+
Version: 2024.2.2
|
|
4
|
+
Summary: A package used to execute some autopkg functions, primarily within the context of a GitHub Actions runner
|
|
5
|
+
Home-page: https://github.com/smithjw/autopkg-wrapper
|
|
6
|
+
License: BSD-3-Clause
|
|
7
|
+
Author: James Smith
|
|
8
|
+
Author-email: james@smithjw.me
|
|
9
|
+
Requires-Python: >=3.12,<4.0
|
|
10
|
+
Classifier: License :: OSI Approved :: BSD License
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
13
|
+
Requires-Dist: chardet (==5.2.0)
|
|
14
|
+
Requires-Dist: idna (==3.6)
|
|
15
|
+
Requires-Dist: pygithub (==2.2.0)
|
|
16
|
+
Requires-Dist: requests (==2.31.0)
|
|
17
|
+
Requires-Dist: ruamel-yaml (==0.18.5)
|
|
18
|
+
Requires-Dist: toml (==0.10.2)
|
|
19
|
+
Requires-Dist: urllib3 (==2.2.0)
|
|
20
|
+
Project-URL: Repository, https://github.com/smithjw/autopkg-wrapper
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
|
|
23
|
+
# autopkg-wrapper
|
|
24
|
+
|
|
25
|
+
`autopkg_wrapper` is a small package that can be used to run [`autopkg`](https://github.com/autopkg/autopkg) within CI/CD environments such as GitHub Actions.
|
|
26
|
+
|
|
27
|
+
The easiest way to run it is by installing with pip.
|
|
28
|
+
|
|
29
|
+
```shell
|
|
30
|
+
pip install autopkg-wrapper
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Command Line Parameters
|
|
34
|
+
|
|
35
|
+
```shell
|
|
36
|
+
-h, --help Show this help message and exit
|
|
37
|
+
--recipe-file RECIPE_FILE Path to a list of recipes to run (cannot be run with --recipes)
|
|
38
|
+
--recipes [RECIPES ...] Recipes to run with autopkg (cannot be run with --recipe-file)
|
|
39
|
+
--debug Enable debug logging when running script
|
|
40
|
+
--override-trust If set recipe override trust verification will be disabled. (Default: True)
|
|
41
|
+
--github-token GITHUB_TOKEN A token used to publish a PR to your GitHub repo if overrides require their trust to be updated
|
|
42
|
+
--branch-name BRANCH_NAME Branch name to be used where recipe overrides have failed their trust verification and need to be updated.
|
|
43
|
+
By default, this will be in the format of "fix/update_trust_information/YYYY-MM-DDTHH-MM-SS"
|
|
44
|
+
--create-pr If enabled, autopkg_wrapper will open a PR for updated trust information
|
|
45
|
+
--autopkg-overrides-repo-path AUTOPKG_OVERRIDES_REPO_PATH
|
|
46
|
+
The path on disk to the git repository containing the autopkg overrides directory. If none is provided, we will try to determine it for you.
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Example
|
|
50
|
+
|
|
51
|
+
An example folder structure and GitHub Actions Workflow is available within the [`actions-demo`](actions-demo)
|
|
52
|
+
|
|
53
|
+
## Credits
|
|
54
|
+
|
|
55
|
+
- [`autopkg_tools` from Facebook](https://github.com/facebook/IT-CPE/tree/main/legacy/autopkg_tools)
|
|
56
|
+
- [`autopkg_tools` from Facebook, modified by Gusto](https://github.com/Gusto/it-cpe-opensource/tree/main/autopkg)
|
|
57
|
+
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# autopkg-wrapper
|
|
2
|
+
|
|
3
|
+
`autopkg_wrapper` is a small package that can be used to run [`autopkg`](https://github.com/autopkg/autopkg) within CI/CD environments such as GitHub Actions.
|
|
4
|
+
|
|
5
|
+
The easiest way to run it is by installing with pip.
|
|
6
|
+
|
|
7
|
+
```shell
|
|
8
|
+
pip install autopkg-wrapper
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Command Line Parameters
|
|
12
|
+
|
|
13
|
+
```shell
|
|
14
|
+
-h, --help Show this help message and exit
|
|
15
|
+
--recipe-file RECIPE_FILE Path to a list of recipes to run (cannot be run with --recipes)
|
|
16
|
+
--recipes [RECIPES ...] Recipes to run with autopkg (cannot be run with --recipe-file)
|
|
17
|
+
--debug Enable debug logging when running script
|
|
18
|
+
--override-trust If set recipe override trust verification will be disabled. (Default: True)
|
|
19
|
+
--github-token GITHUB_TOKEN A token used to publish a PR to your GitHub repo if overrides require their trust to be updated
|
|
20
|
+
--branch-name BRANCH_NAME Branch name to be used where recipe overrides have failed their trust verification and need to be updated.
|
|
21
|
+
By default, this will be in the format of "fix/update_trust_information/YYYY-MM-DDTHH-MM-SS"
|
|
22
|
+
--create-pr If enabled, autopkg_wrapper will open a PR for updated trust information
|
|
23
|
+
--autopkg-overrides-repo-path AUTOPKG_OVERRIDES_REPO_PATH
|
|
24
|
+
The path on disk to the git repository containing the autopkg overrides directory. If none is provided, we will try to determine it for you.
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Example
|
|
28
|
+
|
|
29
|
+
An example folder structure and GitHub Actions Workflow is available within the [`actions-demo`](actions-demo)
|
|
30
|
+
|
|
31
|
+
## Credits
|
|
32
|
+
|
|
33
|
+
- [`autopkg_tools` from Facebook](https://github.com/facebook/IT-CPE/tree/main/legacy/autopkg_tools)
|
|
34
|
+
- [`autopkg_tools` from Facebook, modified by Gusto](https://github.com/Gusto/it-cpe-opensource/tree/main/autopkg)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "2024.2.2"
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env python3
|
|
2
2
|
import logging
|
|
3
|
-
import os
|
|
4
3
|
import plistlib
|
|
5
4
|
import subprocess
|
|
6
5
|
import sys
|
|
@@ -13,8 +12,8 @@ from autopkg_wrapper.utils.logging import setup_logger
|
|
|
13
12
|
|
|
14
13
|
|
|
15
14
|
class Recipe(object):
|
|
16
|
-
def __init__(self,
|
|
17
|
-
self.filename =
|
|
15
|
+
def __init__(self, name):
|
|
16
|
+
self.filename = name
|
|
18
17
|
self.error = False
|
|
19
18
|
self.results = {}
|
|
20
19
|
self.updated = False
|
|
@@ -81,10 +80,8 @@ class Recipe(object):
|
|
|
81
80
|
self.results["failed"] = True
|
|
82
81
|
self.results["imported"] = ""
|
|
83
82
|
else:
|
|
84
|
-
report = "/tmp/autopkg.plist"
|
|
85
|
-
|
|
86
|
-
# Letting autopkg create them has led to errors on github runners
|
|
87
|
-
Path(report).touch()
|
|
83
|
+
report = Path("/tmp/autopkg.plist")
|
|
84
|
+
report.touch(exist_ok=True)
|
|
88
85
|
|
|
89
86
|
try:
|
|
90
87
|
cmd = [
|
|
@@ -95,7 +92,7 @@ class Recipe(object):
|
|
|
95
92
|
"--post",
|
|
96
93
|
"io.github.hjuutilainen.VirusTotalAnalyzer/VirusTotalAnalyzer",
|
|
97
94
|
"--report-plist",
|
|
98
|
-
report,
|
|
95
|
+
str(report),
|
|
99
96
|
]
|
|
100
97
|
cmd = " ".join(cmd)
|
|
101
98
|
logging.debug(f"cmd: {str(cmd)}")
|
|
@@ -114,8 +111,8 @@ class Recipe(object):
|
|
|
114
111
|
|
|
115
112
|
|
|
116
113
|
def get_override_repo_info(args):
|
|
117
|
-
if args.
|
|
118
|
-
|
|
114
|
+
if args.autopkg_overrides_repo_path:
|
|
115
|
+
recipe_override_dirs = args.autopkg_overrides_repo_path
|
|
119
116
|
|
|
120
117
|
else:
|
|
121
118
|
logging.debug("Trying to determine overrides dir from default paths")
|
|
@@ -127,10 +124,12 @@ def get_override_repo_info(args):
|
|
|
127
124
|
|
|
128
125
|
recipe_override_dirs = Path(autopkg_prefs["RECIPE_OVERRIDE_DIRS"]).resolve()
|
|
129
126
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
127
|
+
if Path(recipe_override_dirs / ".git").is_dir():
|
|
128
|
+
override_repo_path = recipe_override_dirs
|
|
129
|
+
elif Path(recipe_override_dirs.parent / ".git").is_dir():
|
|
130
|
+
override_repo_path = recipe_override_dirs.parent
|
|
131
|
+
|
|
132
|
+
logging.debug(f"Override Repo Path: {override_repo_path}")
|
|
134
133
|
|
|
135
134
|
override_repo_git_work_tree = f"--work-tree={override_repo_path}"
|
|
136
135
|
override_repo_git_git_dir = f"--git-dir={override_repo_path / ".git"}"
|
|
@@ -171,10 +170,8 @@ def parse_recipe_list(recipes, recipe_file):
|
|
|
171
170
|
"""Parsing list of recipes into a common format"""
|
|
172
171
|
recipe_list = None
|
|
173
172
|
|
|
174
|
-
if recipes
|
|
175
|
-
|
|
176
|
-
if recipe_file:
|
|
177
|
-
logging.debug(f"Recipe List: {recipe_file}")
|
|
173
|
+
logging.debug(f"Recipes: {recipes}") if recipes else None
|
|
174
|
+
logging.debug(f"Recipe List: {recipe_file}") if recipe_file else None
|
|
178
175
|
|
|
179
176
|
if isinstance(recipes, list):
|
|
180
177
|
recipe_list = recipes
|
|
@@ -226,12 +223,10 @@ def main():
|
|
|
226
223
|
logging.debug(f"Processing {recipe.name}")
|
|
227
224
|
process_recipe(recipe=recipe, override_trust=args.override_trust)
|
|
228
225
|
update_recipe_repo(git_info=override_repo_info, recipe=recipe)
|
|
226
|
+
slack.send_notification(recipe=recipe, token=args.slack_token) if args.slack_token else None
|
|
229
227
|
|
|
230
228
|
recipe.pr_url = git.create_pull_request(git_info=override_repo_info, recipe=recipe) if args.create_pr else None
|
|
231
229
|
|
|
232
|
-
# Send Slack Notification if Slack token is present
|
|
233
|
-
slack.send_notification(recipe=recipe, token=args.slack_token) if args.slack_token else None
|
|
234
|
-
|
|
235
230
|
|
|
236
231
|
if __name__ == "__main__":
|
|
237
232
|
main()
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.0.0"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.0.0"
|
|
@@ -4,24 +4,24 @@ from datetime import datetime
|
|
|
4
4
|
from pathlib import Path
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
def validate_file(
|
|
8
|
-
|
|
9
|
-
file_exists =
|
|
7
|
+
def validate_file(arg):
|
|
8
|
+
file_path = Path(arg).resolve()
|
|
9
|
+
file_exists = file_path.exists()
|
|
10
10
|
|
|
11
11
|
if file_exists:
|
|
12
|
-
return
|
|
12
|
+
return file_path
|
|
13
13
|
else:
|
|
14
|
-
message = f"Error! This is not valid file: {
|
|
14
|
+
message = f"Error! This is not valid file: {arg}"
|
|
15
15
|
raise argparse.ArgumentTypeError(message)
|
|
16
16
|
|
|
17
|
-
def validate_directory(
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
def validate_directory(arg):
|
|
18
|
+
dir_path = Path(arg).resolve()
|
|
19
|
+
dir_exists = dir_path.is_dir()
|
|
20
20
|
|
|
21
|
-
if
|
|
22
|
-
return
|
|
21
|
+
if dir_exists:
|
|
22
|
+
return dir_path
|
|
23
23
|
else:
|
|
24
|
-
message = f"Error! This is not valid directory: {
|
|
24
|
+
message = f"Error! This is not valid directory: {arg}"
|
|
25
25
|
raise argparse.ArgumentTypeError(message)
|
|
26
26
|
|
|
27
27
|
|
|
@@ -52,7 +52,7 @@ def setup_args():
|
|
|
52
52
|
action="store_false",
|
|
53
53
|
help="If set recipe override trust verification will be disabled. (Default: True)",
|
|
54
54
|
)
|
|
55
|
-
parser.add_argument("--slack-token", default=os.getenv("SLACK_WEBHOOK_TOKEN", None))
|
|
55
|
+
parser.add_argument("--slack-token", default=os.getenv("SLACK_WEBHOOK_TOKEN", None), help=argparse.SUPPRESS)
|
|
56
56
|
parser.add_argument("--github-token", default=os.getenv("GITHUB_TOKEN", None))
|
|
57
57
|
parser.add_argument(
|
|
58
58
|
"--branch-name",
|
|
@@ -69,8 +69,8 @@ def setup_args():
|
|
|
69
69
|
help="If enabled, autopkg_wrapper will open a PR for updated trust information",
|
|
70
70
|
)
|
|
71
71
|
parser.add_argument(
|
|
72
|
-
"--autopkg-overrides-repo",
|
|
73
|
-
default=os.getenv("
|
|
72
|
+
"--autopkg-overrides-repo-path",
|
|
73
|
+
default=os.getenv("AUTOPKG_OVERRIDES_REPO_PATH", None),
|
|
74
74
|
type=validate_directory,
|
|
75
75
|
help="""
|
|
76
76
|
The path on disk to the git repository containing the autopkg overrides directory.
|
|
@@ -5,21 +5,22 @@
|
|
|
5
5
|
name = "autopkg-wrapper"
|
|
6
6
|
readme = "README.md"
|
|
7
7
|
repository = "https://github.com/smithjw/autopkg-wrapper"
|
|
8
|
-
version = "
|
|
8
|
+
version = "2024.2.2"
|
|
9
9
|
|
|
10
10
|
[tool.poetry.scripts]
|
|
11
11
|
# When built and installed by pip, the command autopkg_wrapper will be availble in to run within that environment
|
|
12
|
+
autopkg-wrapper = "autopkg_wrapper.autopkg_wrapper:main"
|
|
12
13
|
autopkg_wrapper = "autopkg_wrapper.autopkg_wrapper:main"
|
|
13
14
|
|
|
14
15
|
[tool.poetry.dependencies]
|
|
15
16
|
chardet = "5.2.0"
|
|
16
17
|
idna = "3.6"
|
|
17
|
-
pygithub = "2.
|
|
18
|
+
pygithub = "2.2.0"
|
|
18
19
|
python = "^3.12"
|
|
19
20
|
requests = "2.31.0"
|
|
20
21
|
ruamel-yaml = "0.18.5"
|
|
21
22
|
toml = "0.10.2"
|
|
22
|
-
urllib3 = "2.
|
|
23
|
+
urllib3 = "2.2.0"
|
|
23
24
|
|
|
24
25
|
[tool.poetry_bumpversion.file."autopkg_wrapper/__init__.py"]
|
|
25
26
|
|
autopkg_wrapper-0.2.0/PKG-INFO
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: autopkg-wrapper
|
|
3
|
-
Version: 0.2.0
|
|
4
|
-
Summary: A package used to execute some autopkg functions, primarily within the context of a GitHub Actions runner
|
|
5
|
-
Home-page: https://github.com/smithjw/autopkg-wrapper
|
|
6
|
-
License: BSD-3-Clause
|
|
7
|
-
Author: James Smith
|
|
8
|
-
Author-email: james@smithjw.me
|
|
9
|
-
Requires-Python: >=3.12,<4.0
|
|
10
|
-
Classifier: License :: OSI Approved :: BSD License
|
|
11
|
-
Classifier: Programming Language :: Python :: 3
|
|
12
|
-
Classifier: Programming Language :: Python :: 3.12
|
|
13
|
-
Requires-Dist: chardet (==5.2.0)
|
|
14
|
-
Requires-Dist: idna (==3.6)
|
|
15
|
-
Requires-Dist: pygithub (==2.1.1)
|
|
16
|
-
Requires-Dist: requests (==2.31.0)
|
|
17
|
-
Requires-Dist: ruamel-yaml (==0.18.5)
|
|
18
|
-
Requires-Dist: toml (==0.10.2)
|
|
19
|
-
Requires-Dist: urllib3 (==2.1.0)
|
|
20
|
-
Project-URL: Repository, https://github.com/smithjw/autopkg-wrapper
|
|
21
|
-
Description-Content-Type: text/markdown
|
|
22
|
-
|
|
23
|
-
# autopkg-wrapper
|
|
24
|
-
|
autopkg_wrapper-0.2.0/README.md
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
# autopkg-wrapper
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.2.0"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|