diff --git a/Makefile b/Makefile
index a365cdf3..5b8b5804 100644
--- a/Makefile
+++ b/Makefile
@@ -16,7 +16,7 @@
# along with this program. If not, see .
SHELL = /usr/bin/env bash
-.PHONY: all art cleanart version program lang path deps run race bindata generate build build-debug crossbuild clean test gofmt yamlfmt format docs rpmbuild mkdirs rpm srpm spec tar upload upload-sources upload-srpms upload-rpms upload-releases copr tag release funcgen
+.PHONY: all art cleanart version program lang path deps run race bindata generate build build-debug crossbuild clean test gofmt yamlfmt format docs rpmbuild mkdirs rpm srpm spec tar upload upload-sources upload-srpms upload-rpms upload-releases copr tag mkosi mkosi_rpm mkosi_deb mkosi_pacman release releases_path release_rpm release_deb release_pacman funcgen
.SILENT: clean bindata
# a large amount of output from this `find`, can cause `make` to be much slower!
@@ -165,6 +165,7 @@ clean: ## clean things up
$(MAKE) --quiet -C bindata clean
$(MAKE) --quiet -C lang/funcs clean
$(MAKE) --quiet -C lang clean
+ $(MAKE) --quiet -C misc/mkosi clean
rm -f lang/funcs/core/generated_funcs.go || true
rm -f lang/funcs/core/generated_funcs_test.go || true
[ ! -e $(PROGRAM) ] || rm $(PROGRAM)
@@ -343,11 +344,36 @@ copr: upload-srpms ## build in copr
tag: ## tags a new release
./misc/tag.sh
+#
+# mkosi
+#
+mkosi: mkosi_rpm mkosi_deb mkosi_pacman ## builds distro packages via mkosi
+
+mkosi_rpm: releases/$(VERSION)/.mkdir
+ @echo "Generating: rpm via mkosi..."
+ ./misc/mkosi/make.sh rpm mkosi.default.fedora-29 `realpath "releases/$(VERSION)/"`
+
+mkosi_deb: releases/$(VERSION)/.mkdir
+ @echo "Generating: deb via mkosi..."
+ ./misc/mkosi/make.sh deb mkosi.default.debian-10 `realpath "releases/$(VERSION)/"`
+
+mkosi_pacman: releases/$(VERSION)/.mkdir
+ @echo "Generating: pacman via mkosi..."
+ ./misc/mkosi/make.sh pacman mkosi.default.archlinux `realpath "releases/$(VERSION)/"`
+
#
# release
#
release: releases/$(VERSION)/mgmt-release.url ## generates and uploads a release
+releases_path:
+ @#Don't put any other output or dependencies in here or they'll show!
+ @echo "releases/$(VERSION)/"
+
+release_rpm: $(RPM_PKG)
+release_deb: $(DEB_PKG)
+release_pacman: $(PACMAN_PKG)
+
releases/$(VERSION)/mgmt-release.url: $(RPM_PKG) $(DEB_PKG) $(PACMAN_PKG) $(SHA256SUMS_ASC)
@echo "Creating github release..."
hub release create \
@@ -362,7 +388,7 @@ releases/$(VERSION)/mgmt-release.url: $(RPM_PKG) $(DEB_PKG) $(PACMAN_PKG) $(SHA2
|| rm -f releases/$(VERSION)/mgmt-release.url
releases/$(VERSION)/.mkdir:
- mkdir -p releases/$(VERSION)/{deb,rpm,pacman}/ && touch releases/$(VERSION)/.mkdir
+ mkdir -p releases/$(VERSION)/{rpm,deb,pacman}/ && touch releases/$(VERSION)/.mkdir
releases/$(VERSION)/rpm/changelog: $(PROGRAM) releases/$(VERSION)/.mkdir
@echo "Generating: rpm changelog..."
diff --git a/misc/fpm-pack.sh b/misc/fpm-pack.sh
index a4f2d96c..4e2f9236 100755
--- a/misc/fpm-pack.sh
+++ b/misc/fpm-pack.sh
@@ -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 \
diff --git a/misc/make-deps.sh b/misc/make-deps.sh
index b386e7b7..1900d899 100755
--- a/misc/make-deps.sh
+++ b/misc/make-deps.sh
@@ -45,7 +45,7 @@ if [ ! -z "$YUM" ]; then
$sudo_command $YUM install -y ruby-devel rubygems
$sudo_command $YUM install -y time
# dependencies for building packages with fpm
- $sudo_command $YUM install -y gcc make rpm-build libffi-devel bsdtar || true
+ $sudo_command $YUM install -y gcc make rpm-build libffi-devel bsdtar mkosi || true
$sudo_command $YUM install -y graphviz || true # for debugging
fi
if [ ! -z "$APT" ]; then
diff --git a/misc/mkosi/.gitignore b/misc/mkosi/.gitignore
new file mode 100644
index 00000000..1d1f9458
--- /dev/null
+++ b/misc/mkosi/.gitignore
@@ -0,0 +1,5 @@
+mkosi.cache/
+mkosi.builddir/
+mkosi.output/
+image.raw.cache-pre-dev
+image.raw.cache-pre-inst
diff --git a/misc/mkosi/Makefile b/misc/mkosi/Makefile
new file mode 100644
index 00000000..ad47e5ea
--- /dev/null
+++ b/misc/mkosi/Makefile
@@ -0,0 +1,27 @@
+# Mgmt
+# Copyright (C) 2013-2019+ James Shubin and the project contributors
+# Written by James Shubin and the project contributors
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see .
+
+SHELL = /usr/bin/env bash
+.PHONY: all clean
+
+default: all
+
+all:
+ @echo "This Makefile is used for cleaning."
+
+clean:
+ @rm -rf mkosi.{builddir,cache,output}
diff --git a/misc/mkosi/make.sh b/misc/mkosi/make.sh
new file mode 100755
index 00000000..326cf870
--- /dev/null
+++ b/misc/mkosi/make.sh
@@ -0,0 +1,61 @@
+#!/bin/bash -e
+
+echo running "$0"
+set -o errexit
+set -o pipefail
+
+# Run it the directory this script is in.
+ROOT=$(dirname "${BASH_SOURCE}")
+cd "${ROOT}"
+#pwd
+
+if [ "$3" = "" ]; then
+ # output should be an absolute path
+ echo "Usage: ./$0