summaryrefslogtreecommitdiffstats
path: root/compat32-tools/check-compat32
blob: 2ce17e97347648795b8b92376052d83c8d019247 (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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/bin/bash
#$Id$
#
# Purpose:
#   To check if any of the installed -compat32 packages is older than
#   the accompanying 64-bit package.
#
# Author:
#   Eric Hameleers <alien@slackware.com>
#

# No verbose output by default:
DEBUG=0

showhelp () {
cat <<EOT

Script name:
  $(basename $0)
Purpose:
  To check if any of the installed -compat32 packages is older than
  the accompanying 64-bit package.
Usage:
  Run the program without parameters to make it check your packages.
Parameters:
  -h|--help        Show this help text
  -v|--verbose     Verbose output

EOT
}

# Parse the commandline parameters:
while [ ! -z "$1" ]; do
  case $1 in
    -h|--help)
      showhelp
      exit 0
      ;;
    -v|--verbose)
      DEBUG=1
      shift
      ;;
    -*)
      echo "Unsupported parameter '$1'!"
      exit 1
      ;;
    *)
      # Do nothing
      shift
      ;;
  esac
done


# Loop through the -compat32 packages we find installed,
# and compare their versions to the 64-bit packages
[ $DEBUG -ne 0 ] && echo "-- Checking installed packages..."
for FULL32 in $(find /var/log/packages/ -name "*-compat32-*") ; do
  PKG32=$(echo ${FULL32} |cut -f5 -d'/' |rev |cut -f4- -d'-' |rev)
  VER32=$(echo ${FULL32} |cut -f5 -d'/' |rev |cut -f3 -d'-' |rev)

  [ $DEBUG -ne 0 ] && echo ">> Found '$PKG32'..."

  PKG64=$(echo ${FULL32} |cut -f5 -d'/' |rev |cut -f5- -d'-' |rev)
  VER64=$($(find /var/log/packages/ -name "${PKG64}*" |grep -v -- -compat32) |cut -f5 -d'/' |rev |cut -f3 -d'-' |rev |grep "${PKG64}$")

  # Issue a warning if the version of the 64-bit package differs:
  if [ -n "$VER64" -a "$VER32" != "$VER64" ]; then
      echo "** Package '$PKG64' has version '$VER64' but package '$PKG32' has version '$VER32'"
  fi
done

[ $DEBUG -ne 0 ] && echo "-- Finished checking installed packages."