[cvs] / gkb / gkb.py  

cvs: gkb/gkb.py

Diff for /gkb/gkb.py between version 1.22 and 1.35

version 1.22, Sun Aug 15 04:23:51 2004 UTC version 1.35, Sat Dec 18 19:28:48 2004 UTC
Line 29 
Line 29 
 from urllib2 import urlopen  from urllib2 import urlopen
 from ClientForm import ParseResponse  from ClientForm import ParseResponse
   
   
 debug=0  debug=0
 clean=1  clean=1
 dont_build=0  dont_build=0
Line 91 
Line 92 
         if verbose==1:          if verbose==1:
                 print myoutput                  print myoutput
   
 def clean(text):  def cleantext(text):
         """clean a string of passwords, etc. to make it suitable for logging"""          """clean a string of passwords, etc. to make it suitable for logging"""
         result = string.replace(text,passwd,"XXXXXXXX")          result = string.replace(text,passwd,"XXXXXXXX")
         return result          return result
Line 105 
Line 106 
   
 def runcmd(cmd, kinfo=None, outfile=None, append=False, infile=None):  def runcmd(cmd, kinfo=None, outfile=None, append=False, infile=None):
         """run the specified command, with the optional input and output documents"""          """run the specified command, with the optional input and output documents"""
         log("running " + clean(cmd), kinfo)          log("  \_ running " + cleantext(cmd), kinfo)
   
         p4obj = popen2.Popen4(cmd)          p4obj = popen2.Popen4(cmd)
   
Line 132 
Line 133 
         if err == None:          if err == None:
                 err = 0                  err = 0
   
         log("result code: %i" %  err, kinfo)          log("    \_ exit code: %i" %  err, kinfo)
   
         return err          return err
   
