[cvs] / gkb / gkb.py  

cvs: gkb/gkb.py

Diff for /gkb/gkb.py between version 1.19 and 1.26

version 1.19, Sun Aug 15 03:56:40 2004 UTC version 1.26, Sun Aug 15 05:52:26 2004 UTC
Line 19 
Line 19 
 #  #
 # Ported from PHP version Copyright (c) Tobias McNulty 2000-2003  # Ported from PHP version Copyright (c) Tobias McNulty 2000-2003
   
 import sys, os, ConfigParser  import sys, os, ConfigParser, popen2
 import xml.parsers.expat  import xml.parsers.expat
 import md5  import md5, string
 from ftplib import FTP  from ftplib import FTP
 from commands import getoutput  from commands import getoutput
 from shutil import copy, move  from shutil import copy, move
Line 30 
Line 30 
 from ClientForm import ParseResponse  from ClientForm import ParseResponse
   
 debug=0  debug=0
 clean=0  clean=1
 dont_build=1  dont_build=0
 verbose=1  verbose=1
   
 # parse host-specific configuration information from gkb.cfg  # parse host-specific configuration information from gkb.cfg
Line 91 
Line 91 
         if verbose==1:          if verbose==1:
                 print myoutput                  print myoutput
   
   def clean(text):
           """clean a string of passwords, etc. to make it suitable for logging"""
           result = string.replace(text,passwd,"XXXXXXXX")
           return result
   
 def linkpipes(input, output):  def linkpipes(input, output):
           """link two pipes together, writing all the data from input to output"""
         data = input.read(2048)          data = input.read(2048)
         while data:          while data:
                 output.write(data)                  output.write(data)
                 data = input.read(2048)                  data = input.read(2048)
   
 def runcmd(cmd, outfile=None, append=False, infile=None):  def runcmd(cmd, kinfo=None, outfile=None, append=False, infile=None):
         log("running " + cmd)          """run the specified command, with the optional input and output documents"""
           log("  \_ running " + clean(cmd), kinfo)
   
         p4obj = Popen4(cmd)          p4obj = popen2.Popen4(cmd)
   
         pin = p4obj.tochild          pin = p4obj.tochild
         pouterr = p4obj.fromchild          pouterr = p4obj.fromchild
Line 125 
Line 132 
         if err == None:          if err == None:
                 err = 0                  err = 0
   
         log("result code: %i" %  err)          log("    \_ exit code: %i" %  err, kinfo)
   
         return err          return err
   
 def log(text,kinfo=0):  def log(text,kinfo=0):
