Cloud AutoPkg Runner is a Python library designed to provide asynchronous tools and utilities for managing AutoPkg recipes and workflows. It streamlines AutoPkg automation in cloud environments and CI/CD pipelines, offering enhanced performance and scalability.
This library provides modules for:
- Managing metadata caching
- Processing AutoPkg recipes asynchronously
- Executing shell commands with robust error handling
- Centralized configuration management
- Asynchronous Recipe Processing: Run AutoPkg recipes concurrently for faster execution.
- Metadata Caching: Improve efficiency by caching metadata and reducing redundant data fetching.
- Robust Error Handling: Comprehensive exception handling and logging for reliable automation.
- Flexible Configuration: Easily configure the library using command-line arguments and environment variables.
- Cloud-Friendly: Designed for seamless integration with cloud environments and CI/CD systems.
- Python 3.10 or higher
- AutoPkg installed and configured
uv add cloud-autopkg-runerpip install cloud-autopkg-runnerThe cloud-autopkg-runner library provides a command-line interface (CLI) for running AutoPkg recipes. UV is recommended (uv run autopkg-run), but you can also call it as a python module (python -m cloud_autopkg_runner).
uv run autopkg-run --recipe Firefox.pkg.recipeuv run autopkg-run --recipe Firefox.pkg.recipe --recipe GoogleChrome.pkg.recipeCreate a JSON file (recipes.json) containing a list of recipe names:
[
"Firefox.pkg.recipe",
"GoogleChrome.pkg.recipe"
]Then, run the recipes using the --recipe-list option:
uv run autopkg-run --recipe-list recipes.jsonUse the -v option to control the verbosity level. You can specify it multiple times for increased verbosity (e.g., -vvv).
uv run autopkg-run -vv --recipe Firefox.pkg.recipeUse the --log-file option to specify a log file for the script's output:
uv run autopkg-run --log-file autopkg_runner.log --recipe Firefox.pkg.recipeYou can also use cloud-autopkg-runner as a Python library in your own scripts.
import asyncio
from cloud_autopkg_runner import AppConfig, generate_recipe_list
from cloud_autopkg_runner.__main__ import (
parse_arguments,
load_metadata_cache,
create_dummy_files,
process_recipe_list,
)
from pathlib import Path
async def main():
args = parse_arguments()
# Configure the library
AppConfig.set_config(verbosity_level=args.verbose, log_file=args.log_file)
AppConfig.initialize_logger()
# Generate the recipe list
recipe_list = generate_recipe_list(args)
# Load and create dummy files
metadata_cache = load_metadata_cache(args.cache_file)
create_dummy_files(recipe_list, metadata_cache)
#Get preferences
autopkg_preferences = AppConfig.autopkg_preferences()
overrides_dir = autopkg_preferences.get("RECIPE_OVERRIDE_DIRS")
# Run the recipes
await process_recipe_list(
Path(overrides_dir).expanduser(), recipe_list, Path("tmp")
) # replace with your working dir
if __name__ == "__main__":
asyncio.run(main())Contributions are welcome! Please refer to the CONTRIBUTING.md file for guidelines.
This project is licensed under the MIT License - see the LICENSE file for details.