summaryrefslogtreecommitdiffstats
path: root/process_configs.sh
diff options
context:
space:
mode:
Diffstat (limited to 'process_configs.sh')
-rwxr-xr-xprocess_configs.sh222
1 files changed, 143 insertions, 79 deletions
diff --git a/process_configs.sh b/process_configs.sh
index c1e81ca16..dd134a569 100755
--- a/process_configs.sh
+++ b/process_configs.sh
@@ -6,6 +6,8 @@
# Globally disable suggestion of appending '|| exit' or '|| return' to cd/pushd/popd commands
# shellcheck disable=SC2164
+test -n "$RHTEST" && exit 0
+
usage()
{
# alphabetical order please
@@ -31,6 +33,16 @@ die()
exit 1
}
+get_cross_compile()
+{
+ arch=$1
+ if [[ "$CC_IS_CLANG" -eq 1 ]]; then
+ echo "$arch"
+ else
+ echo "scripts/dummy-tools/"
+ fi
+}
+
# stupid function to find top of tree to do kernel make configs
switch_to_toplevel()
{
@@ -50,6 +62,9 @@ switch_to_toplevel()
checkoptions()
{
+ count=$3
+ variant=$4
+
/usr/bin/awk '
/is not set/ {
@@ -72,14 +87,14 @@ checkoptions()
print "Found "a[1]"="a[2]" after generation, had " a[1]"="configs[a[1]]" in Source tree";
}
}
- ' "$1" "$2" > .mismatches
+ ' "$1" "$2" > .mismatches"${count}"
checkoptions_error=false
- if test -s .mismatches
+ if test -s .mismatches"${count}"
then
while read -r LINE
do
- if find ./ -name "$(echo "$LINE" | awk -F "=" ' { print $1 } ' | awk ' { print $2 }')" | xargs -0 grep ^ | grep -q "process_configs_known_broken"; then
+ if find "${REDHAT}"/configs -name "$(echo "$LINE" | awk -F "=" ' { print $1 } ' | awk ' { print $2 }')" -print0 | xargs -0 grep ^ | grep -q "process_configs_known_broken"; then
# This is a known broken config.
# See script help warning.
checkoptions_error=false
@@ -87,14 +102,13 @@ checkoptions()
checkoptions_error=true
break
fi
- done < .mismatches
+ done < .mismatches"${count}"
! $checkoptions_error && return
- echo "Error: Mismatches found in configuration files"
- cat .mismatches
- RETURNCODE=1
- [ "$CONTINUEONERROR" ] || exit 1
+ sed -i "1s/^/Error: Mismatches found in configuration files for ${arch} ${variant}\n/" .mismatches"${count}"
+ else
+ rm -f .mismatches"${count}"
fi
}
@@ -135,9 +149,9 @@ parsenewconfigs()
BEGIN { inpatch=0;
outfile="none";
symbol="none"; }
- /^CONFIG_.*:$/ {
- split($0, a, ":");
- symbol=a[1];
+ /^Symbol: .*$/ {
+ split($0, a, " ");
+ symbol="CONFIG_"a[2];
outfile=BASE "/fake_"symbol
}
/-----/ {
@@ -179,7 +193,7 @@ function commit_new_configs()
# assume we are in $source_tree/configs, need to get to top level
pushd "$(switch_to_toplevel)" &>/dev/null
- for cfg in "$SCRIPT_DIR/${PACKAGE_NAME}${KVERREL}${SUBARCH}"*.config
+ for cfg in "$SCRIPT_DIR/${PACKAGE_NAME}${KVERREL}"*.config
do
arch=$(head -1 "$cfg" | cut -b 3-)
cfgtmp="${cfg}.tmp"
@@ -193,11 +207,13 @@ function commit_new_configs()
fi
echo -n "Checking for new configs in $cfg ... "
- make ARCH="$arch" KCONFIG_CONFIG="$cfgorig" listnewconfig >& .listnewconfig
+ # shellcheck disable=SC2086
+ make ${MAKEOPTS} ARCH="$arch" CROSS_COMPILE="$(get_cross_compile "$arch")" KCONFIG_CONFIG="$cfgorig" listnewconfig >& .listnewconfig
grep -E 'CONFIG_' .listnewconfig > .newoptions
if test -s .newoptions
then
- make ARCH="$arch" KCONFIG_CONFIG="$cfgorig" helpnewconfig >& .helpnewconfig
+ # shellcheck disable=SC2086
+ make ${MAKEOPTS} ARCH="$arch" CROSS_COMPILE="$(get_cross_compile "$arch")" KCONFIG_CONFIG="$cfgorig" helpnewconfig >& .helpnewconfig
parsenewconfigs
fi
rm .newoptions
@@ -208,78 +224,125 @@ function commit_new_configs()
git commit -m "[redhat] AUTOMATIC: New configs"
}
-function process_configs()
+function process_config()
{
- # assume we are in $source_tree/configs, need to get to top level
- pushd "$(switch_to_toplevel)" &>/dev/null
+ local cfg
+ local arch
+ local cfgtmp
+ local cfgorig
+ local count
+ local variant
- for cfg in "$SCRIPT_DIR/${PACKAGE_NAME}${KVERREL}${SUBARCH}"*.config
- do
- arch=$(head -1 "$cfg" | cut -b 3-)
- cfgtmp="${cfg}.tmp"
- cfgorig="${cfg}.orig"
- cat "$cfg" > "$cfgorig"
+ cfg=$1
+ count=$2
- if [ "$arch" = "EMPTY" ]
- then
- # This arch is intentionally left blank
- continue
- fi
- echo -n "Processing $cfg ... "
+ arch=$(head -1 "$cfg" | cut -b 3-)
- make ARCH="$arch" KCONFIG_CONFIG="$cfgorig" listnewconfig >& .listnewconfig
- grep -E 'CONFIG_' .listnewconfig > .newoptions
- if test -n "$NEWOPTIONS" && test -s .newoptions
- then
- echo "Found unset config items, please set them to an appropriate value"
- cat .newoptions
- rm .newoptions
- RETURNCODE=1
- [ "$CONTINUEONERROR" ] || exit 1
- fi
- rm .newoptions
+ if [ "$arch" = "EMPTY" ]
+ then
+ # This arch is intentionally left blank
+ return
+ fi
- grep -E 'config.*warning' .listnewconfig > .warnings
- if test -n "$CHECKWARNINGS" && test -s .warnings
- then
- echo "Found misconfigured config items, please set them to an appropriate value"
- cat .warnings
- rm .warnings
- RETURNCODE=1
- [ "$CONTINUEONERROR" ] || exit 1
- fi
- rm .warnings
+ variant=$(basename "$cfg" | cut -d"-" -f3- | cut -d"." -f1)
- rm .listnewconfig
+ cfgtmp="${cfg}.tmp"
+ cfgorig="${cfg}.orig"
+ cat "$cfg" > "$cfgorig"
- make ARCH="$arch" KCONFIG_CONFIG="$cfgorig" olddefconfig > /dev/null || exit 1
- echo "# $arch" > "$cfgtmp"
- cat "$cfgorig" >> "$cfgtmp"
- if test -n "$CHECKOPTIONS"
- then
- checkoptions "$cfg" "$cfgtmp"
- fi
- # if test run, don't overwrite original
- if test -n "$TESTRUN"
- then
- rm -f "$cfgtmp"
- else
- mv "$cfgtmp" "$cfg"
+ echo "Processing $cfg ... "
+
+ # shellcheck disable=SC2086
+ make ${MAKEOPTS} ARCH="$arch" CROSS_COMPILE="$(get_cross_compile "$arch")" KCONFIG_CONFIG="$cfgorig" listnewconfig >& .listnewconfig"${count}"
+ grep -E 'CONFIG_' .listnewconfig"${count}" > .newoptions"${count}"
+ if test -n "$NEWOPTIONS" && test -s .newoptions"${count}"
+ then
+ echo "Found unset config items in ${arch} ${variant}, please set them to an appropriate value" >> .errors"${count}"
+ cat .newoptions"${count}" >> .errors"${count}"
+ rm .newoptions"${count}"
+ RETURNCODE=1
+ fi
+ rm -f .newoptions"${count}"
+
+ grep -E 'config.*warning' .listnewconfig"${count}" > .warnings"${count}"
+ if test -n "$CHECKWARNINGS" && test -s .warnings"${count}"
+ then
+ echo "Found misconfigured config items in ${arch} ${variant}, please set them to an appropriate value" >> .errors"${count}"
+ cat .warnings"${count}" >> .errors"${count}"
+ fi
+ rm .warnings"${count}"
+
+ rm .listnewconfig"${count}"
+
+ # shellcheck disable=SC2086
+ make ${MAKEOPTS} ARCH="$arch" CROSS_COMPILE="$(get_cross_compile "$arch")" KCONFIG_CONFIG="$cfgorig" olddefconfig > /dev/null || exit 1
+ echo "# $arch" > "$cfgtmp"
+ cat "$cfgorig" >> "$cfgtmp"
+ if test -n "$CHECKOPTIONS"
+ then
+ checkoptions "$cfg" "$cfgtmp" "$count" "$variant"
+ fi
+ # if test run, don't overwrite original
+ if test -n "$TESTRUN"
+ then
+ rm -f "$cfgtmp"
+ else
+ mv "$cfgtmp" "$cfg"
+ fi
+ rm -f "$cfgorig"
+ echo "Processing $cfg complete"
+}
+
+function process_configs()
+{
+ # assume we are in $source_tree/configs, need to get to top level
+ pushd "$(switch_to_toplevel)" &>/dev/null
+
+ # The next line is throwaway code for transition to parallel
+ # processing. Leaving this line in place is harmless, but it can be
+ # removed the next time anyone updates this function.
+ [ -f .mismatches ] && rm -f .mismatches
+
+ count=0
+ for cfg in "$SCRIPT_DIR/${PACKAGE_NAME}${KVERREL}"*.config
+ do
+ if [ "$count" -eq 0 ]; then
+ # do the first one by itself so that tools are built
+ process_config "$cfg" "$count"
fi
- rm -f "$cfgorig"
- echo "done"
+ process_config "$cfg" "$count" &
+ waitpids[${count}]=$!
+ ((count++))
+ while [ "$(jobs | grep -c Running)" -ge "$RHJOBS" ]; do :; done
+ done
+ for pid in ${waitpids[*]}; do
+ wait ${pid}
done
+
rm "$SCRIPT_DIR"/*.config*.old
+
+ if ls .errors* 1> /dev/null 2>&1; then
+ RETURNCODE=1
+ cat .errors*
+ rm .errors* -f
+ fi
+ if ls .mismatches* 1> /dev/null 2>&1; then
+ RETURNCODE=1
+ cat .mismatches*
+ rm .mismatches* -f
+ fi
+
popd > /dev/null
- echo "Processed config files are in $SCRIPT_DIR"
+ [ $RETURNCODE -eq 0 ] && echo "Processed config files are in $SCRIPT_DIR"
}
CHECKOPTIONS=""
-CONTINUEONERROR=""
NEWOPTIONS=""
TESTRUN=""
CHECKWARNINGS=""
+MAKEOPTS=""
+CC_IS_CLANG=0
RETURNCODE=0
@@ -289,7 +352,6 @@ do
case $key in
-a)
CHECKOPTIONS="x"
- CONTINUEONERROR="x"
NEWOPTIONS="x"
CHECKWARNINGS="x"
;;
@@ -299,9 +361,6 @@ do
-h)
usage
;;
- -i)
- CONTINUEONERROR="x"
- ;;
-n)
NEWOPTIONS="x"
;;
@@ -314,24 +373,29 @@ do
-z)
COMMITNEWCONFIGS="x"
;;
+ -m)
+ shift
+ if [ "$1" = "CC=clang" ] || [ "$1" = "LLVM=1" ]; then
+ CC_IS_CLANG=1
+ fi
+ MAKEOPTS="$MAKEOPTS $1"
+ ;;
*)
break;;
esac
shift
done
-PACKAGE_NAME="${1:-kernel}" # defines the package name used
-KVERREL="$(test -n "$2" && echo "-$2" || echo "")"
-SUBARCH="$(test -n "$3" && echo "-$3" || echo "")"
-FLAVOR="$(test -n "$4" && echo "-$4" || echo "-common")"
+KVERREL="$(test -n "$1" && echo "-$1" || echo "")"
+FLAVOR="$(test -n "$2" && echo "-$2" || echo "-ark")"
+# shellcheck disable=SC2015
SCRIPT=$(readlink -f "$0")
SCRIPT_DIR=$(dirname "$SCRIPT")
-# Most RHEL options are options we want in Fedora so RHEL pending settings head
-# to common/
+# Config options for RHEL should target the pending-ark directory, not pending-common.
if [ "$FLAVOR" = "-rhel" ]
then
- FLAVOR="-common"
+ FLAVOR="-ark"
fi
# to handle this script being a symlink