From nobody Sat Dec 13 04:15:22 2025 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4dStK65Tpfz6Ktdd for ; Sat, 13 Dec 2025 04:15:22 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R12" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4dStK62VFXz4JJ9 for ; Sat, 13 Dec 2025 04:15:22 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1765599322; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=JmMuErVjOjIBu6TXVFS1vrcOD3ZwcUTBhf6BJEhwRM0=; b=O2CUYP0IMEiq6kLnVdd9X1diG2ABwxYDJxA/vJ7NUIcuUmEkpQoF7J3p4B+OIg13WK0LmZ N9LX9kQBxWHMFM6vavDxVdCiu+e8ZLwkBWzPTmmd/d//UZN9onEj9nTecUfdntvEahkkfl PACmVOqYZtUzwSBvKAaaTn1MWUge+378vT/OA1hY1XEsO5+UU3fVfydTCDB7eFvQu41d6U UjyXgngBGPtr9b7DdAtJT3ny86T/A3lWoD6AA2wwQFEvNPcAeIImesQYKpwZya8cK+NZou 9/Gam+nvy0qc54Lfq+LhluW7EcmWlEfYT3TuRPeDokZTKpWsU7M7yrUDxj0T5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1765599322; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=JmMuErVjOjIBu6TXVFS1vrcOD3ZwcUTBhf6BJEhwRM0=; b=V62xOWkNW3VM7ax3OstsZXhUfWLf1KhZjh9VLEbObQ123v5wxdS70kemMi2+FuPcH1tikV GKDr4Nw92lMR9+Yc556+7Vh/XHTdfHKQZDaJC3j9OkZOS/aK7VtygLy8ZGHU5/4X4mYT9j 3vsMar+golafE/opHm7IWQcpjt/xewoBZnK3ry2v+BrjXAmimrPggonRrQH2i203ZcBQqn kGd8RDqdx/9ytds0EaLLyf/Sd9v5eyLfLcgWJuPL/CrQxDp0vEddZ0KNAB4xn2PMvdubE9 CN+45LWHt0Zvn1SnxsUfPqFUNx3S9vEf1pGNGtE4XSzNmE7rOE+1Q8tdwAg4Jw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1765599322; a=rsa-sha256; cv=none; b=nREOqz8//pi2G3iQ92DHgvvCL9xTLNS0fW4nmHusjHmVil9HGxWOq3C7wrkJNjlxN1kNeF w9B4CPj7beEH6VVsDlfQ1Dl04FQj5S8wRHM1UI4yXWM5igXUrs/SJVG/EmbYkWTpj90zHp XYcrBtjgotQoY/8Nei0C/vYm+4aZFGtin4vMMN7TZPxv3jrQW4jAeFidc+4L0ctJMS9XCm R5CISq0QDHS3oSSPwWeve3ic689/y2L5JAEFjLTogp3I3nZpDdyhlbD/PiaAXQ1jdFwtao MHD1VvxZPInUbYOPh6bbRGZ8hH5n3RR2jAoCvDe5B/ufSgMOdBA0aOCQcPKHAA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4dStK61wJ6znK2 for ; Sat, 13 Dec 2025 04:15:22 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 3983c by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Sat, 13 Dec 2025 04:15:22 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Jose Luis Duran Subject: git: 438c3249fb61 - stable/15 - locale: tools: Make finalize idempotent List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jlduran X-Git-Repository: src X-Git-Refname: refs/heads/stable/15 X-Git-Reftype: branch X-Git-Commit: 438c3249fb612d1d264bb122ec70b5a66b462acd Auto-Submitted: auto-generated Date: Sat, 13 Dec 2025 04:15:22 +0000 Message-Id: <693ce85a.3983c.412f43a3@gitrepo.freebsd.org> The branch stable/15 has been updated by jlduran: URL: https://cgit.FreeBSD.org/src/commit/?id=438c3249fb612d1d264bb122ec70b5a66b462acd commit 438c3249fb612d1d264bb122ec70b5a66b462acd Author: Jose Luis Duran AuthorDate: 2025-12-06 12:20:19 +0000 Commit: Jose Luis Duran CommitDate: 2025-12-13 04:14:07 +0000 locale: tools: Make finalize idempotent The finalize script renames source files with 3 components in their name into names with two components with an @modifier, in the process. Running the script for a second time without cleaning will strip the @modifier from the files, producing invalid Makefiles and unusable locales. Prevent this by adding a guard at the beginning of the script. Also, use a sub-shell for directory changes to avoid working directory issues. Reviewed by: bapt MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D53981 (cherry picked from commit 934364da7fc8cd3ba4d030d0478163b41dda1b37) --- tools/tools/locale/tools/finalize | 115 ++++++++++++++++++++------------------ 1 file changed, 60 insertions(+), 55 deletions(-) diff --git a/tools/tools/locale/tools/finalize b/tools/tools/locale/tools/finalize index 23afaddafa9b..b4dc38360451 100755 --- a/tools/tools/locale/tools/finalize +++ b/tools/tools/locale/tools/finalize @@ -69,64 +69,69 @@ AWKCMD="/## PLACEHOLDER/ { \ while ( getline line < \"${TEMP4}\" ) {print line} } \ !/## / { print \$0 }" -# Rename the sources with 3 components name into the POSIX version of the name using @modifier -mkdir -p $old $new -cd $old -pwd -for i in *_*_*.*.src; do - if [ "$i" = "*_*_*.*.src" ]; then - break - fi - oldname=${i%.*} - nname=`echo $oldname | awk '{ split($0, a, "_"); print a[1]"_"a[3]"@"a[2];} '` - mv -f ${oldname}.src ${nname}.src - sed -i '' -e "s/${oldname}/${nname}/g" Makefile -done - -# For variable without @modifier ambiguity do not keep the @modifier -for i in *@*.src; do - if [ "$i" = "*@*.src" ]; then - break - fi - oldname=${i%.*} - shortname=${oldname%@*} - if [ $(ls ${shortname}@* | wc -l) -eq 1 ] ; then - mv -f $i ${shortname}.src - sed -i '' -e "s/${oldname}/${shortname}/g" Makefile - fi -done - -# Rename the modifiers into non abbreviated version -for i in *@Latn.src; do - if [ "$i" = "*@Latn.src" ]; then - break - fi - mv -f ${i} ${i%@*}@latin.src - sed -i '' -e "s/${i%.*}/${i%@*}@latin/g" Makefile -done - -for i in *@Cyrl.src; do - if [ "$i" = "*@Cyrl.src" ]; then - break - fi - mv -f ${i} ${i%@*}@cyrillic.src - sed -i '' -e "s/${i%.*}/${i%@*}@cyrillic/g" Makefile -done - -# On locales with multiple modifiers rename the "default" version without the @modifier -default_locales="sr_RS@cyrillic" -for i in ${default_locales}; do - localename=${i%@*} - mod=${i#*@} - for l in ${localename}.*@${mod}.src; do - if [ "$l" = "${localename}.*@${mod}.src" ]; then +if ! find "$old" -name "*_*_*.*.src" -type f -print -quit | grep -q .; then + exit +fi + +mkdir -p $new +( + cd $old + + # Rename the sources with 3 components name into the POSIX version of the name using @modifier + for i in *_*_*.*.src; do + if [ "$i" = "*_*_*.*.src" ]; then + break + fi + oldname=${i%.*} + nname=`echo $oldname | awk '{ split($0, a, "_"); print a[1]"_"a[3]"@"a[2];} '` + mv -f ${oldname}.src ${nname}.src + sed -i '' -e "s/${oldname}/${nname}/g" Makefile + done + + # For variable without @modifier ambiguity do not keep the @modifier + for i in *@*.src; do + if [ "$i" = "*@*.src" ]; then + break + fi + oldname=${i%.*} + shortname=${oldname%@*} + if [ $(ls ${shortname}@* | wc -l) -eq 1 ] ; then + mv -f $i ${shortname}.src + sed -i '' -e "s/${oldname}/${shortname}/g" Makefile + fi + done + + # Rename the modifiers into non abbreviated version + for i in *@Latn.src; do + if [ "$i" = "*@Latn.src" ]; then break fi - mv -f ${l} ${l%@*}.src - sed -i '' -e "s/${l%.*}/${l%@*}/g" Makefile + mv -f ${i} ${i%@*}@latin.src + sed -i '' -e "s/${i%.*}/${i%@*}@latin/g" Makefile + done + + for i in *@Cyrl.src; do + if [ "$i" = "*@Cyrl.src" ]; then + break + fi + mv -f ${i} ${i%@*}@cyrillic.src + sed -i '' -e "s/${i%.*}/${i%@*}@cyrillic/g" Makefile + done + + # On locales with multiple modifiers rename the "default" version without the @modifier + default_locales="sr_RS@cyrillic" + for i in ${default_locales}; do + localename=${i%@*} + mod=${i#*@} + for l in ${localename}.*@${mod}.src; do + if [ "$l" = "${localename}.*@${mod}.src" ]; then + break + fi + mv -f ${l} ${l%@*}.src + sed -i '' -e "s/${l%.*}/${l%@*}/g" Makefile + done done -done -cd - +) grep '^LOCALES+' ${old}/Makefile > ${TEMP}