summaryrefslogtreecommitdiff
path: root/package-version-matrix
diff options
context:
space:
mode:
authorJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2012-08-23 13:40:12 (GMT)
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2012-08-23 13:40:12 (GMT)
commitbe3183ea867ad6fe909e9684b45d6e3667cf2ede (patch)
treea02ef1b97f5f847f328c460cb81a2c15c4de3776 /package-version-matrix
parent916c3e2934b13bbb4f40b9fb9f04ed84cf142407 (diff)
downloadkolab-scripts-be3183ea867ad6fe909e9684b45d6e3667cf2ede.tar.gz
1) Correct the return value of version_compare()
2) Make the versions installed, native and kolab arrays for the RPM side of things as well 3) Get the return code for version_compare() 4) Divide the suffix for the native side and the kolab side of the table
Diffstat (limited to 'package-version-matrix')
-rwxr-xr-xpackage-version-matrix/package-versions-matrix.sh69
1 files changed, 38 insertions, 31 deletions
diff --git a/package-version-matrix/package-versions-matrix.sh b/package-version-matrix/package-versions-matrix.sh
index b189c83..148076b 100755
--- a/package-version-matrix/package-versions-matrix.sh
+++ b/package-version-matrix/package-versions-matrix.sh
@@ -39,10 +39,16 @@ function version_compare() {
if [ -x "$(which rpmdev-vercmp 2>/dev/null)" ]; then
retval=`rpmdev-vercmp "${wanted_version}" "${actual_version}" >/dev/null 2>&1; echo $?`
- ## Return code 0 says version1 == version2
- ## Return code 12 says version1 < version2,
- [ ${retval} -ne 12 -a ${retval} -ne 0 ] && retval=0 || retval=1
-
+ ## Return code 0 says wanted == actul,
+ ## Return code 11 says wanted > actual, (NOT OK)
+ ## Return code 12 says wanted < actual,
+ if [ ${retval} -eq 0 ]; then
+ return 0
+ elif [ ${retval} -eq 11 ]; then
+ return 1
+ elif [ ${retval} -eq 12 ]; then
+ return 0
+ fi
else
retval=`dpkg --compare-versions "${wanted_version}" gt "${actual_version}" >/dev/null 2>&1; echo $?`
fi
@@ -624,8 +630,9 @@ done
# Placeholder so we can do version comparisons between runs against native and
# kolab.
-declare -a pkg_versions_native
declare -a pkg_versions_kolab
+declare -a pkg_versions_installed
+declare -a pkg_versions_native
if [ -x "$(which apt-cache 2>/dev/null)" ]; then
@@ -783,9 +790,9 @@ else
pkg=${pkgs[${x}]}
_pkg_names=""
- available_version_native=""
- available_version_kolab=""
- installed_version=""
+ pkg_versions_kolab[${x}]=""
+ pkg_versions_native[${x}]=""
+ pkg_versions_installed[${x}]=""
wanted_version=${pkg_versions[${x}]}
@@ -804,16 +811,16 @@ else
fi
for _pkg in ${_pkg_names}; do
- if [ -z "${available_version_native}" ]; then
- available_version_native=`repoquery --disablerepo=\*kolab\* --disablerepo=\*rpmfusion\* --queryformat="%{VERSION}" ${_pkg} | tail -n 1`
+ if [ -z "${pkg_versions_native[${x}]}" ]; then
+ pkg_versions_native[${x}]=`repoquery --disablerepo=\*kolab\* --disablerepo=\*rpmfusion\* --queryformat="%{VERSION}" ${_pkg} | tail -n 1`
fi
- if [ -z "${available_version_kolab}" ]; then
- available_version_kolab=`repoquery --disablerepo=\* --enablerepo=kolab-${kolab_version} --enablerepo=kolab-${kolab_version}-updates --enablerepo=kolab-${kolab_version}-development --queryformat="%{VERSION}" ${_pkg} | tail -n 1`
+ if [ -z "${pkg_versions_kolab[${x}]}" ]; then
+ pkg_versions_kolab[${x}]=`repoquery --disablerepo=\* --enablerepo=kolab-${kolab_version} --enablerepo=kolab-${kolab_version}-updates --enablerepo=kolab-${kolab_version}-development --queryformat="%{VERSION}" ${_pkg} | tail -n 1`
fi
- if [ -z "${installed_version}" ]; then
- installed_version=`rpmquery --queryformat="%{VERSION}" ${_pkg} 2>/dev/null | grep -v "not installed" | tail -n 1`
+ if [ -z "${pkg_versions_installed[${x}]}" ]; then
+ pkg_versions_installed[${x}]=`rpmquery --queryformat="%{VERSION}" ${_pkg} 2>/dev/null | grep -v "not installed" | tail -n 1`
fi
done
@@ -822,37 +829,37 @@ else
retval=""
if [ ! -z "${wanted_version}" ]; then
- if [ -z "${available_version_kolab}" ]; then
- if [ ! -z "${available_version_native}" ]; then
- retval=`version_compare "${pkg}" "${wanted_version}" "${pkg_versions_native[${x}]}"`
+ if [ -z "${pkg_versions_kolab[${x}]}" ]; then
+ if [ ! -z "${pkg_versions_native[${x}]}" ]; then
+ retval=`version_compare "${pkg}" "${wanted_version}" "${pkg_versions_native[${x}]}"; echo $?`
fi
else
- retval=`version_compare "${pkg}" "${wanted_version}" "${pkg_versions_native[${x}]}"`
+ retval=`version_compare "${pkg}" "${wanted_version}" "${pkg_versions_native[${x}]}"; echo $?`
fi
fi
- if [ -z "${installed_version}" ]; then
- suffix=" (Not needed for installation)"
- else
- if [ ! -z "${retval}" -a "${retval}" == "0" -a ! -z "${wanted_version}" ]; then
- suffix=" (Outdated, want ${wanted_version})"
- fi
+ if [ ${retval} -ne 0 -a ! -z "${wanted_version}" ]; then
+ native_suffix="(Outdated, want ${wanted_version})"
+ fi
+
+ if [ -z "${pkg_versions_installed[${x}]}" ]; then
+ kolab_suffix="(Not needed for installation)"
fi
# Native
- if [ -z "${available_version_native}" ]; then
- echo " | ${pkg} = Not Available${suffix}" >> ${package_list_native}
+ if [ -z "${pkg_versions_native[${x}]}" ]; then
+ echo " | ${pkg} = Not Available" >> ${package_list_native}
else
- echo " | ${pkg} = ${available_version_native}${suffix}" >> ${package_list_native}
+ echo " | ${pkg} = ${pkg_versions_native[${x}]} ${native_suffix}" >> ${package_list_native}
fi
# Kolab
- if [ -z "${available_version_kolab}" ]; then
- if [ -z "${available_version_native}" ]; then
- echo " | ${pkg} = Not Available${suffix}" >> ${package_list_kolab}
+ if [ -z "${pkg_versions_kolab[${x}]}" ]; then
+ if [ -z "${pkg_versions_native[${x}]}" ]; then
+ echo " | ${pkg} = Not Available" >> ${package_list_kolab}
fi
else
- echo " | ${pkg} = ${available_version_kolab}${suffix}" >> ${package_list_kolab}
+ echo " | ${pkg} = ${pkg_versions_kolab[${x}]} ${kolab_suffix}" >> ${package_list_kolab}
fi
let x++