示例#1
0
def main(argv=None):
    """
    Entry point
    """
    args = parse_args_or_exit(argv)
    link = Link(args.link)

    # Repo and ending tag are specified in the link file
    repo = link.url
    end_tag = link.commitish
    if end_tag is None:
        end_tag = "HEAD"

    # If the repository URL in the link is remote, look for a
    # local clone in repos (without a .git suffix)
    url = urlparse(repo)
    if url.scheme:
        reponame = os.path.basename(url.path).rsplit(".git")[0]
        repo = os.path.join(args.repos, reponame)

    if repo.endswith(".pg"):
        util.makedirs(os.path.dirname(args.tarball))
        git.archive(repo, end_tag, args.tarball)
        sys.exit(0)

    # Start tag is based on the version specified in the spec file,
    # but the tag name may be slightly different (v1.2.3 rather than 1.2.3)
    # If the link file does not list a spec file, assume that there is one in
    # the usual place
    if link.specfile is not None:
        spec_path = os.path.join(repo, link.specfile)
    else:
        basename = os.path.splitext(os.path.basename(args.link))[0]
        spec_path = os.path.join("SPECS", "%s.spec" % basename)
    spec = Spec(spec_path)

    start_tag = link.base_commitish
    if start_tag is None:
        start_tag = spec.version()
        if start_tag not in git.tags(repo):
            start_tag = "v%s" % start_tag

    try:
        tmpdir = tempfile.mkdtemp(prefix="px-pq-")
        assemble_patchqueue(tmpdir, link, repo, start_tag, end_tag)
        assemble_extra_sources(tmpdir, link, spec.local_sources(),
                               spec.local_patches())
        tarball.make(tmpdir, args.tarball)

    finally:
        if args.keeptmp:
            print "Working directory retained at %s" % tmpdir
        else:
            shutil.rmtree(tmpdir)
示例#2
0
def populate_working_directory(tmpdir, spec, link, sources, patchqueue):
    """
    Build a working directory containing everything needed to build the SRPM.
    """
    # Copy spec to working area
    tmp_specfile = os.path.join(tmpdir, os.path.basename(spec))
    shutil.copyfile(spec, tmp_specfile)

    manifests = {}

    # Copy sources to working area
    for source in sources:
        extract_commit(source, manifests)
        shutil.copy(source, tmpdir)

    if manifests:
        add_manifest_entry(manifests, tmp_specfile)
    else:
        print("No .gitarchive-info found for {0}".format(spec))

    spec = Spec(tmp_specfile, check_package_name=False)

    # Expand patchqueue to working area, rewriting spec as needed
    if link and patchqueue:
        # Extract patches
        if link.patchqueue is not None:
            with Patchqueue(patchqueue, branch=link.patchqueue) as patches:
                patches.extract_all(tmpdir)
                patches.add_to_spec(spec, tmp_specfile)

        # Extract non-patchqueue sources
        with Tarball(patchqueue) as tarball:
            if link.sources is not None:
                for source in spec.local_sources():
                    path = os.path.join(link.sources, source)
                    tarball.extract(path, tmpdir)
            if link.patches is not None:
                for patch in spec.local_patches():
                    path = os.path.join(link.patches, patch)
                    tarball.extract(path, tmpdir)

    return tmp_specfile
示例#3
0
def populate_working_directory(tmpdir, spec, link, sources, patchqueue):
    """
    Build a working directory containing everything needed to build the SRPM.
    """
    # Copy spec to working area
    tmp_specfile = os.path.join(tmpdir, os.path.basename(spec))
    shutil.copyfile(spec, tmp_specfile)

    # Copy sources to working area, rewriting spec as needed
    tarball_filters = ['.tar.gz', '.tar.bz2']
    for source in sources:
        if any([ext in source for ext in tarball_filters]):
            extract_topdir(tmp_specfile, source)
        shutil.copy(source, tmpdir)

    spec = Spec(tmp_specfile, check_package_name=False)

    # Expand patchqueue to working area, rewriting spec as needed
    if link and patchqueue:
        # Extract patches
        if link.patchqueue is not None:
            with Patchqueue(patchqueue, branch=link.patchqueue) as patches:
                patches.extract_all(tmpdir)
                patches.add_to_spec(spec, tmp_specfile)

        # Extract non-patchqueue sources
        with Tarball(patchqueue) as tarball:
            if link.sources is not None:
                for source in spec.local_sources():
                    path = os.path.join(link.sources, source)
                    tarball.extract(path, tmpdir)
            if link.patches is not None:
                for patch in spec.local_patches():
                    path = os.path.join(link.patches, patch)
                    tarball.extract(path, tmpdir)

    return tmp_specfile