]> git.proxmox.com Git - debcargo-conf.git/blob - update.sh
Release package toml-0.5
[debcargo-conf.git] / update.sh
1 #!/bin/bash
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.
8
9 . ./vars.sh.frag
10
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
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
21 if [ ! -d "$PKGDIR/debian" ]; then
22 mkdir -p "$PKGDIR/debian"
23 cat <<-eof > "$PKGCFG"
24 overlay = "."
25 uploaders = ["$DEBFULLNAME <$DEBEMAIL>"]
26 eof
27 git add "$PKGDIR"
28 fi
29 if [ ! -f "$PKGDIR/debian/copyright" ]; then
30 cat <<-eof > "$PKGDIR/debian/copyright"
31 FIXME fill me in using ./copyright.debcargo.hint as a guide
32 eof
33 fi
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
41
42 if ! grep -q uploaders "$PKGCFG"; then
43 # try to auto-fill in uploaders if debcargo.toml doesn't have it
44 uploader="$(grep -E -A1 "[0-9][0-9]*( Debian)? Rust Maintainers" "$PKGDIR/debian/copyright" | tail -n1 | sed -re 's/^\s*[0-9]+\s*//g')"
45 uploader="${uploader:-$DEBFULLNAME <$DEBEMAIL>}"
46 sed -i -e 's/^\(overlay.*\)$/\1\nuploaders = ["'"$uploader"'"]/' "$PKGCFG"
47 echo >&2 "$0: Auto-added $uploader to uploaders in debcargo.toml, based on d/copyright"
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
51 fi
52
53 run_debcargo
54 git add -N "$PKGDIR"
55
56 if ! git diff --quiet -- "$PKGDIR_REL"; then
57 read -p "Update wrote some changes to $PKGDIR_REL, press enter to git diff..." x || true
58 git diff -- "$PKGDIR_REL"
59 echo >&2 "-- end of git diff --"
60 fi
61
62 cat >&2 <<eof
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:
69
70 to deal with a FIXME in:
71 build/$PKGNAME/debian/copyright.debcargo.hint
72 you should edit (and git-add when ready):
73 src/$PKGNAME/debian/copyright
74 and directly git-add without editing:
75 src/$PKGNAME/debian/copyright.debcargo.hint
76
77 When done, git-add all your changes plus any unmodified hint files, and re-run
78 this command (\`./update.sh $*\`).
79
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
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.
88
89 If there was a \`git diff\` above, check it to see if debcargo made changes to
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
93 You can test-build your package by running:
94
95 cd build && ./build.sh $CRATE $VER
96
97 This assumes that you have set up sbuild; see "Build environment" in README.rst
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
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.
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.
127 Instead, add an empty RFS file inside the created debian directory; see
128 TODO.rst's "Ready for upload" section for more details.
129 eof
130 if [ -n "$VER" ]; then
131 cat >&2 <<eof
132
133 You are packaging an older version of a crate. Please document why it's needed,
134 by adding comments to src/$PKGNAME/debian/debcargo.toml. For example because it
135 is a dependency of other crate(s), and it is not possible to update them to use
136 the latest version of $CRATE. Please also mention the names of these crate(s).
137 eof
138 fi