| 1 | #!/bin/sh |
| 2 | # SPDX-License-Identifier: Apache-2.0 |
| 3 | # SPDX-FileCopyrightText: Zygmunt Krynicki |
| 4 | set -eu |
| 5 | |
| 6 | GARDEN_QEMU_SYSTEM=s390x |
| 7 | GARDEN_COMPONENT=qemu-"$GARDEN_QEMU_SYSTEM" |
| 8 | |
| 9 | # Create a symbolic link that makes |
| 10 | # /snap/image-garden/current/components/qemu-aarch64 a valid path, matching |
| 11 | # build-time configuration of qemu. |
| 12 | ln -nfs ../../components/"$SNAP_REVISION"/"$GARDEN_COMPONENT" "$SNAP"/components/"$GARDEN_COMPONENT" |
| 13 | |
| 14 | # If the component is not installed, fail with an error message. |
| 15 | if [ ! -d "$SNAP"/../components/"$SNAP_REVISION"/"$GARDEN_COMPONENT" ]; then |
| 16 | echo "install $GARDEN_COMPONENT component to use $GARDEN_QEMU_SYSTEM emulation" >&2 |
| 17 | exit 1 |
| 18 | fi |
| 19 | |
| 20 | # Execute qemu-system-$GARDEN_QEMU_SYSTEM through the symbolic link created above. |
| 21 | exec "$SNAP"/components/"$GARDEN_COMPONENT"/bin/qemu-system-$GARDEN_QEMU_SYSTEM "$@" |