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

Revision 24417, 2.5 KB checked in by broder, 14 years ago (diff)
Make ood-packages work even if gen-packages hasn't been run in the cwd.
  • 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: ${DEBATHENA_APT=/mit/debathena/apt}
23. $(dirname "$0")/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
63if [ ! -r "$packages" ]; then
64  echo "Can't read packages file; create with gen-packages." >&2
65  exit 1
66fi
67
68exec <"$packages"
69while read pkg path; do
70  # Get the version from the apt repository, checking that it is
71  # consistent across all dists.
72  lastver=
73  for dist in $DEBIAN_CODES; do
74    aptver=$(reprepro -Vb "$DEBATHENA_APT" list "$dist" "$pkg" \
75          | awk '/source:/ { print $3 }')
76    if [ -n "$lastver" -a "x$aptver" != "x$lastver" ]; then
77      echo -n "WARNING: Inconsistent versions for $pkg: "
78      echo "$lastdist $lastver != $dist $aptver" >&2
79    fi
80    lastver=$aptver
81    lastdist=$dist
82  done
83
84  # Get the current version from the checkout or repository.
85  if [ $type = repos ]; then
86    svn cat $loc/$path/debian/changelog > changelog
87    cfile=changelog
88  else
89    cfile=$loc/$path/debian/changelog
90  fi
91  curver=$(dpkg-parsechangelog -l$cfile | sed -n 's/Version: //p')
92
93  # Display the package name if the apt repository version does not
94  # match the current version.
95  if [ "x$aptver" != "x$curver" ]; then
96    case "$pkg" in
97      debathena-linerva*)
98      ;;
99      *)
100        echo "$pkg"
101      ;;
102    esac
103  fi
104done
105
106if [ $type = repos ]; then
107  rm -rf changelog
108fi
Note: See TracBrowser for help on using the repository browser.