From 4f861158cf94510fc6a26b1704fd54ea98f8437f Mon Sep 17 00:00:00 2001 From: Alexandre Pujol Date: Mon, 7 Oct 2024 14:05:40 +0100 Subject: [PATCH] build: unify locally build package output directory. --- .gitlab-ci.yml | 2 +- Makefile | 3 +-- dists/build.sh | 2 +- dists/docker.sh | 10 ++++++---- tests/packer/builds.pkr.hcl | 6 +++--- 5 files changed, 12 insertions(+), 11 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1acf9151..a24ac797 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -4,7 +4,7 @@ include: - template: Security/SAST.gitlab-ci.yml variables: - PKGDEST: $CI_PROJECT_DIR/packages + PKGDEST: $CI_PROJECT_DIR/.pkg PACKAGER: 'Alexandre Pujol ' stages: diff --git a/Makefile b/Makefile index 9b25bb5e..8ee380ab 100644 --- a/Makefile +++ b/Makefile @@ -120,5 +120,4 @@ serve: clean: @rm -rf \ debian/.debhelper debian/debhelper* debian/*.debhelper debian/${PKGNAME} \ - ${PKGNAME}-*.pkg.tar.zst.sig ${PKGNAME}-*.pkg.tar.zst coverage.out \ - ${PKGNAME}_*.* ${PKGNAME}-*.rpm ${BUILD} + .pkg/${PKGNAME}* ${BUILD} coverage.out diff --git a/dists/build.sh b/dists/build.sh index a566291b..08d43a49 100644 --- a/dists/build.sh +++ b/dists/build.sh @@ -8,7 +8,7 @@ set -eu -o pipefail readonly COMMAND="$1" -readonly OUTPUT="${PKGDEST:-$PWD}" +readonly OUTPUT=".pkg" readonly PKGNAME=apparmor.d VERSION="0.$(git rev-list --count HEAD)" readonly VERSION diff --git a/dists/docker.sh b/dists/docker.sh index 500918c5..e0cb6443 100644 --- a/dists/docker.sh +++ b/dists/docker.sh @@ -12,6 +12,7 @@ readonly PREFIX="builder-" readonly PKGNAME=apparmor.d readonly VOLUME=/tmp/build readonly BUILDIR=/home/build/tmp +readonly OUTPUT=".pkg" readonly COMMAND="$1" VERSION="0.$(git rev-list --count HEAD)" PACKAGER="$(git config user.name) <$(git config user.email)>" @@ -62,7 +63,7 @@ build_in_docker_makepkg() { fi docker exec --workdir="$BUILDIR/$PKGNAME" "$img" bash dists/build.sh pkg - mv "$VOLUME/$PKGNAME"-*.pkg.* . + mv "$VOLUME/$PKGNAME"-*.pkg.* "$OUTPUT" } build_in_docker_dpkg() { @@ -85,7 +86,7 @@ build_in_docker_dpkg() { fi docker exec --workdir="$BUILDIR/$PKGNAME" "$img" bash dists/build.sh dpkg - mv "$VOLUME/$PKGNAME/${PKGNAME}_${VERSION}-1"_*.* . + mv "$VOLUME/$PKGNAME/${PKGNAME}_${VERSION}-1"_*.* "$OUTPUT" } build_in_docker_rpm() { @@ -104,14 +105,14 @@ build_in_docker_rpm() { fi docker exec --workdir="$BUILDIR/$PKGNAME" "$img" bash dists/build.sh rpm - mv "$VOLUME/$PKGNAME/$PKGNAME-$VERSION-"*.rpm . + mv "$VOLUME/$PKGNAME/$PKGNAME-$VERSION-"*.rpm "$OUTPUT" } main() { case "$COMMAND" in archlinux) # build_in_docker_makepkg "$COMMAND" - PKGDEST=. makepkg -Cf + PKGDEST="$OUTPUT" makepkg -Cf ;; debian | ubuntu | whonix) @@ -128,4 +129,5 @@ main() { esac } +mkdir -p "$OUTPUT" main "$@" diff --git a/tests/packer/builds.pkr.hcl b/tests/packer/builds.pkr.hcl index 33288e6b..c658a8bf 100644 --- a/tests/packer/builds.pkr.hcl +++ b/tests/packer/builds.pkr.hcl @@ -22,7 +22,7 @@ build { only = ["qemu.archlinux"] destination = "/tmp/src/" sources = [ - "${path.cwd}/../apparmor.d-${var.version}-1-x86_64.pkg.tar.zst", + "${path.cwd}/../.pkg/apparmor.d-${var.version}-1-x86_64.pkg.tar.zst", ] } @@ -61,12 +61,12 @@ build { } post-processor "vagrant" { - output = "${var.base_dir}/packer_${var.prefix}${source.name}.box" + output = "${var.base_dir}/packer_${var.prefix}${source.name}-${var.flavor}.box" } post-processor "shell-local" { inline = [ - "vagrant box add --force --name ${var.prefix}${source.name} ${var.base_dir}/packer_${var.prefix}${source.name}.box" + "vagrant box add --force --name ${var.prefix}${source.name}-${var.flavor} ${var.base_dir}/packer_${var.prefix}${source.name}-${var.flavor}.box" ] }