source: trunk/debathena/scripts/ood-packages @ 25747

Revision 25747, 2.7 KB checked in by jdreed, 12 years ago (diff)
Get rid of "dirname $0" and replace with DA_SCRIPTS_DIR, which allows overriding at run time. (Trac: #1191)
  • Property svn:executable set to *
Line 
1#!/bin/sh
2
3# Usage: ood-packages [-c|-r] [LOCATION]
4
5# Outputs a list of package names which are out of date in the apt
6# repository relative to the source tree.  This script only deals with
7# regular Debian package sources, not equivs-built packages or
8# debathenify packages.  This scripts assumes gen-packages has been
9# run to create the packages file.
10
11# If -c is specified, scans a checkout for current version
12# information.  If -r is specified, scans the repository.  -r is the
13# default.  Using a checkout is faster but will give the wrong results
14# if the checkout is not up to date.  This script is kind of slow
15# regardless, due to all of the reprepro invocations.
16
17# If LOCATION is specified, it is used in preference to the canonical
18# Athena repository trunk or the canonical source checkout.
19
20set -e
21
22: ${DA_SCRIPTS_DIR="$(dirname "$0")"}
23. "$DA_SCRIPTS_DIR"/debian-versions.sh
24
25die() {
26  echo "$@" >&2
27  exit 1
28}
29
30usage() {
31  die "ood-packages [-r|-c] [LOCATION]"
32}
33
34type=repos
35
36while getopts cr opt; do
37  case "$opt" in
38  c)
39    type=checkout
40    ;;
41  r)
42    type=repos
43    ;;
44  \?)
45    usage
46    ;;
47  esac
48done
49
50shift $(($OPTIND - 1))
51if [ $# -gt 0 ]; then
52  loc=$1
53elif [ $type = repos ]; then
54  loc=svn+ssh://svn.mit.edu/athena/trunk
55else
56  loc=/afs/dev.mit.edu/source/src-svn
57fi
58
59packages=packages
60
61if [ ! -r "$packages" ]; then
62    packages=/mit/debathena/packages/packages
63fi
64if [ ! -r "$packages" ]; then
65  echo "Can't read packages file; create with gen-packages." >&2
66  exit 1
67fi
68
69exec <"$packages"
70while read pkg path; do
71  # Get the version from the apt repository, checking that it is
72  # consistent across all dists.
73  lastver=
74  for dist in $DEBIAN_CODES; do
75    if dareprepro list "${dist}-proposed" "$pkg" | grep -q 'source: '; then
76      release=-proposed
77    else
78      release=''
79    fi
80    aptver=$(dareprepro list "${dist}${release}" "$pkg" \
81          | awk '/source:/ { print $3 }')
82    if [ -n "$lastver" -a "x$aptver" != "x$lastver" ]; then
83      echo -n "WARNING: Inconsistent versions for $pkg: "
84      echo "$lastdist $lastver != $dist $aptver" >&2
85    fi
86    lastver=$aptver
87    lastdist=$dist
88  done
89
90  # Get the current version from the checkout or repository.
91  if [ $type = repos ]; then
92    svn cat $loc/$path/debian/changelog > changelog
93    cfile=changelog
94  else
95    cfile=$loc/$path/debian/changelog
96  fi
97  curver=$(dpkg-parsechangelog -l$cfile | sed -n 's/Version: //p')
98
99  # Display the package name if the apt repository version does not
100  # match the current version.
101  if [ "x$aptver" != "x$curver" ]; then
102    case "$pkg" in
103      debathena-linerva*)
104      ;;
105      *)
106        echo "$pkg"
107      ;;
108    esac
109  fi
110done
111
112if [ $type = repos ]; then
113  rm -rf changelog
114fi
Note: See TracBrowser for help on using the repository browser.