From 8d11e9f410f43d11e69d988ae8106a5ceac2b805 Mon Sep 17 00:00:00 2001 From: psykose Date: Thu, 15 Jun 2023 12:50:11 +0000 Subject: [PATCH] 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 --- abuild.in | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/abuild.in b/abuild.in index e842220..8e575e7 100755 --- a/abuild.in +++ b/abuild.in @@ -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