abuild: refactor duplicate python detection to not use find(1)

the previous implementation used -regex, which is subtly different between busybox and findutils

[0-9]\+ matches on busybox, but doesn't match with gnu findutils
[0-9]+ matches with findutils, but doesn't match on busybox

this means python deps were subtly broken when findutils was installed
(sometimes pulled via makedeps) vs not
This commit is contained in:
psykose 2023-06-15 12:50:11 +00:00 committed by alice
parent 8f41a924e3
commit 8d11e9f410

View File

@ -1705,20 +1705,25 @@ scan_symlink_targets() {
# check if python3 site packages are installed and depend on a compatible version
scan_python3_dependency() {
local controldir="$2" datadir="$3"
local site_pkg_dirs
if site_pkg_dirs="$(find "$datadir"/usr/lib/ -type d -regex '.*python3\.[0-9]\+/site-packages' -mindepth 2 -maxdepth 2 2>/dev/null)"; then
local pyver_count="$(echo "$site_pkg_dirs" | wc -l)"
if [ "$pyver_count" -gt 1 ]; then
error "package contains python3 modules for conflicting python3 versions"
exit 1
local dir_count=0
local site_pkg_dir
for site_pkg_dir in "$datadir"/usr/lib/python3*/site-packages; do
if ! [ -d "$site_pkg_dir" ]; then
# empty iteration
continue
fi
local pyver="${site_pkg_dirs##*usr/lib/python}"
dir_count=$((dir_count + 1))
if [ "$dir_count" -gt 1 ]; then
error "package contains python3 modules for conflicting python3 versions"
return 1
fi
local pyver="${site_pkg_dir##*usr/lib/python}"
pyver="${pyver%%/*}"
if [ -n "$pyver" ]; then
echo "python3~$pyver" \
>> "$controldir"/.python3-needs
fi
fi
done
}
#find pkg-config dependencies