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 | |
---|
20 | set -e |
---|
21 | |
---|
22 | : ${DA_SCRIPTS_DIR="$(dirname "$0")"} |
---|
23 | . "$DA_SCRIPTS_DIR"/debian-versions.sh |
---|
24 | |
---|
25 | die() { |
---|
26 | echo "$@" >&2 |
---|
27 | exit 1 |
---|
28 | } |
---|
29 | |
---|
30 | usage() { |
---|
31 | die "ood-packages [-r|-c] [LOCATION]" |
---|
32 | } |
---|
33 | |
---|
34 | type=repos |
---|
35 | |
---|
36 | while 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 |
---|
48 | done |
---|
49 | |
---|
50 | shift $(($OPTIND - 1)) |
---|
51 | if [ $# -gt 0 ]; then |
---|
52 | loc=$1 |
---|
53 | elif [ $type = repos ]; then |
---|
54 | loc=svn+ssh://svn.mit.edu/athena/trunk |
---|
55 | else |
---|
56 | loc=/afs/dev.mit.edu/source/src-svn |
---|
57 | fi |
---|
58 | |
---|
59 | packages=packages |
---|
60 | |
---|
61 | if [ ! -r "$packages" ]; then |
---|
62 | packages=/mit/debathena/packages/packages |
---|
63 | fi |
---|
64 | if [ ! -r "$packages" ]; then |
---|
65 | echo "Can't read packages file; create with gen-packages." >&2 |
---|
66 | exit 1 |
---|
67 | fi |
---|
68 | |
---|
69 | exec <"$packages" |
---|
70 | while 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 |
---|
110 | done |
---|
111 | |
---|
112 | if [ $type = repos ]; then |
---|
113 | rm -rf changelog |
---|
114 | fi |
---|