2017-11-06 21:55:26 +00:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# This script merges together the hierarchy of CONFIG_* files under generic
|
|
|
|
# and debug to form the necessary $PACKAGE_NAME<version>-<arch>-<variant>.config
|
|
|
|
# files for building RHEL kernels, based on the contents of a control file
|
|
|
|
|
2017-11-06 22:00:42 +00:00
|
|
|
PACKAGE_NAME="${1:-kernel}" # defines the package name used
|
|
|
|
KVERREL="${2:-}"
|
2017-12-13 21:19:06 +00:00
|
|
|
SUBARCH="${3:-}" # defines a specific arch
|
2017-11-06 22:00:42 +00:00
|
|
|
SCRIPT="$(readlink -f $0)"
|
|
|
|
OUTPUT_DIR="$PWD"
|
|
|
|
SCRIPT_DIR="$(dirname $SCRIPT)"
|
|
|
|
|
2018-07-25 10:31:21 +00:00
|
|
|
LANG=en_US.UTF-8
|
|
|
|
|
2017-11-06 22:00:42 +00:00
|
|
|
# to handle this script being a symlink
|
|
|
|
cd $SCRIPT_DIR
|
2017-11-06 21:55:26 +00:00
|
|
|
|
|
|
|
set errexit
|
|
|
|
set nounset
|
|
|
|
|
2017-11-06 22:00:42 +00:00
|
|
|
cleanup()
|
|
|
|
{
|
|
|
|
rm -f config-*
|
|
|
|
}
|
|
|
|
|
|
|
|
die()
|
|
|
|
{
|
|
|
|
echo "$1"
|
|
|
|
cleanup
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
2017-11-06 21:55:26 +00:00
|
|
|
function combine_config_layer()
|
|
|
|
{
|
|
|
|
dir=$1
|
|
|
|
file="config-$(echo $dir | sed -e 's|/|-|g')"
|
|
|
|
|
|
|
|
if [ $(ls $dir/ | grep -c "^CONFIG_") -eq 0 ]; then
|
|
|
|
touch $file
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
|
|
|
cat $dir/CONFIG_* > $file
|
|
|
|
}
|
|
|
|
|
|
|
|
function merge_configs()
|
|
|
|
{
|
|
|
|
archvar=$1
|
|
|
|
arch=$(echo "$archvar" | cut -f1 -d"-")
|
|
|
|
configs=$2
|
2017-12-13 21:19:06 +00:00
|
|
|
order=$3
|
2019-11-05 22:10:53 +00:00
|
|
|
flavor=$4
|
|
|
|
|
|
|
|
name=$OUTPUT_DIR/$PACKAGE_NAME-$archvar-$flavor.config
|
2017-11-06 21:55:26 +00:00
|
|
|
echo -n "Building $name ... "
|
|
|
|
touch config-merging config-merged
|
2017-11-06 22:00:42 +00:00
|
|
|
|
2017-12-13 21:19:06 +00:00
|
|
|
# apply based on order
|
|
|
|
skip_if_missing=""
|
|
|
|
for o in $order
|
2017-11-06 22:00:42 +00:00
|
|
|
do
|
2017-12-13 21:19:06 +00:00
|
|
|
for config in $(echo $configs | sed -e 's/:/ /g')
|
|
|
|
do
|
|
|
|
cfile="config-$o-$config"
|
|
|
|
|
|
|
|
test -n "$skip_if_missing" && test ! -e $cfile && continue
|
|
|
|
|
|
|
|
perl merge.pl $cfile config-merging > config-merged
|
|
|
|
if [ ! $? -eq 0 ]; then
|
|
|
|
die "Failed to merge $cfile"
|
|
|
|
fi
|
|
|
|
mv config-merged config-merging
|
|
|
|
done
|
|
|
|
|
|
|
|
# first configs in $order is baseline, all files should be
|
|
|
|
# there. second pass is overrides and can be missing.
|
|
|
|
skip_if_missing="1"
|
2017-11-06 21:55:26 +00:00
|
|
|
done
|
|
|
|
if [ "x$arch" == "xaarch64" ]; then
|
|
|
|
echo "# arm64" > $name
|
|
|
|
elif [ "x$arch" == "xppc64le" ]; then
|
|
|
|
echo "# powerpc" > $name
|
|
|
|
elif [ "x$arch" == "xs390x" ]; then
|
|
|
|
echo "# s390" > $name
|
|
|
|
elif [ "x$arch" == "xarmv7hl" ]; then
|
|
|
|
echo "# arm" > $name
|
|
|
|
elif [ "x$arch" == "xi686" ]; then
|
|
|
|
echo "# i386" > $name
|
|
|
|
else
|
|
|
|
echo "# $arch" > $name
|
|
|
|
fi
|
|
|
|
sort config-merging >> $name
|
|
|
|
rm -f config-merged config-merging
|
|
|
|
echo "done"
|
|
|
|
}
|
|
|
|
|
2019-11-05 22:10:53 +00:00
|
|
|
function build_flavor()
|
|
|
|
{
|
|
|
|
flavor=$1
|
|
|
|
control_file="priority".$flavor
|
|
|
|
while read line
|
|
|
|
do
|
|
|
|
if [ $(echo "$line" | grep -c "^#") -ne 0 ]; then
|
|
|
|
continue
|
|
|
|
elif [ $(echo "$line" | grep -c "^$") -ne 0 ]; then
|
|
|
|
continue
|
|
|
|
elif [ $(echo "$line" | grep -c "^EMPTY") -ne 0 ]; then
|
|
|
|
empty=$(echo "$line" | cut -f2 -d"=")
|
|
|
|
for a in $empty
|
|
|
|
do
|
|
|
|
echo "# EMPTY" > $OUTPUT_DIR/$PACKAGE_NAME-$a-$flavor.config
|
|
|
|
|
|
|
|
done
|
|
|
|
elif [ $(echo "$line" | grep -c "^ORDER") -ne 0 ]; then
|
|
|
|
order=$(echo "$line" | cut -f2 -d"=")
|
|
|
|
for o in $order
|
2017-12-13 21:19:06 +00:00
|
|
|
do
|
2019-11-05 22:10:53 +00:00
|
|
|
glist=$(find $o -type d)
|
|
|
|
for d in $glist
|
|
|
|
do
|
|
|
|
combine_config_layer $d
|
|
|
|
done
|
2017-12-13 21:19:06 +00:00
|
|
|
done
|
2019-11-05 22:10:53 +00:00
|
|
|
else
|
|
|
|
arch=$(echo "$line" | cut -f1 -d"=")
|
|
|
|
configs=$(echo "$line" | cut -f2 -d"=")
|
|
|
|
|
|
|
|
if [ -n "$SUBARCH" ]; then
|
|
|
|
case $arch in
|
|
|
|
$SUBARCH*)
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
continue
|
|
|
|
esac
|
|
|
|
fi
|
2017-11-06 21:55:26 +00:00
|
|
|
|
2019-11-05 22:10:53 +00:00
|
|
|
merge_configs $arch $configs "$order" $flavor
|
2017-11-06 21:55:26 +00:00
|
|
|
fi
|
2019-11-05 22:10:53 +00:00
|
|
|
done < $control_file
|
|
|
|
}
|
2017-11-06 21:55:26 +00:00
|
|
|
|
2019-11-05 22:10:53 +00:00
|
|
|
while read line
|
|
|
|
do
|
|
|
|
build_flavor $line
|
|
|
|
done < flavors
|
2017-11-06 21:55:26 +00:00
|
|
|
|
2017-11-06 22:00:42 +00:00
|
|
|
# A passed in kernel version implies copy to final location
|
|
|
|
# otherwise defer to another script
|
|
|
|
if test -n "$KVERREL"
|
|
|
|
then
|
|
|
|
for i in kernel-*.config
|
|
|
|
do
|
|
|
|
NEW="$(echo $i | sed "s/$PACKAGE_NAME-$SUBARCH/$PACKAGE_NAME-$KVERREL-$SUBARCH/")"
|
|
|
|
mv $i $NEW
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
|
|
|
cleanup
|