
There is no generic way to check apart presence of kernel headers and kernel devel packages. If we know system, we could use package manager, but without this knowledge, we can't distinguish which headers in kernel headers directory belongs to which package. Resolves #280 issue Signed-off-by: Slawomir Jankowski <slawomir.jankowski@intel.com>
114 lines
2.4 KiB
Bash
Executable File
114 lines
2.4 KiB
Bash
Executable File
#!/bin/bash
|
|
#
|
|
# Copyright(c) 2012-2019 Intel Corporation
|
|
# SPDX-License-Identifier: BSD-3-Clause-Clear
|
|
#
|
|
|
|
MISSING_TOOLS=0
|
|
|
|
check_util() {
|
|
which $1 &> /dev/null
|
|
if [ $? -ne 0 ]
|
|
then
|
|
echo >&2 "Error: missing '$1' utility"
|
|
MISSING_TOOLS=1
|
|
fi
|
|
}
|
|
|
|
check_util dirname
|
|
check_util realpath
|
|
check_util basename
|
|
check_util awk
|
|
check_util python3
|
|
check_util sed
|
|
check_util make
|
|
check_util gcc
|
|
check_util lsblk
|
|
|
|
if [ ! -e /lib/modules/$(uname -r)/build/ &> /dev/null ]
|
|
then
|
|
echo >&2 "Error: missing kernel headers and/or kernel devel"
|
|
MISSING_TOOLS=1
|
|
fi
|
|
|
|
`python3 -c "import argparse" &> /dev/null`
|
|
if [ $? -ne 0 ]
|
|
then
|
|
echo >&2 "Error: missing argparse python module"
|
|
MISSING_TOOLS=1
|
|
fi
|
|
|
|
if [ "$MISSING_TOOLS" -ne "0" ]
|
|
then
|
|
exit 1
|
|
fi
|
|
|
|
SCRIPTPATH=`dirname $0`
|
|
SCRIPTPATH=`realpath $SCRIPTPATH`
|
|
|
|
CONFIG_FILES=`ls $SCRIPTPATH/configure.d/*.conf | sort`
|
|
FILES_COUNT=`echo $CONFIG_FILES | wc -w`
|
|
|
|
CONFIG_FILE=$SCRIPTPATH/"config.out"
|
|
|
|
generate_config() {
|
|
rm -f ${CONFIG_FILE}
|
|
touch ${CONFIG_FILE}
|
|
n_cores=$(nproc)
|
|
|
|
# Compile each test module in background
|
|
echo "Preparing configuration"
|
|
for file in $CONFIG_FILES; do
|
|
# $1 - Action to be performed
|
|
# $2 - File with stored configuration
|
|
# $3 - Name of called script (since script is running as subprocess
|
|
# it has to be passed explicitly)
|
|
source $file "check" "$CONFIG_FILE" "$file" &
|
|
|
|
# Prevent spawning more subprocesses than CPU available
|
|
while [ $(ps --no-headers -o pid --ppid=$$ | wc -w) -ge $n_cores ] ; do
|
|
sleep 1
|
|
done
|
|
done
|
|
|
|
# Wait for all compilation processes to finish
|
|
wait
|
|
|
|
grep "X" ${CONFIG_FILE} &> /dev/null
|
|
if [ $? -eq 0 ] ; then
|
|
echo "ERROR! Following steps failed while preparing config:"
|
|
grep "X" ${CONFIG_FILE} | cut -f1 -d ' '
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
generate_header() {
|
|
rm -f $SCRIPTPATH/modules/generated_defines.h
|
|
# Configs starting with '1_' have to be put as first in header
|
|
FIRST=$(echo $CONFIG_FILES | tr ' ' '\n' | grep '1_')
|
|
SECOND=$(echo $CONFIG_FILES | tr ' ' '\n' | grep '2_')
|
|
|
|
echo "Configuring OpenCAS"
|
|
for file in $FIRST; do
|
|
CONF=$(cat ${CONFIG_FILE} | grep $(basename $file) | cut -d' ' -f2)
|
|
source $file "apply" "$CONF" "$file"
|
|
done
|
|
|
|
for file in $SECOND; do
|
|
CONF=$(cat ${CONFIG_FILE} | grep $(basename $file) | cut -d' ' -f2)
|
|
source $file "apply" "$CONF" "$file"
|
|
done
|
|
}
|
|
|
|
if [ -z "$1" ]; then
|
|
generate_config
|
|
else
|
|
CONFIG_FILE=$(realpath $1)
|
|
if [ $? -ne 0 ] ; then
|
|
echo "Invaild path to config file!"
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
generate_header
|