Skip to content

Commit

Permalink
Merge branch 'dev' into dev_new_recipe_logic
Browse files Browse the repository at this point in the history
  • Loading branch information
nmcspadden committed Jan 25, 2024
2 parents ac1bbcb + 142368f commit d30cdc8
Show file tree
Hide file tree
Showing 11 changed files with 40 additions and 56 deletions.
21 changes: 14 additions & 7 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,6 @@ jobs:
with:
python-version: 3.10.4

- name: Set token
# required for githubreleaseinfoprovider in github actions
# without this, API limits will be hit
run: |
cd ~
echo ${{ secrets.GITHUB_TOKEN_PATH }} > "gh_token"
- name: Install requirements
run: pip install --requirement gh_actions_requirements.txt

Expand All @@ -60,12 +53,26 @@ jobs:
shell: cmd
run: |
if not exist "%USERPROFILE%/AppData/Local/Autopkg" mkdir "%USERPROFILE%/AppData/Local/Autopkg"
if not exist "%USERPROFILE%/Library/AutoPkg" mkdir "%USERPROFILE%/Library/AutoPkg"
if not exist "%USERPROFILE%/AppData/Local/Autopkg/config.json" echo {} > "%USERPROFILE%/AppData/Local/Autopkg/config.json"
- name: create empty autopkg config file - Linux
if: runner.os == 'Linux'
run: |
cd ~ && mkdir -p .config/Autopkg
cd ~ && mkdir -p Library/AutoPkg
cd ~ && echo {} > .config/Autopkg/config.json
- name: create folder for recipe map - macOS
if: runner.os == 'macOS'
run: |
cd ~ && mkdir -p Library/AutoPkg
- name: Set token
# required for githubreleaseinfoprovider in github actions
# without this, API limits will be hit
run: |
cd ~
echo ${{ secrets.GITHUB_TOKEN }} > "Library/AutoPkg/gh_token"
- name: run autopkg info to get it to generate recipe map
run: python Code/autopkg info
- name: run unittests
run: python Scripts/run_tests.py
- name: run e2e tests
Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
exclude: "^Code/nuget/generated/.*$"
repos:
- repo: https://github.com/python/black
rev: 22.10.0
rev: 23.10.1
hooks:
- id: black
- repo: https://github.com/pre-commit/mirrors-isort
rev: v5.10.1
hooks:
- id: isort
- repo: https://github.com/pycqa/flake8
rev: 5.0.4
rev: 6.1.0
hooks:
- id: flake8
6 changes: 3 additions & 3 deletions Code/autopkg
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ def old_locate_recipe(
)
elif len(repo_names) > 1:
print()
print("To add a new recipe repo, use 'autopkg repo-add " "<repo name>'")
print("To add a new recipe repo, use 'autopkg repo-add <repo name>'")
return None

return recipe_file
Expand Down Expand Up @@ -2260,12 +2260,12 @@ def printplistitem(label, value, indent=0):
indentspace = " "
if value is None:
log(indentspace * indent + f"{label}: !NONE!")
elif type(value) == list or type(value).__name__ == "NSCFArray":
elif isinstance(value, list) or type(value).__name__ == "NSCFArray":
if label:
log(indentspace * indent + f"{label}:")
for item in value:
printplistitem("", item, indent + 1)
elif type(value) == dict or type(value).__name__ == "NSCFDictionary":
elif isinstance(value, dict) or type(value).__name__ == "NSCFDictionary":
if label:
log(indentspace * indent + f"{label}:")
for subkey in list(value.keys()):
Expand Down
2 changes: 1 addition & 1 deletion Code/autopkgcmd/searchcmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def search_recipes(argv: List[str]):
if len(results) > results_limit:
print()
print(
"Warning: Search yielded more than 100 results. Please try a "
f"Warning: Search yielded more than {results_limit} results. Please try a "
"more specific search term."
)
return 3
Expand Down
53 changes: 17 additions & 36 deletions Code/autopkglib/MunkiCatalogBuilder.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -15,53 +15,34 @@
# limitations under the License.
"""See docstring for MunkiCatalogBuilder class"""

import subprocess
import os

from autopkglib import Processor, ProcessorError
from autopkglib import Processor, remove_recipe_extension

