diff options
author | Nicolás Reynolds <apoyosis@correo.inta.gob.ar> | 2012-02-04 13:17:05 -0300 |
---|---|---|
committer | Nicolás Reynolds <apoyosis@correo.inta.gob.ar> | 2012-02-04 13:17:05 -0300 |
commit | 3fb8e62b798c0dffb201727439a6a0d90bc1b20f (patch) | |
tree | f69c1b6db4082e9188f22be8d3d3d5cc5212f34f /is_built | |
parent | 5ab36af3c7a505ff40bb8ca46ec387b94d85cbdf (diff) | |
parent | 9808018ca09050ade144d0dfc0b0b6edadefa368 (diff) |
Merge branch 'master' of ssh://gparabola/libretools
Conflicts:
libremakepkg
Diffstat (limited to 'is_built')
-rwxr-xr-x | is_built | 29 |
1 files changed, 20 insertions, 9 deletions
@@ -2,9 +2,10 @@ usage() { echo "$0 " echo - echo "Detect is a package is installed or in a database" + echo "Detect if a given package version is already in repos" + echo "Assuming you want greater or equal" echo - echo "Example usage: is_built \"pcre>=20\"" + echo "Example usage: is_built 'pcre' '20'" } while getopts 'h' arg; do @@ -14,12 +15,22 @@ while getopts 'h' arg; do esac done -# Checks for package, if -T returns non-zero output, egrep will return 0 -# because it finds it, so we negate the value to say it's not built. -# -Sp works backwards, it will print output only when the package already -# exists +ver=${2} +pkg=${1} +pver=$(LC_ALL=C pacman -Sddp --print-format "%v" "${pkg}" 2>/dev/null) -!(sudo pacman -T "$1" | egrep "*" >/dev/null) || \ -sudo pacman -Sp "$1" --print-format "%n-%v" 2>/dev/null | egrep "*" >/dev/null +# if pacman fails or returns nothing +r=$? +[ "${pver}" = " there is nothing to do" ] && r=1 -exit $? +result=$(vercmp "${pver}" "${ver}") + +# if vercmp > 1 means our version is bigger +if [ ${result} -ge 0 -a ${r} -eq 0 ]; then + exit 0 +else + exit 1 +fi + +# just in case +exit 1 |