]>
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 | |
2de6944f XL |
32 | if head -n1 "$PKGDIR/debian/changelog" | grep -qv UNRELEASED-FIXME-AUTOGENERATED-DEBCARGO; then |
33 | abort 0 "Package already released." | |
34 | fi | |
35 | ||
e1a9d897 XL |
36 | if [ -e "$PKGDIR/debian/BLOCK" ]; then |
37 | abort 1 "TODO items remain in $PKGDIR/debian/BLOCK, please deal with those" | |
38 | fi | |
39 | ||
32c1fb5b XL |
40 | PREVBRANCH="$(git rev-parse --abbrev-ref HEAD)" |
41 | case "$PREVBRANCH" in | |
b6a1d240 XL |
42 | pending-$PKGNAME) true;; |
43 | 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";; | |
44 | *) if git rev-parse -q --verify "refs/heads/$RELBRANCH" >/dev/null || \ | |
45 | git rev-parse -q --verify "refs/remotes/origin/$RELBRANCH" >/dev/null; then | |
46 | git checkout "$RELBRANCH" | |
47 | else | |
48 | git checkout -b "$RELBRANCH" | |
49 | fi;; | |
50 | esac | |
51 | ||
52 | if head -n1 "$PKGDIR/debian/changelog" | grep -qv UNRELEASED-FIXME-AUTOGENERATED-DEBCARGO; then | |
32c1fb5b | 53 | git checkout "$PREVBRANCH" |
4149dabf | 54 | abort 0 "Package already released on branch $RELBRANCH. If that was a mistake then run:\ngit branch -D $RELBRANCH\nAnd re-run this script ($0 $*). You might have to delete the remote branch too:\ngit push --delete origin $RELBRANCH" |
b6a1d240 | 55 | fi |
1230b71f | 56 | |
931eabc0 XL |
57 | ( cd "$PKGDIR" |
58 | sed -i -e s/UNRELEASED-FIXME-AUTOGENERATED-DEBCARGO/UNRELEASED/ debian/changelog | |
699de4ac SL |
59 | if test -z "$DISTRO"; then |
60 | # To upload to other distro like experimental | |
61 | DISTRO=unstable | |
62 | fi | |
63 | dch -m -r -D $DISTRO "" | |
931eabc0 | 64 | git add debian/changelog |
d30bb8e0 | 65 | git rm --ignore-unmatch debian/RFS |
931eabc0 XL |
66 | ) |
67 | ||
cc003c95 | 68 | revert_git_changes() { |
8c0b9df4 | 69 | git reset --merge |
d30bb8e0 AS |
70 | git checkout -- "$PKGDIR/debian/changelog" |
71 | git checkout -q -- "$PKGDIR/debian/RFS" || true | |
e185876a XL |
72 | git checkout "$PREVBRANCH" |
73 | git branch -d "$RELBRANCH" | |
cc003c95 XL |
74 | } |
75 | ||
76 | if ! run_debcargo --changelog-ready; then | |
77 | revert_git_changes | |
78 | abort 1 "Release attempt failed to run debcargo, probably the package needs updating (./update.sh $*)" | |
79 | fi | |
80 | ||
81 | if ! git diff --exit-code -- "$PKGDIR_REL"; then | |
82 | revert_git_changes | |
e185876a XL |
83 | abort 1 "Release attempt resulted in git diffs to $PKGDIR_REL, probably the package needs updating (./update.sh $*)" |
84 | fi | |
931eabc0 | 85 | |
1057693c | 86 | if ! ( cd build && SOURCEONLY=1 ./build.sh "$CRATE" $VER ); then |
cc003c95 | 87 | revert_git_changes |
98cad301 XL |
88 | abort 1 "Release attempt failed (see messages above), possible reasons are: " \ |
89 | "- build-dependencies not in Debian => release those first." \ | |
90 | "- packaged version is out-of-date => run \`./update.sh $*\`" | |
cc003c95 XL |
91 | fi |
92 | ||
999f9269 | 93 | git commit -m "Release package $PKGNAME" |
931eabc0 | 94 | |
1057693c XL |
95 | DEBVER=$(dpkg-parsechangelog -l $BUILDDIR/debian/changelog -SVersion) |
96 | DEBSRC=$(dpkg-parsechangelog -l $BUILDDIR/debian/changelog -SSource) | |
550dd343 | 97 | DEB_HOST_ARCH=$(dpkg-architecture -q DEB_HOST_ARCH) |
1230b71f | 98 | cat >&2 <<eof |
b6a1d240 XL |
99 | Release of $CRATE ready as a source package in ${BUILDDIR#$PWD/}. You need to |
100 | perform the following steps: | |
101 | ||
102 | Build the package if necessary, and upload | |
103 | ========================================== | |
1230b71f XL |
104 | |
105 | If the source package is already in Debian and this version does not introduce | |
106 | new binaries, then you can just go ahead and directly dput the source package. | |
107 | ||
1057693c | 108 | cd build && dput ${DEBSRC}_${DEBVER}_source.changes |
b6a1d240 | 109 | |
79000db2 | 110 | For your reference, this source package builds $(grep ^Package build/${CRATE//_/-}/debian/control | wc -l) binary package(s). |
f52ac044 | 111 | |
1230b71f XL |
112 | If this is a NEW source package or introduces NEW binary packages not already |
113 | in the Debian archive, you will need to build a binary package out of it. The | |
114 | recommended way is to run something like: | |
115 | ||
1057693c | 116 | cd build && ./build.sh $CRATE $VER && dput ${DEBSRC}_${DEBVER}_${DEB_HOST_ARCH}.changes |
1230b71f | 117 | |
1442fbfc XL |
118 | This assumes you followed the "DD instructions" in README.rst, for setting up |
119 | a build environment for release. | |
1230b71f | 120 | |
db9d5fab XL |
121 | If the build fails e.g. due to missing Build-Dependencies you should revert |
122 | what I did (see below) and package those missing Build-Dependencies first. | |
123 | ||
b6a1d240 XL |
124 | Push this pending-release branch |
125 | ================================ | |
126 | ||
127 | After you have uploaded the package with dput(1), you should push $RELBRANCH so | |
128 | that other people see it's been uploaded. Then, checkout another branch like | |
129 | master to continue development on other packages. | |
130 | ||
ea8e55fe | 131 | git push origin $RELBRANCH && git checkout master |
b6a1d240 XL |
132 | |
133 | Merge the pending-release branch when ACCEPTED | |
134 | ============================================== | |
135 | ||
136 | When it's ACCEPTED by the Debian FTP masters, you may then merge this branch | |
137 | back into the master branch, delete it, and push these updates to origin. | |
138 | ||
ea8e55fe XL |
139 | git checkout master && git merge $RELBRANCH && git branch -d $RELBRANCH |
140 | git push origin master :$RELBRANCH | |
b6a1d240 XL |
141 | |
142 | ---- | |
143 | ||
144 | The above assumes you are a Debian Developer with upload rights. If not, you | |
a957cf62 | 145 | should revert what I just did. To do that, run: |
b6a1d240 | 146 | |
ea8e55fe | 147 | git checkout master && git branch -D $RELBRANCH |
b6a1d240 | 148 | |
680a635e XL |
149 | Then ask a Debian Developer to re-run me ($0 $*) on your behalf. Also touch |
150 | and commit ${PKGDIR_REL}/debian/RFS so it's easy to track. | |
1230b71f | 151 | eof |