[cvs] / gkb / gkb.py  

cvs: gkb/gkb.py

Diff for /gkb/gkb.py between version 1.6 and 1.7

version 1.6, Thu Aug 12 15:52:24 2004 UTC version 1.7, Thu Aug 12 16:26:40 2004 UTC
Line 62 
Line 62 
 mastertrees={}  mastertrees={}
 builds={}  builds={}
   
   class Error(Exception):
           """Base class for exceptions in this module."""
           pass
   
   class BuildError(Error):
           """Exception raised for build-level errors.
   
           Attributes:
                   message -- explanation of the error
           """
   
           def __init__(self, message):
                   self.message = message
   
   class FatalError(Error):
           """Exception for fatal errors that prevent program continuation.
   
           Attributes:
                   message -- explanation of why the specific transition is not allowed
           """
   
           def __init__(self, previous, next, message):
                   self.message = message
   
 def printverbose(myoutput):  def printverbose(myoutput):
         """Supporting method to output info to stdout if verbosity level is set"""          """Supporting method to output info to stdout if verbosity level is set"""
         if verbose==1:          if verbose==1:
Line 73 
Line 97 
         else:          else:
                 printverbose("gkb : " + text)                  printverbose("gkb : " + text)
   
 def deathbyerror(mymsg):  
         """Supporting method to print error to stdout and return system error -1 on exit"""  
         print mymsg  
         sys.exit(-1)  
   
 def verifydir(mydir,kinfo=0):  def verifydir(mydir,kinfo=0):
         """Supporting method to verify a given  exists, if not it will create it"""          """Supporting method to verify a given  exists, if not it will create it"""
         log("verifying directory " + mydir,kinfo)          log("verifying directory " + mydir,kinfo)
Line 94 
Line 113 
 def verifyfile(myfile,kinfo):  def verifyfile(myfile,kinfo):
         """Supporting method to verify file exists, if not it will exit with error"""          """Supporting method to verify file exists, if not it will exit with error"""
         if not os.path.isfile(myfile):          if not os.path.isfile(myfile):
                 deathbyerror("%s : cannot find file expected at %s, exiting" % (kinfo["name"],myfile))                  raise BuildError("cannot find file expected at %s, exiting" % myfile)
         return myfile          return myfile
   
 def md5sum(fileobj):  def md5sum(fileobj):
Line 156 
Line 175 
         """build a kernel, version 2.4.x"""          """build a kernel, version 2.4.x"""
   
         if krn_querymgr("checkout",kinfo):          if krn_querymgr("checkout",kinfo):
                   try:
                 myversion=krn_localversion(kinfo)                  myversion=krn_localversion(kinfo)
   
                 # fetch and cp the config file to work/.config                  # fetch and cp the config file to work/.config
Line 185 
Line 205 
                         copy(kbinloc,mybindir+"/boot/"+kinfo["binname"]+"-"+myversion)                          copy(kbinloc,mybindir+"/boot/"+kinfo["binname"]+"-"+myversion)
                 else:                  else:
                         # the binary is not there, inform user and bail out with error                          # the binary is not there, inform user and bail out with error
                         deathbyerror("%s : %s is not present, assuming build failure and exiting.  See log for details." % (kinfo["name"], kbinloc))                                  raise BuildError("%s is not present, assuming build failure and exiting.  See log for details." % kbinloc)
   
                 # now that we know he binary built, let's continue                  # now that we know he binary built, let's continue
                 if dont_build==0:                  if dont_build==0:
Line 201 
Line 221 
                 log("compressing binary archive "+archive_name,kinfo)                  log("compressing binary archive "+archive_name,kinfo)
   
                 if os.system("tar cjf "+archive_name+" "+os.path.basename(mybindir)):                  if os.system("tar cjf "+archive_name+" "+os.path.basename(mybindir)):
                         deathbyerror("%s : failed to `tar cjf %s`" % (kinfo["name"], archive_name))                                  raise BuildError("failed to `tar cjf %s`" %  archive_name)
   
                 os.system("rm -rf %s" % mybindir)                  os.system("rm -rf %s" % mybindir)
   
                 krn_upload(archive_name,myversion,kinfo)                  krn_upload(archive_name,myversion,kinfo)
                   except BuildError, e:
                           log(e.message, kinfo)
                   finally:
                 krn_querymgr("checkin",kinfo)                  krn_querymgr("checkin",kinfo)
   
 def krn_build26(kinfo):  def krn_build26(kinfo):
Line 238 
Line 260 
   
         log("running rsync : %s %s" % (syncoptions, syncline),kinfo)          log("running rsync : %s %s" % (syncoptions, syncline),kinfo)
         if os.system("%s %s > %s/%s/rsync.log 2>&1" % (syncoptions, syncline, logdir, kinfo["name"])):          if os.system("%s %s > %s/%s/rsync.log 2>&1" % (syncoptions, syncline, logdir, kinfo["name"])):
                 deathbyerror("%s : sync failed, tried %s.  See log for details." % (kinfo["name"], syncline) )                  raise BuildError("sync failed, tried %s.  See log for details." %  syncline)
   
         # Gerk comment:  
         # This above might cause problems ... it (I think) relies on anything coming from stderr to tell  
         # if it has in fact died... we should test this out.  If this is the case me might need to make  
         # a stub of some sorts to handle the build/error return process...  
   
   
 def get_wget(kinfo):  def get_wget(kinfo):
         #needs work          #needs work
