1 | #!/bin/sh |
---|
2 | |
---|
3 | # Usage: dasource [-r REPOS] [PACKAGENAME ...] |
---|
4 | |
---|
5 | # Creates or updates a checkout and source package for each listed |
---|
6 | # PACKAGENAME, or for all regular packages if no PACKAGENAME is |
---|
7 | # specified. |
---|
8 | |
---|
9 | # If REPOS is specified, it is used in preference to the canonical |
---|
10 | # Athena repository trunk. |
---|
11 | |
---|
12 | # Package subdirectories are created in the cwd. The source checkout |
---|
13 | # will reside in PACKAGENAME/PACKAGENAME-VERSION and the source |
---|
14 | # package will be created in PACKAGENAME. |
---|
15 | |
---|
16 | set -e |
---|
17 | |
---|
18 | die() { |
---|
19 | echo "$@" >&2 |
---|
20 | exit 1 |
---|
21 | } |
---|
22 | |
---|
23 | usage() { |
---|
24 | die "dasource [-r repos] [packagename ...]" |
---|
25 | } |
---|
26 | |
---|
27 | : ${DEBATHENA_APT=/mit/debathena/apt} |
---|
28 | basedir=$(dirname "$0") |
---|
29 | repo=svn+ssh://svn.mit.edu/athena/trunk |
---|
30 | |
---|
31 | while getopts r: opt; do |
---|
32 | case "$opt" in |
---|
33 | r) |
---|
34 | type="$OPTARG" |
---|
35 | ;; |
---|
36 | \?) |
---|
37 | usage |
---|
38 | ;; |
---|
39 | esac |
---|
40 | done |
---|
41 | |
---|
42 | do_package() { |
---|
43 | pkgname=$1 |
---|
44 | pkgpath=$2 |
---|
45 | if [ ! -d $pkgname ]; then |
---|
46 | echo "Creating directory $pkgname" |
---|
47 | mkdir $pkgname |
---|
48 | fi |
---|
49 | |
---|
50 | # Check out or update the package source. |
---|
51 | pattern="$pkgname/$pkgname-[0-9]*[0-9]" |
---|
52 | if [ $(echo $pattern | wc -w) -gt 1 ]; then |
---|
53 | die "More than one checkout under $pkgname!" |
---|
54 | elif [ -d $pattern ]; then |
---|
55 | dir=$(echo $pattern) |
---|
56 | echo "Updating and cleaning $dir" |
---|
57 | (cd $dir && svn update && svn revert -R . && |
---|
58 | svn st | awk '/^?/ {print $2}' | xargs rm -vrf) |
---|
59 | else |
---|
60 | dir=$pkgname/$pkgname |
---|
61 | echo "Checking out $repo/$pkgpath into $dir" |
---|
62 | svn co $repo/$pkgpath $dir |
---|
63 | fi |
---|
64 | |
---|
65 | # Extract the changelog version and strip off the epoch and Debian component. |
---|
66 | changever=$(cd $dir && dpkg-parsechangelog | sed -n 's/Version: //p') |
---|
67 | sver=$(echo $changever | sed -re 's/^[0-9]+://p') |
---|
68 | upver=$(echo $sver | sed -re 's/-[^-]*$//') |
---|
69 | |
---|
70 | # Rename the source checkout if necessary. |
---|
71 | correctdir=$pkgname/${pkgname}-$upver |
---|
72 | if [ $dir != $correctdir ]; then |
---|
73 | echo "Renaming $dir to $correctdir" |
---|
74 | mv $dir $correctdir |
---|
75 | dir=$correctdir |
---|
76 | fi |
---|
77 | |
---|
78 | # Add autoconf goo if it's an Athena source directory. |
---|
79 | case $pkgpath in |
---|
80 | athena/*) |
---|
81 | (cd $dir && $basedir/daconfiscate) |
---|
82 | ;; |
---|
83 | esac |
---|
84 | |
---|
85 | # Create a suitable orig tarball if necessary. |
---|
86 | (cd $dir && daorig) |
---|
87 | |
---|
88 | # Build an unsigned package, ignoring version control subdirs in the source. |
---|
89 | echo "Creating source package" |
---|
90 | (cd $dir && debuild -S -i -I.svn -sa -us -uc) |
---|
91 | } |
---|
92 | |
---|
93 | if [ ! -r packages ]; then |
---|
94 | die "Can't read packages file; create with gen-packages" |
---|
95 | fi |
---|
96 | |
---|
97 | if [ $# -gt 0 ]; then |
---|
98 | # Build specific source packages. |
---|
99 | for pkgname; do |
---|
100 | pkgpath=$(sed -nre "s/^$pkgname[[:space:]]+//p" packages) |
---|
101 | [ -n "$pkgpath" ] || die "Can't find package $pkgname" |
---|
102 | do_package $pkgname $pkgpath |
---|
103 | done |
---|
104 | else |
---|
105 | # Build all source packages. |
---|
106 | exec <packages |
---|
107 | while read pkgname pkgpath; do |
---|
108 | do_package $pkgname $pkgpath |
---|
109 | done |
---|
110 | fi |
---|