99 lines · bash
1#2# Small script that refreshes the kernel feature support status in place.3#4 5for F_FILE in Documentation/features/*/*/arch-support.txt; do6 F=$(grep "^# Kconfig:" "$F_FILE" | cut -c26-)7 8 #9 # Each feature F is identified by a pair (O, K), where 'O' can10 # be either the empty string (for 'nop') or "not" (the logical11 # negation operator '!'); other operators are not supported.12 #13 O=""14 K=$F15 if [[ "$F" == !* ]]; then16 O="not"17 K=$(echo $F | sed -e 's/^!//g')18 fi19 20 #21 # F := (O, K) is 'valid' iff there is a Kconfig file (for some22 # arch) which contains K.23 #24 # Notice that this definition entails an 'asymmetry' between25 # the case 'O = ""' and the case 'O = "not"'. E.g., F may be26 # _invalid_ if:27 #28 # [case 'O = ""']29 # 1) no arch provides support for F,30 # 2) K does not exist (e.g., it was renamed/mis-typed);31 #32 # [case 'O = "not"']33 # 3) all archs provide support for F,34 # 4) as in (2).35 #36 # The rationale for adopting this definition (and, thus, for37 # keeping the asymmetry) is:38 #39 # We want to be able to 'detect' (2) (or (4)).40 #41 # (1) and (3) may further warn the developers about the fact42 # that K can be removed.43 #44 F_VALID="false"45 for ARCH_DIR in arch/*/; do46 K_FILES=$(find $ARCH_DIR -name "Kconfig*")47 K_GREP=$(grep "$K" $K_FILES)48 if [ ! -z "$K_GREP" ]; then49 F_VALID="true"50 break51 fi52 done53 if [ "$F_VALID" = "false" ]; then54 printf "WARNING: '%s' is not a valid Kconfig\n" "$F"55 fi56 57 T_FILE="$F_FILE.tmp"58 grep "^#" $F_FILE > $T_FILE59 echo " -----------------------" >> $T_FILE60 echo " | arch |status|" >> $T_FILE61 echo " -----------------------" >> $T_FILE62 for ARCH_DIR in arch/*/; do63 ARCH=$(echo $ARCH_DIR | sed -e 's/^arch//g' | sed -e 's/\///g')64 K_FILES=$(find $ARCH_DIR -name "Kconfig*")65 K_GREP=$(grep "$K" $K_FILES)66 #67 # Arch support status values for (O, K) are updated according68 # to the following rules.69 #70 # - ("", K) is 'supported by a given arch', if there is a71 # Kconfig file for that arch which contains K;72 #73 # - ("not", K) is 'supported by a given arch', if there is74 # no Kconfig file for that arch which contains K;75 #76 # - otherwise: preserve the previous status value (if any),77 # default to 'not yet supported'.78 #79 # Notice that, according these rules, invalid features may be80 # updated/modified.81 #82 if [ "$O" = "" ] && [ ! -z "$K_GREP" ]; then83 printf " |%12s: | ok |\n" "$ARCH" >> $T_FILE84 elif [ "$O" = "not" ] && [ -z "$K_GREP" ]; then85 printf " |%12s: | ok |\n" "$ARCH" >> $T_FILE86 else87 S=$(grep -v "^#" "$F_FILE" | grep " $ARCH:")88 if [ ! -z "$S" ]; then89 echo "$S" >> $T_FILE90 else91 printf " |%12s: | TODO |\n" "$ARCH" \92 >> $T_FILE93 fi94 fi95 done96 echo " -----------------------" >> $T_FILE97 mv $T_FILE $F_FILE98done99