1fe57a
#!/bin/bash
1fe57a
1fe57a
[ $# -ge 1 ] || {
1fe57a
    cat > /dev/null
1fe57a
    exit 0
1fe57a
}
1fe57a
1fe57a
case $1 in
1fe57a
-P|--provides)
1fe57a
    shift
1fe57a
    # Match buildroot/payload paths of the form
1fe57a
    #    /PATH/OF/BUILDROOT/usr/bin/pythonMAJOR.MINOR
1fe57a
    # generating a line of the form
1fe57a
    #    python(abi) = MAJOR.MINOR
1fe57a
    # (Don't match against -config tools e.g. /usr/bin/python2.6-config)
1fe57a
    grep "/usr/bin/python.\..$" \
1fe57a
        | sed -e "s|.*/usr/bin/python\(.\..\)|python(abi) = \1|"
1fe57a
    ;;
1fe57a
-R|--requires)
1fe57a
    shift
1fe57a
    # Match buildroot paths of the form
1fe57a
    #    /PATH/OF/BUILDROOT/usr/lib/pythonMAJOR.MINOR/  and
1fe57a
    #    /PATH/OF/BUILDROOT/usr/lib64/pythonMAJOR.MINOR/
1fe57a
    # generating (uniqely) lines of the form:
1fe57a
    #    python(abi) = MAJOR.MINOR
1fe57a
    grep "/usr/lib[^/]*/python.\../.*" \
1fe57a
        | sed -e "s|.*/usr/lib[^/]*/python\(.\..\)/.*|python(abi) = \1|g" \
1fe57a
        | sort | uniq
1fe57a
    ;;
1fe57a
esac
1fe57a
1fe57a
exit 0