Beispiel #1
0
def build_deb(repository, release, user, all_releases, linux_host, output_dir):
    """
    Builds a .deb package in docker, and copies it to the host.

    Args:
        repository: The github repository to use. username/repo
        release: The release object from github
        user: The github user information. Required for changelog information
        all_releases: All releases from github. Used for generating a changelog
        linux_host: If set, the docker host ot use that can run linux containers
                    If not None, this should be a format that would work with
                    docker -H
        output_dir: The directory to place artifacts in after the build

    Returns:
        The path to the artifact
    """

    release_version, release_timestamp = get_version_and_timestamp_from_release(release)
    release_datetime = dateutil.parser.parse(release["created_at"])
    image_tag = "buck:" + release_version
    deb_name = "buck.{}_all.deb".format(release_version)
    deb_path = os.path.join(output_dir, deb_name)
    logging.info("Building debian docker image...")

    # Move the in-repo changelog out of the way for the moment. We keep the file in
    # repo so that the build rules evaluate properly and don't complain about missing
    # srcs.
    changelog_path = os.path.join(
        "tools", "release", "platforms", "debian", "Changelog"
    )
    changelog = create_changelog(user, all_releases, release_datetime)
    with temp_move_file(changelog_path), temp_file_with_contents(
        changelog_path, changelog
    ):
        docker(
            linux_host,
            [
                "build",
                "-t",
                image_tag,
                "--build-arg",
                "version=" + release_version,
                "--build-arg",
                "timestamp=" + str(release_timestamp),
                "--build-arg",
                "repository=" + repository,
                "tools/release/platforms/debian",
            ],
        )

    logging.info("Copying deb out of docker container")
    copy_from_docker_linux(linux_host, image_tag, "/src/buck.deb", deb_path)

    logging.info("Validating that .deb installs...")
    validate(linux_host, image_tag, deb_path)

    logging.info("Built .deb file at {}".format(deb_path))
    return deb_path
Beispiel #2
0
def build_deb(repository, release, user, all_releases, linux_host, output_dir):
    """
    Builds a .deb package in docker, and copies it to the host.

    Args:
        repository: The github repository to use. username/repo
        release: The release object from github
        user: The github user information. Required for changelog information
        all_releases: All releases from github. Used for generating a changelog
        linux_host: If set, the docker host ot use that can run linux containers
                    If not None, this should be a format that would work with
                    docker -H
        output_dir: The directory to place artifacts in after the build

    Returns:
        The path to the artifact
    """

    release_version, release_timestamp = get_version_and_timestamp_from_release(release)
    release_datetime = dateutil.parser.parse(release["created_at"])
    image_tag = "buck:" + release_version
    deb_name = "buck.{}_all.deb".format(release_version)
    deb_path = os.path.join(output_dir, deb_name)
    logging.info("Building debian docker image...")

    # Move the in-repo changelog out of the way for the moment. We keep the file in
    # repo so that the build rules evaluate properly and don't complain about missing
    # srcs.
    changelog_path = os.path.join(
        "tools", "release", "platforms", "debian", "Changelog"
    )
    changelog = create_changelog(user, all_releases, release_datetime)
    with temp_move_file(changelog_path), temp_file_with_contents(
        changelog_path, changelog
    ):
        docker(
            linux_host,
            [
                "build",
                "-t",
                image_tag,
                "--build-arg",
                "version=" + release_version,
                "--build-arg",
                "timestamp=" + str(release_timestamp),
                "--build-arg",
                "repository=" + repository,
                "tools/release/platforms/debian",
            ],
        )

    logging.info("Copying deb out of docker container")
    copy_from_docker_linux(linux_host, image_tag, "/src/buck.deb", deb_path)

    logging.info("Validating that .deb installs...")
    validate(linux_host, image_tag, deb_path)

    logging.info("Built .deb file at {}".format(deb_path))
    return deb_path
