-
Notifications
You must be signed in to change notification settings - Fork 89
feat(packaging): add universal package build scripts for deb, rpm, and apk #1996
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
jackluo923
wants to merge
10
commits into
y-scope:main
Choose a base branch
from
jackluo923:feat/universal-packages
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 4 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
2c92e41
feat(packaging): add universal package build scripts for deb, rpm, an…
jackluo923 acf9bcf
Merge branch 'main' into feat/universal-packages
jackluo923 4e6444d
fix(packaging): address code review feedback
jackluo923 c006d82
style(packaging): use long-form flags for less common options
jackluo923 f434f68
fix(packaging): address second round of review feedback
jackluo923 b3d809c
fix(packaging): address third round of review feedback
jackluo923 73a8075
fix(packaging): address fourth round of review feedback
jackluo923 17af79b
Merge branch 'main' into feat/universal-packages
jackluo923 ce6f8bd
Merge branch 'main' into feat/universal-packages
jackluo923 4d0f18d
Merge branch 'main' into feat/universal-packages
jackluo923 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| # syntax=docker/dockerfile:1 | ||
| # | ||
| # Extends the CLP musllinux_1_2 build image with tools needed for .apk | ||
| # packaging: patchelf (to rewrite RPATH) and alpine-sdk (for abuild). | ||
| # | ||
| # Usage: | ||
| # docker build --build-arg BASE_IMAGE=clp-core-dependencies-x86-musllinux_1_2:dev ... | ||
|
|
||
| ARG BASE_IMAGE | ||
| FROM ${BASE_IMAGE} | ||
|
|
||
| RUN apk add --no-cache patchelf alpine-sdk |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,110 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| # Creates an Alpine .apk package from pre-built CLP core binaries. | ||
| # | ||
| # This script runs INSIDE the apk-builder container as root. It calls | ||
| # bundle-libs.sh to collect and patch binaries, then uses abuild to create | ||
| # a properly formatted .apk package. | ||
| # | ||
| # The resulting package is built on musllinux_1_2 (musl libc), making it | ||
| # compatible with Alpine Linux 3.20+. | ||
| # | ||
| # Required environment variables: | ||
| # PKG_VERSION Package version (e.g., "0.9.1" or "0.9.1-20260214.5f1d7ca") | ||
| # PKG_ARCH Target APK architecture: x86_64 or aarch64 | ||
| # BIN_DIR Path to the directory containing compiled binaries | ||
| # | ||
| # Optional environment variables: | ||
| # OUTPUT_DIR Where to write the .apk file (default: current directory) | ||
|
|
||
| set -o errexit | ||
| set -o nounset | ||
| set -o pipefail | ||
|
|
||
| script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd)" | ||
|
|
||
| # --- Validate inputs -------------------------------------------------------- | ||
|
|
||
| if [[ -z "${PKG_VERSION:-}" ]]; then | ||
| echo "ERROR: PKG_VERSION is required" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| if [[ -z "${PKG_ARCH:-}" ]]; then | ||
| echo "ERROR: PKG_ARCH is required" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| if [[ -z "${BIN_DIR:-}" ]]; then | ||
| echo "ERROR: BIN_DIR is required" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| output_dir="${OUTPUT_DIR:-$(pwd)}" | ||
| staging="/tmp/clp-apk-staging" | ||
|
|
||
| # APK version: hyphens are invalid and underscore suffixes must use a recognized | ||
| # tag (_alpha, _beta, _pre, _rc, _git, etc.) followed by digits only. We use | ||
| # _git with the date; the commit hash is stored in pkgdesc since apk versions | ||
| # don't allow hex characters. | ||
| # E.g., "0.9.1-20260214.5f1d7ca" -> pkgver=0.9.1_git20260214, hash in pkgdesc | ||
| apk_desc="CLP core universal binaries for log compression and search" | ||
| if [[ "${PKG_VERSION}" == *-* ]]; then | ||
| base_version="${PKG_VERSION%%-*}" | ||
| snapshot_suffix="${PKG_VERSION#*-}" | ||
| snapshot_date="${snapshot_suffix%%.*}" | ||
| snapshot_hash="${snapshot_suffix#*.}" | ||
| apk_version="${base_version}_git${snapshot_date}" | ||
| apk_desc="${apk_desc} (commit: ${snapshot_hash})" | ||
| else | ||
| apk_version="${PKG_VERSION}" | ||
| fi | ||
|
|
||
| # --- Bundle binaries and libraries ------------------------------------------ | ||
|
|
||
| STAGING_DIR="${staging}" \ | ||
| BIN_DIR="${BIN_DIR}" \ | ||
| "${script_dir}/../common/bundle-libs.sh" | ||
|
|
||
| # --- Build .apk via abuild ------------------------------------------------- | ||
|
|
||
| abuild_dir="/tmp/clp-abuild" | ||
| rm -rf "${abuild_dir}" | ||
| mkdir -p "${abuild_dir}" | ||
|
|
||
| # abuild requires a signing key; add it to trusted keys so the post-build | ||
| # repository index step succeeds. | ||
| abuild-keygen -an 2>/dev/null || true | ||
| cp /root/.abuild/*.rsa.pub /etc/apk/keys/ 2>/dev/null || true | ||
|
|
||
| # Create APKBUILD that copies our pre-bundled staging directory | ||
| cat > "${abuild_dir}/APKBUILD" <<APKBUILD | ||
| # Maintainer: YScope Inc. <support@yscope.com> | ||
| pkgname=clp-core | ||
| pkgver=${apk_version} | ||
| pkgrel=0 | ||
| pkgdesc="${apk_desc}" | ||
| url="https://github.com/y-scope/clp" | ||
| arch="${PKG_ARCH}" | ||
| license="Apache-2.0" | ||
| depends="musl libstdc++" | ||
| source="" | ||
| options="!check !strip" | ||
|
|
||
| package() { | ||
| mkdir -p "\${pkgdir}/usr" | ||
| cp -a "${staging}"/* "\${pkgdir}"/ | ||
| } | ||
| APKBUILD | ||
|
|
||
| echo "==> Building apk package..." | ||
|
|
||
| cd "${abuild_dir}" | ||
| # -F: force (allows running as root, skips fakeroot) | ||
| # -d: disable dependency checking | ||
| # -P: set PKGDEST (where the .apk is written) | ||
| abuild -F checksum | ||
| abuild -F -d -P "/tmp/clp-apk-out" | ||
|
|
||
| # Copy the built package to the output directory | ||
| find /tmp/clp-apk-out -name "*.apk" -exec cp {} "${output_dir}/" \; | ||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.