MCPcopy
hub / github.com/corpnewt/gibMacOS / install_oc

Method install_oc

MakeInstall.py:471–617  ·  view source on GitHub ↗
(self, disk, local_file = None)

Source from the content-addressed store, hash-verified

469 else: self.install_clover(disk, clover_version, local_file=local_file)
470
471 def install_oc(self, disk, local_file = None):
472 self.u.head("Installing OpenCore")
473 print("")
474 print("Gathering info...")
475 if not local_file:
476 o = self.get_oc_dl_info()
477 if o is None:
478 print(" - Error communicating with github!")
479 print("")
480 self.u.grab("Press [enter] to return...")
481 return
482 print(" - Got {}".format(o.get("name","Unknown Version")))
483 print("Downloading...")
484 temp = tempfile.mkdtemp()
485 os.chdir(temp)
486 self.dl.stream_to_file(o["url"], os.path.join(temp, o["name"]))
487 else:
488 print("Using local file: {}".format(local_file))
489 temp = tempfile.mkdtemp()
490 os.chdir(temp)
491 o = {"name":os.path.basename(local_file)}
492 # Copy to the temp folder
493 shutil.copy(local_file,os.path.join(temp,o["name"]))
494 print("") # Empty space to clear the download progress
495 if not os.path.exists(os.path.join(temp, o["name"])):
496 shutil.rmtree(temp,ignore_errors=True)
497 print(" - Download failed. Aborting...")
498 print("")
499 self.u.grab("Press [enter] to return...")
500 return
501 oc_zip = o["name"]
502 # Got a valid file in our temp dir
503 print("Extracting {}...".format(oc_zip))
504 out = self.r.run({"args":[self.z_path, "x", os.path.join(temp,oc_zip)]})
505 if out[2] != 0:
506 shutil.rmtree(temp,ignore_errors=True)
507 print(" - An error occurred extracting: {}".format(out[2]))
508 print("")
509 self.u.grab("Press [enter] to return...")
510 return
511 # We need to also gather our boot, boot0af, and boot1f32 files
512 print("Gathering DUET boot files...")
513 uefi_only = False
514 duet_loc = os.path.join(temp,"Utilities","LegacyBoot")
515 for x in (self.oc_boot,self.oc_boot_alt,self.oc_boot0,self.oc_boot1):
516 # Check the local dir first
517 if os.path.exists(os.path.join(duet_loc,x)):
518 print(" - {}".format(x))
519 # Copy it over
520 target_name = self.oc_boot if x == self.oc_boot_alt else x
521 shutil.copy(os.path.join(duet_loc,x), os.path.join(temp,target_name))
522 missing_list = [x for x in (self.oc_boot,self.oc_boot0,self.oc_boot1) if not os.path.exists(os.path.join(temp,x))]
523 if missing_list:
524 print(" - Missing: {}".format(", ".join(missing_list)))
525 print("Attempting to download...")
526 for x in missing_list:
527 print(" - {}".format(x))
528 self.dl.stream_to_file(self.oc_boot_url + x, os.path.join(temp,x),False)

Callers 2

dd_imageMethod · 0.95
mainMethod · 0.95

Calls 6

get_oc_dl_infoMethod · 0.95
headMethod · 0.80
grabMethod · 0.80
stream_to_fileMethod · 0.80
runMethod · 0.80
updateMethod · 0.45

Tested by

no test coverage detected