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 # check if python3 site packages are installed and depend on a compatible version
scan_python3_dependency() { scan_python3_dependency() {
local controldir="$2" datadir="$3" local controldir="$2" datadir="$3"
local site_pkg_dirs local dir_count=0
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 site_pkg_dir
local pyver_count="$(echo "$site_pkg_dirs" | wc -l)" for site_pkg_dir in "$datadir"/usr/lib/python3*/site-packages; do
if [ "$pyver_count" -gt 1 ]; then if ! [ -d "$site_pkg_dir" ]; then
error "package contains python3 modules for conflicting python3 versions" # empty iteration
exit 1 continue
fi 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%%/*}" pyver="${pyver%%/*}"
if [ -n "$pyver" ]; then if [ -n "$pyver" ]; then
echo "python3~$pyver" \ echo "python3~$pyver" \
>> "$controldir"/.python3-needs >> "$controldir"/.python3-needs
fi fi
fi done
} }
#find pkg-config dependencies #find pkg-config dependencies