Example #1
0
def get_repository_url(distribution, flocker_version):
    """
    Return the URL for the repository of a given distribution.

    For ``yum``-using distributions this gives the URL to a package that adds
    entries to ``/etc/yum.repos.d``. For ``apt``-using distributions, this
    gives the URL for a repo containing a Packages(.gz) file.

    :param bytes distribution: The Linux distribution to get a repository for.
    :param bytes flocker_version: The version of Flocker to get a repository
        for.

    :return bytes: The URL pointing to a repository of packages.
    :raises: ``UnsupportedDistribution`` if the distribution is unsupported.
    """
    distribution_to_url = {
        # XXX Use testing repositories when appropriate for CentOS.
        # See FLOC-2080.
        # TODO instead of hardcoding keys, use the _to_Distribution map
        # and then choose the name
        'centos-7': "https://{archive_bucket}.s3.amazonaws.com/"
                    "{key}/clusterhq-release$(rpm -E %dist).noarch.rpm".format(
                        archive_bucket=ARCHIVE_BUCKET,
                        key='centos',
                        ),

        # This could hardcode the version number instead of using
        # ``lsb_release`` but that allows instructions to be shared between
        # versions, and for earlier error reporting if you try to install on a
        # separate version. The $(ARCH) part must be left unevaluated, hence
        # the backslash escapes (one to make shell ignore the $ as a
        # substitution marker, and then doubled to make Python ignore the \ as
        # an escape marker). The output of this value then goes into
        # /etc/apt/sources.list which does its own substitution on $(ARCH)
        # during a subsequent apt-get update

        'ubuntu-14.04': 'https://{archive_bucket}.s3.amazonaws.com/{key}/'
                        '$(lsb_release --release --short)/\\$(ARCH)'.format(
                            archive_bucket=ARCHIVE_BUCKET,
                            key='ubuntu' + get_package_key_suffix(
                                flocker_version),
                        ),

        'ubuntu-15.04': 'https://{archive_bucket}.s3.amazonaws.com/{key}/'
                        '$(lsb_release --release --short)/\\$(ARCH)'.format(
                            archive_bucket=ARCHIVE_BUCKET,
                            key='ubuntu' + get_package_key_suffix(
                                flocker_version),
                        ),
    }

    try:
        return distribution_to_url[distribution]
    except KeyError:
        raise UnsupportedDistribution()
Example #2
0
def get_repository_url(distribution, flocker_version):
    """
    Return the URL for the repository of a given distribution.

    For ``yum``-using distributions this gives the URL to a package that adds
    entries to ``/etc/yum.repos.d``. For ``apt``-using distributions, this
    gives the URL for a repo containing a Packages(.gz) file.

    :param bytes distribution: The Linux distribution to get a repository for.
    :param bytes flocker_version: The version of Flocker to get a repository
        for.

    :return bytes: The URL pointing to a repository of packages.
    :raises: ``UnsupportedDistribution`` if the distribution is unsupported.
    """
    distribution_to_url = {
        # XXX Use testing repositories when appropriate for CentOS.
        # See FLOC-2080.
        # TODO instead of hardcoding keys, use the _to_Distribution map
        # and then choose the name
        'centos-7':
        "https://{archive_bucket}.s3.amazonaws.com/"
        "{key}/clusterhq-release$(rpm -E %dist).noarch.rpm".format(
            archive_bucket=ARCHIVE_BUCKET,
            key='centos',
        ),

        # This could hardcode the version number instead of using
        # ``lsb_release`` but that allows instructions to be shared between
        # versions, and for earlier error reporting if you try to install on a
        # separate version. The $(ARCH) part must be left unevaluated, hence
        # the backslash escapes (one to make shell ignore the $ as a
        # substitution marker, and then doubled to make Python ignore the \ as
        # an escape marker). The output of this value then goes into
        # /etc/apt/sources.list which does its own substitution on $(ARCH)
        # during a subsequent apt-get update
        'ubuntu-14.04':
        'https://{archive_bucket}.s3.amazonaws.com/{key}/'
        '$(lsb_release --release --short)/\\$(ARCH)'.format(
            archive_bucket=ARCHIVE_BUCKET,
            key='ubuntu' + get_package_key_suffix(flocker_version),
        ),
        'ubuntu-15.04':
        'https://{archive_bucket}.s3.amazonaws.com/{key}/'
        '$(lsb_release --release --short)/\\$(ARCH)'.format(
            archive_bucket=ARCHIVE_BUCKET,
            key='ubuntu' + get_package_key_suffix(flocker_version),
        ),
    }

    try:
        return distribution_to_url[distribution]
    except KeyError:
        raise UnsupportedDistribution()
