Path: blob/master/Documentation/features/scripts/features-refresh.sh
26298 views
#1# Small script that refreshes the kernel feature support status in place.2#34for F_FILE in Documentation/features/*/*/arch-support.txt; do5F=$(grep "^# Kconfig:" "$F_FILE" | cut -c26-)67#8# Each feature F is identified by a pair (O, K), where 'O' can9# be either the empty string (for 'nop') or "not" (the logical10# negation operator '!'); other operators are not supported.11#12O=""13K=$F14if [[ "$F" == !* ]]; then15O="not"16K=$(echo $F | sed -e 's/^!//g')17fi1819#20# F := (O, K) is 'valid' iff there is a Kconfig file (for some21# arch) which contains K.22#23# Notice that this definition entails an 'asymmetry' between24# the case 'O = ""' and the case 'O = "not"'. E.g., F may be25# _invalid_ if:26#27# [case 'O = ""']28# 1) no arch provides support for F,29# 2) K does not exist (e.g., it was renamed/mis-typed);30#31# [case 'O = "not"']32# 3) all archs provide support for F,33# 4) as in (2).34#35# The rationale for adopting this definition (and, thus, for36# keeping the asymmetry) is:37#38# We want to be able to 'detect' (2) (or (4)).39#40# (1) and (3) may further warn the developers about the fact41# that K can be removed.42#43F_VALID="false"44for ARCH_DIR in arch/*/; do45K_FILES=$(find $ARCH_DIR -name "Kconfig*")46K_GREP=$(grep "$K" $K_FILES)47if [ ! -z "$K_GREP" ]; then48F_VALID="true"49break50fi51done52if [ "$F_VALID" = "false" ]; then53printf "WARNING: '%s' is not a valid Kconfig\n" "$F"54fi5556T_FILE="$F_FILE.tmp"57grep "^#" $F_FILE > $T_FILE58echo " -----------------------" >> $T_FILE59echo " | arch |status|" >> $T_FILE60echo " -----------------------" >> $T_FILE61for ARCH_DIR in arch/*/; do62ARCH=$(echo $ARCH_DIR | sed -e 's/^arch//g' | sed -e 's/\///g')63K_FILES=$(find $ARCH_DIR -name "Kconfig*")64K_GREP=$(grep "$K" $K_FILES)65#66# Arch support status values for (O, K) are updated according67# to the following rules.68#69# - ("", K) is 'supported by a given arch', if there is a70# Kconfig file for that arch which contains K;71#72# - ("not", K) is 'supported by a given arch', if there is73# no Kconfig file for that arch which contains K;74#75# - otherwise: preserve the previous status value (if any),76# default to 'not yet supported'.77#78# Notice that, according these rules, invalid features may be79# updated/modified.80#81if [ "$O" = "" ] && [ ! -z "$K_GREP" ]; then82printf " |%12s: | ok |\n" "$ARCH" >> $T_FILE83elif [ "$O" = "not" ] && [ -z "$K_GREP" ]; then84printf " |%12s: | ok |\n" "$ARCH" >> $T_FILE85else86S=$(grep -v "^#" "$F_FILE" | grep " $ARCH:")87if [ ! -z "$S" ]; then88echo "$S" >> $T_FILE89else90printf " |%12s: | TODO |\n" "$ARCH" \91>> $T_FILE92fi93fi94done95echo " -----------------------" >> $T_FILE96mv $T_FILE $F_FILE97done9899100