]>
Commit | Line | Data |
---|---|---|
ea4bf6cd | 1 | #!/bin/bash |
931eabc0 XL |
2 | |
3 | . ./vars.sh.frag | |
4 | ||
e19e9e08 SL |
5 | if test ! -d $PKGDIR_REL; then |
6 | abort 1 "Cannot find $PKGDIR_REL. Did you run ./new-package.sh before?" | |
7 | fi | |
8 | ||
c1621660 XL |
9 | if test ! -f "$PKGDIR_REL/debian/changelog"; then |
10 | abort 1 "Cannot find $PKGDIR_REL/debian/changelog. Did you run ./new-package.sh before?" | |
11 | fi | |
12 | ||
e3cf5e2c | 13 | if git grep --quiet FIXME -- "$PKGDIR_REL" :^"$PKGDIR_REL/debian/*.debcargo.hint" :^"$PKGDIR_REL/debian/changelog"; then |
89c70e95 XL |
14 | abort 1 "FIXMEs remain in $PKGDIR_REL, fix and commit those first." |
15 | fi | |
16 | ||
1230b71f XL |
17 | git diff --quiet --cached || \ |
18 | abort 1 "You have other pending changes to git, please complete it or stash it away and re-run this script." | |
19 | ||
20 | git diff --quiet -- "$PKGDIR_REL" || \ | |
931eabc0 XL |
21 | abort 1 "Please git-add your changes to $PKGDIR_REL before running" |
22 | ||
1057693c XL |
23 | type dch >/dev/null || \ |
24 | abort 1 "Install devscripts, we need to run dch." | |
25 | ||
b6a1d240 XL |
26 | RELBRANCH="pending-$PKGNAME" |
27 | git fetch origin --prune | |
2de6944f | 28 | |
c75ca09f | 29 | git merge-base --is-ancestor origin/master HEAD || \ |
90f3bab9 | 30 | abort 1 "You are not synced with origin/master, please do so before running this script." |
1c8790a3 | 31 | |
baae6f7c XL |
32 | if [ "$RERELEASE" = 1 -o "$NOUPDATE" = 1 ]; then |
33 | REALVER="$(get_existing_version "$PKGDIR")" | |
34 | fi | |
35 | ||
2de6944f | 36 | if head -n1 "$PKGDIR/debian/changelog" | grep -qv UNRELEASED-FIXME-AUTOGENERATED-DEBCARGO; then |
baae6f7c XL |
37 | if [ "$RERELEASE" = 1 ]; then |
38 | run_debcargo | |
39 | ( cd "$PKGDIR" && dch -a "No-op source-only re-upload for Debian Testing Migration." ) | |
40 | # sometimes the copyright years need to be updated, try to do this automatically | |
41 | if git diff -- "$PKGDIR_REL/debian/copyright.debcargo.hint" | patch --no-backup-if-mismatch "$PKGDIR_REL/debian/copyright"; then | |
42 | git add "$PKGDIR_REL/debian/copyright.debcargo.hint" "$PKGDIR_REL/debian/copyright" | |
43 | else | |
44 | git diff -- "$PKGDIR_REL/debian/copyright.debcargo.hint" | |
45 | abort 1 \ | |
46 | "copyright file needs updating; apply the above diff to $PKGDIR_REL/debian/copyright" \ | |
47 | "then commit your changes, and run me again." | |
48 | fi | |
49 | else | |
50 | abort 0 \ | |
51 | "Package already released. If you want to do a source-only re-upload e.g. to" \ | |
52 | "hoop-jump through the Debian Testing migration requirements, set RERELEASE=1." | |
53 | fi | |
2de6944f XL |
54 | fi |
55 | ||
e1a9d897 XL |
56 | if [ -e "$PKGDIR/debian/BLOCK" ]; then |
57 | abort 1 "TODO items remain in $PKGDIR/debian/BLOCK, please deal with those" | |
58 | fi | |
59 | ||
32c1fb5b XL |
60 | PREVBRANCH="$(git rev-parse --abbrev-ref HEAD)" |
61 | case "$PREVBRANCH" in | |
b6a1d240 XL |
62 | pending-$PKGNAME) true;; |
63 | pending-*) abort 1 "You are on a pending-release branch for a package other than $PKGNAME, $0 can only be run on another branch, like master";; | |
64 | *) if git rev-parse -q --verify "refs/heads/$RELBRANCH" >/dev/null || \ | |
65 | git rev-parse -q --verify "refs/remotes/origin/$RELBRANCH" >/dev/null; then | |
66 | git checkout "$RELBRANCH" | |
67 | else | |
68 | git checkout -b "$RELBRANCH" | |
69 | fi;; | |
70 | esac | |
71 | ||
72 | if head -n1 "$PKGDIR/debian/changelog" | grep -qv UNRELEASED-FIXME-AUTOGENERATED-DEBCARGO; then | |
32c1fb5b | 73 | git checkout "$PREVBRANCH" |
c6709bfe XL |
74 | abort 0 "Package already released on branch $RELBRANCH. If that was a mistake then run:" \ |
75 | " git branch -D $RELBRANCH" \ | |
76 | "And re-run this script ($0 $*). You might have to delete the remote branch too:" \ | |
77 | " git push --delete origin $RELBRANCH" | |
b6a1d240 | 78 | fi |
1230b71f | 79 | |
931eabc0 XL |
80 | ( cd "$PKGDIR" |
81 | sed -i -e s/UNRELEASED-FIXME-AUTOGENERATED-DEBCARGO/UNRELEASED/ debian/changelog | |
699de4ac SL |
82 | if test -z "$DISTRO"; then |
83 | # To upload to other distro like experimental | |
84 | DISTRO=unstable | |
85 | fi | |
86 | dch -m -r -D $DISTRO "" | |
931eabc0 | 87 | git add debian/changelog |
d30bb8e0 | 88 | git rm --ignore-unmatch debian/RFS |
931eabc0 XL |
89 | ) |
90 | ||
cc003c95 | 91 | revert_git_changes() { |
8c0b9df4 | 92 | git reset --merge |
d30bb8e0 AS |
93 | git checkout -- "$PKGDIR/debian/changelog" |
94 | git checkout -q -- "$PKGDIR/debian/RFS" || true | |
e185876a XL |
95 | git checkout "$PREVBRANCH" |
96 | git branch -d "$RELBRANCH" | |
cc003c95 XL |
97 | } |
98 | ||
99 | if ! run_debcargo --changelog-ready; then | |
100 | revert_git_changes | |
101 | abort 1 "Release attempt failed to run debcargo, probably the package needs updating (./update.sh $*)" | |
102 | fi | |
103 | ||
104 | if ! git diff --exit-code -- "$PKGDIR_REL"; then | |
105 | revert_git_changes | |
baae6f7c XL |
106 | abort 1 \ |
107 | "Release attempt resulted in git diffs to $PKGDIR_REL, probably you need to update the package (./update.sh $*)." \ | |
108 | "Alternatively, set NOUPDATE=1 to override this requirement, but please have a good reason." | |
e185876a | 109 | fi |
931eabc0 | 110 | |
1057693c | 111 | if ! ( cd build && SOURCEONLY=1 ./build.sh "$CRATE" $VER ); then |
cc003c95 | 112 | revert_git_changes |
98cad301 XL |
113 | abort 1 "Release attempt failed (see messages above), possible reasons are: " \ |
114 | "- build-dependencies not in Debian => release those first." \ | |
115 | "- packaged version is out-of-date => run \`./update.sh $*\`" | |
cc003c95 XL |
116 | fi |
117 | ||
999f9269 | 118 | git commit -m "Release package $PKGNAME" |
931eabc0 | 119 | |
1057693c XL |
120 | DEBVER=$(dpkg-parsechangelog -l $BUILDDIR/debian/changelog -SVersion) |
121 | DEBSRC=$(dpkg-parsechangelog -l $BUILDDIR/debian/changelog -SSource) | |
550dd343 | 122 | DEB_HOST_ARCH=$(dpkg-architecture -q DEB_HOST_ARCH) |
b6a1d240 | 123 | |
baae6f7c XL |
124 | print_upload_instructions() { |
125 | if [ "$RERELEASE" = 1 ]; then | |
126 | cat <<eof | |
127 | Upload the source package | |
128 | ========================= | |
129 | ||
130 | Since you set RERELEASE=1, this package is presumably already in Debian. Go | |
131 | ahead and directly dput the source package. | |
132 | ||
133 | cd build && dput ${DEBSRC}_${DEBVER}_source.changes | |
134 | eof | |
135 | else | |
136 | cat <<eof | |
b6a1d240 XL |
137 | Build the package if necessary, and upload |
138 | ========================================== | |
1230b71f XL |
139 | |
140 | If the source package is already in Debian and this version does not introduce | |
141 | new binaries, then you can just go ahead and directly dput the source package. | |
142 | ||
1057693c | 143 | cd build && dput ${DEBSRC}_${DEBVER}_source.changes |
b6a1d240 | 144 | |
baae6f7c XL |
145 | For your reference, this source package builds $(grep ^Package build/${CRATE//_/-}/debian/control | wc -l) binary package(s): |
146 | $(sed -ne 's/^Package: //pg' build/hmac/debian/control | tr '\n' ',') | |
f52ac044 | 147 | |
1230b71f XL |
148 | If this is a NEW source package or introduces NEW binary packages not already |
149 | in the Debian archive, you will need to build a binary package out of it. The | |
150 | recommended way is to run something like: | |
151 | ||
1057693c | 152 | cd build && ./build.sh $CRATE $VER && dput ${DEBSRC}_${DEBVER}_${DEB_HOST_ARCH}.changes |
1230b71f | 153 | |
c6709bfe XL |
154 | This assumes you followed the "Build environment" instructions in README.rst, |
155 | for setting up a build environment for release. | |
1230b71f | 156 | |
db9d5fab XL |
157 | If the build fails e.g. due to missing Build-Dependencies you should revert |
158 | what I did (see below) and package those missing Build-Dependencies first. | |
baae6f7c XL |
159 | eof |
160 | fi | |
161 | } | |
162 | ||
163 | cat >&2 <<eof | |
164 | Release of $CRATE ready as a source package in ${BUILDDIR#$PWD/}. You need to | |
165 | perform the following steps: | |
166 | ||
167 | $(print_upload_instructions) | |
db9d5fab | 168 | |
b6a1d240 XL |
169 | Push this pending-release branch |
170 | ================================ | |
171 | ||
172 | After you have uploaded the package with dput(1), you should push $RELBRANCH so | |
173 | that other people see it's been uploaded. Then, checkout another branch like | |
174 | master to continue development on other packages. | |
175 | ||
ea8e55fe | 176 | git push origin $RELBRANCH && git checkout master |
b6a1d240 | 177 | |
baae6f7c XL |
178 | Merge the pending-release branch if/when ACCEPTED |
179 | ================================================= | |
b6a1d240 XL |
180 | |
181 | When it's ACCEPTED by the Debian FTP masters, you may then merge this branch | |
182 | back into the master branch, delete it, and push these updates to origin. | |
183 | ||
ea8e55fe XL |
184 | git checkout master && git merge $RELBRANCH && git branch -d $RELBRANCH |
185 | git push origin master :$RELBRANCH | |
b6a1d240 | 186 | |
baae6f7c XL |
187 | Delete this branch without merging if/when REJECTED |
188 | =================================================== | |
b6a1d240 | 189 | |
baae6f7c XL |
190 | If your upload is REJECTED, or if you cannot perform an upload in the first |
191 | place e.g. because you are not a Debian Developer, you should revert what I | |
192 | just did. To do that, run: | |
b6a1d240 | 193 | |
ea8e55fe | 194 | git checkout master && git branch -D $RELBRANCH |
b6a1d240 | 195 | |
baae6f7c XL |
196 | Then ask a Debian Developer to re-run me ($0 $*) on your behalf. Also, touch |
197 | and commit ${PKGDIR_REL}/debian/RFS so we can track these easier. | |
1230b71f | 198 | eof |