You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
1.5 KiB

#!/bin/bash
# Copyright (c) Hisilicon Technologies Co., Ltd. 2021. All rights reserved.
set -e
function usage () {
echo "USAGE:"
echo " -d driver part specific config"
echo " -i input defconfig files"
echo " -f common base config file"
echo " -o output config file"
}
function generate_new_config()
{
cp "${BASED_DEFCONFIG_DIR}" "${OUTPUT_DEFCONFIG_FILE}"
for config in ${PRODUCT_DEFCONFIG_DIR[@]}; do echo ${config} >> ${INPUT_DEFOCONFIG_FILE}; done
while read line; do
if [[ "${line}" =~ CONFIG_* ]] ; then
echo "${line}" | sed "s/.*\(CONFIG_[^ ]\+\)[ =].*/\1/g" | \
while read product_item; do
if grep "${product_item}" "${OUTPUT_DEFCONFIG_FILE}" > /dev/null; then
sed -i "/\b${product_item}\b/d" "${OUTPUT_DEFCONFIG_FILE}"
echo "${line}" >> "${OUTPUT_DEFCONFIG_FILE}"
else
echo "${line}" >> "${OUTPUT_DEFCONFIG_FILE}"
fi
done
else
echo "${line}" >> "${OUTPUT_DEFCONFIG_FILE}"
fi
done < "${INPUT_DEFOCONFIG_FILE}"
}
while getopts 'b:i:d:o:' OPT; do
case "$OPT" in
b)
export BASED_DEFCONFIG_DIR="${OPTARG}";;
i)
export INPUT_DEFOCONFIG_FILE="${OPTARG}";;
d)
export PRODUCT_DEFCONFIG_DIR="${OPTARG}";;
o)
export OUTPUT_DEFCONFIG_FILE="${OPTARG}";;
?)
usage
esac
done
generate_new_config