From: Jure C. <gan...@us...> - 2005-05-15 10:50:47
|
Update of /cvsroot/morphix/ibuild/src/intellibuild In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15029 Modified Files: manager.py Log Message: changed the confusing version number Index: manager.py =================================================================== RCS file: /cvsroot/morphix/ibuild/src/intellibuild/manager.py,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** manager.py 25 Sep 2004 20:40:39 -0000 1.33 --- manager.py 15 May 2005 10:50:37 -0000 1.34 *************** *** 1,265 **** ! #!/usr/bin/python ! ! # Changelog ! # 20040907 RKL ! # Adjusted version number to IntelliBuild 0.2.6 for __call__ ! # Changed opt list initialization in __call__ ! # Adjusted xml import in method RunPatch to use configparser.read_xml() routine ! # 20040908 RKL ! # Corrected identation of the exception handling of __call_ ! ! ! import hotshot ! import sys ! import weakref ! import xml.parsers.expat ! import configparser ! import console ! import getopt ! import os ! import exceptions ! ! import clientlib.accessors.settings ! import clientlib.accessors.filesystem ! import clientlib.accessors.chroot ! import clientlib.accessors.apt ! import clientlib.accessors.shell ! import clientlib.accessors.menu ! import clientlib.accessors.mime ! import clientlib.accessors.morphix ! import clientlib.accessors.grub ! import clientlib.accessors.log ! import clientlib.accessors.fs ! import clientlib.accessors.pack ! import clientlib.accessors.patchname ! ! __version__ = 'IntelliBuild 0.2.7' ! ! class BuildSystemManager: ! def __init__(self): ! self.__profiler = hotshot.Profile('build.prof') ! self.__settings = None ! self.__patchList = None ! ! def __del__(self): ! self.__profiler.close() ! ! def __call__(self): ! try: ! self.__profiler.start() ! cmd = console.Console(weakref.ref(self)(), __version__) ! if len(sys.argv) > 1: ! try: ! optlist, args = getopt.getopt(sys.argv[1:], ! 'cvfb:r:s:p:d:i:l:',['continue','verbose','fake','base=','release=','source=','patches=','data=','image=','length=']) ! except getopt.GetoptError: ! self.Usage() ! sys.exit(2) ! ! configfile = None ! patch = None ! ! opt = {} ! ! opt['base'] = None ! opt['release'] = None ! opt['source'] = None ! opt['patches'] = None ! opt['data'] = None ! opt['verbose'] = False ! opt['continue'] = False ! opt['simulate'] = False ! opt['image'] = None ! opt['length'] = None ! ! for o, a in optlist: ! print opt ! if o in ('-h','--help'): ! self.Usage() ! elif o in ('-l','--length'): ! print "running only " + a + " patches" ! opt['length'] = int(a) ! elif o in ('-v','--verbose'): ! print "verbose enabled" ! opt['verbose'] = True ! elif o in ('-c','--continue'): ! print "continuing from selected patch" ! opt['continue'] = True ! elif o in ('-f','--fake'): ! print "simulate enabled" ! opt['simulate'] = True ! elif o in ('-b','--base'): ! print "Using base " + a ! opt['base'] = a ! elif o in ('-r','--release'): ! print "Using release " + a ! opt['release'] = a ! elif o in ('-s','--source'): ! print "Using source " + a ! opt['source'] = a ! elif o in ('-p','--patches'): ! print "Using patches " + a ! opt['patches'] = a ! elif o in ('-d','--data'): ! print "Using data " + a ! opt['data'] = a ! elif o in ('-i','--image'): ! print "Using image " + a ! opt['image'] = a ! ! # all getopt'ed parameters parsed, everything left is in args ! if len(args) < 1 or len(args) > 2: ! self.Usage() ! configfile = args[0] ! if len(args) == 2: ! patch = args[1] ! cmd.do_load('baseconfig ' + configfile) ! self.OverwriteWithOpts(cmd,opt) ! if patch != None: ! if opt['continue']: ! self.RunPatchesFrom(patch,opt['length']) ! else: ! self.RunPatch(patch) ! self.EndWork() ! else: ! self.RunPatches(opt['length']) ! # uncomment this to force non-interactive mode ! #else: ! #self.Usage() ! cmd.cmdloop() ! ! except Exception, e: ! if str(e) == '0': ! pass ! else: ! print 'Unhandled exception:', str(e) ! ! def Usage(self): ! print "Usage:" ! print sys.argv[0] + " [OPTION] configfile" ! print ! print "Intellibuild lets you build a new KNOPPIX/Morphix iso using patches" ! print ! print "All options will override the defaults of the config file" ! print "-l, --length N\t\t\truns only N patches and then exits" ! print "-c, --continue\t\t\tcontinues from selected patch to be run" ! print "\t\t\t\teg: " + sys.argv[0] + " -c configfile patch" ! print "-b, --base basepath\t\tbase path for building the ISO in" ! print "-i, --image sourceimage\t\timage which you want to unleash iBuild upon" ! print "-r, --release releasepath\trelease path, contains the final output files" ! print "-s, --source sourceimagespath\tsource path, contains the input files" ! print "-p, --patches patchpath\t\tpath containing iBuild patches" ! print "-d, --data datapath\t\tpath containing the config's data files" ! print "-v, --verbose\t\t\tthrows everything including the kitchensink at you" ! print "-f, --fake\t\t\tfakes the building of the ISO" ! sys.exit(0) ! ! def EndWork(self): ! print "All done." ! sys.exit(0) ! ! def OverwriteWithOpts(self, cmd, opts): ! settings = self.__settings ! if opts['base'] != None: ! settings.base['basepath'] = opts['base'] ! if opts['release'] != None: ! settings.base['releasepath'] = opts['releasepath'] ! if opts['source'] != None: ! settings.base['sourcepath'] = opts['source'] ! if opts['patches'] != None: ! settings.base['patchsource'] = opts['patches'] ! if opts['verbose'] != False: ! settings.base['verbose'] = 1 ! if opts['simulate'] != False: ! settings.base['simulate'] = 0 ! if opts['image'] != None: ! settings.base['image'] = opts['image'] ! ! self.__settings = settings ! ! ! def SetSettings(self, settings): ! self.__settings = settings ! ! def SetPatchList(self, patch_list): ! self.__patchList = patch_list ! ! def RunPatches(self, length=None): ! for patch in self.__patchList: ! if not length == None: ! if length == 0: ! self.EndWork() ! length = length - 1 ! self.RunPatch(patch) ! self.EndWork() ! ! def RunPatchesFrom(self, patch_name, length=None): ! runThem = 0 ! for patch in self.__patchList: ! if patch_name != patch and not runThem: ! pass ! else: ! runThem = 1 ! if runThem: ! if not length == None: ! if length == 0: ! self.EndWork() ! length = length - 1 ! self.RunPatch(patch) ! ! self.EndWork() ! ! ! ! ! ! def RunPatch(self, patch_name): ! try: ! if os.path.exists(os.path.join(self.__settings.base['userpatchsource'], patch_name)): ! fp = file(os.path.join(self.__settings.base['userpatchsource'],patch_name,'info.xml'), 'r') ! else: ! fp = file(os.path.join(self.__settings.base['patchsource'],patch_name,'info.xml'), 'r') ! except IOError: ! pass ! else: ! config_parser = configparser.parse_xml(fp) ! ! for setting in config_parser.settings.local.localSettings.items(): ! for a in setting[1].patchSettings.items(): ! if not self.__settings.local.localSettings[setting[0]].patchSettings.has_key(a[0]): ! self.__settings.local.localSettings[setting[0]].patchSettings[a[0]] = a[1]; ! ! # possibly ugly ! self.__settings.base['whoami'] = patch_name ! if os.path.exists(os.path.join(self.__settings.base['userpatchsource'], patch_name)): ! self.__settings.base['whereami'] = os.path.join(self.__settings.base['userpatchsource'],patch_name) ! else: ! self.__settings.base['whereami'] = os.path.join(self.__settings.base['patchsource'],patch_name) ! ! settings_dict = self.__settings.base ! ! if patch_name in self.__settings.local: ! settings_dict.update(self.__settings.local[patch_name]) ! ! includes = { ! 'getsetting' : clientlib.accessors.settings.Settings(settings_dict), ! 'filesystem' : clientlib.accessors.filesystem.FileSystem(settings_dict), ! 'apt' : clientlib.accessors.apt.Apt(settings_dict), ! 'shell' : clientlib.accessors.shell.Shell(settings_dict), ! 'chroot' : clientlib.accessors.chroot.ChRoot(settings_dict), ! 'menu': clientlib.accessors.menu.Menu(settings_dict), ! 'mime': clientlib.accessors.mime.Mime(settings_dict), ! 'morphix': clientlib.accessors.morphix.Morphix(settings_dict), ! 'grub': clientlib.accessors.grub.Grub(settings_dict), ! 'log': clientlib.accessors.log.Log(settings_dict), ! 'fs': clientlib.accessors.fs.FS(settings_dict), ! 'pack': clientlib.accessors.pack.Pack(settings_dict), ! 'patchname': clientlib.accessors.patchname.Patchname(settings_dict) ! } ! if os.path.exists(os.path.join(self.__settings.base['userpatchsource'], patch_name)): ! execfile(os.path.join(self.__settings.base['userpatchsource'],patch_name,'control.py'), {}, includes) ! else: ! execfile(os.path.join(self.__settings.base['patchsource'],patch_name,'control.py'), {}, includes) ! ! manager = BuildSystemManager() ! manager() --- 1,265 ---- ! #!/usr/bin/python ! ! # Changelog ! # 20040907 RKL ! # Adjusted version number to IntelliBuild 0.2.6 for __call__ ! # Changed opt list initialization in __call__ ! # Adjusted xml import in method RunPatch to use configparser.read_xml() routine ! # 20040908 RKL ! # Corrected identation of the exception handling of __call_ ! ! ! import hotshot ! import sys ! import weakref ! import xml.parsers.expat ! import configparser ! import console ! import getopt ! import os ! import exceptions ! ! import clientlib.accessors.settings ! import clientlib.accessors.filesystem ! import clientlib.accessors.chroot ! import clientlib.accessors.apt ! import clientlib.accessors.shell ! import clientlib.accessors.menu ! import clientlib.accessors.mime ! import clientlib.accessors.morphix ! import clientlib.accessors.grub ! import clientlib.accessors.log ! import clientlib.accessors.fs ! import clientlib.accessors.pack ! import clientlib.accessors.patchname ! ! __version__ = 'IntelliBuild 0.3x generation' ! ! class BuildSystemManager: ! def __init__(self): ! self.__profiler = hotshot.Profile('build.prof') ! self.__settings = None ! self.__patchList = None ! ! def __del__(self): ! self.__profiler.close() ! ! def __call__(self): ! try: ! self.__profiler.start() ! cmd = console.Console(weakref.ref(self)(), __version__) ! if len(sys.argv) > 1: ! try: ! optlist, args = getopt.getopt(sys.argv[1:], ! 'cvfb:r:s:p:d:i:l:',['continue','verbose','fake','base=','release=','source=','patches=','data=','image=','length=']) ! except getopt.GetoptError: ! self.Usage() ! sys.exit(2) ! ! configfile = None ! patch = None ! ! opt = {} ! ! opt['base'] = None ! opt['release'] = None ! opt['source'] = None ! opt['patches'] = None ! opt['data'] = None ! opt['verbose'] = False ! opt['continue'] = False ! opt['simulate'] = False ! opt['image'] = None ! opt['length'] = None ! ! for o, a in optlist: ! print opt ! if o in ('-h','--help'): ! self.Usage() ! elif o in ('-l','--length'): ! print "running only " + a + " patches" ! opt['length'] = int(a) ! elif o in ('-v','--verbose'): ! print "verbose enabled" ! opt['verbose'] = True ! elif o in ('-c','--continue'): ! print "continuing from selected patch" ! opt['continue'] = True ! elif o in ('-f','--fake'): ! print "simulate enabled" ! opt['simulate'] = True ! elif o in ('-b','--base'): ! print "Using base " + a ! opt['base'] = a ! elif o in ('-r','--release'): ! print "Using release " + a ! opt['release'] = a ! elif o in ('-s','--source'): ! print "Using source " + a ! opt['source'] = a ! elif o in ('-p','--patches'): ! print "Using patches " + a ! opt['patches'] = a ! elif o in ('-d','--data'): ! print "Using data " + a ! opt['data'] = a ! elif o in ('-i','--image'): ! print "Using image " + a ! opt['image'] = a ! ! # all getopt'ed parameters parsed, everything left is in args ! if len(args) < 1 or len(args) > 2: ! self.Usage() ! configfile = args[0] ! if len(args) == 2: ! patch = args[1] ! cmd.do_load('baseconfig ' + configfile) ! self.OverwriteWithOpts(cmd,opt) ! if patch != None: ! if opt['continue']: ! self.RunPatchesFrom(patch,opt['length']) ! else: ! self.RunPatch(patch) ! self.EndWork() ! else: ! self.RunPatches(opt['length']) ! # uncomment this to force non-interactive mode ! #else: ! #self.Usage() ! cmd.cmdloop() ! ! except Exception, e: ! if str(e) == '0': ! pass ! else: ! print 'Unhandled exception:', str(e) ! ! def Usage(self): ! print "Usage:" ! print sys.argv[0] + " [OPTION] configfile" ! print ! print "Intellibuild lets you build a new KNOPPIX/Morphix iso using patches" ! print ! print "All options will override the defaults of the config file" ! print "-l, --length N\t\t\truns only N patches and then exits" ! print "-c, --continue\t\t\tcontinues from selected patch to be run" ! print "\t\t\t\teg: " + sys.argv[0] + " -c configfile patch" ! print "-b, --base basepath\t\tbase path for building the ISO in" ! print "-i, --image sourceimage\t\timage which you want to unleash iBuild upon" ! print "-r, --release releasepath\trelease path, contains the final output files" ! print "-s, --source sourceimagespath\tsource path, contains the input files" ! print "-p, --patches patchpath\t\tpath containing iBuild patches" ! print "-d, --data datapath\t\tpath containing the config's data files" ! print "-v, --verbose\t\t\tthrows everything including the kitchensink at you" ! print "-f, --fake\t\t\tfakes the building of the ISO" ! sys.exit(0) ! ! def EndWork(self): ! print "All done." ! sys.exit(0) ! ! def OverwriteWithOpts(self, cmd, opts): ! settings = self.__settings ! if opts['base'] != None: ! settings.base['basepath'] = opts['base'] ! if opts['release'] != None: ! settings.base['releasepath'] = opts['releasepath'] ! if opts['source'] != None: ! settings.base['sourcepath'] = opts['source'] ! if opts['patches'] != None: ! settings.base['patchsource'] = opts['patches'] ! if opts['verbose'] != False: ! settings.base['verbose'] = 1 ! if opts['simulate'] != False: ! settings.base['simulate'] = 0 ! if opts['image'] != None: ! settings.base['image'] = opts['image'] ! ! self.__settings = settings ! ! ! def SetSettings(self, settings): ! self.__settings = settings ! ! def SetPatchList(self, patch_list): ! self.__patchList = patch_list ! ! def RunPatches(self, length=None): ! for patch in self.__patchList: ! if not length == None: ! if length == 0: ! self.EndWork() ! length = length - 1 ! self.RunPatch(patch) ! self.EndWork() ! ! def RunPatchesFrom(self, patch_name, length=None): ! runThem = 0 ! for patch in self.__patchList: ! if patch_name != patch and not runThem: ! pass ! else: ! runThem = 1 ! if runThem: ! if not length == None: ! if length == 0: ! self.EndWork() ! length = length - 1 ! self.RunPatch(patch) ! ! self.EndWork() ! ! ! ! ! ! def RunPatch(self, patch_name): ! try: ! if os.path.exists(os.path.join(self.__settings.base['userpatchsource'], patch_name)): ! fp = file(os.path.join(self.__settings.base['userpatchsource'],patch_name,'info.xml'), 'r') ! else: ! fp = file(os.path.join(self.__settings.base['patchsource'],patch_name,'info.xml'), 'r') ! except IOError: ! pass ! else: ! config_parser = configparser.parse_xml(fp) ! ! for setting in config_parser.settings.local.localSettings.items(): ! for a in setting[1].patchSettings.items(): ! if not self.__settings.local.localSettings[setting[0]].patchSettings.has_key(a[0]): ! self.__settings.local.localSettings[setting[0]].patchSettings[a[0]] = a[1]; ! ! # possibly ugly ! self.__settings.base['whoami'] = patch_name ! if os.path.exists(os.path.join(self.__settings.base['userpatchsource'], patch_name)): ! self.__settings.base['whereami'] = os.path.join(self.__settings.base['userpatchsource'],patch_name) ! else: ! self.__settings.base['whereami'] = os.path.join(self.__settings.base['patchsource'],patch_name) ! ! settings_dict = self.__settings.base ! ! if patch_name in self.__settings.local: ! settings_dict.update(self.__settings.local[patch_name]) ! ! includes = { ! 'getsetting' : clientlib.accessors.settings.Settings(settings_dict), ! 'filesystem' : clientlib.accessors.filesystem.FileSystem(settings_dict), ! 'apt' : clientlib.accessors.apt.Apt(settings_dict), ! 'shell' : clientlib.accessors.shell.Shell(settings_dict), ! 'chroot' : clientlib.accessors.chroot.ChRoot(settings_dict), ! 'menu': clientlib.accessors.menu.Menu(settings_dict), ! 'mime': clientlib.accessors.mime.Mime(settings_dict), ! 'morphix': clientlib.accessors.morphix.Morphix(settings_dict), ! 'grub': clientlib.accessors.grub.Grub(settings_dict), ! 'log': clientlib.accessors.log.Log(settings_dict), ! 'fs': clientlib.accessors.fs.FS(settings_dict), ! 'pack': clientlib.accessors.pack.Pack(settings_dict), ! 'patchname': clientlib.accessors.patchname.Patchname(settings_dict) ! } ! if os.path.exists(os.path.join(self.__settings.base['userpatchsource'], patch_name)): ! execfile(os.path.join(self.__settings.base['userpatchsource'],patch_name,'control.py'), {}, includes) ! else: ! execfile(os.path.join(self.__settings.base['patchsource'],patch_name,'control.py'), {}, includes) ! ! manager = BuildSystemManager() ! manager() |