Line 138 
Line 146 
         """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)
         if not os.path.isdir(mydir):          if not os.path.isdir(mydir):
                 log("%s doesn't exist, creating" % mydir,kinfo)                  log("  \_ %s doesn't exist, creating" % mydir,kinfo)
                 os.mkdir(mydir)                  os.mkdir(mydir)
         return mydir          return mydir
   
Line 169 
Line 177 
         version=krn_localversion(kinfo)          version=krn_localversion(kinfo)
         log("querying distribution site manager with command '%s' (kernel version=%s)" % (command,version),kinfo)          log("querying distribution site manager with command '%s' (kernel version=%s)" % (command,version),kinfo)
         result=getoutput("wget --quiet --output-document=- \"%s/manager.php?cmd=%s&host=%s&pass=%s&build=%s&version=%s\"" % (msite,command,host,passwd,kinfo["name"],version))          result=getoutput("wget --quiet --output-document=- \"%s/manager.php?cmd=%s&host=%s&pass=%s&build=%s&version=%s\"" % (msite,command,host,passwd,kinfo["name"],version))
         log("result: '"+result+"'",kinfo)          log("  \_ result: '"+result+"'",kinfo)
         return result=="1"          return result=="1"
   
 def krn_localversion(kinfo):  def krn_localversion(kinfo):
Line 186 
Line 194 
         verifydir("%s/%s" % (patchdir, kinfo["name"]),kinfo)          verifydir("%s/%s" % (patchdir, kinfo["name"]),kinfo)
   
         # sync the source to make sure we are up to date ...          # sync the source to make sure we are up to date ...
         log("calling gkb_getsource",kinfo)          log("fetching latest source",kinfo)
         gkb_getsource(kinfo)          gkb_getsource(kinfo)
   
         # go into the work directory          # go into the work directory
Line 194 
Line 202 
   
         # archive the clean source for later uploading          # archive the clean source for later uploading
         log("archiving source to " + kinfo["mastertree"] + ".tar.bz2", kinfo)          log("archiving source to " + kinfo["mastertree"] + ".tar.bz2", kinfo)
         runcmd("tar cjf " + kinfo["mastertree"] + ".tar.bz2 " + kinfo["mastertree"])          runcmd("tar cjf " + kinfo["mastertree"] + ".tar.bz2 " + kinfo["mastertree"], kinfo)
   
         # now we'll go into the tree's work dir          # now we'll go into the tree's work dir
         chdir(kinfo["workdir"],kinfo)          chdir(kinfo["workdir"],kinfo)
Line 269 
Line 277 
   
                         log("compressing binary archive "+archive_name,kinfo)                          log("compressing binary archive "+archive_name,kinfo)
   
                         if runcmd("tar cjf "+archive_name+" "+os.path.basename(mybindir)):                          if runcmd("tar cjf "+archive_name+" "+os.path.basename(mybindir), kinfo):
                                 raise BuildError("failed to `tar cjf %s`" %  archive_name)                                  raise BuildError("failed to `tar cjf %s`" %  archive_name)
   
                         runcmd("rm -rf %s" % mybindir)                          runcmd("rm -rf %s" % mybindir, kinfo)
   
                         krn_upload(archive_name,"kernel",myversion,kinfo)                          krn_upload(archive_name,"kernel",myversion,kinfo)
                         krn_querymgr("checkin",kinfo)                          krn_querymgr("checkin",kinfo)
   
                         if (os.fork() == 0):                          #if os.fork() == 0:
                                 #in child                                  #in child
                                 krn_upload(workdir + "/" + kinfo["mastertree"] + ".tar.bz2", "source", myversion, kinfo)                                  krn_upload(workdir + "/" + kinfo["mastertree"] + ".tar.bz2", "source", myversion, kinfo)
                                   #sys.exit(0)
   
                 except BuildError, e:                  except BuildError, e:
                         log(e.message, kinfo)                          log(e.message, kinfo)
Line 315 
Line 324 
   
         syncline=args+" "+kinfo["workdir"]          syncline=args+" "+kinfo["workdir"]
   
         log("running rsync : %s %s" % (syncoptions, syncline),kinfo)          #logging now in runcmd
         if runcmd("%s %s" % (syncoptions, syncline), "%s/%s/rsync.log" % (logdir, kinfo["name"])):          #log("running rsync : %s %s" % (syncoptions, syncline),kinfo)
           if runcmd("%s %s" % (syncoptions, syncline), kinfo, "%s/%s/rsync.log" % (logdir, kinfo["name"])):
                 raise BuildError("sync failed, tried %s.  See log for details." %  syncline)                  raise BuildError("sync failed, tried %s.  See log for details." %  syncline)
   
 def get_wget(kinfo):  def get_wget(kinfo):
Line 327 
Line 337 
         log("fetching source archive " % args,kinfo)          log("fetching source archive " % args,kinfo)
         mysourcefile="%s/%s.tar.bz2" % (kinfo["workdir"],kinfo["name"])          mysourcefile="%s/%s.tar.bz2" % (kinfo["workdir"],kinfo["name"])
   
         if runcmd("wget --quiet --output-document=%s %s/configs/%s" % (myconfigfile,msite,kinfo["name"])):          if runcmd("wget --quiet --output-document=%s %s/configs/%s" % (myconfigfile,msite,kinfo["name"]), kinfo):
                 raise BuildError("unable to download configfile, aborting.")                  raise BuildError("unable to download configfile, aborting.")
   
         log("decompressing source file",kinfo)          log("decompressing source file",kinfo)
         if runcmd("tar xjf " % (myconfigfile,msite,kinfo["name"])):          if runcmd("tar xjf " % (myconfigfile,msite,kinfo["name"]), kinfo):
                 raise BuildError("unable to decompress source file, aborting.")                  raise BuildError("unable to decompress source file, aborting.")
   
 def get_vanilla(kinfo):  def get_vanilla(kinfo):
Line 340 
Line 350 
         log("fetching source archive %s" % args)          log("fetching source archive %s" % args)
         mysourcefile="%s/%s.tar.bz2" % (workdir,kinfo["name"])          mysourcefile="%s/%s.tar.bz2" % (workdir,kinfo["name"])
   
         if runcmd("wget -c --output-document=%s %s" % (mysourcefile,args)):          if runcmd("wget -c --output-document=%s %s" % (mysourcefile,args), kinfo):
                 raise BuildError("unable to download source file %s, aborting." %  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 361 
Line 371 
         fnames=split(data)          fnames=split(data)
         name=fnames[0]          name=fnames[0]
   
         runcmd("rm -rf %s" % kinfo["workdir"])          runcmd("rm -rf %s" % kinfo["workdir"], kinfo)
         move(work + "/" + dirname, kinfo["workdir"])          move(work + "/" + dirname, kinfo["workdir"])
   
         #restore the previous working ectory          #restore the previous working ectory
Line 379 
Line 389 
                         mypatchfile="%s/%s/%s.patch" % (patchdir,kinfo["name"],patch)                          mypatchfile="%s/%s/%s.patch" % (patchdir,kinfo["name"],patch)
   
                         # download pathfile or bail                          # download pathfile or bail
                         if runcmd("wget --quiet --output-document=%s %s/patches/%s/%s" % (mypatchfile,msite,kinfo["name"],patch)):                          if runcmd("wget --quiet --output-document=%s %s/patches/%s/%s" % (mypatchfile,msite,kinfo["name"],patch), kinfo):
                                 raise BuildError("unable to download patchfile %s, aborting." % 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
Line 390 
Line 400 
                         #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 runcmd("patch -p1", "%s/%s/patch-%s.log" % (logdir,kinfo["name"],patch), False, mypatchfile):                          if runcmd("patch -p1", kinfo, "%s/%s/patch-%s.log" % (logdir,kinfo["name"],patch), False, mypatchfile):
                                 raise BuildError("patchfile %s failed, aborting.  See patch log for details." % 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 402 
Line 412 
                 log("fetching config file",kinfo)                  log("fetching config file",kinfo)
                 myconfigfile="%s/%s.config" % (configdir,kinfo["name"])                  myconfigfile="%s/%s.config" % (configdir,kinfo["name"])
   
                 if runcmd("wget --quiet --output-document=%s %s/configs/%s" % (myconfigfile,msite,kinfo["name"])):                  if runcmd("wget --quiet --output-document=%s %s/configs/%s" % (myconfigfile,msite,kinfo["name"]), kinfo):
                         raise BuildError("unable to download configfile, aborting.")                          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)
Line 412 
Line 422 
 def gkb_runmake(command, kinfo, premake, makeopts):  def gkb_runmake(command, kinfo, premake, makeopts):
         """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 runcmd("%s make %s %s" % (premake, makeopts, command), "%s/%s/make-%s.log" % (logdir, kinfo["name"], command)):          if runcmd("%s make %s %s" % (premake, makeopts, command), kinfo, "%s/%s/make-%s.log" % (logdir, kinfo["name"], command)):
                 raise BuildError("unable to run make %s, aborting." % command)                  raise BuildError("unable to run make %s, aborting." % command)
   
 def gkb_parsexml(name):  def gkb_parsexml(name):
