1 | #!/bin/sh |
---|
2 | set -e |
---|
3 | |
---|
4 | # Usage: daupload-release [-A] [-S] CHANGESFILE |
---|
5 | # daupload-beta [-A] [-S] CHANGESFILE |
---|
6 | |
---|
7 | # After a package has been built for all Debian/Ubuntu versions and |
---|
8 | # platforms (typically using "da sbuildhack DSCFILE"), this script |
---|
9 | # uploads the package into the release or beta apt repository. If -A |
---|
10 | # is specified, only one architecture per Debian/Ubuntu version is |
---|
11 | # uploaded. If -S is specified, only the source package is uploaded. |
---|
12 | |
---|
13 | # Upon completion, moves all of the generated files into the "built" |
---|
14 | # subdirectory. |
---|
15 | |
---|
16 | : ${DEBATHENA_APT=/mit/debathena/apt} |
---|
17 | . $(dirname "$0")/debian-versions.sh |
---|
18 | |
---|
19 | case "$(basename "$0")" in |
---|
20 | daupload-release) |
---|
21 | repo=$DEBATHENA_APT |
---|
22 | ;; |
---|
23 | daupload-beta) |
---|
24 | repo=${DEBATHENA_APT}-beta |
---|
25 | ;; |
---|
26 | *) |
---|
27 | echo "Unknown repo." >&2 |
---|
28 | exit 1 |
---|
29 | ;; |
---|
30 | esac |
---|
31 | |
---|
32 | v () { |
---|
33 | echo "$@" |
---|
34 | "$@" |
---|
35 | } |
---|
36 | |
---|
37 | A=0 |
---|
38 | if [ "$1" = "-A" ]; then A=1; shift; fi |
---|
39 | S=0 |
---|
40 | if [ "$1" = "-S" ]; then S=1; shift; fi |
---|
41 | |
---|
42 | change=$1 |
---|
43 | cd "$(dirname "$change")" |
---|
44 | change=$(basename "$change") |
---|
45 | base=${change%_source.changes} |
---|
46 | |
---|
47 | check () { |
---|
48 | [ -s "$1" ] || missing="$missing$1 " |
---|
49 | } |
---|
50 | uncheck () { |
---|
51 | ! [ -s "$1" ] || missing="$missing-$1 " |
---|
52 | } |
---|
53 | |
---|
54 | missing= |
---|
55 | [ -s "$change" ] |
---|
56 | if [ $S -ne 1 ]; then |
---|
57 | for code in $DEBIAN_CODES; do |
---|
58 | if [ "$code" = "sarge" ]; then |
---|
59 | check "$base~debian3.1_i386.changes" |
---|
60 | else |
---|
61 | tag=$(gettag "$code") |
---|
62 | check "${base}${tag}_amd64.changes" |
---|
63 | fi |
---|
64 | done |
---|
65 | if [ $A -eq 1 ]; then |
---|
66 | for code in $DEBIAN_CODES; do |
---|
67 | if [ "$code" = "sarge" ]; then |
---|
68 | true; |
---|
69 | else |
---|
70 | tag=$(gettag "$code") |
---|
71 | uncheck "${base}${tag}_i386.changes" |
---|
72 | fi |
---|
73 | done |
---|
74 | else |
---|
75 | for code in $DEBIAN_CODES; do |
---|
76 | if [ "$code" = "sarge" ]; then |
---|
77 | true; |
---|
78 | else |
---|
79 | tag=$(gettag "$code") |
---|
80 | check "${base}${tag}_i386.changes" |
---|
81 | fi |
---|
82 | done |
---|
83 | fi |
---|
84 | fi |
---|
85 | |
---|
86 | if [ -n "$missing" ]; then |
---|
87 | echo "Missing $missing" >&2 |
---|
88 | echo -n "Continue? [y/N]" |
---|
89 | read a |
---|
90 | [ "$a" = "y" ] |
---|
91 | fi |
---|
92 | |
---|
93 | REPREPRO="v reprepro -Vb $repo" |
---|
94 | REPREPROI="$REPREPRO --ignore=wrongdistribution" |
---|
95 | |
---|
96 | for code in $DEBIAN_CODES; do |
---|
97 | $REPREPROI include "$code" "$change" |
---|
98 | done |
---|
99 | |
---|
100 | if [ $S -ne 1 ]; then |
---|
101 | for code in $DEBIAN_CODES; do |
---|
102 | if [ "$code" = "sarge" ]; then |
---|
103 | $REPREPRO include sarge "$base~debian3.1_i386.changes" |
---|
104 | else |
---|
105 | tag=$(gettag "$code") |
---|
106 | [ $A -eq 1 ] || $REPREPRO include "$code" "${base}${tag}_i386.changes" |
---|
107 | $REPREPRO include "$code" "${base}${tag}_amd64.changes" |
---|
108 | fi |
---|
109 | done |
---|
110 | fi |
---|
111 | |
---|
112 | changes=$change |
---|
113 | for code in $DEBIAN_CODES; do |
---|
114 | if [ "$code" = "sarge" ]; then |
---|
115 | changes=$changes\ $base~debian3.1_i386.changes |
---|
116 | else |
---|
117 | tag=$(gettag "$code") |
---|
118 | [ $A -eq 1 ] || changes=$changes\ "${base}${tag}"_i386.changes |
---|
119 | changes=$changes\ "${base}${tag}"_amd64.changes |
---|
120 | fi |
---|
121 | done |
---|
122 | |
---|
123 | files=${change%.changes}.build\ $changes |
---|
124 | origfiles= |
---|
125 | for change in $changes; do |
---|
126 | files=$files\ $(perl -0ne '$_ =~ /\nFiles: *\n(( [^\n]*\n)*)/; print $1;' "$change" | awk '{print $5}' | grep -v '\.orig\.tar\.gz$' || :) |
---|
127 | origfiles=$origfiles\ $(perl -0ne '$_ =~ /\nFiles: *\n(( [^\n]*\n)*)/; print $1;' "$change" | awk '{print $5}' | grep '\.orig\.tar\.gz$' || :) |
---|
128 | done |
---|
129 | |
---|
130 | built=built/ |
---|
131 | [ -d "$built" ] || mkdir "$built" |
---|
132 | mv -i $files "$built" |
---|
133 | if [ -n "$origfiles" ]; then |
---|
134 | for orig in $origfiles; do |
---|
135 | [ -e "$built/$orig" ] || cp -ai "$orig" "$built/" |
---|
136 | done |
---|
137 | fi |
---|