Permalink
Browse files

Add installcheck_script based on Graham Gilbert's here: https://githu…

  • Loading branch information...
gregneagle committed Dec 12, 2014
1 parent 8810cff commit f8828736c5eb545c6461cb00a5b0d6e03093847a
Showing with 33 additions and 0 deletions.
  1. +33 −0 make_profile_pkg.py
@@ -172,13 +172,46 @@ def main():
with open(uninstall_script_path, "w") as fd:
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?
if opts.munki_import:
subprocess.call([
munkiimport,
"--nointeractive",
"--subdirectory", opts.munki_repo_destination,
"--uninstall-script", uninstall_script_path,
"--installcheck-script", installcheck_script_path,
"--minimum-os-version", "10.7",
pkg_output_path
]

0 comments on commit f882873

Please sign in to comment.