Line 472 
Line 482 
         today=getoutput("date +%D")          today=getoutput("date +%D")
         buildtime=getoutput("date +'%R:%S %Z'")          buildtime=getoutput("date +'%R:%S %Z'")
   
         print "GKB started %s %s" % (today,buildtime)          print "GNU Kernel Builder started %s %s" % (today,buildtime)
   
         # verify the existence important directories, and create if necessary          # verify the existence important directories, and create if necessary
         verifydir(logdir)          verifydir(logdir)
Line 482 
Line 492 
         verifydir("%s/work" % buildroot) # build dir, make sure it exists          verifydir("%s/work" % buildroot) # build dir, make sure it exists
   
         # download the build jobs from the master site          # download the build jobs from the master site
           log("fetching build jobs from master site")
         if runcmd("wget --quiet --output-document=gkb.xml \"%s/manager.php?cmd=getjobs&host=%s&pass=%s\"" % (msite,host,passwd)):          if runcmd("wget --quiet --output-document=gkb.xml \"%s/manager.php?cmd=getjobs&host=%s&pass=%s\"" % (msite,host,passwd)):
                 raise FatalError, "Unable to download build config from master site %s, aborting." % msite                  raise FatalError, "Unable to download build jobs from master site %s, aborting." % msite
   
         # sets up 'mastertrees' and 'builds' dicts          # sets up 'mastertrees' and 'builds' dicts
         gkb_parsexml('gkb.xml')          gkb_parsexml('gkb.xml')
   
         runcmd("sleep 10")  
   
         for bdict in builds.values():          for bdict in builds.values():
                 myworkdir="%s/%s" % (workdir,bdict["mastertree"])                  myworkdir="%s/%s" % (workdir,bdict["mastertree"])
                 bdict["workdir"]=myworkdir                  bdict["workdir"]=myworkdir


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

Tobias McNulty

Powered by ViewCVS 1.0-dev
(Powered by ViewCVS)

ViewCVS and CVS Help