Beispiel #3
0
def build_chocolatey(repository, release, windows_host, docker_memory,
                     docker_isolation, output_dir):
    """
    Builds a .nupkg package in docker, and copies it to the host.

    Args:
        repository: The github repository to use. username/repo
        release: The release object from github
        windows_host: If set, the docker host ot use that can run windows containers
                      If not None, this should be a format that would work with
                      docker -H
        output_dir: The directory to place artifacts in after the build

    Returns:
        The path to the artifact
    """
    release_version, release_timestamp = get_version_and_timestamp_from_release(
        release)
    image_tag = "buck:" + release_version
    nupkg_name = "buck.{}.nupkg".format(release_version)
    nupkg_path = os.path.join(output_dir, nupkg_name)

    # Get the changelog from github rather than locally
    changelog_path = os.path.join("tools", "release", "platforms",
                                  "chocolatey", "Changelog.md.new")
    changelog = release["body"].strip() or "Periodic release"

    with temp_file_with_contents(changelog_path, changelog):
        logging.info("Building windows docker image...")
        docker(
            windows_host,
            [
                "build",
                "--isolation=" + docker_isolation,
                "-m",
                docker_memory,  # Default memory is 1G
                "-t",
                image_tag,
                "--build-arg",
                "version=" + release_version,
                "--build-arg",
                "timestamp=" + str(release_timestamp),
                "--build-arg",
                "repository=" + repository,
                "tools/release/platforms/chocolatey",
            ],
        )

    logging.info("Copying nupkg out of docker container")
    copy_from_docker_windows(windows_host, image_tag, "/src/buck.nupkg",
                             nupkg_path)

    logging.info("Validating that .nupkg installs...")
    validate(windows_host, docker_memory, docker_isolation, image_tag,
             nupkg_path)

    logging.info("Built .nupkg file at {}".format(nupkg_path))
    return nupkg_path
Beispiel #4
0
def build_chocolatey(repository, release, windows_host, output_dir):
    """
    Builds a .nupkg package in docker, and copies it to the host.

    Args:
        repository: The github repository to use. username/repo
        release: The release object from github
        windows_host: If set, the docker host ot use that can run windows containers
                      If not None, this should be a format that would work with
                      docker -H
        output_dir: The directory to place artifacts in after the build

    Returns:
        The path to the artifact
    """
    release_version, release_timestamp = get_version_and_timestamp_from_release(release)
    image_tag = "buck:" + release_version
    nupkg_name = "buck.{}.nupkg".format(release_version)
    nupkg_path = os.path.join(output_dir, nupkg_name)

    # Get the changelog from github rather than locally
    changelog_path = os.path.join(
        "tools", "release", "platforms", "chocolatey", "Changelog.md"
    )
    changelog = release["body"].strip() or "Periodic release"

    with temp_move_file(changelog_path), temp_file_with_contents(
        changelog_path, changelog
    ):
        logging.info("Building windows docker image...")
        docker(
            windows_host,
            [
                "build",
                "-m",
                "2g",  # Default memory is 1G
                "-t",
                image_tag,
                "--build-arg",
                "version=" + release_version,
                "--build-arg",
                "timestamp=" + str(release_timestamp),
                "--build-arg",
                "repository=" + repository,
                "tools/release/platforms/chocolatey",
            ],
        )

    logging.info("Copying nupkg out of docker container")
    copy_from_docker_windows(windows_host, image_tag, "/src/buck.nupkg", nupkg_path)

    logging.info("Validating that .nupkg installs...")
    validate(windows_host, image_tag, nupkg_path)

    logging.info("Built .nupkg file at {}".format(nupkg_path))
    return nupkg_path
Beispiel #5
0
def build_bottle(
    homebrew_dir,
    release,
    repository,
    tap_repository,
    target_macos_version,
    target_macos_version_spec,
    output_dir,
):
    release_version, release_timestamp = get_version_and_timestamp_from_release(
        release)

    if not os.path.exists(os.path.join(homebrew_dir, "bin", "brew")):
        install_homebrew(homebrew_dir)
    setup_tap(homebrew_dir, tap_repository)
    formula_path = get_formula_path(homebrew_dir, tap_repository)
    tap_path = os.path.dirname(formula_path)

    # This is a wholly undocumented endpoint, but is not subject to ratelimiting
    # See https://github.com/facebook/homebrew-fb/pull/33
    undocumented_tarball_url = "https://github.com/{repository}/archive/{tag_name}.tar.gz".format(
        repository=repository, tag_name=release["tag_name"])
    tarball_sha256 = fetch_tarball_sha256(undocumented_tarball_url)

    # First, update the bottle to have the new version and tarball sha.
    update_formula_before_bottle(repository, release_version,
                                 release_timestamp, formula_path,
                                 tarball_sha256)

    # Build the actual bottle file
    bottle_path = build_bottle_file(
        homebrew_dir,
        tap_repository,
        tap_path,
        release_version,
        target_macos_version,
        output_dir,
    )

    # Get the bottle file sha, and update the bottle formula
    bottle_sha = get_sha256(bottle_path)
    update_formula_after_bottle(formula_path, bottle_sha,
                                target_macos_version_spec)

    # Make sure that we still pass `brew audit`
    audit_tap(homebrew_dir, tap_repository)

    return bottle_path
