Skip to content

Commit

Permalink
remove custom IPSW from previous run if exists
Browse files Browse the repository at this point in the history
  • Loading branch information
m1stadev committed Aug 23, 2020
1 parent 8b8d1a5 commit 9aadcc3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
4 changes: 1 addition & 3 deletions inferius.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
output = str(ldid_check.stdout.read())
if len(output) == 3:
sys.exit('ldid not installed! Please install ldid from Homebrew, then run this script again.')
if os.path.exists(f'work'): # In case work directory is here from a previous run, remove it
if os.path.exists(f'work'): # In case work directory is still here from a previous run, remove it
shutil.rmtree(f'work')
print(f'Finding Firmware bundle for:\nDevice: {args.device[0]}\niOS: {args.version[0]}')
if args.verbose:
Expand All @@ -63,7 +63,5 @@
print(f'Done!\nCustom IPSW at: {ipsw_name}')
print('Cleaning up...')
shutil.rmtree('work')


else:
exit(parser.print_help(sys.stderr))
9 changes: 7 additions & 2 deletions resources/ipsw.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import zipfile
import requests
from remotezip import RemoteZip
import glob

def extract_ipsw(ipsw, verbose=None):
os.makedirs('work/ipsw', exist_ok = True)
Expand Down Expand Up @@ -32,7 +33,7 @@ def find_bundle(device_identifier, version, verbose=None):
else:
sys.exit(f"Firmware bundle for\nDevice: {device_identifier}\nVersion: {version}\ndoesn't exist!\nIf you have provided your own firmware bundle,\nplease make sure it is in 'resources/FirmwareBundles'\nand named {device_identifier}_{version}_bundle")

def grab_latest_llb_iboot(device_identifier, ipsw_dir, firm_bundle):
def grab_latest_llb_iboot(device_identifier, ipsw_dir, firm_bundle, verbose=None):
with open(f'{firm_bundle}/Info.json') as f:
data = json.load(f)
hardware_model = data['boardconfig']
Expand All @@ -50,7 +51,11 @@ def grab_latest_llb_iboot(device_identifier, ipsw_dir, firm_bundle):
shutil.copy(f'Firmware/all_flash/iBoot.{hardware_model}.RELEASE.im4p', f'{ipsw_dir}/Firmware/all_flash/')
shutil.rmtree('Firmware')

def make_ipsw(ipsw_dir, firm_bundle):
def make_ipsw(ipsw_dir, firm_bundle, verbose=None):
if os.path.isfile(f'{firm_bundle[26:-7]}_custom.ipsw'):
if verbose:
print(f'Found custom IPSW from previous run: {firm_bundle[26:-7]}_custom.ipsw, deleting...')
os.remove(f'{firm_bundle[26:-7]}_custom.ipsw')
shutil.make_archive(f'{firm_bundle[26:-7]}', 'zip', ipsw_dir)
os.rename(f'{firm_bundle[26:-7]}.zip', f'{firm_bundle[26:-7]}_custom.ipsw')
return f'{firm_bundle[26:-7]}_custom.ipsw'

0 comments on commit 9aadcc3

Please sign in to comment.