[OS-BUILD PATCH] redhat/configs/evaluate_configs: insert EMPTY tags at correct place

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Jan Stancek <jstancek@xxxxxxxxxx>

redhat/configs/evaluate_configs: insert EMPTY tags at correct place

evaluate_configs currently inserts empty tags always at the end
of cfgvariants line, which breaks the table if a new variant
is introduced (which is not a super-set of debug variant).

Let's walk cfgvariants to discover all toplevel directories
and give each an ordering number. Then during addition of EMPTY
tags walk through existing tags and compare ordering number of
toplevel portion of each tag. This number determines where
to insert new tag.

Signed-off-by: Jan Stancek <jstancek@xxxxxxxxxx>

diff --git a/redhat/configs/evaluate_configs b/redhat/configs/evaluate_configs
index blahblah..blahblah 100755
--- a/redhat/configs/evaluate_configs
+++ b/redhat/configs/evaluate_configs
@@ -25,6 +25,7 @@ numorder=
 longheader=
 weightorig=
 weight=
+declare -A toplevel_order
 
 tempdir=$(mktemp -d)
 
@@ -141,9 +142,35 @@ get_subdirs() { # uses $cfgvariants and $toplevels
 	done
 }
 
+# Walk through cfgvariants and give each toplevel dir an ordering number.
+# This number is later used to insert EMPTY tags at correct place.
+create_toplevel_order() { # uses toplevel_order
+
+while read -r cfgvariant
+do
+	local i
+	local max
+	local order
+	local topname
+
+	LINE=$(echo "$cfgvariant" | cut -d "|" -f 2)
+
+	for i in $LINE; do
+		topname="${i%%-*}"
+		order=${toplevel_order[$topname]}
+		if [ -z "$order" ]; then
+			max=$(echo "${toplevel_order[@]}" | wc -w)
+			max=$((max + 1))
+			toplevel_order[$topname]=$max
+			$DEBUG && echo "toplevel_order[$topname] = $max"
+		fi
+	done
+done <<< "$cfgvariants"
+}
+
 # For each config-variant, find missing sub-directories and mark them as "EMPTY"
 # This is very helpful for stage 3.
-fix_config_variants() { # uses $toplevels, $subdirs, $cfgvariants
+fix_config_variants() { # uses $toplevels, $subdirs, $cfgvariants, $toplevel_order
 
 for toplevel in $toplevels
 do
@@ -157,6 +184,8 @@ do
 	local found
 	local dashcount
 	local new
+	local topname
+	local new_topname
 
 	subdircnt=$(echo "$subdirs" | grep "$toplevel" | awk -F "subdirs" ' { print $2 } ')
 	linenum=0
@@ -218,12 +247,25 @@ do
 		if echo "$LINE" | grep -q "$toplevel"; then
 			new=${cfgvariant//$oldentry/$newentry}
 		else
-			# Assuming that there is always a generic entry
-			# followed by a debug entry.  If a debug only config
-			# variant exists, there is a possibility that this
-			# screws up badly because the EMPTY tags are always
-			# added the end of the string. #FIXME
-			new="$cfgvariant $newentry"
+			# Find out toplevel name of new EMPTY entries and use
+			# toplevel_order to figure out where to insert those.
+			found=0
+			new_topname="${newentry%%-*}"
+			new="$(echo "$cfgvariant" | cut -d "|" -f 1)|"
+			LINE=$(echo "$cfgvariant" | cut -d "|" -f 2)
+
+			for i in $LINE; do
+				topname="${i%%-*}"
+				if [ $found -eq 1 -o ${toplevel_order[$topname]} -lt ${toplevel_order[$new_topname]} ]; then
+					new="$new $i"
+				else
+					found=1
+					new="$new $newentry $i"
+				fi
+			done
+			if [ $found -eq 0 ]; then
+				new="$new $newentry"
+			fi
 		fi
 
 		$DEBUG && echo "REPLACED:"
@@ -818,6 +860,9 @@ subdirs=$(get_subdirs)
 $DEBUG && echo "Top-level sub-directories:"
 $DEBUG && echo "$subdirs"
 
+# Create ordering for toplevel dirs
+create_toplevel_order
+
 # Add EMPTY entries for each missing subdirectory level in the config
 # variants
 echo "$cfgvariants" > "$tempdir"/cfgvariants

--
https://gitlab.com/cki-project/kernel-ark/-/merge_requests/1437
_______________________________________________
kernel mailing list -- kernel@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to kernel-leave@xxxxxxxxxxxxxxxxxxxxxxx
Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedoraproject.org/archives/list/kernel@xxxxxxxxxxxxxxxxxxxxxxx
Do not reply to spam on the list, report it: https://pagure.io/fedora-infrastructure




[Index of Archives]     [Fedora General Discussion]     [Older Fedora Users Archive]     [Fedora Advisory Board]     [Fedora Security]     [Fedora Devel Java]     [Fedora Legacy]     [Fedora Desktop]     [ATA RAID]     [Fedora Marketing]     [Fedora Mentors]     [Fedora Package Announce]     [Fedora Package Review]     [Fedora Music]     [Fedora Packaging]     [Centos]     [Fedora SELinux]     [Coolkey]     [Yum Users]     [Tux]     [Yosemite News]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [USB]     [Asterisk PBX]

  Powered by Linux