Beispiel #6
0
def build_bottle(
    homebrew_dir,
    release,
    repository,
    tap_repository,
    target_macos_version,
    target_macos_version_spec,
    output_dir,
):
    release_version, release_timestamp = get_version_and_timestamp_from_release(release)

    if not os.path.exists(os.path.join(homebrew_dir, "bin", "brew")):
        install_homebrew(homebrew_dir)
    setup_tap(homebrew_dir, tap_repository)
    formula_path = get_formula_path(homebrew_dir, tap_repository)
    tap_path = os.path.dirname(formula_path)

    # This is a wholly undocumented endpoint, but is not subject to ratelimiting
    # See https://github.com/facebook/homebrew-fb/pull/33
    undocumented_tarball_url = "https://github.com/{repository}/archive/{tag_name}.tar.gz".format(
        repository=repository, tag_name=release["tag_name"]
    )
    tarball_sha256 = fetch_tarball_sha256(undocumented_tarball_url)

    # First, update the bottle to have the new version and tarball sha.
    update_formula_before_bottle(
        repository, release_version, release_timestamp, formula_path, tarball_sha256
    )

    # Build the actual bottle file
    bottle_path = build_bottle_file(
        homebrew_dir,
        tap_repository,
        tap_path,
        release_version,
        target_macos_version,
        output_dir,
    )

    # Get the bottle file sha, and update the bottle formula
    bottle_sha = get_sha256(bottle_path)
    update_formula_after_bottle(formula_path, bottle_sha, target_macos_version_spec)

    # Make sure that we still pass `brew audit`
    audit_tap(homebrew_dir, tap_repository)

    return bottle_path
Beispiel #7
0
def build_bottle(
    homebrew_dir,
    release,
    tap_repository,
    target_macos_version,
    target_macos_version_spec,
    output_dir,
):
    release_version, release_timestamp = get_version_and_timestamp_from_release(
        release)

    if not os.path.exists(os.path.join(homebrew_dir, "bin", "brew")):
        install_homebrew(homebrew_dir)
    setup_tap(homebrew_dir, tap_repository)
    formula_path = get_formula_path(homebrew_dir, tap_repository)
    tap_path = os.path.dirname(formula_path)

    tarball_sha256 = fetch_tarball_sha256(release["tarball_url"])

    # First, update the bottle to have the new version and tarball sha.
    update_formula_before_bottle(release, release_version, release_timestamp,
                                 formula_path, tarball_sha256)

    # Build the actual bottle file
    bottle_path = build_bottle_file(
        homebrew_dir,
        tap_repository,
        tap_path,
        release_version,
        target_macos_version,
        output_dir,
    )

    # Get the bottle file sha, and update the bottle formula
    bottle_sha = get_sha256(bottle_path)
    update_formula_after_bottle(formula_path, bottle_sha,
                                target_macos_version_spec)

    return bottle_path
Beispiel #8
0
def build_bottle(
    homebrew_dir,
    release,
    tap_repository,
    target_macos_version,
    target_macos_version_spec,
    output_dir,
):
    release_version, release_timestamp = get_version_and_timestamp_from_release(release)

    if not os.path.exists(os.path.join(homebrew_dir, "bin", "brew")):
        install_homebrew(homebrew_dir)
    setup_tap(homebrew_dir, tap_repository)
    formula_path = get_formula_path(homebrew_dir, tap_repository)
    tap_path = os.path.dirname(formula_path)

    tarball_sha256 = fetch_tarball_sha256(release["tarball_url"])

    # First, update the bottle to have the new version and tarball sha.
    update_formula_before_bottle(
        release, release_version, release_timestamp, formula_path, tarball_sha256
    )

    # Build the actual bottle file
    bottle_path = build_bottle_file(
        homebrew_dir,
        tap_repository,
        tap_path,
        release_version,
        target_macos_version,
        output_dir,
    )

    # Get the bottle file sha, and update the bottle formula
    bottle_sha = get_sha256(bottle_path)
    update_formula_after_bottle(formula_path, bottle_sha, target_macos_version_spec)

    return bottle_path