#!/bin/sh
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Zygmunt Krynicki
set -eu

GARDEN_QEMU_SYSTEM=aarch64
GARDEN_COMPONENT=qemu-"$GARDEN_QEMU_SYSTEM"
ln -nfs ../../components/"$SNAP_REVISION"/"$GARDEN_COMPONENT" "$SNAP"/components/"$GARDEN_COMPONENT"

GARDEN_QEMU_SYSTEM=ppc64
GARDEN_COMPONENT=qemu-"$GARDEN_QEMU_SYSTEM"
ln -nfs ../../components/"$SNAP_REVISION"/"$GARDEN_COMPONENT" "$SNAP"/components/"$GARDEN_COMPONENT"

GARDEN_QEMU_SYSTEM=riscv64
GARDEN_COMPONENT=qemu-"$GARDEN_QEMU_SYSTEM"
ln -nfs ../../components/"$SNAP_REVISION"/"$GARDEN_COMPONENT" "$SNAP"/components/"$GARDEN_COMPONENT"

GARDEN_QEMU_SYSTEM=s390x
GARDEN_COMPONENT=qemu-"$GARDEN_QEMU_SYSTEM"
ln -nfs ../../components/"$SNAP_REVISION"/"$GARDEN_COMPONENT" "$SNAP"/components/"$GARDEN_COMPONENT"

# NOTE The difference between _ and -.
GARDEN_QEMU_SYSTEM=x86_64
GARDEN_COMPONENT=qemu-x86-64
ln -nfs ../../components/"$SNAP_REVISION"/"$GARDEN_COMPONENT" "$SNAP"/components/"$GARDEN_COMPONENT"

unset GARDEN_QEMU_SYSTEM
unset GARDEN_COMPONENT

# Execute subsequent element of the command-chain.
exec "$@"
