ci: add rpm pkg build.

This commit is contained in:
Alexandre Pujol 2023-09-19 20:16:55 +01:00
parent 7f87b69bf7
commit 55d46631da
No known key found for this signature in database
GPG Key ID: C5469996F0DF68EC
2 changed files with 20 additions and 7 deletions

View File

@ -101,6 +101,18 @@ ubuntu:
variables:
DISTRIBUTION: ubuntu
opensuse:
stage: build
image: registry.gitlab.com/roddhjav/builders/opensuse
script:
- mkdir -p "$PKGDEST"
- sudo zypper install -y distribution-release golang-packaging rsync
- bash dists/build.sh rpm
artifacts:
expire_in: 1 day
paths:
- $PKGDEST/*.rpm
# Profile Preprocessing
# ---------------------
@ -140,10 +152,11 @@ preprocess-ubuntu:
preprocess-opensuse:
stage: preprocess
image: opensuse/tumbleweed
dependencies:
- opensuse
script:
- zypper install -y apparmor-profiles go git rsync util-linux findutils make
- make
- make install
- zypper install -y apparmor-profiles
- rpm -i $PKGDEST/*
- apparmor_parser --preprocess /etc/apparmor.d 1> /dev/null

View File

@ -8,6 +8,7 @@
set -eu -o pipefail
readonly COMMAND="$1"
readonly OUTPUT="${PKGDEST:-$PWD}"
readonly PKGNAME=apparmor.d
VERSION="0.$(git rev-list --count HEAD)"
readonly VERSION
@ -21,14 +22,13 @@ main() {
dpkg)
dch --newversion="$VERSION-1" --urgency=medium --distribution=stable --controlmaint "Release $VERSION-1"
dpkg-buildpackage -b -d --no-sign
mv ../"${PKGNAME}_${VERSION}-1"_*.deb .
mv ../"${PKGNAME}_${VERSION}-1"_*.deb "$OUTPUT"
;;
rpm)
RPMBUILD_ROOT=$(mktemp -d)
OUTPUT_DIR=$(pwd)
ARCH=$(uname -m)
readonly RPMBUILD_ROOT ARCH OUTPUT_DIR
readonly RPMBUILD_ROOT ARCH
mkdir -p "$RPMBUILD_ROOT"/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS/tmp}
cp -p "dists/$PKGNAME.spec" "$RPMBUILD_ROOT/SPECS"
@ -38,7 +38,7 @@ main() {
sed -i "s/^Version:.*/Version: $VERSION/" "SPECS/$PKGNAME.spec"
rpmbuild -bb --define "_topdir $RPMBUILD_ROOT" "SPECS/$PKGNAME.spec"
cp "$RPMBUILD_ROOT/RPMS/$ARCH/"*.rpm "$OUTPUT_DIR"
cp "$RPMBUILD_ROOT/RPMS/$ARCH/"*.rpm "$OUTPUT"
rm -rf "$RPMBUILD_ROOT"
;;