From f09d4c462692667596b83bb94d7b23643ac645ee Mon Sep 17 00:00:00 2001 From: "James O. D. Hunt" Date: Thu, 19 Apr 2018 16:23:03 +0100 Subject: [PATCH] rootfs: Check function parameters Add some checks to ensure function parameters are set. This fixes a bug `copy_kernel_modules()` where a test would never fail due to missing dollars. Signed-off-by: James O. D. Hunt --- rootfs-builder/rootfs.sh | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/rootfs-builder/rootfs.sh b/rootfs-builder/rootfs.sh index 9a7ecff9d0..d838009b71 100755 --- a/rootfs-builder/rootfs.sh +++ b/rootfs-builder/rootfs.sh @@ -119,6 +119,10 @@ setup_agent_init() { agent_bin="$1" init_bin="$2" + + [ -z "$agent_bin" ] && die "need agent binary path" + [ -z "$init_bin" ] && die "need init bin path" + info "Install $agent_bin as init process" mv -f "${agent_bin}" ${init_bin} OK "Agent is installed as init process" @@ -126,10 +130,11 @@ setup_agent_init() copy_kernel_modules() { - local module_dir=$1 - local rootfs_dir=$2 + local module_dir="$1" + local rootfs_dir="$2" - [ -z "module_dir" -o -z "rootfs_dir" ] && die "module dir and rootfs dir must be specified" + [ -z "$module_dir" ] && die "need module directory" + [ -z "$rootfs_dir" ] && die "need rootfs directory" info "Copy kernel modules from ${KERNEL_MODULES_DIR}" mkdir -p ${rootfs_dir}/lib/modules/