]>
Commit | Line | Data |
---|---|---|
931eabc0 | 1 | #!/bin/sh |
5e18ef4f XL |
2 | # Package or update a new or existing crate. |
3 | # | |
4 | # Usage: [REALVER=<EXACTVER>] ./release.sh <CRATE> [<SEMVER>] | |
5 | # | |
6 | # Envvars: | |
7 | # See also ./vars.sh.frag for its envvars, which we pass through. | |
931eabc0 XL |
8 | |
9 | . ./vars.sh.frag | |
10 | ||
b6a1d240 XL |
11 | case "$(git rev-parse --abbrev-ref HEAD)" in |
12 | pending-*) abort 1 "You are on a pending-release branch, $0 can only be run on another branch, like master";; | |
13 | esac | |
14 | ||
999f9269 XL |
15 | if [ -n "$VER" ]; then |
16 | if [ ! -d "$PWD/src/$PKGBASE" ]; then | |
17 | abort 1 "Using crate $CRATE with version $VER but default-version is not packaged." \ | |
18 | "Package that first by running this script without the explicit version." | |
19 | fi | |
20 | fi | |
931eabc0 XL |
21 | if [ ! -d "$PKGDIR/debian" ]; then |
22 | mkdir -p "$PKGDIR/debian" | |
54042c4c XL |
23 | cat <<-eof > "$PKGCFG" |
24 | overlay = "." | |
25 | uploaders = ["$DEBFULLNAME <$DEBEMAIL>"] | |
26 | eof | |
931eabc0 XL |
27 | git add "$PKGDIR" |
28 | fi | |
11d3113b | 29 | if [ ! -f "$PKGDIR/debian/copyright" ]; then |
c97440ec XL |
30 | cat <<-eof > "$PKGDIR/debian/copyright" |
31 | FIXME fill me in using ./copyright.debcargo.hint as a guide | |
c97440ec | 32 | eof |
11d3113b | 33 | fi |
999f9269 XL |
34 | if [ -n "$VER" -a "$(sed -ne 's/^semver_suffix\s*=\s*//p' "$PKGCFG")" != "true" ]; then |
35 | if grep -q semver_suffix "$PKGCFG"; then | |
36 | sed -i -e 's/^\(semver_suffix\s*=\s*\).*/\1true/' "$PKGCFG" | |
37 | else | |
38 | sed -i -e '1isemver_suffix = true' "$PKGCFG" | |
39 | fi | |
40 | fi | |
931eabc0 | 41 | |
54042c4c XL |
42 | if ! grep -q uploaders "$PKGCFG"; then |
43 | # try to auto-fill in uploaders if debcargo.toml doesn't have it | |
4919b031 | 44 | uploader="$(egrep -A1 "[0-9][0-9]*( Debian)? Rust Maintainers" "$PKGDIR/debian/copyright" | tail -n1 | sed -re 's/^\s*[0-9]+\s*//g')" |
d8c5cd99 | 45 | uploader="${uploader:-$DEBFULLNAME <$DEBEMAIL>}" |
54042c4c | 46 | sed -i -e 's/^\(overlay.*\)$/\1\nuploaders = ["'"$uploader"'"]/' "$PKGCFG" |
d8c5cd99 | 47 | echo >&2 "$0: Auto-added $uploader to uploaders in debcargo.toml, based on d/copyright" |
8300cec0 SL |
48 | if [ "$uploader" != "$DEBFULLNAME <$DEBEMAIL>" ]; then |
49 | read >&2 -p "$0: You may also want to add yourself; ctrl-c if you want to do that, or press enter to continue... " x | |
50 | fi | |
54042c4c XL |
51 | fi |
52 | ||
cc003c95 | 53 | run_debcargo |
c5c80e37 | 54 | git add -N "$PKGDIR" |
931eabc0 | 55 | |
1230b71f | 56 | if ! git diff --quiet -- "$PKGDIR_REL"; then |
8300cec0 SL |
57 | read -p "Update wrote some changes to $PKGDIR_REL, press enter to git diff..." x || true |
58 | git diff -- "$PKGDIR_REL" | |
01f68998 | 59 | echo >&2 "-- end of git diff --" |
931eabc0 XL |
60 | fi |
61 | ||
62 | cat >&2 <<eof | |
999f9269 XL |
63 | Automatic update of $CRATE finished; now it's your turn to manually review it. |
64 | ||
65 | Deal with any FIXMEs mentioned above, by editing any corresponding source files | |
66 | in $PKGDIR_REL. If a hint file is listed, indicated by (•), you should edit the | |
67 | *NON*-hint file, without the suffix .debcargo.hint, and git-add the hint file | |
68 | exactly as output by debcargo. So for example: | |
931eabc0 | 69 | |
999f9269 XL |
70 | to deal with a FIXME in: |
71 | build/$PKGNAME/debian/copyright.debcargo.hint | |
73560a1f | 72 | you should edit (and git-add when ready): |
999f9269 | 73 | src/$PKGNAME/debian/copyright |
73560a1f | 74 | and directly git-add without editing: |
999f9269 | 75 | src/$PKGNAME/debian/copyright.debcargo.hint |
d580884e | 76 | |
73560a1f XL |
77 | When done, git-add all your changes plus any unmodified hint files, and re-run |
78 | this command (\`./update.sh $*\`). | |
d580884e | 79 | |
01be05d0 XL |
80 | For issues with debian/control, edit src/$PKGNAME/debian/debcargo.toml instead. |
81 | You can find docs for that in debcargo.toml.example in the debcargo git repo. | |
82 | ||
d580884e XL |
83 | Check that your fixes actually get rid of the FIXMEs. Of course, you can ignore |
84 | FIXMEs listed in hint files, assuming you actually fixed the issues in the | |
85 | corresponding non-hint files. (We have no way to auto-detect this so you have | |
86 | to be honest!) You should also ignore the FIXME in the Distribution field in | |
87 | the top entry of debian/changelog, that will be dealt with in the next step. | |
931eabc0 | 88 | |
1e20dc1a | 89 | If there was a \`git diff\` above, check it to see if debcargo made changes to |
510d9803 XL |
90 | any auto-generated hint files. If so, you should make the equivalent changes to |
91 | the non-hint files, and git-add these too. | |
92 | ||
1057693c XL |
93 | You can test-build your package by running: |
94 | ||
95 | cd build && ./build.sh $CRATE $VER | |
96 | ||
c6709bfe | 97 | This assumes that you have set up sbuild; see "Build environment" in README.rst |
1057693c XL |
98 | for details. Try to fix any lintian errors, but note that some errors are due |
99 | to lintian being out-of-date and/or are expected at this stage of the process | |
100 | (e.g. bad-distribution-in-changes-file). Ask on IRC when in doubt. | |
101 | ||
9966e517 XL |
102 | If your update includes raising the semver level i.e. from 0.x.* to 0.y.* or |
103 | from x.*.* to y.*.*., then you should also check the reverse-deps of your | |
104 | package, by running: | |
105 | ||
106 | dev/list-rdeps.sh $CRATE | |
107 | ||
108 | If any of the reverse-dependencies depend on an older version of your crate, | |
109 | please try to update those too, to depend on the newer version that you just | |
110 | packaged. If this is impossible or too hard, you should retain the old version | |
111 | of your crate by running \`./update.sh $CRATE <OLD SEMVER>\`, where <OLD | |
112 | SEMVER> looks like 0.n or n - but you must have a good reason for this, which | |
113 | you should document in src/$PKGNAME-<OLD SEMVER>/debian/debcargo.toml. | |
114 | ||
115 | When satisfied with all of these outputs: | |
116 | ||
117 | - of debcargo after running ./update.sh | |
118 | - of lintian after running ./build.sh | |
119 | - of dev/list-rdeps.sh $CRATE | |
120 | ||
121 | then you can commit and push all your changes. | |
1057693c XL |
122 | |
123 | Then, ask a Debian Developer to run \`./release.sh $*\`. This finalises your | |
124 | changes in the changelog, and allows them to build and upload the package. If | |
125 | you're not a Debian Developer and are unable to upload, please don't run that | |
126 | script or else you will need to revert the changes that it makes to your git. | |
931eabc0 | 127 | eof |
f3600938 XL |
128 | if [ -n "$VER" ]; then |
129 | cat >&2 <<eof | |
130 | ||
56fc8aa3 XL |
131 | You are packaging an older version of a crate. Please document why it's needed, |
132 | by adding comments to src/$PKGNAME/debian/debcargo.toml. For example because it | |
133 | is a dependency of other crate(s), and it is not possible to update them to use | |
134 | the latest version of $CRATE. Please also mention the names of these crate(s). | |
f3600938 | 135 | eof |
56fc8aa3 | 136 | fi |