[88834] users/ryandesign/scripts/badpyports

ryandesign at macports.org ryandesign at macports.org
Fri Jan 13 00:51:02 PST 2012


Revision: 88834
          http://trac.macports.org/changeset/88834
Author:   ryandesign at macports.org
Date:     2012-01-13 00:51:02 -0800 (Fri, 13 Jan 2012)
Log Message:
-----------
badpyports: identifies problems in ports using the unified python portgroup

Added Paths:
-----------
    users/ryandesign/scripts/badpyports

Added: users/ryandesign/scripts/badpyports
===================================================================
--- users/ryandesign/scripts/badpyports	                        (rev 0)
+++ users/ryandesign/scripts/badpyports	2012-01-13 08:51:02 UTC (rev 88834)
@@ -0,0 +1,49 @@
+#!/bin/bash
+
+# Finds ports that are using the unified python portgroup incorrectly.
+
+# Ports using the unified python portgroup.
+PYPORTS=$(port info --subports --index --line name:^py- | sed -n -e 's/^py[[:digit:]]*-//' -e 's/,.*$//p')
+
+# Count them.
+TOTALPYPORTS=$(echo $PYPORTS | wc -w)
+
+PROBLEMPORTS=0
+DEPENDENCYPROBLEMS=0
+DEFAULTVERSIONPROBLEMS=0
+for PORT in $PYPORTS; do
+    DEPS=$(port info --depends_lib --depends_build --depends_run --index --line py-$PORT | sed 's/[^[:space:]]*://g')
+    
+    # If the port declares dependencies correctly, get the default python version.
+    # If the port declares dependencies incorrectly, this will be empty.
+    DEFAULTVERSION=$(echo $DEPS | sed -E -n "s/^py([[:digit:]]{2})-$PORT$/\1/p")
+    
+    if [ -z "$DEFAULTVERSION" ]; then
+        printf "%s declares dependencies even in the stub port\n" py-$PORT
+        PROBLEMPORTS=$(($PROBLEMPORTS + 1))
+        DEPENDENCYPROBLEMS=$(($DEPENDENCYPROBLEMS + 1))
+    else
+        # Get the file of the default subport. If the default is set incorrectly, this will be empty.
+        FILE=$(port file py$DEFAULTVERSION-$PORT 2>/dev/null)
+        if [ -z "$FILE" ]; then
+            printf "%s declares default python version %s but does not offer python version %s\n" py-$PORT $DEFAULTVERSION $DEFAULTVERSION
+            PROBLEMPORTS=$(($PROBLEMPORTS + 1))
+            DEFAULTVERSIONPROBLEMS=$(($DEFAULTVERSIONPROBLEMS + 1))
+        fi
+    fi
+done
+
+echo
+printf "Out of %d ports using the unified python portgroup, %d have problems.\n" $TOTALPYPORTS $PROBLEMPORTS
+
+if [ $DEPENDENCYPROBLEMS -gt 0 ]; then
+    echo
+    printf "%d of these have dependency problems. Dependencies should only be declared in subports.\n" $DEPENDENCYPROBLEMS
+    echo "Enclose dependencies and all other \"real\" port actions in an \"if {\${name} != \${subport}}\" block."
+fi
+
+if [ $DEPENDENCYPROBLEMS -gt 0 ]; then
+    echo
+    printf "%d of these have default python version problems. python.default_version needs to be\n" $DEFAULTVERSIONPROBLEMS
+    echo "set to one of the values you set in python.versions."
+fi


Property changes on: users/ryandesign/scripts/badpyports
___________________________________________________________________
Added: svn:executable
   + *
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20120113/e11de2fc/attachment.html>


More information about the macports-changes mailing list