From 6d651362c387ac29cae1ea6904db5719f3915cee Mon Sep 17 00:00:00 2001 From: Shung-Hsi Yu Date: Mar 07 2023 14:31:44 +0000 Subject: rpm/group-source-files.pl: Deal with {pre,post}fixed / in location When the source file location provided with -L is either prefixed or postfixed with forward slash, the script get stuck in a infinite loop inside calc_dirs() where $path is an empty string. user@localhost:/tmp> perl "$HOME/group-source-files.pl" -D devel.files -N nondevel.files -L /usr/src/linux-5.14.21-150500.41/ ... path = /usr/src/linux-5.14.21-150500.41/Documentation/Kconfig path = /usr/src/linux-5.14.21-150500.41/Documentation path = /usr/src/linux-5.14.21-150500.41 path = /usr/src path = /usr path = path = path = ... # Stuck in an infinite loop This workarounds the issue by breaking out the loop once path is an empty string. For a proper fix we'd want something that filesystem-aware, but this workaround should be enough for the rare occation that this script is ran manually. Link: http://mailman.suse.de/mlarch/SuSE/kernel/2023/kernel.2023.03/msg00024.html --- diff --git a/rpm/group-source-files.pl b/rpm/group-source-files.pl index 768ecff..89fa8e8 100755 --- a/rpm/group-source-files.pl +++ b/rpm/group-source-files.pl @@ -66,7 +66,7 @@ sub calc_dirs do { $path =~ s{/[^/]+$}{}; $dirs{$path} = 1; - } while ($path ne $base); + } while ($path ne $base and $path ne ""); # This loop also makes sure that $base itself is included. }