2023-09-19 20:04:12 +02:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
# Build the package for Archlinux/openSUSE/Debian/Ubuntu
|
2024-02-07 00:16:21 +01:00
|
|
|
# Copyright (C) 2022-2024 Alexandre Pujol <alexandre@pujol.io>
|
2023-09-19 20:04:12 +02:00
|
|
|
# SPDX-License-Identifier: GPL-2.0-only
|
|
|
|
|
|
|
|
# Usage: make [ dpkg | pkg | rpm ]
|
|
|
|
|
|
|
|
set -eu -o pipefail
|
|
|
|
|
|
|
|
readonly COMMAND="$1"
|
2023-09-19 21:16:55 +02:00
|
|
|
readonly OUTPUT="${PKGDEST:-$PWD}"
|
2023-09-19 20:04:12 +02:00
|
|
|
readonly PKGNAME=apparmor.d
|
|
|
|
VERSION="0.$(git rev-list --count HEAD)"
|
|
|
|
readonly VERSION
|
|
|
|
|
|
|
|
main() {
|
|
|
|
case "$COMMAND" in
|
|
|
|
pkg)
|
2023-10-21 22:51:23 +02:00
|
|
|
PKGDEST="$OUTPUT" makepkg --syncdeps --force --cleanbuild --noconfirm --noprogressbar
|
2023-09-19 20:04:12 +02:00
|
|
|
;;
|
|
|
|
|
|
|
|
dpkg)
|
|
|
|
dch --newversion="$VERSION-1" --urgency=medium --distribution=stable --controlmaint "Release $VERSION-1"
|
|
|
|
dpkg-buildpackage -b -d --no-sign
|
2023-12-10 16:48:32 +01:00
|
|
|
mv ../"${PKGNAME}_${VERSION}-1"_*.deb "$OUTPUT"
|
2023-09-19 20:04:12 +02:00
|
|
|
;;
|
|
|
|
|
|
|
|
rpm)
|
|
|
|
RPMBUILD_ROOT=$(mktemp -d)
|
|
|
|
ARCH=$(uname -m)
|
2023-09-19 21:16:55 +02:00
|
|
|
readonly RPMBUILD_ROOT ARCH
|
2023-09-19 20:04:12 +02:00
|
|
|
|
|
|
|
mkdir -p "$RPMBUILD_ROOT"/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS/tmp}
|
|
|
|
cp -p "dists/$PKGNAME.spec" "$RPMBUILD_ROOT/SPECS"
|
|
|
|
tar -czf "$RPMBUILD_ROOT/SOURCES/$PKGNAME-$VERSION.tar.gz" --transform "s,^,$PKGNAME-$VERSION/," ./*
|
|
|
|
|
|
|
|
cd "$RPMBUILD_ROOT"
|
|
|
|
sed -i "s/^Version:.*/Version: $VERSION/" "SPECS/$PKGNAME.spec"
|
|
|
|
rpmbuild -bb --define "_topdir $RPMBUILD_ROOT" "SPECS/$PKGNAME.spec"
|
|
|
|
|
2023-09-19 21:16:55 +02:00
|
|
|
cp "$RPMBUILD_ROOT/RPMS/$ARCH/"*.rpm "$OUTPUT"
|
2023-09-19 20:04:12 +02:00
|
|
|
rm -rf "$RPMBUILD_ROOT"
|
|
|
|
;;
|
|
|
|
|
|
|
|
*) ;;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
|
|
|
main "$@"
|