요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.
1. 요약·해설
원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.
2. 영어 원문 전체
번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.
원문 전체 펼치기
#
# Small script that refreshes the kernel feature support status in place.
#
for F_FILE in Documentation/features/*/*/arch-support.txt; do
F=$(grep "^# Kconfig:" "$F_FILE" | cut -c26-)
#
# Each feature F is identified by a pair (O, K), where 'O' can
# be either the empty string (for 'nop') or "not" (the logical
# negation operator '!'); other operators are not supported.
#
O=""
K=$F
if [[ "$F" == !* ]]; then
O="not"
K=$(echo $F | sed -e 's/^!//g')
fi
#
# F := (O, K) is 'valid' iff there is a Kconfig file (for some
# arch) which contains K.
#
# Notice that this definition entails an 'asymmetry' between
# the case 'O = ""' and the case 'O = "not"'. E.g., F may be
# _invalid_ if:
#
# [case 'O = ""']
# 1) no arch provides support for F,
# 2) K does not exist (e.g., it was renamed/mis-typed);
#
# [case 'O = "not"']
# 3) all archs provide support for F,
# 4) as in (2).
#
# The rationale for adopting this definition (and, thus, for
# keeping the asymmetry) is:
#
# We want to be able to 'detect' (2) (or (4)).
#
# (1) and (3) may further warn the developers about the fact
# that K can be removed.
#
F_VALID="false"
for ARCH_DIR in arch/*/; do
K_FILES=$(find $ARCH_DIR -name "Kconfig*")
K_GREP=$(grep "$K" $K_FILES)
if [ ! -z "$K_GREP" ]; then
F_VALID="true"
break
fi
done
if [ "$F_VALID" = "false" ]; then
printf "WARNING: '%s' is not a valid Kconfig\n" "$F"
fi
T_FILE="$F_FILE.tmp"
grep "^#" $F_FILE > $T_FILE
echo " -----------------------" >> $T_FILE
echo " | arch |status|" >> $T_FILE
echo " -----------------------" >> $T_FILE
for ARCH_DIR in arch/*/; do
ARCH=$(echo $ARCH_DIR | sed -e 's/^arch//g' | sed -e 's/\///g')
K_FILES=$(find $ARCH_DIR -name "Kconfig*")
K_GREP=$(grep "$K" $K_FILES)
#
# Arch support status values for (O, K) are updated according
# to the following rules.
#
# - ("", K) is 'supported by a given arch', if there is a
# Kconfig file for that arch which contains K;
#
# - ("not", K) is 'supported by a given arch', if there is
# no Kconfig file for that arch which contains K;
#
# - otherwise: preserve the previous status value (if any),
# default to 'not yet supported'.
#
# Notice that, according these rules, invalid features may be
# updated/modified.
#
if [ "$O" = "" ] && [ ! -z "$K_GREP" ]; then
printf " |%12s: | ok |\n" "$ARCH" >> $T_FILE
elif [ "$O" = "not" ] && [ -z "$K_GREP" ]; then
printf " |%12s: | ok |\n" "$ARCH" >> $T_FILE
else
S=$(grep -v "^#" "$F_FILE" | grep " $ARCH:")
if [ ! -z "$S" ]; then
echo "$S" >> $T_FILE
else
printf " |%12s: | TODO |\n" "$ARCH" \
>> $T_FILE
fi
fi
done
echo " -----------------------" >> $T_FILE
mv $T_FILE $F_FILE
done
3. 한국어 전문 번역
영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.
Kconfig 존재 여부로 arch-support.txt를 제자리 재생성
1-98`features-refresh.sh`는 `Documentation/features/*/*/arch-support.txt`의 아키텍처별 지원 상태 표를 현재 커널 소스의 Kconfig 내용과 대조해 제자리에서 다시 만드는 셸 스크립트입니다. 각 기능 파일의 `# Kconfig:` 헤더에서 표현식 `F`를 추출하고, 이를 연산자 `O`와 Kconfig 심볼 `K`의 쌍으로 해석합니다.
지원하는 연산자는 두 가지뿐입니다. 긍정형은 `O`가 빈 문자열이고 `K=F`이며, 표현식이 `!`로 시작하면 `O=not`으로 두고 선두 `!`를 제거한 나머지를 `K`로 사용합니다. 다른 논리 연산자는 지원하지 않습니다.
스크립트는 먼저 어느 아키텍처의 `Kconfig*` 파일에라도 `K`가 있는지 검사해 기능 표현식의 유효성을 판단합니다. 그 뒤 원래 파일의 주석 행만 임시 파일에 복사하고 새 표 머리글을 쓴 다음, 각 아키텍처를 다시 순회해 `ok`, 기존 상태 또는 `TODO` 행을 선택합니다. 마지막에 임시 파일을 원래 `arch-support.txt`로 이동합니다.
기능 파일 하나마다 표현식을 해석하고 유효성을 검사한 뒤 아키텍처 표를 재구성합니다.
원문 5-18줄에서 헤더 문자열과 부정 연산자를 처리합니다.
원문 20-43줄의 정의와 네 가지 경고 가능 상황을 그대로 풀어 씁니다.
원문 44-55줄은 모든 `arch/*/Kconfig*`에서 K 문자열을 찾습니다.
원문 57-61줄은 기존 데이터 행을 버리고 주석과 새 머리글만 남깁니다.
원문 62-95줄에서 `(O,K)`와 K 검색 결과를 상태 행으로 바꿉니다.
반복 중 경로를 이름으로 바꾸고 고정 폭 행을 출력하는 세부입니다.
98줄 전체의 주석·판정·파일 교체 범위입니다.
아래 코드는 Linux v6.18.37 원문 1-98줄 전체입니다. 표시 안정성을 위해 탭만 여덟 칸으로 정규화했으며 변수명, glob, grep·find·sed 표현식, 주석의 사례 번호, 표 문자와 파일 교체 순서를 변경하지 않았습니다.
#
# Small script that refreshes the kernel feature support status in place.
#
for F_FILE in Documentation/features/*/*/arch-support.txt; do
F=$(grep "^# Kconfig:" "$F_FILE" | cut -c26-)
#
# Each feature F is identified by a pair (O, K), where 'O' can
# be either the empty string (for 'nop') or "not" (the logical
# negation operator '!'); other operators are not supported.
#
O=""
K=$F
if [[ "$F" == !* ]]; then
O="not"
K=$(echo $F | sed -e 's/^!//g')
fi
#
# F := (O, K) is 'valid' iff there is a Kconfig file (for some
# arch) which contains K.
#
# Notice that this definition entails an 'asymmetry' between
# the case 'O = ""' and the case 'O = "not"'. E.g., F may be
# _invalid_ if:
#
# [case 'O = ""']
# 1) no arch provides support for F,
# 2) K does not exist (e.g., it was renamed/mis-typed);
#
# [case 'O = "not"']
# 3) all archs provide support for F,
# 4) as in (2).
#
# The rationale for adopting this definition (and, thus, for
# keeping the asymmetry) is:
#
# We want to be able to 'detect' (2) (or (4)).
#
# (1) and (3) may further warn the developers about the fact
# that K can be removed.
#
F_VALID="false"
for ARCH_DIR in arch/*/; do
K_FILES=$(find $ARCH_DIR -name "Kconfig*")
K_GREP=$(grep "$K" $K_FILES)
if [ ! -z "$K_GREP" ]; then
F_VALID="true"
break
fi
done
if [ "$F_VALID" = "false" ]; then
printf "WARNING: '%s' is not a valid Kconfig\n" "$F"
fi
T_FILE="$F_FILE.tmp"
grep "^#" $F_FILE > $T_FILE
echo " -----------------------" >> $T_FILE
echo " | arch |status|" >> $T_FILE
echo " -----------------------" >> $T_FILE
for ARCH_DIR in arch/*/; do
ARCH=$(echo $ARCH_DIR | sed -e 's/^arch//g' | sed -e 's/\///g')
K_FILES=$(find $ARCH_DIR -name "Kconfig*")
K_GREP=$(grep "$K" $K_FILES)
#
# Arch support status values for (O, K) are updated according
# to the following rules.
#
# - ("", K) is 'supported by a given arch', if there is a
# Kconfig file for that arch which contains K;
#
# - ("not", K) is 'supported by a given arch', if there is
# no Kconfig file for that arch which contains K;
#
# - otherwise: preserve the previous status value (if any),
# default to 'not yet supported'.
#
# Notice that, according these rules, invalid features may be
# updated/modified.
#
if [ "$O" = "" ] && [ ! -z "$K_GREP" ]; then
printf " |%12s: | ok |\n" "$ARCH" >> $T_FILE
elif [ "$O" = "not" ] && [ -z "$K_GREP" ]; then
printf " |%12s: | ok |\n" "$ARCH" >> $T_FILE
else
S=$(grep -v "^#" "$F_FILE" | grep " $ARCH:")
if [ ! -z "$S" ]; then
echo "$S" >> $T_FILE
else
printf " |%12s: | TODO |\n" "$ARCH" \
>> $T_FILE
fi
fi
done
echo " -----------------------" >> $T_FILE
mv $T_FILE $F_FILE
done
요약·해설
features-refresh.sh:1-98각 기능의 Kconfig 표현식을 긍정형 또는 부정형 `(O,K)`로 해석하고 모든 아키텍처의 Kconfig를 검사해 `arch-support.txt` 상태 표를 주석·기존 상태 보존 규칙과 함께 재생성합니다.
K가 어디에도 없으면 이름 변경·오타 가능성을 포함한 경고를 내지만 표 갱신은 계속합니다. 명확한 지원 조건은 `ok`, 나머지는 기존 상태를 보존하고 기존 행이 없을 때만 `TODO`를 기록합니다.
기능 파일마다 유효성 검사와 상태 표 생성을 차례로 수행합니다.