From c4eb645a0bce470aefea9b5c9cbb878095451d8a Mon Sep 17 00:00:00 2001 From: Yidi Lin Date: Fri, 6 Jun 2025 08:40:25 +0800 Subject: [PATCH] update_submodules: Fix submodule path handling There are two regressions introduced by CB:87823. 1. If the specified repo path has a tailing slash, `submodule` becames a empty variable due to `${submodule##*/}`, e.g., `./util/scripts/update_submodules -R 3rdparty/arm-trusted-firmware/` 2. CB:87823 uses `git submodule status | cut -d ' ' -f 3` to retrieve all submodule paths. The script gets the wrong path if the format is wrong, e.g., -26c572974bcf7255930b0e9a51da3144ed0104b5 3rdparty/amd_blobs 57ac3f74b34a3303f03deee264a1f2247c68008d 3rdparty/arm-trusted-firmware (v2.12.0-908-g57ac3f74b) +5b7492979fc139efdfdc7f97ae53a2349798f160 3rdparty/cmocka (cmocka-1.1.5-263-g5b74929) The script gets the empty path for 3rdparty/amd_blobs and get cmocka-1.1.5-263-g5b74929 for 3rdparty/cmocka. This patch fixes 1 by removing the tailing slash for the input directory and fixes 2 by the below command. `git submodule foreach 'echo ${sm_path}'|grep -v Entering` Note that `smp_path` is an environment variable[1] set by `git submodule` when travelling the submodule directory. [1]: https://git-scm.com/docs/git-submodule Change-Id: I0016f3a867e2b4594788d71a790ff9a938121da5 Signed-off-by: Yidi Lin Reviewed-on: https://review.coreboot.org/c/coreboot/+/87972 Tested-by: build bot (Jenkins) Reviewed-by: Yu-Ping Wu Reviewed-by: Matt DeVillier --- util/scripts/update_submodules | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/util/scripts/update_submodules b/util/scripts/update_submodules index be3273b4a2..9438e756d9 100755 --- a/util/scripts/update_submodules +++ b/util/scripts/update_submodules @@ -65,7 +65,7 @@ get_args() { exit 0 ;; -R | --repo) - submodule_dirs="${1}" + submodule_dirs="${1%/}" shift if [[ ! -d "${submodule_dirs[0]}" ]]; then echo "Error: ${submodule_dirs[0]} is not valid." @@ -92,7 +92,7 @@ main() { get_args "$@" if (( ${#submodule_dirs[@]} == 0 )); then - readarray -t submodule_dirs < <(git submodule status | cut -d ' ' -f 3) + readarray -t submodule_dirs < <(git submodule foreach 'echo ${sm_path}'|grep -v Entering) fi for submodule in "${submodule_dirs[@]}"; do