Esempio n. 1
0
def is_outdated(package_dir):
    """Return True if the package has been changed since the revision in the
    SVN working dir.

    """
    if utils.is_url(package_dir):
        return False
    out, err = utils.sbacktick("svn status -u -q " + package_dir)
    if err:
        raise SVNError("Exit code %d getting SVN status. Output:\n%s" %
                       (err, out))
    outdated_files = []
    for line in out.split("\n"):
        try:
            outdated_flag = line[8]
        except IndexError:
            continue
        if outdated_flag == "*":
            outdated_files.append(line)
    if outdated_files:
        print "The following outdated files exist:"
        print "\n".join(outdated_files)
        return True
    else:
        return False
Esempio n. 2
0
def verify_correct_branch(package_dir, buildopts):
    """Check that the user is not trying to build with bad branch/target
    combinations. For example, building from trunk into upcoming, or building
    from osg-3.1 into osg-3.2.

    """
    package_info = get_package_info(package_dir)
    url = package_info['canon_url']
    branch_match = re.search(SVN_REDHAT_PATH + r'/(trunk|branches/[^/]+)/',
                             url)
    if not branch_match:
        # Building from a weird path (such as a tag). Be permissive -- koji
        # itself will catch building from outside SVN so we don't have to
        return
    branch = branch_match.group(1)
    if not is_restricted_branch(branch):
        # Developer branch -- any target ok
        return
    for dver in buildopts['enabled_dvers']:
        target = buildopts['targetopts_by_dver'][dver]['koji_target']
        if not is_restricted_target(target):
            # Some custom target -- any branch ok
            continue
        if not restricted_branch_matches_target(branch, target):
            raise SVNError("Forbidden to build from %s branch into %s target" %
                           (branch, target))
Esempio n. 3
0
def is_uncommitted(package_dir):
    """Return True if there are uncommitted changes in the SVN working dir."""
    out, err = utils.sbacktick("svn status -q " + package_dir)
    if err:
        raise SVNError("Exit code %d getting SVN status. Output:\n%s" %
                       (err, out))
    if out:
        print "The following uncommitted changes exist:"
        print out
        return True
    else:
        return False
Esempio n. 4
0
def verify_package_info(package_info):
    """Check if package_info points to a valid package dir (i.e. contains
    at least an osg/ dir or an upstream/ dir).

    """
    url = package_info['canon_url']
    rev = package_info['revision']
    command = ["svn", "ls", url, "-r", rev]
    out, err = utils.sbacktick(command, clocale=True, err2out=True)
    if err:
        raise SVNError(
            "Exit code %d getting SVN listing of %s (rev %s). Output:\n%s" %
            (err, url, rev, out))
    for line in out.split("\n"):
        if line.startswith('osg/') or line.startswith('upstream/'):
            return True
    return False
Esempio n. 5
0
def get_package_info(package_dir, rev=None):
    """Return the svn info for a package dir."""
    command = ["svn", "info", package_dir]
    if rev:
        command += ["-r", rev]
    else:
        command += ["-r", "HEAD"]

    out, err = utils.sbacktick(command, clocale=True, err2out=True)
    if err:
        raise SVNError("Exit code %d getting SVN info. Output:\n%s" %
                       (err, out))
    info = dict()
    for line in out.split("\n"):
        label, value = line.strip().split(": ", 1)
        label = label.strip().lower().replace(' ', '_')
        info[label] = value
    info['canon_url'] = re.sub("^" + re.escape(info['repository_root']),
                               SVN_ROOT, info['url'])
    return info
Esempio n. 6
0
def get_package_info(package_dir):
    """Return the svn info for a package dir."""
    command = ["svn", "info", package_dir]
    # If we don't specify the revision in the argument (e.g. no foo@19999)
    # then explicitly specify HEAD to make sure we're not getting an older
    # version.
    if not re.search(r'@\d+$', package_dir):
        command += ['-r', 'HEAD']

    out, err = utils.sbacktick(command, err2out=True)
    if err:
        raise SVNError("Exit code %d getting SVN info. Output:\n%s" %
                       (err, out))
    info = dict()
    for line in out.split("\n"):
        label, value = line.strip().split(": ", 1)
        label = label.strip().lower().replace(' ', '_')
        info[label] = value
    info['canon_url'] = re.sub("^" + re.escape(info['repository_root']),
                               SVN_ROOT, info['url'])
    return info