Skip to content
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions .azure-pipelines/pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,74 @@ stages:
artifactSuffix: ".arm64"
bazelBuildExtraOptions: "--sandbox_base=/tmp/sandbox_base"

- stage: distribution
dependsOn: ["linux_arm64", "linux_x64"]
jobs:
- job: package_x64
dependsOn: []
timeoutInMinutes: 120
pool:
vmImage: "ubuntu-18.04"
steps:
- template: bazel.yml
parameters:
ciTarget: bazel.distribution
- job: package_arm64
dependsOn: []
timeoutInMinutes: 120
pool: "arm-large"
steps:
- template: bazel.yml
parameters:
managedAgent: false
ciTarget: bazel.distribution
rbe: false
artifactSuffix: ".arm64"
bazelBuildExtraOptions: "--sandbox_base=/tmp/sandbox_base"
- job: verify_x64
dependsOn: ["package_x64"]
timeoutInMinutes: 120
pool:
vmImage: "ubuntu-18.04"
steps:
- task: DownloadBuildArtifacts@0
inputs:
buildType: current
artifactName: "bazel.distribution"
itemPattern: "bazel.distribution/packages.x64.tar.gz"
downloadType: single
targetPath: $(Build.StagingDirectory)
- script: ci/run_envoy_docker.sh 'ci/do_ci.sh verify_distro'
workingDirectory: $(Build.SourcesDirectory)
env:
AZP_BRANCH: $(Build.SourceBranch)
ENVOY_DOCKER_BUILD_DIR: $(Build.StagingDirectory)
BAZEL_REMOTE_CACHE: grpcs://remotebuildexecution.googleapis.com
BAZEL_REMOTE_INSTANCE: projects/envoy-ci/instances/default_instance
GCP_SERVICE_ACCOUNT_KEY: $(GcpServiceAccountKey)
displayName: "Verify packages"
- job: verify_arm64
dependsOn: ["package_arm64"]
timeoutInMinutes: 120
pool: "arm-large"
steps:
- task: DownloadBuildArtifacts@0
inputs:
buildType: current
artifactName: "bazel.distribution.arm64"
itemPattern: "bazel.distribution.arm64/packages.arm64.tar.gz"
downloadType: single
targetPath: $(Build.StagingDirectory)
- script: ci/run_envoy_docker.sh 'ci/do_ci.sh verify_distro'
workingDirectory: $(Build.SourcesDirectory)
env:
AZP_BRANCH: $(Build.SourceBranch)
ENVOY_DOCKER_BUILD_DIR: $(Build.StagingDirectory)
BAZEL_REMOTE_CACHE: grpcs://remotebuildexecution.googleapis.com
BAZEL_REMOTE_INSTANCE: projects/envoy-ci/instances/default_instance
GCP_SERVICE_ACCOUNT_KEY: $(GcpServiceAccountKey)
displayName: "Verify packages"

- stage: check
dependsOn: ["linux_x64"]
jobs:
Expand Down
6 changes: 3 additions & 3 deletions bazel/repository_locations.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -680,12 +680,12 @@ REPOSITORY_LOCATIONS_SPEC = dict(
project_name = "Packaging rules for Bazel",
project_desc = "Bazel rules for the packaging distributions",
project_url = "https://github.com/bazelbuild/rules_pkg",
version = "e5d1ed4e23b291073d8a9058a671a1bd9664f230",
sha256 = "c76ca18f745673b8c2a7bbe867893ffb252c6bebf91f9a1eee15cfa054957ea7",
version = "62b1443f4f92cb2bfd81c47ed155e86cc6854786",
sha256 = "f9b0592eb1d4c0c7505f00f457a3e913fd483cc08bcca4c47cc7080c0894684a",
strip_prefix = "rules_pkg-{version}",
urls = ["https://github.com/bazelbuild/rules_pkg/archive/{version}.tar.gz"],
use_category = ["build"],
release_date = "2021-12-15",
release_date = "2022-01-29",
),
org_llvm_llvm = dict(
# When changing this, you must re-generate the list of llvm libs
Expand Down
37 changes: 35 additions & 2 deletions ci/do_ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ set -e

build_setup_args=""
if [[ "$1" == "format_pre" || "$1" == "fix_format" || "$1" == "check_format" || "$1" == "docs" || \
"$1" == "bazel.clang_tidy" || "$1" == "tooling" || "$1" == "deps" || "$1" == "verify_examples" || \
"$1" == "verify_build_examples" ]]; then
"$1" == "bazel.clang_tidy" || "$1" == "bazel.distribution" || "$1" == "tooling" \
|| "$1" == "deps" || "$1" == "verify_examples" || "$1" == "verify_build_examples" \
|| "$1" == "verify_distro" ]]; then
build_setup_args="-nofetch"
fi

