Skip to content

Commit

Permalink
Add installcheck_script based on Graham Gilbert's here: https://githu…
Browse files Browse the repository at this point in the history
  • Loading branch information
gregneagle committed Dec 12, 2014
1 parent 8810cff commit f882873
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions make_profile_pkg.py
Expand Up @@ -172,13 +172,46 @@ def main():
with open(uninstall_script_path, "w") as fd: with open(uninstall_script_path, "w") as fd:
fd.write(uninstall_script) fd.write(uninstall_script)


# -- installcheck_script
installcheck_script_path = os.path.join(output_dir, "%s_installcheck.sh" % item_name)
installcheck_script = """#!/bin/bash
# The version of the package
PKG_VERSION="%s"
# The identifier of the package
PKG_ID="%s"
# The identifier of the profile
PROFILE_ID="%s"
# The version installed from pkgutil
VERSION_INSTALLED=`/usr/sbin/pkgutil --pkg-info "$PKG_ID" | grep version | sed 's/^[^:]*: //'`
if ( /usr/bin/profiles -P | /usr/bin/grep -q $PROFILE_ID ); then
# Profile is present, check the version
if [ "$VERSION_INSTALLED" = "$PKG_VERSION" ]; then
# Correct version, all good
exit 1
else
exit 0
fi
else
# Profile isn't there, need to install
exit 0
fi
""" % (version, pkg_identifier, profile_identifier)
with open(installcheck_script_path, "w") as fd:
fd.write(installcheck_script)

# -- munkiimport it? # -- munkiimport it?
if opts.munki_import: if opts.munki_import:
subprocess.call([ subprocess.call([
munkiimport, munkiimport,
"--nointeractive", "--nointeractive",
"--subdirectory", opts.munki_repo_destination, "--subdirectory", opts.munki_repo_destination,
"--uninstall-script", uninstall_script_path, "--uninstall-script", uninstall_script_path,
"--installcheck-script", installcheck_script_path,
"--minimum-os-version", "10.7", "--minimum-os-version", "10.7",
pkg_output_path pkg_output_path
] ]
Expand Down

0 comments on commit f882873

Please sign in to comment.