Line 255 
Line 271 
         mysourcefile="%s/%s.tar.bz2" % (kinfo["workdir"],kinfo["name"])          mysourcefile="%s/%s.tar.bz2" % (kinfo["workdir"],kinfo["name"])
   
         if os.system("wget --quiet --output-document=%s %s/configs/%s" % (myconfigfile,msite,kinfo["name"])):          if os.system("wget --quiet --output-document=%s %s/configs/%s" % (myconfigfile,msite,kinfo["name"])):
                 deathbyerror("%s : unable to download configfile, aborting." % (kinfo["name"]))                  raise BuildError("unable to download configfile, aborting.")
   
         log("decompressing source file",kinfo)          log("decompressing source file",kinfo)
         if os.system("tar xjf " % (myconfigfile,msite,kinfo["name"])):          if os.system("tar xjf " % (myconfigfile,msite,kinfo["name"])):
                 deathbyerror("%s : unable to decompress source file, aborting." % (kinfo["name"]))                  raise BuildError("unable to decompress source file, aborting.")
   
 def get_vanilla(kinfo):  def get_vanilla(kinfo):
         args=mastertrees[kinfo["mastertree"]]["args"]          args=mastertrees[kinfo["mastertree"]]["args"]
Line 268 
Line 284 
         mysourcefile="%s/%s.tar.bz2" % (workdir,kinfo["name"])          mysourcefile="%s/%s.tar.bz2" % (workdir,kinfo["name"])
   
         if os.system("wget -c --output-document=%s %s" % (mysourcefile,args)):          if os.system("wget -c --output-document=%s %s" % (mysourcefile,args)):
                 deathbyerror("%s : unable to download source file %s, aborting." % (kinfo["name"], args))                  raise BuildError("unable to download source file %s, aborting." %  args)
   
         log("decompressing source file %s" % mysourcefile,kinfo)          log("decompressing source file %s" % mysourcefile,kinfo)
   
Line 283 
Line 299 
                 trash=pfd.read(4096)                  trash=pfd.read(4096)
   
         if pfd.close():          if pfd.close():
                 deathbyerror("%s : unable to decompress source file, aborting." % (kinfo["name"]))                  raise BuildError("unable to decompress source file, aborting.")
   
         fnames=split(data)          fnames=split(data)
         name=fnames[0]          name=fnames[0]
Line 307 
Line 323 
   
                         # download pathfile or bail                          # download pathfile or bail
                         if os.system("wget --quiet --output-document=%s %s/patches/%s/%s" % (mypatchfile,msite,kinfo["name"],patch)):                          if os.system("wget --quiet --output-document=%s %s/patches/%s/%s" % (mypatchfile,msite,kinfo["name"],patch)):
                                 deathbyerror("%s : unable to download patchfile %s, aborting." % (kinfo["name"],patch))                                  raise BuildError("unable to download patchfile %s, aborting." % patch)
   
                         # we have a patch file, apply it or bail                          # we have a patch file, apply it or bail
                         log("perfoming patch with %s" % patch,kinfo)                          log("perfoming patch with %s" % patch,kinfo)
Line 315 
Line 331 
                         log("using %s from %s" % (patchcommand,kinfo["workdir"]),kinfo)                          log("using %s from %s" % (patchcommand,kinfo["workdir"]),kinfo)
                         chdir(kinfo["workdir"],kinfo)                          chdir(kinfo["workdir"],kinfo)
                         if os.system(patchcommand):                          if os.system(patchcommand):
                                 deathbyerror("%s : patchfile %s failed, aborting.  See patch log for details." % (kinfo["name"],patch))                                  raise BuildError("patchfile %s failed, aborting.  See patch log for details." % patch)
         else:          else:
                 log("no patchfiles, continuing",kinfo)                  log("no patchfiles, continuing",kinfo)
   
Line 327 
Line 343 
                 myconfigfile="%s/%s.config" % (configdir,kinfo["name"])                  myconfigfile="%s/%s.config" % (configdir,kinfo["name"])
   
                 if os.system("wget --quiet --output-document=%s %s/configs/%s" % (myconfigfile,msite,kinfo["name"])):                  if os.system("wget --quiet --output-document=%s %s/configs/%s" % (myconfigfile,msite,kinfo["name"])):
                         deathbyerror("%s : unable to download configfile, aborting." % (kinfo["name"]))                          raise BuildError("unable to download configfile, aborting.")
   
                 log("copying config file to %s/.config" % kinfo["workdir"],kinfo)                  log("copying config file to %s/.config" % kinfo["workdir"],kinfo)
                 copy(verifyfile(myconfigfile,kinfo),"%s/.config" % kinfo["workdir"])                  copy(verifyfile(myconfigfile,kinfo),"%s/.config" % kinfo["workdir"])
Line 337 
Line 353 
         """Supporting method for build() ... a stub to run a make target and auto log it, given make target (command) and name (kernel name)"""          """Supporting method for build() ... a stub to run a make target and auto log it, given make target (command) and name (kernel name)"""
         log("running make %s" % command,kinfo)          log("running make %s" % command,kinfo)
         if os.system("%s make %s %s > %s/%s/make-%s.log 2>&1" % (premake, makeopts, command, logdir, kinfo["name"], command)):          if os.system("%s make %s %s > %s/%s/make-%s.log 2>&1" % (premake, makeopts, command, logdir, kinfo["name"], command)):
                 deathbyerror("%s : unable to run make %s, aborting." % (kinfo["name"],command))                  raise BuildError("unable to run make %s, aborting." % command)
   
 def gkb_parsexml(name):  def gkb_parsexml(name):
         """parse the xml build file into mastertrees and builds"""          """parse the xml build file into mastertrees and builds"""


Generate output suitable for use with a patch program
Legend:
Removed from v.1.6  
changed lines
  Added in v.1.7

Tobias McNulty

Powered by ViewCVS 1.0-dev
(Powered by ViewCVS)

ViewCVS and CVS Help