Expand Down Expand Up @@ -214,6 +215,30 @@ if [[ "$CI_TARGET" == "bazel.release" ]]; then
echo "bazel contrib release build..."
bazel_contrib_binary_build release

exit 0
elif [[ "$CI_TARGET" == "bazel.distribution" ]]; then
echo "Building distro packages..."

setup_clang_toolchain

# By default the packages will be signed by the first available key.
# If there is no key available, a throwaway key is created
# and the packages signed with it, for the purpose of testing only.
if ! gpg --list-secret-keys "*"; then
Comment thread
phlax marked this conversation as resolved.
export PACKAGES_MAINTAINER_NAME="Envoy CI"
export PACKAGES_MAINTAINER_EMAIL="envoy@snake.oil"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it real mail? I do not see it in the doc.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is not - and is intended to denote that - perhaps this could be more explicit in some way

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BAZEL_BUILD_OPTIONS+=(
"--action_env=PACKAGES_GEN_KEY=1"
"--action_env=PACKAGES_MAINTAINER_NAME"
"--action_env=PACKAGES_MAINTAINER_EMAIL")
fi

bazel build "${BAZEL_BUILD_OPTIONS[@]}" -c opt //distribution:packages.tar.gz
if [[ "${ENVOY_BUILD_ARCH}" == "x86_64" ]]; then
cp -a bazel-bin/distribution/packages.tar.gz "${ENVOY_BUILD_DIR}/packages.x64.tar.gz"
else
cp -a bazel-bin/distribution/packages.tar.gz "${ENVOY_BUILD_DIR}/packages.arm64.tar.gz"
fi
exit 0
elif [[ "$CI_TARGET" == "bazel.release.server_only" ]]; then
setup_clang_toolchain
Expand Down Expand Up @@ -485,6 +510,14 @@ elif [[ "$CI_TARGET" == "tooling" ]]; then
elif [[ "$CI_TARGET" == "verify_examples" ]]; then
run_ci_verify "*" "wasm-cc|win32-front-proxy"
exit 0
elif [[ "$CI_TARGET" == "verify_distro" ]]; then
if [[ "${ENVOY_BUILD_ARCH}" == "x86_64" ]]; then
PACKAGE_BUILD=/build/bazel.distribution/packages.x64.tar.gz
else
PACKAGE_BUILD=/build/bazel.distribution.arm64/packages.arm64.tar.gz
fi
bazel run "${BAZEL_BUILD_OPTIONS[@]}" //distribution:verify_packages "$PACKAGE_BUILD"
exit 0
elif [[ "$CI_TARGET" == "verify_build_examples" ]]; then
run_ci_verify wasm-cc
exit 0
Expand Down
47 changes: 47 additions & 0 deletions distribution/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
load("//bazel:envoy_build_system.bzl", "envoy_package")
load(":packages.bzl", "envoy_pkg_distros")
load("@envoy_repo//:version.bzl", "VERSION")

licenses(["notice"]) # Apache 2

envoy_package()

MAINTAINER = "Envoy maintainers <envoy-maintainers@googlegroups.com>"

genrule(
name = "envoy-bin",
srcs = ["//source/exe:envoy-static.stripped"],
outs = ["envoy"],
cmd = "cp -L $< $@",
)

envoy_pkg_distros(
name = "packages",
maintainer = MAINTAINER,
version = VERSION,
)

genrule(
name = "verification",
outs = ["verification.sh"],
cmd = """
echo 'exec $${@}' > $@ \
&& chmod +x $@
""",
)

