Specify nonstandard path and specific version to keep: Same as above, but with umask of 077 (i.e. Same as above, and delete current Keystone updates, and block This script must be run with admin privilegs.Ĭlean Chrome versions from "/Applications/Google Optional Arguments: Specify path to Google Chrome app andĭefaults to "/Applications/Google Chrome.app" and installed Usage = """%prog ĭeletes non-current (both older and newer) versions of GoogleĬhrome that can accumulate in the /Applications/GoogleĬhrome.app/Contents/Versions folder over time if Google Chrome Os.chown(googlesoftwareupdate_dir, user_id, group_id) # Create ~/Library/Google/GoogleSoftwareUpdate # ~/Library/Google/GoogleSoftwareUpdate does not exist
Os.chflags(googlesoftwareupdate_dir, flags | stat.UF_IMMUTABLE)
# Lock folder to prevent future Keystone update attempts # Delete contents of ~/Library/Google/GoogleSoftwareUpdateįor filename in os.listdir(googlesoftwareupdate_dir):įilepath = os.path.join(googlesoftwareupdate_dir, filename) Mutable = not bool(flags & stat.UF_IMMUTABLE) # Make no changes if folder is locked, even though sudo user can override If os.path.exists(googlesoftwareupdate_dir):įlags = os.stat(googlesoftwareupdate_dir).st_flags # If ~/Library/Google/GoogleSoftwareUpdate exists. Googlesoftwareupdate_dir = os.path.join(google_dir, "GoogleSoftwareUpdate") Google_dir = os.path.join(user_home_dir, "Library/Google") If user_home_dir.startswith("/var/") or user_home_dir.startswith("/private/") or user_home_dir.startswith("/Library/"): """Disables Google Keystone in user home folders""" Info_plist = plistlib.readPlist(info_plist_path)īundle_short_version = info_plistĭef clean_user_level_keystone_updates(disable_current_updates, block_future_updates, umask): Info_plist_path = os.path.realpath(os.path.join(chrome_path, 'Contents/ist')) Print > sys.stderr, "Error: Path %s does not exist." % (versions_dir)ĭef installed_chrome_version(chrome_path):
Path_to_delete = os.path.join(versions_dir, version) Versions_dir = os.path.join(path_to_app, 'Contents', 'Versions') """Delete all Google Chrome versions except keep version""" # Created by Hannes Juutilainen, optparseĭefault_chrome_path = "/Applications/Google Chrome.app"ĭef clean_app_versions(path_to_app, app_keep_version):
# Use of this source code is governed by a BSD-style license that can be A feature request may need to be submitted to Here you go: #!/usr/bin/env python
Ideally, Google would add support to Google Chrome for Mac (and other Google software for Mac) to clean old versions automatically, immediately after each update is installed.
Does anyone know where to find the source code for Google's Keystone update subsystem? (This doesn't appear to be available on - I looked.).Does anyone know of a built-in mechanism in Google Chrome for Mac to clean out these older versions, similar to what exists for Google Chrome for Windows?.Google Earth) that are also under Keystone management, and modifying this script (or creating yet another version of it) soon becomes an unwieldy approach.
the script has to be run separately and periodically via a separate JAMF Pro policy.Īlso, some enterprise sites may have other Google products installed (e.g. The downside to having a separate script is that it isn't run automatically after Keystone updates Google Chrome, i.e. Removing /Applications/Google Chrome.app/Contents/Versions/.87 Removing /Applications/Google Chrome.app/Contents/Versions/.170
Removing /Applications/Google Chrome.app/Contents/Versions/.181 The resulting script now correctly detects the current version installed on disk, leaves it intact, and deletes all other versions installed inside the /Applications/Google Chrome.app/Contents/Versions folder: $ sudo /tmp/clean_up_old_chrome_versions.py I did find a Google build tool ( clean_up_old_versions.py), and modified it for my needs, while also borrowing some code from Hannes Juutilainen's excellent chrome-enable-autoupdates.py. (Again, these only appear if you've configured Google Chrome to autoupdate.)ĭespite extensive searching online (Chrome's online documentation, Chrome's source code on ), I could not find any built-in mechanism in Google Chrome for Mac to clean out these old versions. Applications/Google Chrome.app/Contents/Versions Unlike on Windows, if you've enabled Google Chrome for Mac to autoupdate for all users, over time you'll start to see an accumulation of old versions: $ pwd