Skip to content

Commit

Permalink
feat(build): create debug symbols package
Browse files Browse the repository at this point in the history
  • Loading branch information
locao committed Aug 31, 2023
1 parent 443801f commit 3cf112e
Show file tree
Hide file tree
Showing 4 changed files with 170 additions and 5 deletions.
16 changes: 12 additions & 4 deletions .github/matrix-full.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,63 +10,71 @@ build-packages:
- label: ubuntu-20.04
image: ubuntu:20.04
package: deb
bazel-args: --//:debug_symbols_package=true
check-manifest-suite: ubuntu-20.04-amd64
- label: ubuntu-22.04
package: deb
bazel-args: --//:debug_symbols_package=true
check-manifest-suite: ubuntu-22.04-amd64
- label: ubuntu-22.04-arm64
package: deb
bazel-args: --platforms=//:generic-crossbuild-aarch64
bazel-args: --platforms=//:generic-crossbuild-aarch64 --//:debug_symbols_package=true
check-manifest-suite: ubuntu-22.04-arm64

# Debian
- label: debian-10
image: debian:10
package: deb
bazel-args: --//:debug_symbols_package=true
check-manifest-suite: debian-10-amd64
- label: debian-11
image: debian:11
package: deb
bazel-args: --//:debug_symbols_package=true
check-manifest-suite: debian-11-amd64

# RHEL
- label: rhel-7
image: centos:7
package: rpm
package-type: el7
bazel-args: --//:wasmx_el7_workaround=true
bazel-args: --//:wasmx_el7_workaround=true --//:debug_symbols_package=true
check-manifest-suite: el7-amd64
- label: rhel-8
image: rockylinux:8
package: rpm
package-type: el8
bazel-args: --//:debug_symbols_package=true
check-manifest-suite: el8-amd64
- label: rhel-9
image: rockylinux:9
package: rpm
package-type: el9
bazel-args: --//:debug_symbols_package=true
check-manifest-suite: el9-amd64
- label: rhel-9-arm64
package: rpm
package-type: el9
bazel-args: --platforms=//:rhel9-crossbuild-aarch64
bazel-args: --platforms=//:rhel9-crossbuild-aarch64 --//:debug_symbols_package=true
check-manifest-suite: el9-arm64

# Amazon Linux
- label: amazonlinux-2
image: amazonlinux:2
package: rpm
package-type: aws2
bazel-args: --//:debug_symbols_package=true
check-manifest-suite: amazonlinux-2-amd64
- label: amazonlinux-2023
image: amazonlinux:2023
package: rpm
package-type: aws2023
bazel-args: --//:debug_symbols_package=true
check-manifest-suite: amazonlinux-2023-amd64
- label: amazonlinux-2023-arm64
package: rpm
package-type: aws2023
bazel-args: --platforms=//:aws2023-crossbuild-aarch64
bazel-args: --platforms=//:aws2023-crossbuild-aarch64 --//:debug_symbols_package=true
check-manifest-suite: amazonlinux-2023-arm64

build-images:
Expand Down
91 changes: 91 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,83 @@ nfpm_pkg(
visibility = ["//visibility:public"],
)

#### debug package

nfpm_pkg(
name = "kong-debuginfo_deb",
config = "//build:package/nfpm-debuginfo.yaml",
env = nfpm_env,
packager = "deb",
pkg_name = "kong-debuginfo",
visibility = ["//visibility:public"],
)

nfpm_pkg(
name = "kong-debuginfo_apk",
config = "//build:package/nfpm-debuginfo.yaml",
env = nfpm_env,
packager = "apk",
pkg_name = "kong-debuginfo",
visibility = ["//visibility:public"],
)

nfpm_pkg(
name = "kong-debuginfo_el9",
config = "//build:package/nfpm-debuginfo.yaml",
env = nfpm_env,
packager = "rpm",
pkg_name = "kong-debuginfo.el9",
visibility = ["//visibility:public"],
)

nfpm_pkg(
name = "kong-debuginfo_el8",
config = "//build:package/nfpm-debuginfo.yaml",
env = nfpm_env,
packager = "rpm",
pkg_name = "kong-debuginfo.el8",
visibility = ["//visibility:public"],
)

nfpm_pkg(
name = "kong-debuginfo_el7",
config = "//build:package/nfpm-debuginfo.yaml",
env = nfpm_env,
extra_env = {
"RPM_EXTRA_DEPS": "hostname",
},
packager = "rpm",
pkg_name = "kong-debuginfo.el7",
visibility = ["//visibility:public"],
)

nfpm_pkg(
name = "kong-debuginfo_aws2",
config = "//build:package/nfpm-debuginfo.yaml",
env = nfpm_env,
extra_env = {
"RPM_EXTRA_DEPS": "/usr/sbin/useradd",
"RPM_EXTRA_DEPS_2": "/usr/sbin/groupadd",
},
packager = "rpm",
pkg_name = "kong-debuginfo.aws2",
visibility = ["//visibility:public"],
)

