예제 #1
0
def git_version_summary(path, env=None):
    git = find_git(env)

    if git is None:
        return ("GIT-UNKNOWN", {})

    env.GIT = git

    environ = dict(os.environ)
    environ["GIT_DIR"] = '%s/.git' % path
    environ["GIT_WORK_TREE"] = path
    git = samba_utils.get_string(Utils.cmd_output(env.GIT + ' show --pretty=format:"%h%n%ct%n%H%n%cd" --stat HEAD', silent=True, env=environ))

    lines = git.splitlines()
    if not lines or len(lines) < 4:
        return ("GIT-UNKNOWN", {})

    fields = {
            "GIT_COMMIT_ABBREV": lines[0],
            "GIT_COMMIT_FULLREV": lines[2],
            "COMMIT_TIME": int(lines[1]),
            "COMMIT_DATE": lines[3],
            }

    ret = "GIT-" + fields["GIT_COMMIT_ABBREV"]

    if env.GIT_LOCAL_CHANGES:
        clean = Utils.cmd_output('%s diff HEAD | wc -l' % env.GIT, silent=True).strip()
        if clean == "0":
            fields["COMMIT_IS_CLEAN"] = 1
        else:
            fields["COMMIT_IS_CLEAN"] = 0
            ret += "+"

    return (ret, fields)
예제 #2
0
def CHECK_COMMAND(conf,
                  cmd,
                  msg=None,
                  define=None,
                  on_target=True,
                  boolean=False):
    '''run a command and return result'''
    if msg is None:
        msg = 'Checking %s' % ' '.join(cmd)
    conf.COMPOUND_START(msg)
    cmd = cmd[:]
    if on_target:
        cmd.extend(conf.SAMBA_CROSS_ARGS(msg=msg))
    try:
        ret = get_string(Utils.cmd_output(cmd))
    except:
        conf.COMPOUND_END(False)
        return False
    if boolean:
        conf.COMPOUND_END('ok')
        if define:
            conf.DEFINE(define, '1')
    else:
        ret = ret.strip()
        conf.COMPOUND_END(ret)
        if define:
            conf.DEFINE(define, ret, quote=True)
    return ret
예제 #3
0
def vcs_dir_contents(path):
    """Return the versioned files under a path.

    :return: List of paths relative to path
    """
    repo = path
    while repo != "/":
        if os.path.exists(os.path.join(repo, ".git")):
            ls_files_cmd = [ 'git', 'ls-files', '--full-name',
                             os.path.relpath(path, repo) ]
            cwd = None
            env = dict(os.environ)
            env["GIT_DIR"] = os.path.join(repo, ".git")
            break
        repo = os.path.dirname(repo)
    if repo == "/":
        raise Exception("unsupported or no vcs for %s" % path)
    return get_string(Utils.cmd_output(ls_files_cmd, cwd=cwd, env=env)).split('\n')
예제 #4
0
def CHECK_STANDARD_LIBPATH(conf):
    # at least gcc and clang support this:
    try:
        cmd = conf.env.CC + ['-print-search-dirs']
        out = get_string(Utils.cmd_output(cmd)).split('\n')
    except ValueError:
        # option not supported by compiler - use a standard list of directories
        dirlist = ['/usr/lib', '/usr/lib64']
    except:
        raise Errors.WafError('Unexpected error running "%s"' % (cmd))
    else:
        dirlist = []
        for line in out:
            line = line.strip()
            if line.startswith("libraries: ="):
                dirliststr = line[len("libraries: ="):]
                dirlist = [os.path.normpath(x) for x in dirliststr.split(':')]
                break

    conf.env.STANDARD_LIBPATH = dirlist
예제 #5
0
 def read_perl_config_var(cmd):
     output = Utils.cmd_output(
         [conf.env.get_flat('PERL'), '-MConfig', '-e', cmd])
     if not isinstance(output, str):
         output = get_string(output)
     return Utils.to_list(output)