mirror of
https://github.com/aljazceru/kata-containers.git
synced 2025-12-24 01:24:26 +01:00
git-subtree-dir: tools/packaging git-subtree-mainline:f818b46a41git-subtree-split:1f22d72d5dSigned-off-by: Peng Tao <bergwolf@hyper.sh>
61 lines
1.1 KiB
Bash
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
|