def changesInSVN(workingDir, log): changesDict = {} os.chdir(workingDir) for module in reposModules: log.write("[tbox] Checking for updates [%s] [%s]\n" % (workingDir, module)) moduleDir = os.path.join(workingDir, module) changesDict[module] = False print "[%s] [%s] [%s]" % (workingDir, module, moduleDir) os.chdir(moduleDir) outputList = hardhatutil.executeCommandReturnOutputRetry( [svnProgram, "up"]) hardhatutil.dumpOutputList(outputList, log) if NeedsUpdate(outputList): changesDict[module] = True log.write("%s needs updating\n" % module) else: log.write("%s unchanged\n" % module) log.write(separator) log.write("Done with SVN\n") return changesDict
def changesInSVN(moduleDir, workingDir, log): changesAtAll = False for module in reposModules: log.write("[tbox] Checking for updates [%s] [%s]\n" % (workingDir, module)) moduleDir = os.path.join(workingDir, module) print "[%s] [%s] [%s]" % (workingDir, module, moduleDir) os.chdir(moduleDir) outputList = hardhatutil.executeCommandReturnOutputRetry( [svnProgram, "up"]) hardhatutil.dumpOutputList(outputList, log) if NeedsUpdate(outputList): changesAtAll = True print "" + module + " needs updating" else: # print "NO, unchanged" log.write("Module unchanged" + "\n") log.write(separator) log.write("Done with SVN\n") return changesAtAll
def changesInSVN(workingDir, log): changesDict = {} os.chdir(workingDir) for module in reposModules: log.write("[tbox] Checking for updates [%s] [%s]\n" % (workingDir, module)) moduleDir = os.path.join(workingDir, module) changesDict[module] = False print "[%s] [%s] [%s]" % (workingDir, module, moduleDir) os.chdir(moduleDir) outputList = hardhatutil.executeCommandReturnOutputRetry([svnProgram, "up"]) hardhatutil.dumpOutputList(outputList, log) if NeedsUpdate(outputList): changesDict[module] = True log.write("%s needs updating\n" % module) else: log.write("%s unchanged\n" % module) log.write(separator) log.write("Done with SVN\n") return changesDict
def changesInSVN(moduleDir, workingDir, log): changesAtAll = False for module in reposModules: log.write("[tbox] Checking for updates [%s] [%s]\n" % (workingDir, module)) moduleDir = os.path.join(workingDir, module) print "[%s] [%s] [%s]" % (workingDir, module, moduleDir) os.chdir(moduleDir) outputList = hardhatutil.executeCommandReturnOutputRetry([svnProgram, "up"]) hardhatutil.dumpOutputList(outputList, log) if NeedsUpdate(outputList): changesAtAll = True print "" + module + " needs updating" else: # print "NO, unchanged" log.write("Module unchanged" + "\n") log.write(separator) log.write("Done with SVN\n") return changesAtAll
def main(): curDir = os.path.abspath(os.getcwd()) path = os.environ.get('PATH', os.environ.get('path')) svnProgram = hardhatutil.findInPath(path, "svn") if os.path.exists(stopFile): os.remove(stopFile) go = 1 firstRound = 1 while go: os.chdir(curDir) if not firstRound: print "Sleeping 5 minutes" time.sleep(5 * 60) nowString = time.strftime("%Y-%m-%d %H:%M:%S") # check SVN for any new hardhat script try: # bring this hardhat directory up to date outputList = hardhatutil.executeCommandReturnOutputRetry( [svnProgram, "-q", "update"]) hardhatutil.dumpOutputList(outputList) except: raise TinderbuildError, "Error updating HardHat" try: # launch the real build script outputList = hardhatutil.executeCommandReturnOutput( [os.path.join(curDir, 'tinderbox.py'), ' '.join(sys.argv[1:])]) hardhatutil.dumpOutputList(outputList) except: raise TinderbuildError, "Failed to launch build script" if os.path.exists(stopFile): go = 0 firstRound = 0
os.mkdir(outputDir) buildVersionEscaped = "\'" + buildVersion + "\'" buildVersionEscaped = buildVersionEscaped.replace(" ", "|") if not os.path.exists(chanDir): # Initialize sources print "Setup source tree..." log.write("- - - - tree setup - - - - - - -\n") for module in reposModules: svnSource = os.path.join(reposRoot, reposBase, module) log.write("[tbox] Retrieving source tree [%s]\n" % svnSource) outputList = hardhatutil.executeCommandReturnOutputRetry( [svnProgram, "-q", "co", svnSource, module]) hardhatutil.dumpOutputList(outputList, log) os.chdir(chanDir) for releaseMode in releaseModes: doInstall(releaseMode, workingDir, log) doDistribution(releaseMode, workingDir, log, outputDir, buildVersion, buildVersionEscaped, hardhatScript) if skipTests: ret = 'success' else: ret = doTests(hardhatScript, releaseMode, workingDir,
buildVersionEscaped = buildVersionEscaped.replace(" ", "|") if not os.path.exists(chanDir): # Initialize sources print "Setup source tree..." log.write("- - - - tree setup - - - - - - -\n") svnChanges = {} clean = '' for module in reposModules: svnSource = os.path.join(reposRoot, reposBase, module) log.write("[tbox] Retrieving source tree [%s]\n" % svnSource) outputList = hardhatutil.executeCommandReturnOutputRetry( [svnProgram, "-q", "co", svnSource, module]) hardhatutil.dumpOutputList(outputList, log) svnChanges[module] = True for releaseMode in releaseModes: doBuild(releaseMode, workingDir, log, svnChanges, clean) if upload: doUploadToStaging(releaseMode, workingDir, buildVersion, log) clean = 'clean' for releaseMode in releaseModes: doDistribution(releaseMode, workingDir, log, outputDir, buildVersion, buildVersionEscaped, hardhatScript)
def Start(hardhatScript, workingDir, buildVersion, clobber, log, skipTests=False, upload=False): # make sure workingDir is absolute workingDir = os.path.abspath(workingDir) os.chdir(workingDir) # remove outputDir and create it outputDir = os.path.join(workingDir, "output") if os.path.exists(outputDir): hardhatutil.rmdirRecursive(outputDir) os.mkdir(outputDir) buildVersionEscaped = "'" + buildVersion + "'" buildVersionEscaped = buildVersionEscaped.replace(" ", "|") sourceChanged = False log.write("[tbox] Pulling source tree\n") for (module, moduleSource) in reposModules: moduleDir = os.path.join(workingDir, module) if os.path.exists(moduleDir): log.write("[tbox] Checking for source updates\n") print "updating %s" % module os.chdir(moduleDir) outputList = hardhatutil.executeCommandReturnOutputRetry([svnProgram, "up"]) hardhatutil.dumpOutputList(outputList, log) if NeedsUpdate(outputList): sourceChanged = True log.write("[tbox] %s modified\n" % module) else: log.write("[tbox] %s unchanged\n" % module) else: svnSource = os.path.join(reposRoot, moduleSource) log.write("[tbox] Retrieving source tree [%s]\n" % svnSource) print "pulling %s" % module os.chdir(workingDir) outputList = hardhatutil.executeCommandReturnOutputRetry([svnProgram, "-q", "co", svnSource, module]) hardhatutil.dumpOutputList(outputList, log) sourceChanged = True os.chdir(workingDir) doBuild(workingDir, log) if skipTests: ret = "success" else: ret = doTests(workingDir, log) if sourceChanged: doDistribution(workingDir, log, outputDir, buildVersion, buildVersionEscaped) changes = "-changes" else: changes = "-nochanges" print ret + changes return ret + changes
print "Calling RotateDirectories" log.write("Calling RotateDirectories\n") RotateDirectories(outputDir) buildNameNoSpaces = buildName.replace(" ", "") if skipRsync: print "skipping rsync" log.write("skipping rsync") else: print "Rsyncing..." log.write('rsync -e ssh -avzp ' + outputDir + os.sep + ' ' + options.rsyncServer + ':continuous/' + buildNameNoSpaces) outputList = hardhatutil.executeCommandReturnOutputRetry( [rsyncProgram, "-e", "ssh", "-avzp", outputDir + os.sep, options.rsyncServer + ":continuous/" + buildNameNoSpaces]) hardhatutil.dumpOutputList(outputList, log) if not uploadStaging: print "skipping rsync to staging area" log.write("skipping rsync to staging area") else: timestamp = nowString.replace("-", "") timestamp = timestamp.replace(":", "") timestamp = timestamp.replace(" ", "") if not os.path.isdir(timestamp): print "skipping rsync to staging area, no dir", timestamp log.write("skipping rsync to staging area, no dir") else:
def main(): global project nowString = time.strftime("%Y-%m-%d %H:%M:%S") nowShort = hardhatutil.RemovePunctuation(nowString) # nowString is the current time, in a SVN-compatible format print nowString # nowShort is nowString without punctuation or whitespace print nowShort try: opts, args = getopt.getopt(sys.argv[1:], "b:d:m:p:t:n:s") except getopt.GetoptError: usage() sys.exit(1) buildVersionArg = None svnDateArg = None toAddrArg = None projectArg = None svnTagArg = None buildName = 'buildname' noTests = 0 for opt, arg in opts: if opt == "-b": buildVersionArg = arg if opt == "-d": svnDateArg = arg if opt == "-m": toAddrArg = arg if opt == "-p": projectArg = arg if opt == "-t": svnTagArg = arg if opt == "-n": buildName = arg if opt == "-s": noTests = 1 if svnDateArg and svnTagArg: print "Please choose either a svn date or tag, not both" sys.exit(1) # defaults: if projectArg: project = projectArg if toAddrArg: toAddr = toAddrArg else: toAddr = None buildVersion = nowString if svnDateArg: buildVersion = svnDateArg if svnTagArg: buildVersion = svnTagArg if buildVersionArg: buildVersion = buildVersionArg print "nowString", nowString print "nowShort", nowShort print "buildVersion", buildVersion print "buildName", buildName print "skipTests=", noTests # buildVersion is encoded into the application's internal version whereAmI = os.path.dirname(os.path.abspath(hardhatutil.__file__)) hardhatFile = os.path.join(whereAmI, "hardhat.py") homeDir = os.environ['HOME'] buildDir = os.path.join(homeDir, "singlebuild") logFile = os.path.join(buildDir, "build.log") buildscriptFile = os.path.join("buildscripts", project + ".py") fromAddr = "builds" fromAddr += "@" fromAddr += "osafoundation.org" print "Mail to ", toAddr print "Build dir", buildDir print "Build file ", buildscriptFile curDir = os.path.abspath(os.getcwd()) if os.path.exists(buildDir): hardhatutil.rmdirRecursive(buildDir) os.mkdir(buildDir) path = os.environ.get('PATH', os.environ.get('path')) svnProgram = hardhatutil.findInPath(path, "svn") log = open(logFile, "w+") try: # bring this hardhat directory up to date outputList = hardhatutil.executeCommandReturnOutputRetry( [svnProgram, "update"]) # load the buildscript file for the project mod = hardhatutil.ModuleFromFile(buildscriptFile, "buildscript") # SendMail(fromAddr, toAddr, nowString, nowString, buildName, # "building", None) mod.Start(hardhatFile, buildDir, buildVersion, 1, log, skipTests=noTests, tagID=svnTagArg) except Exception, e: import traceback traceback.print_exc() print "something failed" log.write("something failed") status = "build_failed"
def checkoutMinimal(self): outputList = hardhatutil.executeCommandReturnOutputRetry( [svnProgram, "-q", "checkout", "chandler/distrib/osx/bundle"] )
def Start(hardhatScript, workingDir, buildVersion, clobber, log, skipTests=False, upload=False): # make sure workingDir is absolute workingDir = os.path.abspath(workingDir) os.chdir(workingDir) # remove outputDir and create it outputDir = os.path.join(workingDir, "output") if os.path.exists(outputDir): hardhatutil.rmdirRecursive(outputDir) os.mkdir(outputDir) buildVersionEscaped = "\'" + buildVersion + "\'" buildVersionEscaped = buildVersionEscaped.replace(" ", "|") sourceChanged = False log.write("[tbox] Pulling source tree\n") for (module, moduleSource) in reposModules: moduleDir = os.path.join(workingDir, module) if os.path.exists(moduleDir): log.write("[tbox] Checking for source updates\n") print "updating %s" % module os.chdir(moduleDir) outputList = hardhatutil.executeCommandReturnOutputRetry( [svnProgram, "up"]) hardhatutil.dumpOutputList(outputList, log) if NeedsUpdate(outputList): sourceChanged = True log.write("[tbox] %s modified\n" % module) else: log.write("[tbox] %s unchanged\n" % module) else: svnSource = os.path.join(reposRoot, moduleSource) log.write("[tbox] Retrieving source tree [%s]\n" % svnSource) print "pulling %s" % module os.chdir(workingDir) outputList = hardhatutil.executeCommandReturnOutputRetry( [svnProgram, "-q", "co", svnSource, module]) hardhatutil.dumpOutputList(outputList, log) sourceChanged = True os.chdir(workingDir) doBuild(workingDir, log) if skipTests: ret = 'success' else: ret = doTests(workingDir, log) if sourceChanged: doDistribution(workingDir, log, outputDir, buildVersion, buildVersionEscaped) changes = "-changes" else: changes = "-nochanges" print ret + changes return ret + changes
def main(): global project nowString = time.strftime("%Y-%m-%d %H:%M:%S") nowShort = hardhatutil.RemovePunctuation(nowString) # nowString is the current time, in a SVN-compatible format print nowString # nowShort is nowString without punctuation or whitespace print nowShort try: opts, args = getopt.getopt(sys.argv[1:], "b:d:m:p:t:n:s") except getopt.GetoptError: usage() sys.exit(1) buildVersionArg = None svnDateArg = None toAddrArg = None projectArg = None svnTagArg = None buildName = 'buildname' noTests = 0 for opt, arg in opts: if opt == "-b": buildVersionArg = arg if opt == "-d": svnDateArg = arg if opt == "-m": toAddrArg = arg if opt == "-p": projectArg = arg if opt == "-t": svnTagArg = arg if opt == "-n": buildName = arg if opt == "-s": noTests = 1 if svnDateArg and svnTagArg: print "Please choose either a svn date or tag, not both" sys.exit(1) # defaults: if projectArg: project = projectArg if toAddrArg: toAddr = toAddrArg else: toAddr = None buildVersion = nowString if svnDateArg: buildVersion = svnDateArg if svnTagArg: buildVersion = svnTagArg if buildVersionArg: buildVersion = buildVersionArg print "nowString", nowString print "nowShort", nowShort print "buildVersion", buildVersion print "buildName", buildName print "skipTests=", noTests # buildVersion is encoded into the application's internal version whereAmI = os.path.dirname(os.path.abspath(hardhatutil.__file__)) hardhatFile = os.path.join(whereAmI, "hardhat.py") homeDir = os.environ['HOME'] buildDir = os.path.join(homeDir, "singlebuild") logFile = os.path.join(buildDir, "build.log") buildscriptFile = os.path.join("buildscripts", project + ".py") fromAddr = "builds" fromAddr += "@" fromAddr += "osafoundation.org" print "Mail to ", toAddr print "Build dir", buildDir print "Build file ", buildscriptFile curDir = os.path.abspath(os.getcwd()) if os.path.exists(buildDir): hardhatutil.rmdirRecursive(buildDir) os.mkdir(buildDir) path = os.environ.get('PATH', os.environ.get('path')) svnProgram = hardhatutil.findInPath(path, "svn") log = open(logFile, "w+") try: # bring this hardhat directory up to date outputList = hardhatutil.executeCommandReturnOutputRetry([svnProgram, "update"]) # load the buildscript file for the project mod = hardhatutil.ModuleFromFile(buildscriptFile, "buildscript") # SendMail(fromAddr, toAddr, nowString, nowString, buildName, # "building", None) mod.Start(hardhatFile, buildDir, buildVersion, 1, log, skipTests=noTests, tagID=svnTagArg) except Exception, e: import traceback traceback.print_exc() print "something failed" log.write("something failed") status = "build_failed"
def checkoutMinimal(self): outputList = hardhatutil.executeCommandReturnOutputRetry( [svnProgram, "-q", "checkout", 'chandler/distrib/osx/bundle'])