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 <james.o.hunt@intel.com>
This commit is contained in:
James O. D. Hunt 2018-04-19 16:23:03 +01:00
parent 2751de0768
commit f09d4c4626

View File

@ -119,6 +119,10 @@ setup_agent_init()
{ {
agent_bin="$1" agent_bin="$1"
init_bin="$2" 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" info "Install $agent_bin as init process"
mv -f "${agent_bin}" ${init_bin} mv -f "${agent_bin}" ${init_bin}
OK "Agent is installed as init process" OK "Agent is installed as init process"
@ -126,10 +130,11 @@ setup_agent_init()
copy_kernel_modules() copy_kernel_modules()
{ {
local module_dir=$1 local module_dir="$1"
local rootfs_dir=$2 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}" info "Copy kernel modules from ${KERNEL_MODULES_DIR}"
mkdir -p ${rootfs_dir}/lib/modules/ mkdir -p ${rootfs_dir}/lib/modules/