build: add support for various version in OCI based package build.

This commit is contained in:
Alexandre Pujol 2025-04-04 21:52:44 +02:00
parent 49a2a21c11
commit b9ec70b8bb
No known key found for this signature in database
GPG key ID: C5469996F0DF68EC
3 changed files with 27 additions and 17 deletions

View file

@ -163,12 +163,18 @@ clean:
[doc('Build the apparmor.d package')]
package dist:
#!/usr/bin/env bash
set -eu -o pipefail
dist="{{dist}}"
[[ $dist =~ ubuntu* ]] && dist=ubuntu
[[ $dist =~ debian* ]] && dist=debian
bash dists/docker.sh $dist
#!/usr/bin/env bash
set -eu -o pipefail
dist="{{dist}}"
version=""
if [[ $dist =~ ubuntu([0-9]+) ]]; then
version="${BASH_REMATCH[1]}.04"
dist="ubuntu"
elif [[ $dist =~ debian([0-9]+) ]]; then
version="${BASH_REMATCH[1]}"
dist="debian"
fi
bash dists/docker.sh $dist $version
[doc('Build the image')]
img dist flavor: (package dist)

View file

@ -55,7 +55,7 @@ func init() {
case "debian":
switch prebuild.Release["VERSION_CODENAME"] {
case "bookworm":
case "bullseye", "bookworm":
prebuild.ABI = 3
prebuild.Version = 3.0
case "trixie", "sid":

View file

@ -3,7 +3,7 @@
# Copyright (C) 2022-2024 Alexandre Pujol <alexandre@pujol.io>
# SPDX-License-Identifier: GPL-2.0-only
# Usage: make package dist=<distribution>
# Usage: make package dist=<distribution> version=<version>
set -eu -o pipefail
@ -14,7 +14,8 @@ readonly VOLUME=/tmp/build
readonly BUILDIR=/home/build/tmp
readonly OUTDIR=".pkg"
readonly OUTPUT="$PWD/$OUTDIR"
readonly COMMAND="${1:-}"
readonly DISTRIBUTION="${1:-}"
readonly RELEASE="${2:-}"
VERSION="0.$(git rev-list --count HEAD)"
PACKAGER="$(git config user.name) <$(git config user.email)>"
readonly VERSION PACKAGER
@ -68,21 +69,24 @@ build_in_docker_makepkg() {
}
build_in_docker_dpkg() {
local dist="$1" target="$1"
local img="$PREFIX$dist"
local img dist="$1" target="$1" release="$2"
[[ "$dist" == whonix ]] && dist=debian
[[ "$release" == "13" ]] && release=trixie
img="$PREFIX$dist$release"
if _exist "$img"; then
if ! _is_running "$img"; then
_start "$img"
fi
else
docker pull "$BASEIMAGE/$dist"
docker pull "$BASEIMAGE/$dist:$release"
docker run -tid --name "$img" --volume "$VOLUME:$BUILDIR" \
--env DISTRIBUTION="$target" "$BASEIMAGE/$dist"
--env DISTRIBUTION="$target" "$BASEIMAGE/$dist:$release"
docker exec "$img" sudo apt-get update -q
docker exec "$img" sudo apt-get install -y config-package-dev lsb-release libdistro-info-perl
[[ "$dist" == debian ]] && aptopt=(-t bookworm-backports)
if [[ "$dist" == debian && "$release" == "12" ]]; then
aptopt=(-t bookworm-backports)
fi
docker exec "$img" sudo apt-get install -y "${aptopt[@]}" golang-go
fi
@ -110,7 +114,7 @@ build_in_docker_rpm() {
}
main() {
case "$COMMAND" in
case "$DISTRIBUTION" in
archlinux)
# build_in_docker_makepkg "$COMMAND"
PKGDEST="$OUTPUT" makepkg -Cf
@ -118,12 +122,12 @@ main() {
debian | ubuntu | whonix)
sync
build_in_docker_dpkg "$COMMAND"
build_in_docker_dpkg "$DISTRIBUTION" "$RELEASE"
;;
opensuse)
sync
build_in_docker_rpm "$COMMAND"
build_in_docker_rpm "$DISTRIBUTION"
;;
*) ;;