Add multi-package Alpine packaging
This commit is contained in:
28
packaging/alpine/blueprint/APKBUILD
Normal file
28
packaging/alpine/blueprint/APKBUILD
Normal file
@@ -0,0 +1,28 @@
|
||||
# Maintainer: Your Name <you@example.com>
|
||||
pkgname=example-package
|
||||
pkgver=0.1.0
|
||||
pkgrel=0
|
||||
pkgdesc="Short package description"
|
||||
url="https://example.com/example-package"
|
||||
arch="x86_64 aarch64"
|
||||
license="Apache-2.0"
|
||||
depends=""
|
||||
makedepends="build-base"
|
||||
subpackages="$pkgname-doc"
|
||||
source="$pkgname-$pkgver.tar.gz::https://example.com/releases/$pkgver.tar.gz"
|
||||
builddir="$srcdir/$pkgname-$pkgver"
|
||||
|
||||
build() {
|
||||
make
|
||||
}
|
||||
|
||||
check() {
|
||||
make check
|
||||
}
|
||||
|
||||
package() {
|
||||
install -Dm755 "$builddir"/example-package "$pkgdir"/usr/bin/example-package
|
||||
}
|
||||
|
||||
sha512sums="
|
||||
"
|
||||
26
packaging/alpine/blueprint/README.md
Normal file
26
packaging/alpine/blueprint/README.md
Normal file
@@ -0,0 +1,26 @@
|
||||
# Alpine Package Blueprint
|
||||
|
||||
Copy this directory to `packaging/alpine/local/<pkgname>/` and replace the
|
||||
placeholder values before building.
|
||||
|
||||
Required:
|
||||
|
||||
- `APKBUILD`
|
||||
|
||||
Optional package-local hooks:
|
||||
|
||||
- `scripts/test-install.sh` validates README-style installation instructions.
|
||||
- `scripts/update-generated-sources.sh` refreshes generated files that are
|
||||
listed in `source=`.
|
||||
|
||||
Repo-level tasks discover packages from `packaging/alpine/local/*/APKBUILD`.
|
||||
Limit a task to one or more packages with:
|
||||
|
||||
```sh
|
||||
ALPINE_PACKAGE=<pkgname> mise run apk:build
|
||||
ALPINE_PACKAGES="<pkg-a> <pkg-b>" mise run apk:build-all
|
||||
ALPINE_PACKAGE=<pkgname> mise run apk:test-install
|
||||
```
|
||||
|
||||
For compiled software, put normal Alpine build logic in `build()`, `check()`,
|
||||
and `package()` and declare build tools in `makedepends`.
|
||||
41
packaging/alpine/blueprint/scripts/test-install.sh
Executable file
41
packaging/alpine/blueprint/scripts/test-install.sh
Executable file
@@ -0,0 +1,41 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
repo_root="${REPO_ROOT:-$(cd "$(dirname "${BASH_SOURCE[0]}")/../../../../.." && pwd)}"
|
||||
package_name="${PACKAGE_NAME:-$(basename "$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)")}"
|
||||
alpine_version="${ALPINE_VERSION:-3.23}"
|
||||
arch="${ALPINE_ARCH:-x86_64}"
|
||||
|
||||
case "${arch}" in
|
||||
x86_64)
|
||||
platform="${ALPINE_TEST_PLATFORM:-linux/amd64}"
|
||||
;;
|
||||
aarch64)
|
||||
platform="${ALPINE_TEST_PLATFORM:-linux/arm64}"
|
||||
;;
|
||||
*)
|
||||
printf 'unsupported Alpine architecture: %s\n' "${arch}" >&2
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
|
||||
if [[ "${SKIP_BUILD:-0}" != "1" ]]; then
|
||||
ALPINE_PACKAGE="${package_name}" "${repo_root}/scripts/apk/build.sh" build "${arch}"
|
||||
fi
|
||||
|
||||
docker run --rm --platform "${platform}" \
|
||||
-e "ALPINE_ARCH=${arch}" \
|
||||
-e "PACKAGE_NAME=${package_name}" \
|
||||
-v "${repo_root}/packages/local:/repo:ro" \
|
||||
"alpine:${alpine_version}" \
|
||||
sh -lc '
|
||||
set -e
|
||||
|
||||
cp "/repo/${ALPINE_ARCH}"/*.rsa.pub /etc/apk/keys/
|
||||
printf "%s\n" /repo >> /etc/apk/repositories
|
||||
apk update
|
||||
apk add "${PACKAGE_NAME}"
|
||||
|
||||
# Replace these with package-specific install assertions.
|
||||
apk info -e "${PACKAGE_NAME}"
|
||||
'
|
||||
6
packaging/alpine/blueprint/scripts/update-generated-sources.sh
Executable file
6
packaging/alpine/blueprint/scripts/update-generated-sources.sh
Executable file
@@ -0,0 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
package_dir="${PACKAGE_DIR:-$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)}"
|
||||
|
||||
printf 'No generated sources for %s\n' "${package_dir}"
|
||||
Reference in New Issue
Block a user