#!/usr/bin/python
# Script to add DropSSDT for Chameleon boot loaders
import sys
import os
import shutil
vol = str(sys.argv[3])
# Check for .ChameleonEFI file at root of target volume
# to indicate user wants to install to EFI system partition.
espfile = "/.ChameleonEFI"
espvol = vol + espfile
if os.path.exists(espvol):
if not os.path.exists('/Volumes/EFI/Extra'):
os.makedirs('/Volumes/EFI/Extra')
plist = "/Volumes/EFI/Extra/org.chameleon.Boot.plist"
else:
extrafolder = vol + "/Extra"
if not os.path.exists(extrafolder):
os.makedirs(extrafolder)
boot = "/Extra/org.chameleon.Boot.plist"
plist = vol + boot
if not os.path.exists(plist):
shutil.copy('/Library/Preferences/SystemConfiguration/com.apple.Boot.plist', plist)
infile = open(plist, "r")
# check if DropSSDT has been written or not
DropSSDTCheck = False
body = ""
for line in infile:
# if we finish the tags and haven't written DropSSDT Yet
if "" in line and DropSSDTCheck == False:
line = " DropSSDT\n"
line += " Yes\n"
line += "\n"
DropSSDTCheck = True
body += line
infile.close()
outfile = open(plist, "w")
outfile.write(body)
outfile.close()