Skip to content

Commit

Permalink
support for versioning autopkglib and MinimumVersion in recipe keys
Browse files Browse the repository at this point in the history
- store AUTOPKG_VERSION in env so that it's available for reporting or other purposes (for recipes, metadata, etc.)
- currently version.plist contains a single value that would be manually incremented when new features added
  - would be good in the future to have another patch version that auto-increments with Git commits, ala munkitools
  • Loading branch information
timsutton committed Aug 11, 2013
1 parent 2d4f007 commit 82c57a7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
12 changes: 12 additions & 0 deletions Code/autopkglib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import subprocess

from Foundation import CFPreferencesCopyAppValue
from distutils.version import LooseVersion

BUNDLE_ID = "com.github.autopkg"
LOCAL_OVERRIDE_KEY = "RecipeInputOverrides"
Expand Down Expand Up @@ -210,6 +211,10 @@ def __init__(self, options, env):
self.env = env
self.results = []

version_plist = plistlib.readPlist(
os.path.join(os.path.dirname(__file__), "version.plist"))
self.env["AUTOPKG_VERSION"] = version_plist["Version"]

def output(msg, verbose_level=1):
if self.verbose >= verbose_level:
print msg
Expand Down Expand Up @@ -269,6 +274,13 @@ def process_input_overrides(self, recipe, cli_values):
def verify(self, recipe):
"""Verify a recipe and check for errors."""

# Check for MinimumAutopkgVersion
if "MinimumVersion" in recipe.keys():
if LooseVersion(self.env["AUTOPKG_VERSION"]) < LooseVersion(recipe.get("MinimumVersion")):
raise AutoPackagerError(
"Recipe requires at least version %s, but we are version %s."
% (recipe.get("MinimumVersion"), self.env["AUTOPKG_VERSION"]))

# Initialize variable set with input variables.
variables = set(recipe["Input"].keys())
# Add environment.
Expand Down
8 changes: 8 additions & 0 deletions Code/autopkglib/version.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Version</key>
<string>0.1.0</string>
</dict>
</plist>

0 comments on commit 82c57a7

Please sign in to comment.