misc: Add mkosi based package building with fpm

Building distro packages is great, however if they aren't built in the
correct environment with the associated dependencies, then they won't
work properly on those distros.

This patch adds an `mkosi` based image building environment that builds
the packages in their respective distros, and then copies them out into
our releases directory.

You'll now want to `make tag && make mkosi && make release` to get a new
release out. We use a small hack to trick the `make release` portion to
not re-build the distro packages if they're already present in the
releases/ directory for that version.

This commit depends on a very recent version of mkosi (it was tested
with git master) and also depends on two currently unmerged patches:
https://github.com/systemd/mkosi/pull/363 and
https://github.com/systemd/mkosi/pull/365
This commit is contained in:
James Shubin
2019-09-14 21:39:25 -04:00
parent 9dae5ef83b
commit a4db9fc8e5
10 changed files with 393 additions and 4 deletions

View File

@@ -43,11 +43,37 @@ if [ "$VERSION" != "$TAG" ]; then
fi
# make sure the package type is valid
if [ "$1" != "deb" ] && [ "$1" != "rpm" ] && [ "$1" != "pacman" ]; then
if [ "$1" != "rpm" ] && [ "$1" != "deb" ] && [ "$1" != "pacman" ]; then
echo "invalid package type"
exit 1
fi
# don't run if the file already exists (bad idempotent implementation)
if [ -d "${DIR}/${VERSION}/${1}/" ]; then
if [ "$1" = "rpm" ]; then
if ls "${DIR}/${VERSION}/${1}/"*.rpm &>/dev/null; then
# update timestamp so the Makefile is happy =D
touch "${DIR}/${VERSION}/${1}/"*.rpm
echo "a .rpm already exists"
exit 0 # don't error, we want to be idempotent
fi
fi
if [ "$1" = "deb" ]; then
if ls "${DIR}/${VERSION}/${1}/"*.deb &>/dev/null; then
touch "${DIR}/${VERSION}/${1}/"*.deb
echo "a .deb already exists"
exit 0
fi
fi
if [ "$1" = "pacman" ]; then
if ls "${DIR}/${VERSION}/${1}/"*.tar.xz &>/dev/null; then
touch "${DIR}/${VERSION}/${1}/"*.tar.xz
echo "a .tar.xz already exists"
exit 0
fi
fi
fi
# there are no changelogs for pacman packages
if [ "$1" != "pacman" ]; then
CHANGELOG="--${1}-changelog=${DIR}/${VERSION}/${1}/changelog"
@@ -58,6 +84,11 @@ for i in "${@:3}"; do
DEPS="$DEPS -d $i"
done
# in case the `fpm` gem bin isn't in the $PATH
if which ruby >/dev/null && which gem >/dev/null && ! command -v fpm 2>/dev/null; then
PATH="$(ruby -r rubygems -e 'puts Gem.user_dir')/bin:$PATH"
fi
# build the package
fpm \
--log error \