kernel: auto-indent build-kernel.sh

Signed-off-by: Eric Ernst <eric.ernst@intel.com>
This commit is contained in:
Eric Ernst 2019-09-04 09:53:01 -07:00
parent 94c36df640
commit 2b617ed8c7

View File

@ -88,11 +88,11 @@ arch_to_kernel() {
local -r arch="$1" local -r arch="$1"
case "$arch" in case "$arch" in
aarch64) echo "arm64" ;; aarch64) echo "arm64" ;;
ppc64le) echo "powerpc" ;; ppc64le) echo "powerpc" ;;
x86_64) echo "$arch" ;; x86_64) echo "$arch" ;;
s390x) echo "s390" ;; s390x) echo "s390" ;;
*) die "unsupported architecture: $arch" ;; *) die "unsupported architecture: $arch" ;;
esac esac
} }
@ -167,8 +167,8 @@ get_kernel_frag_path() {
info "Constructing config from fragments: ${config_path}" info "Constructing config from fragments: ${config_path}"
local results=$(export KCONFIG_CONFIG=${config_path}; \ local results=$(export KCONFIG_CONFIG=${config_path}; \
export ARCH=${arch_target}; \ export ARCH=${arch_target}; \
cd ${kernel_path}; ${cmdpath} -r -n ${all_configs}) cd ${kernel_path}; ${cmdpath} -r -n ${all_configs})
# Did we request any entries that did not make it? # Did we request any entries that did not make it?
local missing=$(echo $results | grep -v -q "${not_in_string}"; echo $?) local missing=$(echo $results | grep -v -q "${not_in_string}"; echo $?)
@ -285,18 +285,18 @@ setup_kernel() {
[ -n "${arch_target}" ] || arch_target="$(uname -m)" [ -n "${arch_target}" ] || arch_target="$(uname -m)"
arch_target=$(arch_to_kernel "${arch_target}") arch_target=$(arch_to_kernel "${arch_target}")
( (
cd "${kernel_path}" || exit 1 cd "${kernel_path}" || exit 1
for p in ${kernel_patches}; do for p in ${kernel_patches}; do
info "Applying patch $p" info "Applying patch $p"
patch -p1 --fuzz 0 <"$p" patch -p1 --fuzz 0 <"$p"
done done
[ -n "${hypervisor_target}" ] || hypervisor_target="kvm" [ -n "${hypervisor_target}" ] || hypervisor_target="kvm"
[ -n "${kernel_config_path}" ] || kernel_config_path=$(get_default_kernel_config "${kernel_version}" "${hypervisor_target}" "${arch_target}" "${kernel_path}") [ -n "${kernel_config_path}" ] || kernel_config_path=$(get_default_kernel_config "${kernel_version}" "${hypervisor_target}" "${arch_target}" "${kernel_path}")
info "Copying config file from: ${kernel_config_path}" info "Copying config file from: ${kernel_config_path}"
cp "${kernel_config_path}" ./.config cp "${kernel_config_path}" ./.config
make oldconfig make oldconfig
) )
} }
@ -350,31 +350,31 @@ install_kata() {
main() { main() {
while getopts "a:c:hk:p:t:v:" opt; do while getopts "a:c:hk:p:t:v:" opt; do
case "$opt" in case "$opt" in
a) a)
arch_target="${OPTARG}" arch_target="${OPTARG}"
;; ;;
c) c)
kernel_config_path="${OPTARG}" kernel_config_path="${OPTARG}"
;; ;;
h) h)
usage usage
exit 0 exit 0
;; ;;
k) k)
kernel_path="${OPTARG}" kernel_path="${OPTARG}"
;; ;;
t) t)
hypervisor_target="${OPTARG}" hypervisor_target="${OPTARG}"
;; ;;
p) p)
patches_path="${OPTARG}" patches_path="${OPTARG}"
;; ;;
v) v)
kernel_version="${OPTARG}" kernel_version="${OPTARG}"
;; ;;
esac esac
done done
@ -400,21 +400,21 @@ main() {
info "Kernel version: ${kernel_version}" info "Kernel version: ${kernel_version}"
case "${subcmd}" in case "${subcmd}" in
build) build)
build_kernel "${kernel_path}" build_kernel "${kernel_path}"
;; ;;
install) install)
build_kernel "${kernel_path}" build_kernel "${kernel_path}"
install_kata "${kernel_path}" install_kata "${kernel_path}"
;; ;;
setup) setup)
setup_kernel "${kernel_path}" setup_kernel "${kernel_path}"
[ -d "${kernel_path}" ] || die "${kernel_path} does not exist" [ -d "${kernel_path}" ] || die "${kernel_path} does not exist"
echo "Kernel source ready: ${kernel_path} " echo "Kernel source ready: ${kernel_path} "
;; ;;
*) *)
usage 1 usage 1
;; ;;
esac esac
} }