ignition/ignition-suse-generator
Ignaz Forster afaa367f82 - Drop "go clean" from the upstream build script: since we build in
clean environments, we don't have caches. Additionally, the way
  it is used does not even work and reports:
    go: clean -cache cannot be used with package arguments
  The error was masked until GO 1.23, as the test wether go
  supported caching was checking for go 1.23 formatted output.

OBS-URL: https://build.opensuse.org/package/show/devel:kubic:ignition/ignition?expand=0&rev=129
2024-09-06 21:57:18 +00:00

54 lines
1.5 KiB
Bash

#!/bin/bash
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
set -e
# Generators don't have logging right now
# https://github.com/systemd/systemd/issues/15638
exec 1>/dev/kmsg; exec 2>&1
UNIT_DIR="${1:-/tmp}"
cmdline=( $(</proc/cmdline) )
cmdline_arg() {
local name="$1" value="$2"
for arg in "${cmdline[@]}"; do
if [[ "${arg%%=*}" == "${name}" ]]; then
value="${arg#*=}"
fi
done
echo "${value}"
}
add_requires() {
local name="$1"; shift
local target="$1"; shift
local requires_dir="${UNIT_DIR}/${target}.requires"
mkdir -p "${requires_dir}"
ln -sf "../${name}" "${requires_dir}/${name}"
}
add_requires ignition-complete.target firstboot.target
add_requires ignition-diskful.target ignition-complete.target
# TODO: Add support for ignition-subsequent.target, when needed?
echo "PLATFORM_ID=$(cmdline_arg ignition.platform.id)" > /run/ignition.env
. /run/ignition.env
add_requires ignition-mount-initrd-fstab.service ignition-files.service
add_requires ignition-umount-initrd-fstab.service ignition-files.service
add_requires ignition-enable-network.service ignition-fetch.service
if [ -z "${PLATFORM_ID}" ]; then
platform="$(systemd-detect-virt || true)"
case "${platform}" in
*vmware*) platform="vmware" ;;
*oracle*) platform="virtualbox" ;;
*kvm*|*qemu*) platform="qemu" ;;
*) platform="metal" ;;
esac
echo "PLATFORM_ID=${platform}" > /run/ignition.env
fi