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