Example #3
0
def upload_packages(scratch_directory, target_bucket, version, build_server,
                    top_level):
    """
    The ClusterHQ yum and deb repositories contain packages for Flocker, as
    well as the dependencies which aren't available in CentOS 7. It is
    currently hosted on Amazon S3. When doing a release, we want to add the
    new Flocker packages, while preserving the existing packages in the
    repository. To do this, we download the current repository, add the new
    package, update the metadata, and then upload the repository.

    :param FilePath scratch_directory: Temporary directory to download
        repository to.
    :param bytes target_bucket: S3 bucket to upload repository to.
    :param bytes version: Version to download packages for.
    :param bytes build_server: Server to download new packages from.
    :param FilePath top_level: The top-level of the flocker repository.
    """
    distribution_names = available_distributions(
        flocker_source_path=top_level,
    )

    for distribution_name in distribution_names:
        distribution = DISTRIBUTION_NAME_MAP[distribution_name]
        architecture = distribution.native_package_architecture()

        yield update_repo(
            package_directory=scratch_directory.child(
                b'{}-{}-{}'.format(
                    distribution.name,
                    distribution.version,
                    architecture)),
            target_bucket=target_bucket,
            target_key=os.path.join(
                distribution.name + get_package_key_suffix(version),
                distribution.version,
                architecture),
            source_repo=os.path.join(
                build_server, b'results/omnibus',
                version,
                b'{}-{}'.format(distribution.name, distribution.version)),
            packages=FLOCKER_PACKAGES,
            flocker_version=version,
            distribution=distribution,
        )
Example #4
0
def upload_packages(scratch_directory, target_bucket, version, build_server,
                    top_level):
    """
    The ClusterHQ yum and deb repositories contain packages for Flocker, as
    well as the dependencies which aren't available in CentOS 7. It is
    currently hosted on Amazon S3. When doing a release, we want to add the
    new Flocker packages, while preserving the existing packages in the
    repository. To do this, we download the current repository, add the new
    package, update the metadata, and then upload the repository.

    :param FilePath scratch_directory: Temporary directory to download
        repository to.
    :param bytes target_bucket: S3 bucket to upload repository to.
    :param bytes version: Version to download packages for.
    :param bytes build_server: Server to download new packages from.
    :param FilePath top_level: The top-level of the flocker repository.
    """
    distribution_names = available_distributions(
        flocker_source_path=top_level,
    )

    for distribution_name in distribution_names:
        distribution = DISTRIBUTION_NAME_MAP[distribution_name]
        architecture = distribution.native_package_architecture()

        yield update_repo(
            package_directory=scratch_directory.child(
                b'{}-{}-{}'.format(
                    distribution.name,
                    distribution.version,
                    architecture)),
            target_bucket=target_bucket,
            target_key=os.path.join(
                distribution.name + get_package_key_suffix(version),
                distribution.version,
                architecture),
            source_repo=os.path.join(
                build_server, b'results/omnibus',
                version,
                b'{}-{}'.format(distribution.name, distribution.version)),
            packages=FLOCKER_PACKAGES,
            flocker_version=version,
            distribution=distribution,
        )