teknoraver / rpms / rpm

Forked from rpms/rpm 4 months ago
Clone
Blob Blame History Raw
diff --git a/scripts/pythondeps.sh b/scripts/pythondeps.sh
index 7ccd076..7bf6fec 100755
--- a/scripts/pythondeps.sh
+++ b/scripts/pythondeps.sh
@@ -5,17 +5,27 @@
     exit 0
 }
 
-PYVER=`python -c "import sys; v=sys.version_info[:2]; print '%d.%d'%v"`
 case $1 in
 -P|--provides)
     shift
-    grep "/usr/bin/python\*\$" >& /dev/null && echo "python(abi) = ${PYVER}"
-    exit 0
+    # Match buildroot/payload paths of the form
+    #    /PATH/OF/BUILDROOT/usr/bin/pythonMAJOR.MINOR
+    # generating a line of the form
+    #    python(abi) = MAJOR.MINOR
+    # (Don't match against -config tools e.g. /usr/bin/python2.6-config)
+    grep "/usr/bin/python.\..$" \
+        | sed -e "s|.*/usr/bin/python\(.\..\)|python(abi) = \1|"
     ;;
 -R|--requires)
     shift
-    grep "/usr/lib[^/]*/python${PYVER}/" >& /dev/null && echo "python(abi) = ${PYVER}"
-    exit 0
+    # Match buildroot paths of the form
+    #    /PATH/OF/BUILDROOT/usr/lib/pythonMAJOR.MINOR/  and
+    #    /PATH/OF/BUILDROOT/usr/lib64/pythonMAJOR.MINOR/
+    # generating (uniqely) lines of the form:
+    #    python(abi) = MAJOR.MINOR
+    grep "/usr/lib[^/]*/python.\../*" \
+        | sed -e "s|.*/usr/lib[^/]*/python\(.\..\)/.*|python(abi) = \1|g" \
+        | sort | uniq
     ;;
 esac