__all__ = ["MunkiCatalogBuilder"]


class MunkiCatalogBuilder(Processor):
"""Rebuilds Munki catalogs."""
"""DEPRECATED. This processor now emits a warning and performs no function.
Previously it rebuilt Munki catalogs."""

input_variables = {
"MUNKI_REPO": {"required": True, "description": "Path to the Munki repo."},
"munki_repo_changed": {
"required": False,
"description": (
"If not defined or False, causes running makecatalogs to be skipped."
),
},
}
input_variables = {}
output_variables = {}
description = __doc__

def main(self):
# MunkiImporter or other processor must set
# env["munki_repo_changed"] = True in order for makecatalogs
# to run
if not self.env.get("munki_repo_changed"):
self.output("Skipping makecatalogs because repo is unchanged.")
return

# Generate arguments for makecatalogs.
args = ["/usr/local/munki/makecatalogs", self.env["MUNKI_REPO"]]

# Call makecatalogs.
try:
proc = subprocess.Popen(
args, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True
)
(_, err_out) = proc.communicate()
except OSError as err:
raise ProcessorError(
f"makecatalog execution failed with error code {err.errno}: "
f"{err.strerror}"
) from err
if proc.returncode != 0:
raise ProcessorError(f"makecatalogs failed: {err_out}")
self.output("Munki catalogs rebuilt!")
warning_message = self.env.get(
"warning_message",
"### The MunkiCatalogBuilder processor has been deprecated. It currently does nothing. It will be removed in the future. ###",
)
self.output(warning_message)
recipe_name = os.path.basename(self.env["RECIPE_PATH"])
recipe_name = remove_recipe_extension(recipe_name)
self.env["deprecation_summary_result"] = {
"summary_text": "The following recipes have deprecation warnings:",
"report_fields": ["name", "warning"],
"data": {"name": recipe_name, "warning": warning_message},
}


if __name__ == "__main__":
Expand Down
3 changes: 1 addition & 2 deletions Code/autopkglib/MunkiImporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,8 +395,7 @@ def main(self):
self.env["MUNKI_REPO"], "pkgs", installer_item_location
)
self.env["munki_info"] = {}
if "munki_repo_changed" not in self.env:
self.env["munki_repo_changed"] = False
self.env["munki_repo_changed"] = False

self.output(
f"Item {os.path.basename(self.env['pkg_path'])} already exists in the "
Expand Down
2 changes: 1 addition & 1 deletion Code/autopkglib/PkgInfoCreator.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def get_pkgroot_size(self, pkgroot):

size = 0
nfiles = 0
for (dirpath, _, filenames) in os.walk(pkgroot):
for dirpath, _, filenames in os.walk(pkgroot):
# Count the current directory and the number of files in it.
nfiles += 1 + len(filenames)
for filename in filenames:
Expand Down
1 change: 0 additions & 1 deletion Code/autopkglib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,6 @@ def process(self, recipe: RecipeChain):
pprint.pprint(self.env)

for step in recipe.process:

if self.verbose:
print(step["Processor"])

Expand Down
1 change: 0 additions & 1 deletion Code/autopkgserver/itemcopier.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ def copy_items(self):
"""
mountpoint = self.request["mount_point"]
for item in self.request["items_to_copy"]:

# get itemname
source_itemname = item.get("source_item")
dest_itemname = item.get("destination_item")
Expand Down
2 changes: 1 addition & 1 deletion Code/autopkgserver/packager.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ def verify_relative_valid_path(root, path):
self.log.info(f"Setting mode of {entry['path']} to {entry['mode']}")
os.lchmod(chownpath, int(entry["mode"], 8))
else:
for (dirpath, dirnames, filenames) in os.walk(chownpath):
for dirpath, dirnames, filenames in os.walk(chownpath):
try:
os.lchown(dirpath, uid, gid)
except OSError as e:
Expand Down
1 change: 0 additions & 1 deletion Code/tests/test_chocolatey_generators.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ def test_nuspec_generator_basic_validation(self):


class TestChocolateyInstallGenerator(unittest.TestCase):

COMMON_HEADER = dedent(
"""\
$ErrorActionPreference = 'Stop'
Expand Down

0 comments on commit d30cdc8

Please sign in to comment.