Esempio n. 1
0
def update_dependency_versions(repositories, control_path, workdir=None, accepted_tag_pattern=None):
    """
    Update control_path (presumably debian/control) with package version collected
    by parsing debian/controls in dependencies.
    Also updates with change of my path.

    If any versioned dependencies are present, replace them too, as well as debian files
    """
    workdir = workdir or os.curdir
    cfile = ControlFile(filename=control_path)

    deps_from_repositories = []

    current_meta_version = None
    for package in cfile.get_versioned_dependencies():
        if not current_meta_version:
            current_meta_version = package.version
        else:
            assert current_meta_version == package.version, "Versioned packages with different versions, aborting"

    for repository in repositories:
        deps = fetch_new_dependencies(repository, workdir)
        deps_from_repositories.extend(deps)


    #FIXME: This will download deps again, fix it
    meta_version = compute_meta_version(repositories, workdir=workdir, accepted_tag_pattern=accepted_tag_pattern)
    meta_version_string = ".".join(map(str, meta_version))
    

    # also add myself as dependency
    deps = get_new_dependencies(workdir, accepted_tag_pattern=accepted_tag_pattern)

    # deps are my actual version; we want to update it to metaversion
    for dep in deps:
        dep.version = meta_version_string
    deps_from_repositories.extend(deps)

    cfile.replace_dependencies(deps_from_repositories)

    # if versioned packages present, replace'em
    if current_meta_version:
        replace_versioned_debian_files(debian_path=dirname(control_path), original_version=current_meta_version, new_version=meta_version_string, control_file=cfile)
        cfile.replace_versioned_packages(meta_version_string)

    cfile.dump(control_path)
Esempio n. 2
0
def test_versioned_packages_replaced_in_provides():
    versioned_metapackage = u"""\
Source: centrum-python-metapackage
Section: python
Priority: optional
Maintainer: John Doe <*****@*****.**>
Build-Depends: cdbs (>= 0.4.41), debhelper (>= 5.0.37.2), python-dev, python-support (>= 0.3), python-setuptools
Standards-Version: 3.7.2

Package: centrum-python-metapackage-aaa
Architecture: all
Provides: centrum-python-metapackage-aaa-%(metaversion)s
Depends: centrum-python-package-aaa (= 1.0.0)
Description: metapackage aaa
"""
    cfile = ControlFile(versioned_metapackage % {'metaversion' : '0.0.0'})
    cfile.replace_versioned_packages(version='2.0.2', old_version='0.0.0')
    assert_equals([l.strip() for l in (versioned_metapackage % {'metaversion' : '2.0.2'}).splitlines()], [l.strip() for l in cfile.dump().splitlines()])
Esempio n. 3
0
def replace_versioned_packages(control_path, version, workdir=None):
    workdir = workdir or os.curdir
    cfile = ControlFile(filename=control_path)
    cfile.replace_versioned_packages(version)
    cfile.dump(control_path)