Skip to content

Instantly share code, notes, and snippets.

@chris-pcguy
Created July 13, 2023 18:35
Show Gist options
  • Select an option

  • Save chris-pcguy/821e46c6e1e090e4f729c4d243008812 to your computer and use it in GitHub Desktop.

Select an option

Save chris-pcguy/821e46c6e1e090e4f729c4d243008812 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
"""
DEVNAME=n104ap
#DEVNAME=n841ap
RELTYPE=research
#RELTYPE=release
RDPATH=$(get_entries_from_plist.py BuildManifest.plist RestoreRamDisk "$DEVNAME" "$RELTYPE")
KERNELCACHE=$(get_entries_from_plist.py BuildManifest.plist KernelCache "$DEVNAME" "$RELTYPE")
#DTB=$(get_entries_from_plist.py BuildManifest.plist DeviceTree "$DEVNAME" "$RELTYPE")
"""
import sys, plistlib, json
fn = sys.argv[1]
image_type = sys.argv[2]
model = sys.argv[3]
variant = sys.argv[4]
#print(len(sys.argv))
if (len(sys.argv) == 6):
in_variant = sys.argv[5]
else:
in_variant = 'Erase Install'
# image_type: RestoreRamDisk/KernelCache
pl = plistlib.load(open(fn,'rb'))
#print(pl)
for i0 in pl['BuildIdentities']:
#print(i0)
device_class = i0['Info']['DeviceClass']
device_variant = i0['Info']['Variant']
if (device_class != model):
continue
elif (variant == 'research' and 'research' not in device_variant.lower()):
continue
elif (variant != 'research' and 'research' in device_variant.lower()):
continue
elif (in_variant not in device_variant):
#print(f'Skipped device_variant: {device_variant}')
continue
#print(i0)
#print(json.dumps(i0, default=lambda o:"<not serializable>"))
ramdisk_path = i0['Manifest'][image_type]['Info']['Path']
print(ramdisk_path)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment