Files
mgmt/misc/mkosi/mkosi.build
James Shubin 88516546fa lib: Move to go modules and shed a few tears
The old system with vendor/ and git submodules worked great,
unfortunately FUD around git submodules seemed to scare people away and
golang moved to a go.mod system that adds a new lock file format instead
of using the built-in git version. It's now almost impossible to use
modern golang without this, so we've switched.

So much for the golang compatibility promise-- turns out it doesn't
apply to the useful parts that I actually care about like this.

Thanks to frebib for his incredibly valuable contributions to this
patch. This snide commit message is mine alone.

This patch also mixes in some changes due to legacy golang as we've also
bumped the minimum version to 1.16 in the docs and tests.

Lastly, we had to disable some tests and fix up a few other misc things
to get this passing. We've definitely hot bugs in the go.mod system, and
our Makefile tries to workaround those.
2021-10-05 08:34:51 -04:00

72 lines
2.1 KiB
Bash
Executable File

#!/bin/bash
# If mkosi.builddir/ exists mkosi will set $BUILDDIR to it, let's then use it as
# out-of-tree build dir. Otherwise, let's make up our own builddir.
[ -z "$BUILDDIR" ] && BUILDDIR=build
# After some inspection, we've noticed that:
# `pwd` is: /root/src
# $SRCDIR is: /root/src
# $DESTDIR is: /root/dest
# TODO: Can we use misc/make-path.sh here instead?
# The default that will get used automatically.
export GOPATH=~/go/
# The golang binaries are stored here.
export GOBIN="${GOPATH}bin/"
# Needed so that golang build tools will get found.
export PATH="${GOBIN}:${PATH}"
# Pull from the MKOSI_DEFAULT var: https://github.com/systemd/mkosi/pull/367
mkosi_default="mkosi.default." # remove this prefix
MGMT_MKOSI_DISTRO="${MKOSI_DEFAULT##$mkosi_default}"
# Lookup the type of image build we're doing.
if [ "${MGMT_MKOSI_DISTRO}" = "" ]; then
echo "The MGMT_MKOSI_DISTRO variable is empty."
exit 1
fi
echo "Build distro: $MGMT_MKOSI_DISTRO"
# Arch mirror fixes.
if [ -e "/etc/arch-release" ]; then
cp /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.backup
# Enable all mirrors.
sed -i 's/^#Server/Server/' /etc/pacman.d/mirrorlist.backup
#rankmirrors -n 6 /etc/pacman.d/mirrorlist.backup > /etc/pacman.d/mirrorlist # SLOW
echo 'Server = http://mirror.rackspace.com/archlinux/$repo/os/$arch' > /etc/pacman.d/mirrorlist
cat /etc/pacman.d/mirrorlist.backup >> /etc/pacman.d/mirrorlist
pacman -Syu --noconfirm pacman-mirrorlist
pacman -Syu
fi
# Get all the dependencies for mgmt.
make deps
# Build it!
make || exit 1
# Store the output.
# TODO: is this required?
mv mgmt $BUILDDIR
# Get the releases directory path.
releases_path=$(make releases_path) # It captures any other output, careful!
if [ "$releases_path" = "" ]; then
echo "Releases path is unknown."
exit 1
fi
mkdir -p "$releases_path" # Ensure it exists.
echo "The releases_path is: ${releases_path}."
# Build the package for the distribution that we're in.
make release_${MGMT_MKOSI_DISTRO}
# Store releases.
mv "$releases_path${MGMT_MKOSI_DISTRO}/" $BUILDDIR # mv releases/$(VERSION)/fedora-29/ $BUILDDIR
echo "Done mkosi build!"