% module) else: raise misc.builderr( "Configuration file specified unrecognised `repostype' for module `%s': `%s'" % (module, repostype)) lexer.restore_vars(save) if not git: newrev = None if details[0][0] == "rev": rev = details[0][1] # If this is a simple revision number, use it as newrev # unless told otherwise later. if misc.numeric(rev): newrev = rev # If this is the special revision number HEAD, we try # to find out the real revision number after doing the # export, and we save that in the `headrevs' hash in # this module. Further head checkouts from this # repository are done with that explicit revision # number, so that if we're checking out multiple # modules we get an effectively atomic checkout over # all of them. if rev == "HEAD": if headrevs.has_key(svnrepos): rev = headrevs[svnrepos] else: set_headrev = 1
def expand_varfunc(var, cfg): global builddate # Expand a variable or function enclosed in $(...). Takes a # string containing the text from inside the parentheses (after # any further expansion has been done on that); returns a # string containing the expansion. if var[0] == "!": # `$(!' introduces a special function. try: pos = var.index(" ") fn, val = var[1:pos], var[pos + 1:] except ValueError: fn, val = var[1:], "" if fn == "numeric": # The entire function call has already been lexed, so # don't lex it again. log.logmsg("testing numericity of `%s'" % val) if misc.numeric(val): return "yes" else: return "no" elif fn == "available": log.logmsg("testing availability of variable `%s'" % val) try: get_multicharvar(val) return "yes" except VarInvalid: return "no" elif fn == "builddate": if val != "": raise misc.builderr("$(!builddate) expects no arguments") if builddate is None: # Invent a build date. cachefile = os.path.join(cfg.builddatecache, cfg.mainmodule) builddate = time.strftime("%Y%m%d", time.localtime(time.time())) verdata = checkout.verdata() new = True if os.path.exists(cachefile): with open(cachefile, "r") as f: last_builddate = f.readline().rstrip("\r\n") last_verdata = f.read() if verdata == last_verdata: new = False if new: try: os.mkdir(cfg.builddatecache, 0700) except OSError as e: if e.errno != os.errno.EEXIST: raise with open(cachefile + ".tmp", "w") as f: f.write(builddate + "\n" + verdata) os.rename(cachefile + ".tmp", cachefile) log.logmsg("using new build date " + builddate) else: builddate = last_builddate log.logmsg("reusing last build date " + builddate) return builddate else: raise misc.builderr("unexpected string function `%s'" % var) else: # Just look up var in our list of variables, and return its # value. try: return get_multicharvar(var, "") except VarInvalid: raise misc.builderr( "special variable `%s' is not currently valid" % var)
def expand_varfunc(var, cfg): global builddate # Expand a variable or function enclosed in $(...). Takes a # string containing the text from inside the parentheses (after # any further expansion has been done on that); returns a # string containing the expansion. if var[0] == "!": # `$(!' introduces a special function. try: pos = var.index(" ") fn, val = var[1:pos], var[pos+1:] except ValueError: fn, val = var[1:], "" if fn == "numeric": # The entire function call has already been lexed, so # don't lex it again. log.logmsg("testing numericity of `%s'" % val) if misc.numeric(val): return "yes" else: return "no" elif fn == "available": log.logmsg("testing availability of variable `%s'" % val) try: get_multicharvar(val) return "yes" except VarInvalid: return "no" elif fn == "builddate": if val != "": raise misc.builderr("$(!builddate) expects no arguments") if builddate is None: # Invent a build date. cachefile = os.path.join(cfg.builddatecache, cfg.mainmodule) builddate = time.strftime("%Y%m%d",time.localtime(time.time())) verdata = checkout.verdata() new = True if os.path.exists(cachefile): with open(cachefile, "r") as f: last_builddate = f.readline().rstrip("\r\n") last_verdata = f.read() if verdata == last_verdata: new = False if new: try: os.mkdir(cfg.builddatecache, 0700) except OSError as e: if e.errno != os.errno.EEXIST: raise with open(cachefile + ".tmp", "w") as f: f.write(builddate + "\n" + verdata) os.rename(cachefile + ".tmp", cachefile) log.logmsg("using new build date " + builddate) else: builddate = last_builddate log.logmsg("reusing last build date " + builddate) return builddate else: raise misc.builderr("unexpected string function `%s'" % var) else: # Just look up var in our list of variables, and return its # value. try: return get_multicharvar(var, "") except VarInvalid: raise misc.builderr("special variable `%s' is not currently valid" % var)
git = git_native = True elif repostype is None: raise misc.builderr("Configuration file did not specify `repostype' for module `%s'" % module) else: raise misc.builderr("Configuration file specified unrecognised `repostype' for module `%s': `%s'" % (module, repostype)) lexer.restore_vars(save) if not git: newrev = None if details[0][0] == "rev": rev = details[0][1] # If this is a simple revision number, use it as newrev # unless told otherwise later. if misc.numeric(rev): newrev = rev # If this is the special revision number HEAD, we try # to find out the real revision number after doing the # export, and we save that in the `headrevs' hash in # this module. Further head checkouts from this # repository are done with that explicit revision # number, so that if we're checking out multiple # modules we get an effectively atomic checkout over # all of them. if rev == "HEAD": if headrevs.has_key(svnrepos): rev = headrevs[svnrepos] else: set_headrev = 1