nfpm_pkg(
name = "kong-debuginfo_aws2023",
config = "//build:package/nfpm-debuginfo.yaml",
env = nfpm_env,
extra_env = {
"RPM_EXTRA_DEPS": "/usr/sbin/useradd",
"RPM_EXTRA_DEPS_2": "/usr/sbin/groupadd",
"RPM_EXTRA_DEPS_3": "libxcrypt-compat",
},
packager = "rpm",
pkg_name = "kong-debuginfo.aws2023",
visibility = ["//visibility:public"],
)

###### flags

# --//:debug=true
Expand Down Expand Up @@ -245,6 +322,20 @@ config_setting(
visibility = ["//visibility:public"],
)

# --//:debug_symbols_package=false
bool_flag(
name = "debug_symbols_package",
build_setting_default = False,
)

config_setting(
name = "debug_symbols_package_flag",
flag_values = {
":debug_symbols_package": "true",
},
visibility = ["//visibility:public"],
)

##### constraints, platforms and config_settings for cross-compile

constraint_setting(name = "cross_build_setting")
Expand Down
25 changes: 24 additions & 1 deletion build/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ load("//build:build_system.bzl", "kong_directory_genrule", "kong_rules_group", "

exports_files([
"package/nfpm.yaml",
"package/nfpm-debuginfo.yaml",
])

lib_deps = [
Expand Down Expand Up @@ -82,6 +83,26 @@ link_modules_dir = select({
"//conditions:default": "",
})

##### debug symbols
create_symbols_objects = select({
"@kong//:debug_symbols_package_flag": """
if [[ "$OSTYPE" == "linux"* ]]; then
mkdir -p ${BUILD_DESTDIR}/debug/openresty/nginx/modules ${BUILD_DESTDIR}/debug/openresty/lualib
objcopy --only-keep-debug ${BUILD_DESTDIR}/openresty/nginx/modules/ngx_wasm_module.so \
${BUILD_DESTDIR}/debug/openresty/nginx/modules/ngx_wasm_module.so.dbg
objcopy --only-keep-debug ${BUILD_DESTDIR}/openresty/lualib/libatc_router.so \
${BUILD_DESTDIR}/debug/openresty/lualib/libatc_router.so.dbg
objcopy --strip-unneeded ${BUILD_DESTDIR}/openresty/nginx/modules/ngx_wasm_module.so
objcopy --strip-unneeded ${BUILD_DESTDIR}/openresty/lualib/libatc_router.so
objcopy --add-gnu-debuglink=${BUILD_DESTDIR}/debug/openresty/nginx/modules/ngx_wasm_module.so.dbg \
${BUILD_DESTDIR}/openresty/nginx/modules/ngx_wasm_module.so
objcopy --add-gnu-debuglink=${BUILD_DESTDIR}/debug/openresty/lualib/libatc_router.so.dbg \
${BUILD_DESTDIR}/openresty/lualib/libatc_router.so
fi
""",
"//conditions:default": "",
})

kong_directory_genrule(
name = "kong",
srcs = [
Expand Down Expand Up @@ -145,10 +166,12 @@ kong_directory_genrule(
ATC_ROUTER=${WORKSPACE_PATH}/$(location @atc_router)
cp $ATC_ROUTER ${BUILD_DESTDIR}/openresty/lualib/.
chmod -R "+rw" ${BUILD_DESTDIR}/openresty/lualib
cp -r $(locations @protoc//:all_srcs) ${BUILD_DESTDIR}/kong/.
""" + install_lib_deps_cmd + install_lualib_deps_cmd + install_webui_cmd + link_modules_dir + install_wasm_deps_cmd + """
""" + install_lib_deps_cmd + install_lualib_deps_cmd + install_webui_cmd +
create_symbols_objects + link_modules_dir + install_wasm_deps_cmd + """
mkdir -p ${BUILD_DESTDIR}/etc/kong
cp kong.conf.default ${BUILD_DESTDIR}/etc/kong/kong.conf.default
Expand Down
43 changes: 43 additions & 0 deletions build/package/nfpm-debuginfo.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: "${KONG_NAME}-debuginfo"
arch: ${ARCH}
platform: "linux"
version: "${KONG_VERSION}"
section: "default"
priority: "extra"
provides:
- kong-debuginfo
maintainer: "Kong Inc. <[email protected]>"
description: |
This package provides debug information for package kong. Kong is a distributed gateway for APIs and Microservices, focused on high performance and reliability.
vendor: "Kong Inc."
license: "Apache-2.0"
contents:
- src: nfpm-prefix/debug/openresty
dst: /usr/local/openresty
replaces:
- ${KONG_REPLACES_1}
- ${KONG_REPLACES_2}
conflicts:
- ${KONG_CONFLICTS_1}
- ${KONG_CONFLICTS_2}
overrides:
deb:
depends:
- kong
rpm:
depends:
- kong
# Workaround for https://github.com/goreleaser/nfpm/issues/589
- ${RPM_EXTRA_DEPS}
- ${RPM_EXTRA_DEPS_2}
- ${RPM_EXTRA_DEPS_3}
apk:
depends:
- kong

rpm:
signature:
# PGP secret key (can also be ASCII-armored), the passphrase is taken
# from the environment variable $NFPM_RPM_PASSPHRASE with a fallback
# to $NFPM_PASSPHRASE.
key_file: ${RPM_SIGNING_KEY_FILE}

0 comments on commit 3cf112e

Please sign in to comment.