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 | # This script will skip dists listed in ./nobuild. |
---|
17 | |
---|
18 | : ${DEBATHENA_APT=/mit/debathena/apt} |
---|
19 | . $(dirname "$0")/debian-versions.sh |
---|
20 | |
---|
21 | case "$(basename "$0")" in |
---|
22 | daupload-release) |
---|
23 | repo=$DEBATHENA_APT |
---|
24 | ;; |
---|
25 | daupload-beta) |
---|
26 | repo=${DEBATHENA_APT}-beta |
---|
27 | ;; |
---|
28 | *) |
---|
29 | echo "Unknown repo." >&2 |
---|
30 | exit 1 |
---|
31 | ;; |
---|
32 | esac |
---|
33 | |
---|
34 | v () { |
---|
35 | echo "$@" |
---|
36 | "$@" |
---|
37 | } |
---|
38 | |
---|
39 | A=0 |
---|
40 | if [ "$1" = "-A" ]; then A=1; shift; fi |
---|
41 | S=0 |
---|
42 | if [ "$1" = "-S" ]; then S=1; shift; fi |
---|
43 | |
---|
44 | change=$1 |
---|
45 | cd "$(dirname "$change")" |
---|
46 | change=$(basename "$change") |
---|
47 | base=${change%_source.changes} |
---|
48 | |
---|
49 | check () { |
---|
50 | [ -s "$1" ] || missing="$missing$1 " |
---|
51 | } |
---|
52 | uncheck () { |
---|
53 | ! [ -s "$1" ] || missing="$missing-$1 " |
---|
54 | } |
---|
55 | |
---|
56 | # If ./nobuild exists, filter out its contents from DEBIAN_CODES. |
---|
57 | if [ -e nobuild ]; then |
---|
58 | newcodes= |
---|
59 | for code in $DEBIAN_CODES; do |
---|
60 | if ! fgrep -q "$code" nobuild; then |
---|
61 | newcodes="$newcodes $code" |
---|
62 | fi |
---|
63 | done |
---|
64 | DEBIAN_CODES=$newcodes |
---|
65 | fi |
---|
66 | |
---|
67 | missing= |
---|
68 | [ -s "$change" ] |
---|
69 | if [ $S -ne 1 ]; then |
---|
70 | for code in $DEBIAN_CODES; do |
---|
71 | tag=$(gettag "$code") |
---|
72 | check "${base}${tag}_amd64.changes" |
---|
73 | done |
---|
74 | if [ $A -eq 1 ]; then |
---|
75 | for code in $DEBIAN_CODES; do |
---|
76 | tag=$(gettag "$code") |
---|
77 | uncheck "${base}${tag}_i386.changes" |
---|
78 | done |
---|
79 | else |
---|
80 | for code in $DEBIAN_CODES; do |
---|
81 | tag=$(gettag "$code") |
---|
82 | check "${base}${tag}_i386.changes" |
---|
83 | done |
---|
84 | fi |
---|
85 | fi |
---|
86 | |
---|
87 | if [ -n "$missing" ]; then |
---|
88 | echo "Missing $missing" >&2 |
---|
89 | echo -n "Continue? [y/N]" |
---|
90 | read a |
---|
91 | [ "$a" = "y" ] |
---|
92 | fi |
---|
93 | |
---|
94 | REPREPRO="v reprepro -Vb $repo" |
---|
95 | REPREPROI="$REPREPRO --ignore=wrongdistribution" |
---|
96 | |
---|
97 | for code in $DEBIAN_CODES; do |
---|
98 | $REPREPROI include "$code" "$change" |
---|
99 | done |
---|
100 | |
---|
101 | if [ $S -ne 1 ]; then |
---|
102 | for code in $DEBIAN_CODES; do |
---|
103 | tag=$(gettag "$code") |
---|
104 | [ $A -eq 1 ] || $REPREPRO include "$code" "${base}${tag}_i386.changes" |
---|
105 | $REPREPRO include "$code" "${base}${tag}_amd64.changes" |
---|
106 | done |
---|
107 | fi |
---|
108 | |
---|
109 | changes=$change |
---|
110 | for code in $DEBIAN_CODES; do |
---|
111 | tag=$(gettag "$code") |
---|
112 | [ $A -eq 1 ] || changes=$changes\ "${base}${tag}"_i386.changes |
---|
113 | changes=$changes\ "${base}${tag}"_amd64.changes |
---|
114 | done |
---|
115 | |
---|
116 | files=${change%.changes}.build\ $changes |
---|
117 | origfiles= |
---|
118 | for change in $changes; do |
---|
119 | files=$files\ $(perl -0ne '$_ =~ /\nFiles: *\n(( [^\n]*\n)*)/; print $1;' "$change" | awk '{print $5}' | grep -v '\.orig\.tar\.gz$' || :) |
---|
120 | origfiles=$origfiles\ $(perl -0ne '$_ =~ /\nFiles: *\n(( [^\n]*\n)*)/; print $1;' "$change" | awk '{print $5}' | grep '\.orig\.tar\.gz$' || :) |
---|
121 | done |
---|
122 | |
---|
123 | built=built/ |
---|
124 | [ -d "$built" ] || mkdir "$built" |
---|
125 | mv -i $files "$built" |
---|
126 | if [ -n "$origfiles" ]; then |
---|
127 | for orig in $origfiles; do |
---|
128 | [ -e "$built/$orig" ] || cp -ai "$orig" "$built/" |
---|
129 | done |
---|
130 | fi |
---|