churchyard / rpms / python2

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