scripts/kernel_bump: Use git to obtain the list of files
authorOlliver Schinagl <oliver@schinagl.nl>
Mon, 18 Mar 2024 12:24:12 +0000 (13:24 +0100)
committerRobert Marko <robimarko@gmail.com>
Fri, 12 Apr 2024 16:20:52 +0000 (18:20 +0200)
Instead of looping of a directory to find directories related to kernel
changes, use the git index instead.

Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
scripts/kernel_bump.sh

index 069f53bb77646c61ec46621cfc2e061ea361fa93..d9fc5287dfccf017d1ce39ad72a3125d685cdb57 100755 (executable)
@@ -18,8 +18,10 @@ REQUIRED_COMMANDS='
        exit
        git
        printf
+       sed
        set
        shift
+       sort
 '
 
 _msg()
@@ -115,7 +117,9 @@ bump_kernel()
        git switch --force-create '__openwrt_kernel_files_mover'
 
        if [ "${config_only:-false}" != 'true' ]; then
-               for _path in "${_target_dir}/"*; do
+               for _path in $(git ls-tree -d -r --name-only '__openwrt_kernel_files_mover' "${_target_dir}" |
+                              sed -n "s|^\(.*-${source_version}\).*|\1|p" |
+                              sort -u); do
                        if [ ! -e "${_path}" ] || \
                           [ "${_path}" = "${_path%%"-${source_version}"}" ]; then
                                continue