Skip to content
This repository has been archived by the owner on Feb 7, 2024. It is now read-only.

Commit

Permalink
Forced, Add 'group' option for joining all payloads
Browse files Browse the repository at this point in the history
New option for joining payloads in 1 profile, renamed 'github' option to 'profile_id'.  Changes frequency in payloads to Forced, as Set-Once may be less enforceable.
  • Loading branch information
arubdesu committed Feb 7, 2016
1 parent e5fae15 commit 73a6b9c
Showing 1 changed file with 69 additions and 29 deletions.
98 changes: 69 additions & 29 deletions extinguish.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#!/usr/bin/python
"""
Generates a sparkle disabler profile from an app bundle id, writing a mobileconfig
to wherever this script is run from.
to wherever this script is run from. You can then sign/distribute as you see fit.
Drag-drop an app bundle as an argument, or feed it one (or more)
bundle identifiers from the CFBundleIdentifier value in an apps Info.plist.
Optionally specify your org and/or github acct, and it'll spit out profiles you can distribute.
Add the '-g or --group' option to make one big profile for all affected apps.
Optionally specify your org and/or an identifier(like a github acct).
"""
import argparse
import CoreFoundation
Expand All @@ -18,10 +18,11 @@

def build_payload(bundle_id, payload_id, in_uuid):
"""populates payload with bundle_id, returns array"""
once_dict = {"mcx_preference_settings": {"SUAutomaticallyUpdate": False,
"SUEnableAutomaticChecks": False}
}
bundle_dict = {"Set-Once": [once_dict]}
forced_dict = {"mcx_preference_settings": {"SUAutomaticallyUpdate": False,
"SUEnableAutomaticChecks": False,
"SUFeedURL": "https://127.0.0.1"}
}
bundle_dict = {"Forced": [forced_dict]}
content_dict = {bundle_id: bundle_dict}
payload_dict = {"PayloadContent": content_dict,
"PayloadEnabled": True,
Expand All @@ -30,18 +31,14 @@ def build_payload(bundle_id, payload_id, in_uuid):
"PayloadUUID": in_uuid,
"PayloadVersion": 1,
}
content_array = [payload_dict]
return content_array
return payload_dict


