From a082c08a1dc6c90ece57af34981c18633c55b228 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Wed, 10 Dec 2025 20:05:07 +0100 Subject: [PATCH] CMake artifacts cleanup: fix the new code on Ubuntu 16.04 Signed-off-by: Gilles Peskine --- scripts/all-core.sh | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/scripts/all-core.sh b/scripts/all-core.sh index 208506aa4..903d09c9e 100644 --- a/scripts/all-core.sh +++ b/scripts/all-core.sh @@ -369,6 +369,19 @@ Tool path options: EOF } +# list_git_files PATTERN... +# List files known to git, matching pattern. +# Equivalent to `git ls-files --recurse-submodules PATTERN...`, but +# works with older Git (especially on Ubuntu 16.04) that understand +# submodules but not `git ls-files --recurse-submodules`. +list_git_files () +{ + git ls-files -- "$@" + for d in $(git submodule status --recursive | awk '{print $2}'); do + git ls-files "$@" | sed "s!^!$d/!" + done +} + # Cleanup before/after running a component. # Remove built files as well as the cmake cache/config. # Does not remove generated source files. @@ -383,8 +396,7 @@ cleanup() # subdirectories. # Remove **/Makefile only if it looks like it was created by an in-tree # CMake build. - local cmake_dirs=($(git ls-files --recurse-submodules \ - 'CMakeLists.txt' '**/CMakeLists.txt' | + local cmake_dirs=($(list_git_files 'CMakeLists.txt' '**/CMakeLists.txt' | sed -e 's![^/]*$!!')) for d in "${cmake_dirs[@]}"; do if [ -d "$d/CMakeFiles" ]; then