blob: 99b871b337c354affdcb8dd10d943b774a460c9b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
#!/bin/bash
usage() {
echo "$0 "
echo
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'"
}
while getopts 'h' arg; do
case $arg in
h) usage; exit 0 ;;
*) usage; exit 1 ;;
esac
done
ver=${2}
pkg=${1}
pver=$(LC_ALL=C pacman -Spdd --print-format "%v" "${pkg}" 2>/dev/null)
# if pacman fails or returns nothing
r=$?
[ "${pver}" = " there is nothing to do" ] && r=1
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
|