Files
kata-containers/tools/packaging/obs-packaging/linux-container/kata-multiarch.sh
Peng Tao 782cd2ed10 packaging: merge packaging repository
git-subtree-dir: tools/packaging
git-subtree-mainline: f818b46a41
git-subtree-split: 1f22d72d5d

Signed-off-by: Peng Tao <bergwolf@hyper.sh>
2020-06-23 22:58:18 -07:00

61 lines
1.1 KiB
Bash

#!/usr/bin/env bash
set -e
# Convert architecture to the name used by the Linux kernel build system
arch_to_kernel() {
local -r arch="$1"
case "${arch}" in
aarch64) echo "arm64";;
ppc64le) echo "powerpc";;
s390|s390x) echo "s390";;
x86_64) echo "${arch}";;
*) echo "unsupported architecture: ${arch}" >&2; exit 1;;
esac
}
# Convert architecture to the location of the compressed linux image
arch_to_image() {
local -r arch="$1"
case "${arch}" in
aarch64)
echo "arch/arm64/boot/Image"
;;
ppc64le)
# No compressed image
;;
s390|s390x)
echo "arch/s390/boot/image"
;;
*)
echo "arch/${arch}/boot/bzImage"
;;
esac
}
usage() {
echo "$(basename $0) FLAG ARCHITECTURE"
echo "Allowed flags:"
echo " -a : Print kernel architecture"
echo " -i : Print kernel compressed image location (may be empty)"
}
if [ "$#" != "2" ]; then
echo -e "Invalid options\n\n$(usage)" >&2
exit 1
fi
case "$1" in
-a)
arch_to_kernel $2
;;
-i)
arch_to_image $2
;;
*)
echo -e "Invalid options\n\n$(usage)" >&2
exit 1
;;
esac