def integrate_whole(payload, bundle_id, github_acct, org, out_uuid):
def integrate_whole(payload, github_acct, org, out_uuid):
"""integrates payload into whole of profile, returns dict"""
appname = bundle_id.split('.')[-1]
if type(payload) != list:
payload = [payload]
finished_profile = {"PayloadContent": payload,
"PayloadDescription": "Custom settings to disable sparkle updates "
"for %s.app" % appname,
"PayloadDisplayName": "SparkleDisabler: %s" % bundle_id,
"PayloadIdentifier": github_acct + '.' + appname,
"PayloadOrganization": org,
"PayloadRemovalDisallowed": True,
"PayloadScope": "System",
Expand All @@ -61,30 +58,42 @@ def main():
parser.add_argument('app_bundle', type=str, help='Path to app bundle'
' to make a profile for', nargs='?')
parser.add_argument('-a', '--apps', action='append',
#default=['com.github.GitHub'],
help='One or more app bundle ids to create profiles for',
)
parser.add_argument('-g', type=str, dest='github_acct',
default="com.github.arubdesu.extinguish",
help='Used as identifier for payload id, '
'uses "com.github.arubdesu.extinguish" by default',
parser.add_argument('-g', '--group', type=bool, dest='group',
default=False,
help='Generates one mobileconfig for all apps specified',
)
parser.add_argument('-o', type=str, dest='org',
default="",
help='Sets organization in profile, empty by default',
)
parser.add_argument('-p', '--profile_id', type=str, dest='profile_id',
default="com.github.arubdesu.extinguish",
help='Used as identifier for payload id in reverse-domain format. '
'Uses "com.github.arubdesu.extinguish" by default',
)
options = parser.parse_args()
#build_payload
#build_payload, handling one-off drag-drops first
out_uuid = str(uuid.uuid4())
if options.app_bundle:
if options.app_bundle.endswith('.app'):
try:
infoplist_path = (options.app_bundle + '/Contents/Info.plist')
bundle_id = CoreFoundation.CFPreferencesCopyAppValue("CFBundleIdentifier", infoplist_path)
in_uuid, out_uuid = str(uuid.uuid4()), str(uuid.uuid4())
appname = bundle_id.split('.')[-1]
in_uuid = str(uuid.uuid4())
payload_id = "SparkleDisabler." + out_uuid + ".alacarte.customsettings." + in_uuid
payload = build_payload(bundle_id, payload_id, in_uuid)
whole = integrate_whole(payload, bundle_id, options.github_acct,
whole = integrate_whole(payload, options.profile_id,
options.org, out_uuid)
extend_dict = {"PayloadDescription": "Custom settings to disable "
"sparkle updates for %s.app" % appname,
"PayloadDisplayName": "SparkleDisabler: %s" % bundle_id,
"PayloadIdentifier": options.profile_id + '.' + appname,
}
whole.update(extend_dict)

mobilecfg_path = ('').join([os.getcwd(), '/disable_autoupdates_',
bundle_id.split('.')[-1], '.mobileconfig'])
with open(mobilecfg_path, 'w') as final:
Expand All @@ -101,15 +110,46 @@ def main():
if not to_process:
print parser.print_help()
sys.exit(0)
mobilecfg_path, whole = '', ''
if options.group:
mobilecfg_path = ('').join([os.getcwd(), '/disable_all_sparkle_',
'autoupdates.mobileconfig'])
payload_list = []
for bundle_id in to_process:
#gen uuid's for containing profile and payload
in_uuid, out_uuid = str(uuid.uuid4()), str(uuid.uuid4())
payload_id = "SparkleDisabler." + out_uuid + ".alacarte.customsettings." + in_uuid
payload = build_payload(bundle_id, payload_id, in_uuid)
whole = integrate_whole(payload, bundle_id, options.github_acct,
appname = bundle_id.split('.')[-1]
if options.group:
in_uuid = str(uuid.uuid4())
payload_id = ('').join(["SparkleDisabler.", out_uuid,
".alacarte.customsettings.", in_uuid])
payload = build_payload(bundle_id, payload_id, in_uuid)
payload_list.append(payload)
else:
in_uuid, out_uuid = str(uuid.uuid4()), str(uuid.uuid4())
payload_id = ('').join(["SparkleDisabler.", out_uuid,
".alacarte.customsettings.", in_uuid])
payload = build_payload(bundle_id, payload_id, in_uuid)
whole = integrate_whole(payload, options.profile_id,
options.org, out_uuid)
extend_dict = {"PayloadDescription": "Custom settings to disable "
"sparkle updates for %s.app" % appname,
"PayloadDisplayName": "SparkleDisabler: %s" % bundle_id,
"PayloadIdentifier": options.profile_id + '.' + appname,
}
whole.update(extend_dict)
mobilecfg_path = ('').join([os.getcwd(), '/disable_autoupdates_',
bundle_id.split('.')[-1], '.mobileconfig'])
with open(mobilecfg_path, 'w') as final:
plistlib.writePlist(whole, final)
if options.group:
whole = integrate_whole(payload_list, options.profile_id,
options.org, out_uuid)
mobilecfg_path = ('').join([os.getcwd(), '/disable_autoupdates_',
bundle_id.split('.')[-1], '.mobileconfig'])
extend_dict = {"PayloadDescription": "Custom settings to disable "
"all sparkle apps from updating over http",
"PayloadDisplayName": "ExtinguishGeneratedSparkleDisabler",
"PayloadIdentifier": options.profile_id
}
whole.update(extend_dict)
with open(mobilecfg_path, 'w') as final:
plistlib.writePlist(whole, final)

Expand Down

0 comments on commit 73a6b9c

Please sign in to comment.