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"
|
2024-10-09 14:31:57 +02:00
|
|
|
readonly OUTPUT="$PWD/.pkg"
|
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
|
2024-03-06 13:51:08 +01:00
|
|
|
lintian || true
|
2023-12-10 16:48:32 +01:00
|
|
|
mv ../"${PKGNAME}_${VERSION}-1"_*.deb "$OUTPUT"
|
2023-09-19 20:04:12 +02:00
|
|
|
;;
|
|
|
|
|
|
|
|
rpm)
|
2024-03-17 22:34:06 +01:00
|
|
|
RPMBUILD_ROOT=$(mktemp -d /tmp/$PKGNAME.XXXXXX)
|
2023-09-19 20:04:12 +02:00
|
|
|
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"
|
|
|
|
|
2024-03-17 22:34:06 +01:00
|
|
|
mv "$RPMBUILD_ROOT/RPMS/$ARCH/"*.rpm "$OUTPUT"
|
2023-09-19 20:04:12 +02:00
|
|
|
rm -rf "$RPMBUILD_ROOT"
|
|
|
|
;;
|
|
|
|
|
|
|
|
*) ;;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
2024-03-20 01:05:30 +01:00
|
|
|
mkdir -p "$OUTPUT"
|
2023-09-19 20:04:12 +02:00
|
|
|
main "$@"
|