From: Prarit Bhargava <pra...@redhat.com>

redhat/configs/evaluate_configs: Add find dead configs option

Add an option to evaluate_configs to find configs that are no longer
referenced in the configs.  The "-D" command only find unreferenced
configs and there is no guarantee that the resulting changes will result
in valid config generation.  ie) Additional changes may be required after
running the -D command.

Add an option to find dead configs.

Signed-off-by: Prarit Bhargava <pra...@redhat.com>

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
@@ -771,6 +771,40 @@ map_configs_to_array() { #uses CONFIG, configmap, cfgs
        return 0
 }
 
+generate_finalconfiglist() {
+       awk '
+               /is not set/ {
+                       split ($0, a, "#");
+                       split(a[2], b);
+                       print b[1] ;
+               }
+               /=/ {
+                       split ($0, a, "=");
+                       print a[1];
+               }
+       ' *.config | sort -u >> .finalconfiglist
+}
+
+find_dead_configs() {
+       echo > .finalconfiglist
+       echo > .configlist
+
+       grep -q "rhel" flavors && (cd ..; make rh-configs) && 
generate_finalconfiglist
+       grep -q "fedora" flavors && (cd ..; make fedora-configs) && 
generate_finalconfiglist
+       sort -o .finalconfiglist -u .finalconfiglist
+
+       find ./ -name CONFIG_* | sed 's!.*/!!' | sort -u > .configlist
+
+       echo "These CONFIGS defined in redhat/configs but not the final 
.configs have been deleted:"
+       comm .configlist .finalconfiglist -2 -3 | while read FILENAME
+       do
+               echo $FILENAME
+               find ./ -name $FILENAME | xargs rm -f
+       done
+
+       rm -f .configlist .finalconfiglist
+}
+
 #
 #
 # MAIN
@@ -781,7 +815,7 @@ map_configs_to_array() { #uses CONFIG, configmap, cfgs
 FINDFIXES=false
 FIXCOMMON=false
 configs=
-while getopts "c:dfhjp:" opt; do
+while getopts "c:dDfhjp:" opt; do
        case ${opt} in
        c )
                configs=$OPTARG
@@ -789,6 +823,10 @@ while getopts "c:dfhjp:" opt; do
        d )
                DEBUG=true
                ;;
+       D )
+               find_dead_configs
+               exit 0
+               ;;
        f )
                # Find fixes per config-variant
                FINDFIXES=true

--
https://gitlab.com/cki-project/kernel-ark/-/merge_requests/1498
_______________________________________________
kernel mailing list -- kernel@lists.fedoraproject.org
To unsubscribe send an email to kernel-le...@lists.fedoraproject.org
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@lists.fedoraproject.org
Do not reply to spam on the list, report it: 
https://pagure.io/fedora-infrastructure

Reply via email to