]>
Commit | Line | Data |
---|---|---|
931eabc0 XL |
1 | #!/bin/sh |
2 | ||
3 | . ./vars.sh.frag | |
4 | ||
1230b71f XL |
5 | git diff --quiet --cached || \ |
6 | abort 1 "You have other pending changes to git, please complete it or stash it away and re-run this script." | |
7 | ||
8 | git diff --quiet -- "$PKGDIR_REL" || \ | |
931eabc0 XL |
9 | abort 1 "Please git-add your changes to $PKGDIR_REL before running" |
10 | ||
b6a1d240 XL |
11 | RELBRANCH="pending-$PKGNAME" |
12 | git fetch origin --prune | |
2de6944f XL |
13 | |
14 | if head -n1 "$PKGDIR/debian/changelog" | grep -qv UNRELEASED-FIXME-AUTOGENERATED-DEBCARGO; then | |
15 | abort 0 "Package already released." | |
16 | fi | |
17 | ||
32c1fb5b XL |
18 | PREVBRANCH="$(git rev-parse --abbrev-ref HEAD)" |
19 | case "$PREVBRANCH" in | |
b6a1d240 XL |
20 | pending-$PKGNAME) true;; |
21 | 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";; | |
22 | *) if git rev-parse -q --verify "refs/heads/$RELBRANCH" >/dev/null || \ | |
23 | git rev-parse -q --verify "refs/remotes/origin/$RELBRANCH" >/dev/null; then | |
24 | git checkout "$RELBRANCH" | |
25 | else | |
26 | git checkout -b "$RELBRANCH" | |
27 | fi;; | |
28 | esac | |
29 | ||
30 | if head -n1 "$PKGDIR/debian/changelog" | grep -qv UNRELEASED-FIXME-AUTOGENERATED-DEBCARGO; then | |
32c1fb5b | 31 | git checkout "$PREVBRANCH" |
2de6944f | 32 | abort 0 "Package already released on branch $RELBRANCH. If that was a mistake then run \`git branch -D $RELBRANCH\`, and re-run this script ($0 $*)" |
b6a1d240 | 33 | fi |
1230b71f | 34 | |
931eabc0 XL |
35 | ( cd "$PKGDIR" |
36 | sed -i -e s/UNRELEASED-FIXME-AUTOGENERATED-DEBCARGO/UNRELEASED/ debian/changelog | |
37 | dch -r -D unstable "" | |
38 | git add debian/changelog | |
39 | ) | |
40 | ||
d4afe994 | 41 | rm -rf "$BUILDDIR" "$(dirname "$BUILDDIR")/rust-${PKGNAME}_$VER"*.orig.tar.* |
999f9269 | 42 | $DEBCARGO package --config "$PKGCFG" --directory "$BUILDDIR" --changelog-ready "$CRATE" "$VER" |
931eabc0 | 43 | |
c8a5aadf | 44 | git diff --exit-code -- "$PKGDIR_REL" || \ |
01f68998 | 45 | abort 1 "Release attempt resulted in git diffs to $PKGDIR_REL. Check it, git add or reset as appropriate, and re-run this again." |
931eabc0 | 46 | |
999f9269 | 47 | git commit -m "Release package $PKGNAME" |
931eabc0 XL |
48 | |
49 | ( cd "$BUILDDIR" && dpkg-buildpackage -d -S --no-sign ) | |
1230b71f | 50 | |
a957cf62 XL |
51 | cat >"$BUILDDIR/../sbuild-and-sign.sh" <<'eof' |
52 | #!/bin/sh | |
53 | set -e | |
54 | ||
55 | if [ -n "$DEBCARGO" ]; then | |
56 | true | |
57 | elif which debcargo >/dev/null; then | |
58 | DEBCARGO=$(which debcargo) | |
59 | elif [ -f "$HOME/.cargo/bin/debcargo" ]; then | |
60 | DEBCARGO="$HOME/.cargo/bin/debcargo" | |
61 | else | |
62 | abort 1 "debcargo not found, run \`cargo install debcargo\` or set DEBCARGO to point to it" | |
63 | fi | |
64 | ||
65 | CRATE="$1" | |
66 | VER="$2" | |
3d84b395 | 67 | DISTRIBUTION="${DISTRIBUTION:-unstable}" |
a957cf62 XL |
68 | |
69 | PKGNAME=$($DEBCARGO deb-src-name "$CRATE" $VER || abort 1 "couldn't find crate $CRATE") | |
70 | DEBVER=$(dpkg-parsechangelog -l $PKGNAME/debian/changelog -SVersion) | |
71 | DEBSRC=$(dpkg-parsechangelog -l $PKGNAME/debian/changelog -SSource) | |
72 | DEB_HOST_ARCH=$(dpkg-architecture -q DEB_HOST_ARCH) | |
73 | ||
3d84b395 | 74 | sbuild --no-source --arch-any --arch-all ${CHROOT:+-c $CHROOT }${DISTRIBUTION:+-d $DISTRIBUTION }${DEBSRC}_${DEBVER}.dsc |
a957cf62 XL |
75 | changestool ${DEBSRC}_${DEBVER}_${DEB_HOST_ARCH}.changes adddsc ${DEBSRC}_${DEBVER}.dsc |
76 | debsign ${DEBSIGN_KEYID:+-k $DEBSIGN_KEYID }--no-re-sign ${DEBSRC}_${DEBVER}_${DEB_HOST_ARCH}.changes | |
77 | eof | |
78 | chmod +x "$BUILDDIR/../sbuild-and-sign.sh" | |
79 | ||
550dd343 XL |
80 | DEBVER=$(dpkg-parsechangelog -l build/$PKGNAME/debian/changelog -SVersion) |
81 | DEBSRC=$(dpkg-parsechangelog -l build/$PKGNAME/debian/changelog -SSource) | |
82 | DEB_HOST_ARCH=$(dpkg-architecture -q DEB_HOST_ARCH) | |
1230b71f | 83 | cat >&2 <<eof |
b6a1d240 XL |
84 | Release of $CRATE ready as a source package in ${BUILDDIR#$PWD/}. You need to |
85 | perform the following steps: | |
86 | ||
87 | Build the package if necessary, and upload | |
88 | ========================================== | |
1230b71f XL |
89 | |
90 | If the source package is already in Debian and this version does not introduce | |
91 | new binaries, then you can just go ahead and directly dput the source package. | |
92 | ||
ea8e55fe | 93 | dput ${DEBSRC}_${DEBVER}_source.changes |
b6a1d240 | 94 | |
1230b71f XL |
95 | If this is a NEW source package or introduces NEW binary packages not already |
96 | in the Debian archive, you will need to build a binary package out of it. The | |
97 | recommended way is to run something like: | |
98 | ||
ea8e55fe XL |
99 | cd build |
100 | ./sbuild-and-sign.sh $CRATE $VER | |
101 | dput ${DEBSRC}_${DEBVER}_${DEB_HOST_ARCH}.changes | |
1230b71f XL |
102 | |
103 | See https://wiki.debian.org/sbuild for instructions on how to set it up. The | |
104 | other tools are from the 'devscripts' package. | |
105 | ||
db9d5fab XL |
106 | If the build fails e.g. due to missing Build-Dependencies you should revert |
107 | what I did (see below) and package those missing Build-Dependencies first. | |
108 | ||
b6a1d240 XL |
109 | Push this pending-release branch |
110 | ================================ | |
111 | ||
112 | After you have uploaded the package with dput(1), you should push $RELBRANCH so | |
113 | that other people see it's been uploaded. Then, checkout another branch like | |
114 | master to continue development on other packages. | |
115 | ||
ea8e55fe | 116 | git push origin $RELBRANCH && git checkout master |
b6a1d240 XL |
117 | |
118 | Merge the pending-release branch when ACCEPTED | |
119 | ============================================== | |
120 | ||
121 | When it's ACCEPTED by the Debian FTP masters, you may then merge this branch | |
122 | back into the master branch, delete it, and push these updates to origin. | |
123 | ||
ea8e55fe XL |
124 | git checkout master && git merge $RELBRANCH && git branch -d $RELBRANCH |
125 | git push origin master :$RELBRANCH | |
b6a1d240 XL |
126 | |
127 | ---- | |
128 | ||
129 | The above assumes you are a Debian Developer with upload rights. If not, you | |
a957cf62 | 130 | should revert what I just did. To do that, run: |
b6a1d240 | 131 | |
ea8e55fe | 132 | git checkout master && git branch -D $RELBRANCH |
b6a1d240 | 133 | |
1302be74 | 134 | Then ask a Debian Developer to re-run me ($0 $*) on your behalf. |
1230b71f | 135 | eof |