Line 146 
Line 147 
         """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 172 
Line 173 
         digest = md.hexdigest()          digest = md.hexdigest()
         return digest          return digest
   
 def krn_querymgr(command,kinfo):  def krn_querymgr(command,kinfo,extra=""):
         """queries the build host manager with a variety of commands, such as checkout, checkin, etc."""          """queries the build host manager with a variety of commands, such as checkout, checkin, etc."""
         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%s\"" % (msite,command,host,passwd,kinfo["name"],version,extra))
         log("result: '"+result+"'",kinfo)          log("  \_ result: '"+result+"'",kinfo)
         return result=="1"          return result=="1"
   
   def krn_modulesenabled(kinfo):
           """Checks the source to see if modules are enabled"""
           output=getoutput("""awk -F '=' '/^CONFIG_MODULES/{v=$2} END { printf("%s\\n", v) }' """ + kinfo["workdir"] + """/.config | sed "s/ //g" """)
           if (output=='y'):
                   result=1
           else:
                   result=0
   
           return result
   
 def krn_localversion(kinfo):  def krn_localversion(kinfo):
         """Checks the version of the local source tree specified in kinfo"""          """Checks the version of the local source tree specified in kinfo"""
         version=getoutput("""awk -F '=' '/^VERSION/{v=$2} /^PATCHLEVEL/{p=$2} /^SUBLEVEL/{s=$2} /^EXTRAVERSION/{e=$2} END { printf("%s.%s.%s%s\\n", v, p, s, e) }' """ + kinfo["workdir"] + """/Makefile | sed "s/ //g" """)          version=getoutput("""awk -F '=' '/^VERSION/{v=$2} /^PATCHLEVEL/{p=$2} /^SUBLEVEL/{s=$2} /^EXTRAVERSION/{e=$2} END { printf("%s.%s.%s%s\\n", v, p, s, e) }' """ + kinfo["workdir"] + """/Makefile | sed "s/ //g" """)
Line 194 
Line 205 
         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
         chdir(workdir, kinfo)          #chdir(workdir, kinfo)
   
         # 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"], kinfo)          #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 255 
Line 266 
                         if verifyfile(kbinloc,kinfo):                          if verifyfile(kbinloc,kinfo):
                                 # the binary exists, so let's cp it to bin...                                  # the binary exists, so let's cp it to bin...
                                 copy(kbinloc,mybindir+"/boot/"+kinfo["binname"]+"-"+myversion)                                  copy(kbinloc,mybindir+"/boot/"+kinfo["binname"]+"-"+myversion)
                                   copy("%s/System.map" % kinfo["workdir"],mybindir+"/boot/System.map-"+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
                                 raise BuildError("%s is not present, assuming build failure and exiting.  See log for details." % kbinloc)                                  raise BuildError("%s is not present, assuming build failure and exiting.  See log for details." % kbinloc)
   
                           if krn_modulesenabled(kinfo):
                         # 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:
                                 gkb_runmake("modules",kinfo, premake, makeopts)                                  gkb_runmake("modules",kinfo, premake, makeopts)
Line 266 
Line 279 
                         # **Note** : we prepend the INSTALL_MOD_PATH to the makeopts inline instead                          # **Note** : we prepend the INSTALL_MOD_PATH to the makeopts inline instead
                         # of globally as it is only needed in this target                          # of globally as it is only needed in this target
                         gkb_runmake("modules_install", kinfo, premake, "INSTALL_MOD_PATH=%s %s" % (mybindir, makeopts))                          gkb_runmake("modules_install", kinfo, premake, "INSTALL_MOD_PATH=%s %s" % (mybindir, makeopts))
                           else:
                                   log("skipping make modules (disabled in .config)",kinfo)
   
                         # compress and upload source archive                          # compress and upload source archive
                         chdir(kinfo["workdir"]+"/..",kinfo)                          chdir(kinfo["workdir"]+"/..",kinfo)
Line 285 
Line 300 
                         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
                                   try:
                                           # sync the source to make sure we are up to date ...
                                           log("re-fetching latest source",kinfo)
                                           gkb_getsource(kinfo)
   
                                           # go into the work directory
                                           chdir(workdir, kinfo)
   
                                           # archive the clean source for later uploading
                                           log("archiving source to " + kinfo["mastertree"] + ".tar.bz2", kinfo)
                                           runcmd("tar cjf " + kinfo["mastertree"] + ".tar.bz2 " + kinfo["mastertree"], kinfo)
   
                                 krn_upload(workdir + "/" + kinfo["mastertree"] + ".tar.bz2", "source", myversion, kinfo)                                  krn_upload(workdir + "/" + kinfo["mastertree"] + ".tar.bz2", "source", myversion, kinfo)
                                   finally:
                                           sys.exit(0)
   
                 except BuildError, e:                  except BuildError, e:
                         log(e.message, kinfo)                          log(e.message, kinfo)
                         krn_querymgr("checkin",kinfo)                          krn_querymgr("checkin",kinfo,"&failed=%s" % krn_localversion(kinfo))
                 except:                  except:
                         krn_querymgr("checkin",kinfo)                          krn_querymgr("checkin",kinfo,"&failed=%s" % krn_localversion(kinfo))
                         raise                          raise
   
 def krn_build26(kinfo):  def krn_build26(kinfo):
Line 323 
Line 352 
   
         syncline=args+" "+kinfo["workdir"]          syncline=args+" "+kinfo["workdir"]
   
         log("running rsync : %s %s" % (syncoptions, syncline),kinfo)          #logging now in runcmd
           #log("running rsync : %s %s" % (syncoptions, syncline),kinfo)
         if runcmd("%s %s" % (syncoptions, syncline), kinfo, "%s/%s/rsync.log" % (logdir, kinfo["name"])):          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)
   
Line 406 
Line 436 
 def krn_config(kinfo):  def krn_config(kinfo):
         """method to fetch and place config file for running kernel build"""          """method to fetch and place config file for running kernel build"""
   
         if kinfo["config"]==1:          if kinfo["configpath"]:
                   log("using config file %s" % kinfo["configpath"],kinfo)
                   myconfigfile="%s/%s" % (kinfo["workdir"],kinfo["configpath"])
   
                   log("copying config file to %s/.config" % kinfo["workdir"],kinfo)
                   copy(verifyfile(myconfigfile,kinfo),"%s/.config" % kinfo["workdir"])
   
           elif kinfo["config"]==1:
                 log("fetching config file",kinfo)                  log("fetching config file",kinfo)
                 myconfigfile="%s/%s.config" % (configdir,kinfo["name"])                  myconfigfile="%s/%s.config" % (configdir,kinfo["name"])
   
Line 420 
Line 457 
 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)
   
           # check to see if we need to run a simple make
           # for some reason 2.2 kernels can't handle premake, makeopts, etc.
           localversion = krn_localversion(kinfo)
   
           if (string.find(localversion,"2.2") == 0):
                   if runcmd("%s make %s" % (premake,command), kinfo, "%s/%s/make-%s.log" % (logdir, kinfo["name"], command)):
                           raise BuildError("unable to run make %s, aborting." % command)
           else:
         if runcmd("%s make %s %s" % (premake, makeopts, command), kinfo, "%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)
   
Line 467 
Line 513 
                 print response.info()  # headers                  print response.info()  # headers
                 print response.read()  # body                  print response.read()  # body
   
         log("response: " + response.read(),kinfo)          log("  \_ response: " + response.read(),kinfo)
   
         response.close()          response.close()
   
Line 480 
Line 526 
         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 490 
Line 536 
         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')


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

Tobias McNulty

Powered by ViewCVS 1.0-dev
(Powered by ViewCVS)

ViewCVS and CVS Help