1 | #!/bin/sh |
---|
2 | |
---|
3 | # Usage: gen-packages [-c|-r] [LOCATION] |
---|
4 | |
---|
5 | # Scans the repository or a checkout of it and generates a file named |
---|
6 | # "packages" in the current directory containing a table of source |
---|
7 | # package names and their corresponding directories. Scanning a |
---|
8 | # checkout is much faster, but relies on the checkout being |
---|
9 | # sufficiently up to date. |
---|
10 | |
---|
11 | # If -c is specified, scans a checkout. If -r is specified, scans the |
---|
12 | # repository. -r is the default. |
---|
13 | |
---|
14 | # If LOCATION is specified, it is used in preference to the canonical |
---|
15 | # Athena repository trunk or the canonical source checkout. |
---|
16 | |
---|
17 | set -e |
---|
18 | |
---|
19 | die() { |
---|
20 | echo "$@" >&2 |
---|
21 | exit 1 |
---|
22 | } |
---|
23 | |
---|
24 | usage() { |
---|
25 | die "gen-packages [-r|-c] [LOCATION]" |
---|
26 | } |
---|
27 | |
---|
28 | type=repos |
---|
29 | |
---|
30 | while getopts cr opt; do |
---|
31 | case "$opt" in |
---|
32 | c) |
---|
33 | type=checkout |
---|
34 | ;; |
---|
35 | r) |
---|
36 | type=repos |
---|
37 | ;; |
---|
38 | \?) |
---|
39 | usage |
---|
40 | ;; |
---|
41 | esac |
---|
42 | done |
---|
43 | |
---|
44 | shift $(($OPTIND - 1)) |
---|
45 | if [ $# -gt 0 ]; then |
---|
46 | loc=$1 |
---|
47 | elif [ $type = repos ]; then |
---|
48 | loc=svn+ssh://svn.mit.edu/athena/trunk |
---|
49 | else |
---|
50 | loc=/afs/dev.mit.edu/source/src-svn |
---|
51 | fi |
---|
52 | |
---|
53 | rm -f packages.unsorted |
---|
54 | echo "Scanning file list of $loc" |
---|
55 | if [ $type = repos ]; then |
---|
56 | for cf in $(svn ls -R $loc | grep 'debian/control$'); do |
---|
57 | echo "Reading $cf" |
---|
58 | name=$(svn cat $loc/$cf | sed -ne 's/^Source: \(.*\)$/\1/p') |
---|
59 | dir=${cf%/debian/control} |
---|
60 | printf "%-35s %s\n" $name $dir >> packages.unsorted |
---|
61 | done |
---|
62 | else |
---|
63 | for cf in $(cd $loc && find | sed -ne '/debian\/control$/s/^\.\///p'); do |
---|
64 | echo "Reading $cf" |
---|
65 | name=$(sed -ne 's/^Source: \(.*\)$/\1/p' $loc/$cf) |
---|
66 | dir=${cf%/debian/control} |
---|
67 | printf "%-35s %s\n" $name $dir >> packages.unsorted |
---|
68 | done |
---|
69 | fi |
---|
70 | |
---|
71 | # Athena 10 uses a different version of gdm-config from SIPB. Using |
---|
72 | # DEBATHENA_APT to distinguish between the two is a little hackish, |
---|
73 | # but it's what we've got. We're setting $gdm to the location we want |
---|
74 | # to filter out, not the path we want to keep. |
---|
75 | case $DEBATHENA_APT in |
---|
76 | *athena10*) |
---|
77 | gdm=' debathena/config/gdm-config$' |
---|
78 | ;; |
---|
79 | *) |
---|
80 | gdm=' debathena/config/gdm-config-athena10$' |
---|
81 | ;; |
---|
82 | esac |
---|
83 | |
---|
84 | # cyrus-sasl2-mit has a debian dir but is really a debathenify package. |
---|
85 | # config-package dev has some example packages we want to filter out. |
---|
86 | sort packages.unsorted | egrep -v "cyrus-sasl2-mit|/examples/|$gdm" > packages |
---|
87 | rm -f packages.unsorted |
---|