sh_binary(
name = "verify_packages",
Comment thread
phlax marked this conversation as resolved.
srcs = [":verification.sh"],
args = [
"$(location //tools/distribution:verify)",
"$(location :distrotest.sh)",
VERSION,
"$(location :distros.yaml)",
],
data = [
":distros.yaml",
":distrotest.sh",
"//tools/distribution:verify",
],
)
11 changes: 11 additions & 0 deletions distribution/debian/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
load("//bazel:envoy_build_system.bzl", "envoy_package")

licenses(["notice"]) # Apache 2

envoy_package()

exports_files([
"copyright",
"preinst",
"postinst",
])
8 changes: 8 additions & 0 deletions distribution/debian/copyright
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: Envoy
Source: <https://github.com/envoyproxy/envoy>

Files: *
Copyright: Copyright 2016-2018 Envoy Project Authors
License: Apache
/usr/share/common-licenses/Apache-2.0
102 changes: 102 additions & 0 deletions distribution/debian/packages.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
load("@rules_pkg//pkg:pkg.bzl", "pkg_tar")
load("@rules_pkg//pkg:deb.bzl", "pkg_deb")

GLIBC_MIN_VERSION = "2.27"

def envoy_pkg_deb(
name,
data,
homepage = "https://www.envoyproxy.io/",
description = "Envoy built for Debian/Ubuntu",
preinst = "//distribution/debian:preinst",
postinst = "//distribution/debian:postinst",
supported_distributions = "buster bullseye bionic focal hirstute impish",

@phlax phlax Dec 17, 2021

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add a note about ensuring these match distros.yaml

Comment thread
phlax marked this conversation as resolved.
Outdated
architecture = select({
"//bazel:x86": "amd64",
"//conditions:default": "arm64",
}),
depends = [
"libc6 (>= %s)" % GLIBC_MIN_VERSION,
],
version = None,
maintainer = None,
**kwargs):
"""Wrapper for `pkg_deb` with Envoy defaults"""
pkg_deb(
name = "%s-deb" % name,
architecture = architecture,
data = data,
depends = depends,
description = description,
distribution = supported_distributions,
homepage = homepage,
maintainer = maintainer,
package = name,
version = version,
preinst = preinst,
postinst = postinst,
**kwargs
)

native.filegroup(
name = "%s.changes" % name,
srcs = ["%s-deb" % name],
output_group = "changes",
)
native.filegroup(
name = "%s.deb" % name,
srcs = ["%s-deb" % name],
output_group = "deb",
)

def envoy_pkg_debs(name, version, release_version, maintainer, bin_files = ":envoy-bin-files", config = ":envoy-config"):
"""Package the Envoy .debs with their .changes files.

Packages are created for the version *and* the release version, eg

- envoy_1.21.0_amd64.deb
- envoy-1.21_1.21.0_amd64.deb

This way packages are available for both "envoy" and "envoy-1.21" in package managers.
"""

# generate deb data for all packages
pkg_tar(
name = "deb-data",
srcs = [
"//distribution/debian:copyright",
config,
bin_files,
],
remap_paths = {"/copyright": "/usr/share/doc/envoy/copyright"},
)

# generate package for this patch version
envoy_pkg_deb(
name = "envoy",
data = ":deb-data",
version = version,
maintainer = maintainer,
)

# generate package for this minor version
envoy_pkg_deb(
name = "envoy-%s" % release_version,
data = ":deb-data",
version = version,
conflicts = ["envoy"],
provides = ["envoy"],
maintainer = maintainer,
)

pkg_tar(
name = name,
srcs = [
"envoy.changes",
"envoy.deb",
"envoy-%s.changes" % release_version,
"envoy-%s.deb" % release_version,
],
extension = "tar",
package_dir = "deb",
)
42 changes: 42 additions & 0 deletions distribution/debian/postinst
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/sh

# postinst script for envoy

set -e

case "$1" in

configure)
cat <<BANNER

You have installed the Envoy proxy server.

You can check your Envoy version by running the following in a terminal:

$ envoy --version

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add info about running as envoy user


Documentation for your version is available at:

https://www.envoyproxy.io/docs

The Envoy project can be found at:

https://github.com/envoyproxy/envoy

BANNER
;;

abort-upgrade|abort-remove|abort-deconfigure)
exit 0
;;

*)
echo "postinst called with unknown argument \`$1'" >&2
exit 1
;;

esac

#DEBHELPER#

exit 0
Loading