Mac Build Scripts: Python
Jump to navigation
Jump to search
Now let's try that Linux Disk Replication script in Python.
Disk Replication
replicate.py
#!/usr/bin/python
from platform import *
from globals import *
import sys, getopt
def getArgs():
pass
def verifyTarget(t):
pass
def createPartitions():
pass
def setupForCopy():
pass
def copyPartitions():
pass
def tweakConfigFiles(type):
pass
if __name__ == "__main__":
dump_platform(aPlatform("imac"))
globals.py
linuxroot = "/root/rootdir" bootpartimg = "/root/bootpart.img"
platform.py
class Platform:
def __init__(self):
self.name = "prototype"
self.hd_device = "hda"
self.cd_device = "hdc"
self.of_bootdev = "hd:"
def get_name(self):
return self.name
def set_name(self,name):
self.name = name
def get_hd(self):
return self.hd_device
def set_hd(self,device):
self.hd_device = device
def get_cd(self):
return self.cd_device
def set_cd(self,device):
self.cd_device = device
def get_bootdev(self):
return self.of_bootdev
def set_cd(self,ofpath):
self.of_bootdev = ofpath
class imac(Platform):
def __init__(self):
self.name = "iMac"
self.hd_device = "hda"
self.cd_device = "hdb"
self.of_bootdev = "/pci@f2000000/mac-io@17/ata-4@1f000/disk@0:"
class g3(Platform):
def __init__(self):
self.name = "g3"
self.hd_device = "hdc"
self.cd_device = "hda"
self.of_bootdev = "/pci@80000000/pci-bridge@d/pci-ata@1/@0/disk@0:"
class g4(Platform):
def __init__(self):
self.name = "g4"
self.hd_device = "hda"
self.cd_device = "hdc"
self.of_bootdev = "/pci@f2000000/pci-bridge@d/mac-io@7/ata-4@1f000/disk@0:"
class g4q(Platform):
def __init__(self):
self.name = "g4q"
self.hd_device = "hda"
self.cd_device = "hdc"
self.of_bootdev = "/pci@f2000000/mac-io@17/ata-4@1f000/disk@0:"
def aPlatform(name):
if name == "imac":
return imac()
elif name == "g3":
return g3()
elif name == "g4":
return g4()
elif name == "g4q":
return g4q()
else:
return Platform()
def dump_platform(p):
print 'name : %s '% p.get_name().upper()
print 'hd : %s '% p.get_hd()
print 'cd : %s '% p.get_cd()
print 'of_bootdev: %s '% p.get_bootdev()
print
if __name__ == "__main__":
dump_platform(aPlatform("g4"))
dump_platform(aPlatform("imac"))
dump_platform(aPlatform("g3"))
dump_platform(aPlatform("g4q"))