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