1 | #!/bin/sh |
---|
2 | set -e |
---|
3 | |
---|
4 | # Usage: daupload-release [-A] [-S] CHANGESFILE |
---|
5 | # daupload-proposed [-A] [-S] CHANGESFILE |
---|
6 | # daupload-dev [-A] [-S] CHANGESFILE |
---|
7 | |
---|
8 | # After a package has been built for all Debian/Ubuntu versions and |
---|
9 | # platforms (typically using "da sbuildhack DSCFILE"), this script |
---|
10 | # uploads the package into the release, proposed, or beta apt |
---|
11 | # repository. If -A is specified, only one architecture per |
---|
12 | # Debian/Ubuntu version is uploaded. If -S is specified, only the |
---|
13 | # source package is uploaded. |
---|
14 | |
---|
15 | # Upon completion, moves all of the generated files into the "built" |
---|
16 | # subdirectory. |
---|
17 | |
---|
18 | # This script will skip dists listed in ./nobuild. |
---|
19 | |
---|
20 | : ${DA_SCRIPTS_DIR="$(dirname "$0")"} |
---|
21 | . "$DA_SCRIPTS_DIR"/debian-versions.sh |
---|
22 | |
---|
23 | if [ -n "$DEBIAN_CODES_OVERRIDE" ]; then |
---|
24 | echo "Will override DEBIAN_CODES with: $DEBIAN_CODES_OVERRIDE" |
---|
25 | echo -n "Continue? [y/N] " |
---|
26 | read a |
---|
27 | [ "$a" = "y" ] |
---|
28 | DEBIAN_CODES="$DEBIAN_CODES_OVERRIDE" |
---|
29 | fi |
---|
30 | |
---|
31 | case "$(basename "$0")" in |
---|
32 | daupload-release) |
---|
33 | echo "You're uploading to PRODUCTION. This may not be a good idea." >&2 |
---|
34 | echo -n "Continue? [y/N]" |
---|
35 | read a |
---|
36 | [ "$a" = "y" ] |
---|
37 | release="" |
---|
38 | ;; |
---|
39 | daupload-proposed) |
---|
40 | release="-proposed" |
---|
41 | ;; |
---|
42 | daupload-dev) |
---|
43 | release="-development" |
---|
44 | ;; |
---|
45 | daupload-bleeding) |
---|
46 | release="-bleeding" |
---|
47 | ;; |
---|
48 | *) |
---|
49 | echo "Unknown release." >&2 |
---|
50 | exit 1 |
---|
51 | ;; |
---|
52 | esac |
---|
53 | |
---|
54 | v () { |
---|
55 | echo "$@" |
---|
56 | "$@" |
---|
57 | } |
---|
58 | |
---|
59 | A=0 |
---|
60 | if [ "$1" = "-A" ]; then A=1; shift; fi |
---|
61 | S=0 |
---|
62 | if [ "$1" = "-S" ]; then S=1; shift; fi |
---|
63 | |
---|
64 | change=$1 |
---|
65 | cd "$(dirname "$change")" |
---|
66 | change=$(basename "$change") |
---|
67 | base=${change%_source.changes} |
---|
68 | |
---|
69 | check () { |
---|
70 | [ -s "$1" ] || missing="$missing$1 " |
---|
71 | } |
---|
72 | uncheck () { |
---|
73 | ! [ -s "$1" ] || missing="$missing-$1 " |
---|
74 | } |
---|
75 | |
---|
76 | # If ./nobuild exists, filter out its contents from DEBIAN_CODES. |
---|
77 | if [ -e nobuild ]; then |
---|
78 | newcodes= |
---|
79 | for code in $DEBIAN_CODES; do |
---|
80 | if ! fgrep -q "$code" nobuild; then |
---|
81 | newcodes="$newcodes $code" |
---|
82 | fi |
---|
83 | done |
---|
84 | DEBIAN_CODES=$newcodes |
---|
85 | fi |
---|
86 | |
---|
87 | missing= |
---|
88 | [ -s "$change" ] |
---|
89 | if [ $S -ne 1 ]; then |
---|
90 | for code in $DEBIAN_CODES; do |
---|
91 | tag=$(gettag "$code") |
---|
92 | check "${base}${tag}_amd64.changes" |
---|
93 | done |
---|
94 | if [ $A -eq 1 ]; then |
---|
95 | for code in $DEBIAN_CODES; do |
---|
96 | tag=$(gettag "$code") |
---|
97 | uncheck "${base}${tag}_i386.changes" |
---|
98 | done |
---|
99 | else |
---|
100 | for code in $DEBIAN_CODES; do |
---|
101 | tag=$(gettag "$code") |
---|
102 | check "${base}${tag}_i386.changes" |
---|
103 | done |
---|
104 | fi |
---|
105 | fi |
---|
106 | |
---|
107 | if [ -n "$missing" ]; then |
---|
108 | echo "Missing $missing" >&2 |
---|
109 | echo -n "Continue? [y/N]" |
---|
110 | read a |
---|
111 | [ "$a" = "y" ] |
---|
112 | fi |
---|
113 | |
---|
114 | for code in $DEBIAN_CODES; do |
---|
115 | v dareprepro include "${code}${release}" "$change" |
---|
116 | done |
---|
117 | |
---|
118 | if [ $S -ne 1 ]; then |
---|
119 | for code in $DEBIAN_CODES; do |
---|
120 | tag=$(gettag "$code") |
---|
121 | [ $A -eq 1 ] || v dareprepro include "${code}${release}" "${base}${tag}_i386.changes" |
---|
122 | v dareprepro include "${code}${release}" "${base}${tag}_amd64.changes" |
---|
123 | done |
---|
124 | fi |
---|
125 | |
---|
126 | if [ -n "$DEBIAN_CODES_OVERRIDE" ]; then |
---|
127 | echo "Codes overridden, skipping copy of files. Cleanup by hand." |
---|
128 | exit 0 |
---|
129 | fi |
---|
130 | |
---|
131 | changes=$change |
---|
132 | for code in $DEBIAN_CODES; do |
---|
133 | tag=$(gettag "$code") |
---|
134 | [ $A -eq 1 ] || changes=$changes\ "${base}${tag}"_i386.changes |
---|
135 | changes=$changes\ "${base}${tag}"_amd64.changes |
---|
136 | done |
---|
137 | |
---|
138 | files=${change%.changes}.build\ $changes |
---|
139 | origfiles= |
---|
140 | for change in $changes; do |
---|
141 | files=$files\ $(perl -0ne '$_ =~ /\nFiles: *\n(( [^\n]*\n)*)/; print $1;' "$change" | awk '{print $5}' | grep -v '\.orig\.tar\.gz$' || :) |
---|
142 | origfiles=$origfiles\ $(perl -0ne '$_ =~ /\nFiles: *\n(( [^\n]*\n)*)/; print $1;' "$change" | awk '{print $5}' | grep '\.orig\.tar\.gz$' || :) |
---|
143 | done |
---|
144 | |
---|
145 | built=built/ |
---|
146 | [ -d "$built" ] || mkdir "$built" |
---|
147 | mv -i $files "$built" |
---|
148 | if [ -n "$origfiles" ]; then |
---|
149 | for orig in $origfiles; do |
---|
150 | [ -e "$built/$orig" ] || cp -ai "$orig" "$built/" |
---|
151 | done |
---|
152 | fi |
---|