]> git.proxmox.com Git - debcargo-conf.git/blame - release.sh
Merge branch 'pending-clang-sys'
[debcargo-conf.git] / release.sh
CommitLineData
ea4bf6cd 1#!/bin/bash
931eabc0
XL
2
3. ./vars.sh.frag
4
e19e9e08
SL
5if test ! -d $PKGDIR_REL; then
6 abort 1 "Cannot find $PKGDIR_REL. Did you run ./new-package.sh before?"
7fi
8
c1621660
XL
9if test ! -f "$PKGDIR_REL/debian/changelog"; then
10 abort 1 "Cannot find $PKGDIR_REL/debian/changelog. Did you run ./new-package.sh before?"
11fi
12
e3cf5e2c 13if 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."
15fi
16
1230b71f
XL
17git diff --quiet --cached || \
18abort 1 "You have other pending changes to git, please complete it or stash it away and re-run this script."
19
20git diff --quiet -- "$PKGDIR_REL" || \
931eabc0
XL
21abort 1 "Please git-add your changes to $PKGDIR_REL before running"
22
1057693c
XL
23type dch >/dev/null || \
24abort 1 "Install devscripts, we need to run dch."
25
b6a1d240
XL
26RELBRANCH="pending-$PKGNAME"
27git fetch origin --prune
2de6944f 28
c75ca09f 29git merge-base --is-ancestor origin/master HEAD || \
90f3bab9 30abort 1 "You are not synced with origin/master, please do so before running this script."
1c8790a3 31
baae6f7c
XL
32if [ "$RERELEASE" = 1 -o "$NOUPDATE" = 1 ]; then
33 REALVER="$(get_existing_version "$PKGDIR")"
34fi
35
2de6944f 36if 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
54fi
55
e1a9d897
XL
56if [ -e "$PKGDIR/debian/BLOCK" ]; then
57 abort 1 "TODO items remain in $PKGDIR/debian/BLOCK, please deal with those"
58fi
59
32c1fb5b
XL
60PREVBRANCH="$(git rev-parse --abbrev-ref HEAD)"
61case "$PREVBRANCH" in
b6a1d240
XL
62pending-$PKGNAME) true;;
63pending-*) 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;;
70esac
71
72if 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 78fi
1230b71f 79
931eabc0
XL
80( cd "$PKGDIR"
81sed -i -e s/UNRELEASED-FIXME-AUTOGENERATED-DEBCARGO/UNRELEASED/ debian/changelog
699de4ac
SL
82if test -z "$DISTRO"; then
83 # To upload to other distro like experimental
84 DISTRO=unstable
85fi
86dch -m -r -D $DISTRO ""
931eabc0 87git add debian/changelog
d30bb8e0 88git rm --ignore-unmatch debian/RFS
931eabc0
XL
89)
90
cc003c95 91revert_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
99if ! 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 $*)"
102fi
103
104if ! 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 109fi
931eabc0 110
1057693c 111if ! ( 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
116fi
117
999f9269 118git commit -m "Release package $PKGNAME"
931eabc0 119
1057693c
XL
120DEBVER=$(dpkg-parsechangelog -l $BUILDDIR/debian/changelog -SVersion)
121DEBSRC=$(dpkg-parsechangelog -l $BUILDDIR/debian/changelog -SSource)
550dd343 122DEB_HOST_ARCH=$(dpkg-architecture -q DEB_HOST_ARCH)
b6a1d240 123
baae6f7c
XL
124print_upload_instructions() {
125if [ "$RERELEASE" = 1 ]; then
126cat <<eof
127Upload the source package
128=========================
129
130Since you set RERELEASE=1, this package is presumably already in Debian. Go
131ahead and directly dput the source package.
132
133 cd build && dput ${DEBSRC}_${DEBVER}_source.changes
134eof
135else
136cat <<eof
b6a1d240
XL
137Build the package if necessary, and upload
138==========================================
1230b71f
XL
139
140If the source package is already in Debian and this version does not introduce
141new 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
145For 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
148If this is a NEW source package or introduces NEW binary packages not already
149in the Debian archive, you will need to build a binary package out of it. The
150recommended 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
154This assumes you followed the "Build environment" instructions in README.rst,
155for setting up a build environment for release.
1230b71f 156
db9d5fab
XL
157If the build fails e.g. due to missing Build-Dependencies you should revert
158what I did (see below) and package those missing Build-Dependencies first.
baae6f7c
XL
159eof
160fi
161}
162
163cat >&2 <<eof
164Release of $CRATE ready as a source package in ${BUILDDIR#$PWD/}. You need to
165perform the following steps:
166
167$(print_upload_instructions)
db9d5fab 168
b6a1d240
XL
169Push this pending-release branch
170================================
171
172After you have uploaded the package with dput(1), you should push $RELBRANCH so
173that other people see it's been uploaded. Then, checkout another branch like
174master to continue development on other packages.
175
ea8e55fe 176 git push origin $RELBRANCH && git checkout master
b6a1d240 177
baae6f7c
XL
178Merge the pending-release branch if/when ACCEPTED
179=================================================
b6a1d240
XL
180
181When it's ACCEPTED by the Debian FTP masters, you may then merge this branch
182back 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
187Delete this branch without merging if/when REJECTED
188===================================================
b6a1d240 189
baae6f7c
XL
190If your upload is REJECTED, or if you cannot perform an upload in the first
191place e.g. because you are not a Debian Developer, you should revert what I
192just did. To do that, run:
b6a1d240 193
ea8e55fe 194 git checkout master && git branch -D $RELBRANCH
b6a1d240 195
baae6f7c
XL
196Then ask a Debian Developer to re-run me ($0 $*) on your behalf. Also, touch
197and commit ${PKGDIR_REL}/debian/RFS so we can track these easier.
1230b71f 198eof