summaryrefslogtreecommitdiffstats
path: root/redhat/build/is_latest_package_installed.sh
blob: 997b1f99df19b52499d3df9b0839850c674f6f6f (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
#!/bin/bash

PKGNAME="${1##*/}"
TDE_VERSION="${2:-${TDE_VERSION:-14.1.2}}"

INSTALLED=$(get_installed_package_version.sh ${PKGNAME} ${TDE_VERSION})
TARBALL=$(get_latest_tarball_version.sh ${PKGNAME} ${TDE_VERSION})
SPEC=$(get_spec_version.sh ${PKGNAME} ${TDE_VERSION})
DIST="$(rpmdist.sh --dist)"

# Package containing "~" (e.g. R14 preversion tarballs):
if [ "${TARBALL/\~/}" != "${TARBALL}" ]; then
  # Only compare the part after '~'
  if [ "${INSTALLED##*_}" = "${TARBALL#*\~}" ] ||[ "${INSTALLED#*\~}" = "${TARBALL#*\~}" ]; then
    echo "Latest package '${PKGNAME}' version '${TARBALL}' is already built and installed."
    exit 0
  fi
else
  # Other package (e.g. akode)
  if [ "${INSTALLED%-*}" = "${TARBALL%-*}" ]; then
    echo "Latest package '${PKGNAME}' version '${INSTALLED}' is already built and installed."
    exit 0
  fi

  # Other package (e.g. QT3)
  if [ "${INSTALLED}" = "${SPEC}" ] || [ "${INSTALLED}${DIST}" = "${SPEC}" ]; then
    echo "Latest package '${PKGNAME}' version '${INSTALLED}' is already built and installed."
    exit 0
  fi
fi

exit 1