Improve release scripts to make it easier for non-DD contributors to build the packages
Ximin Luo
5 years ago
0 | 0 | Instructions |
1 | 1 | ============ |
2 | 2 | |
3 | First, ``cargo install debcargo``. Then for each new package: | |
3 | To get set up, run:: | |
4 | ||
5 | apt update && apt build-dep cargo && apt install cargo dh-cargo | |
6 | cargo install debcargo # eventually will be replaced by "apt install debcargo" | |
7 | ||
8 | Then for each new package: | |
4 | 9 | |
5 | 10 | **To package a new crate, or to update an existing crate:** |
6 | 11 |
0 | #!/bin/sh | |
1 | set -e | |
2 | ||
3 | abort() { local x=$1; shift; for i in "$@"; do echo >&2 "$0: abort: $i"; done; exit "$x"; } | |
4 | ||
5 | if [ "$(basename "$PWD")" != "build" ]; then | |
6 | abort 1 "This script is only meant to be run from the build/ directory." | |
7 | fi | |
8 | ||
9 | if [ -n "$DEBCARGO" ]; then | |
10 | true | |
11 | elif which debcargo >/dev/null; then | |
12 | DEBCARGO=$(which debcargo) | |
13 | elif [ -f "$HOME/.cargo/bin/debcargo" ]; then | |
14 | DEBCARGO="$HOME/.cargo/bin/debcargo" | |
15 | else | |
16 | abort 1 "debcargo not found, run \`cargo install debcargo\` or set DEBCARGO to point to it" | |
17 | fi | |
18 | ||
19 | CRATE="$1" | |
20 | VER="$2" | |
21 | DISTRIBUTION="${DISTRIBUTION:-unstable}" | |
22 | ||
23 | PKGNAME=$($DEBCARGO deb-src-name "$CRATE" $VER || abort 1 "couldn't find crate $CRATE") | |
24 | DEBVER=$(dpkg-parsechangelog -l $PKGNAME/debian/changelog -SVersion) | |
25 | DEBSRC=$(dpkg-parsechangelog -l $PKGNAME/debian/changelog -SSource) | |
26 | DEBDIST=$(dpkg-parsechangelog -l $PKGNAME/debian/changelog -SDistribution) | |
27 | DEB_HOST_ARCH=$(dpkg-architecture -q DEB_HOST_ARCH) | |
28 | if [ -z "$CHROOT" ] && schroot -i -c "debcargo-unstable-${DEB_HOST_ARCH}-sbuild" >/dev/null 2>&1; then | |
29 | CHROOT="debcargo-unstable-${DEB_HOST_ARCH}-sbuild" | |
30 | fi | |
31 | ||
32 | shouldbuild() { | |
33 | local dst="$1" | |
34 | local src="$2" | |
35 | test ! -e "$dst" -o "$src" -nt "$dst" | |
36 | } | |
37 | ||
38 | if shouldbuild ${DEBSRC}_${DEBVER}.dsc "$PKGNAME/debian/changelog" ]; then | |
39 | ( cd "$PKGNAME" && dpkg-buildpackage -d -S --no-sign ) | |
40 | # sign if not UNRELEASED | |
41 | if echo "$DEBDIST" | grep -qv UNRELEASED-FIXME-AUTOGENERATED-DEBCARGO; then | |
42 | debsign ${DEBSRC}_${DEBVER}_source.changes | |
43 | fi | |
44 | fi | |
45 | ||
46 | check_build_deps() { | |
47 | mkdir -p dpkg-dummy | |
48 | if shouldbuild dpkg-dummy/status /var/cache/apt/pkgcache.bin; then | |
49 | # pretend dpkg status file that marks all packages as installed | |
50 | # this is because dpkg-checkbuilddeps only works on installed pkgs | |
51 | apt-cache dumpavail | \ | |
52 | sed -e 's/Package: .*/\0\nStatus: install ok installed/g' > dpkg-dummy/status | |
53 | fi | |
54 | cd "$PKGNAME" && dpkg-checkbuilddeps --admindir=../dpkg-dummy | |
55 | } | |
56 | ||
57 | if ! check_build_deps; then | |
58 | abort 1 "Missing build-dependencies, but maybe try '{apt,cargo} update'" | |
59 | fi | |
60 | ||
61 | if [ "$SOURCEONLY" = 1 ]; then | |
62 | exit | |
63 | fi | |
64 | ||
65 | sbuild --no-source --arch-any --arch-all ${CHROOT:+-c $CHROOT }${DISTRIBUTION:+-d $DISTRIBUTION }${DEBSRC}_${DEBVER}.dsc | |
66 | changestool ${DEBSRC}_${DEBVER}_${DEB_HOST_ARCH}.changes adddsc ${DEBSRC}_${DEBVER}.dsc | |
67 | ||
68 | # sign if not UNRELEASED | |
69 | if echo "$DEBDIST" | grep -qv UNRELEASED-FIXME-AUTOGENERATED-DEBCARGO; then | |
70 | debsign ${DEBSIGN_KEYID:+-k $DEBSIGN_KEYID }--no-re-sign ${DEBSRC}_${DEBVER}_${DEB_HOST_ARCH}.changes | |
71 | fi |
0 | #!/bin/bash | |
1 | # Filter list of crates by whether all their build-deps are in Debian | |
2 | # Use like, e.g. `dev/list-unreleased.sh | dev/filter-builddeps-ok.sh` | |
3 | set -e | |
4 | ||
5 | shouldbuild() { | |
6 | local dst="$1" | |
7 | local src="$2" | |
8 | test ! -e "$dst" -o "$src" -nt "$dst" | |
9 | } | |
10 | ||
11 | echo >&2 "redirecting all other output e.g. from debcargo to stderr" | |
12 | while read crate ver; do | |
13 | pkgname="${crate//_/-}${ver:+-$ver}" | |
14 | if shouldbuild "build/$pkgname/debian/changelog" "src/$pkgname/debian/changelog"; then | |
15 | ./update.sh "$crate" $ver >&2 # TODO: no-overlay-write-back | |
16 | fi | |
17 | if ( cd build && SOURCEONLY=1 ./build.sh "$crate" $ver >&2 ); then | |
18 | ok=1 | |
19 | else | |
20 | ok=0 | |
21 | fi | |
22 | echo "$crate $ver $ok" | |
23 | done |
7 | 7 | cut '-d ' -f1 | \ |
8 | 8 | while read crate; do |
9 | 9 | pkg="${crate//_/-}" |
10 | head -n1 src/$pkg/debian/changelog | |
10 | sed -nre "s/.*Package (.*) .* from crates.io.*/\1/gp" src/$pkg/debian/changelog | head -n1 | |
11 | 11 | done |
10 | 10 | |
11 | 11 | git diff --quiet -- "$PKGDIR_REL" || \ |
12 | 12 | abort 1 "Please git-add your changes to $PKGDIR_REL before running" |
13 | ||
14 | type dch >/dev/null || \ | |
15 | abort 1 "Install devscripts, we need to run dch." | |
13 | 16 | |
14 | 17 | RELBRANCH="pending-$PKGNAME" |
15 | 18 | git fetch origin --prune |
58 | 61 | abort 1 "Release attempt resulted in git diffs to $PKGDIR_REL, probably the package needs updating (./update.sh $*)" |
59 | 62 | fi |
60 | 63 | |
61 | check_build_deps() { | |
62 | local success=true | |
63 | sed -ne '/Build-Depends/,/^[^ ]/p' "build/$PKGNAME/debian/control" | \ | |
64 | grep -Eo 'librust-.*+.*-dev' | \ | |
65 | { while read pkg; do | |
66 | if [ $(apt-cache showpkg "$pkg" | grep ^Package: | wc -l) = 0 ]; then | |
67 | echo >&2 "Build-Dependency not yet in debian: $pkg (don't forget to '{apt,cargo} update')" | |
68 | success=false | |
69 | fi | |
70 | done; $success; } | |
71 | } | |
72 | ||
73 | if ! check_build_deps; then | |
64 | if ! ( cd build && SOURCEONLY=1 ./build.sh "$CRATE" $VER ); then | |
74 | 65 | revert_git_changes |
75 | 66 | abort 1 "Release attempt detected build-dependencies not in Debian (see messages above), release those first." |
76 | 67 | fi |
77 | 68 | |
78 | 69 | git commit -m "Release package $PKGNAME" |
79 | 70 | |
80 | ( cd "$BUILDDIR" && dpkg-buildpackage -d -S --no-sign ) | |
81 | ||
82 | cat >"$BUILDDIR/../sbuild-and-sign.sh" <<'eof' | |
83 | #!/bin/sh | |
84 | set -e | |
85 | ||
86 | if [ -n "$DEBCARGO" ]; then | |
87 | true | |
88 | elif which debcargo >/dev/null; then | |
89 | DEBCARGO=$(which debcargo) | |
90 | elif [ -f "$HOME/.cargo/bin/debcargo" ]; then | |
91 | DEBCARGO="$HOME/.cargo/bin/debcargo" | |
92 | else | |
93 | abort 1 "debcargo not found, run \`cargo install debcargo\` or set DEBCARGO to point to it" | |
94 | fi | |
95 | ||
96 | CRATE="$1" | |
97 | VER="$2" | |
98 | DISTRIBUTION="${DISTRIBUTION:-unstable}" | |
99 | ||
100 | PKGNAME=$($DEBCARGO deb-src-name "$CRATE" $VER || abort 1 "couldn't find crate $CRATE") | |
101 | DEBVER=$(dpkg-parsechangelog -l $PKGNAME/debian/changelog -SVersion) | |
102 | DEBSRC=$(dpkg-parsechangelog -l $PKGNAME/debian/changelog -SSource) | |
103 | DEB_HOST_ARCH=$(dpkg-architecture -q DEB_HOST_ARCH) | |
104 | if [ -z "$CHROOT" ] && schroot -i -c "debcargo-unstable-${DEB_HOST_ARCH}-sbuild" >/dev/null 2>&1; then | |
105 | CHROOT="debcargo-unstable-${DEB_HOST_ARCH}-sbuild" | |
106 | fi | |
107 | ||
108 | sbuild --no-source --arch-any --arch-all ${CHROOT:+-c $CHROOT }${DISTRIBUTION:+-d $DISTRIBUTION }${DEBSRC}_${DEBVER}.dsc | |
109 | changestool ${DEBSRC}_${DEBVER}_${DEB_HOST_ARCH}.changes adddsc ${DEBSRC}_${DEBVER}.dsc | |
110 | debsign ${DEBSIGN_KEYID:+-k $DEBSIGN_KEYID }--no-re-sign ${DEBSRC}_${DEBVER}_${DEB_HOST_ARCH}.changes | |
111 | eof | |
112 | chmod +x "$BUILDDIR/../sbuild-and-sign.sh" | |
113 | ||
114 | DEBVER=$(dpkg-parsechangelog -l build/$PKGNAME/debian/changelog -SVersion) | |
115 | DEBSRC=$(dpkg-parsechangelog -l build/$PKGNAME/debian/changelog -SSource) | |
71 | DEBVER=$(dpkg-parsechangelog -l $BUILDDIR/debian/changelog -SVersion) | |
72 | DEBSRC=$(dpkg-parsechangelog -l $BUILDDIR/debian/changelog -SSource) | |
116 | 73 | DEB_HOST_ARCH=$(dpkg-architecture -q DEB_HOST_ARCH) |
117 | 74 | cat >&2 <<eof |
118 | 75 | Release of $CRATE ready as a source package in ${BUILDDIR#$PWD/}. You need to |
124 | 81 | If the source package is already in Debian and this version does not introduce |
125 | 82 | new binaries, then you can just go ahead and directly dput the source package. |
126 | 83 | |
127 | cd build | |
128 | debsign ${DEBSRC}_${DEBVER}_source.changes | |
129 | dput ${DEBSRC}_${DEBVER}_source.changes | |
84 | cd build && dput ${DEBSRC}_${DEBVER}_source.changes | |
130 | 85 | |
131 | 86 | If this is a NEW source package or introduces NEW binary packages not already |
132 | 87 | in the Debian archive, you will need to build a binary package out of it. The |
133 | 88 | recommended way is to run something like: |
134 | 89 | |
135 | cd build | |
136 | ./sbuild-and-sign.sh $CRATE $VER | |
137 | dput ${DEBSRC}_${DEBVER}_${DEB_HOST_ARCH}.changes | |
90 | cd build && ./build.sh $CRATE $VER && dput ${DEBSRC}_${DEBVER}_${DEB_HOST_ARCH}.changes | |
138 | 91 | |
139 | 92 | This assumes you followed the "DD instructions" in README.rst, for setting up |
140 | 93 | a build environment for release. |
42 | 42 | run_debcargo |
43 | 43 | |
44 | 44 | if ! git diff --quiet -- "$PKGDIR_REL"; then |
45 | read -p "Update wrote some changes to $PKGDIR_REL, press enter to git diff..." x | |
45 | read -p "Update wrote some changes to $PKGDIR_REL, press enter to git diff..." x || true | |
46 | 46 | git diff -- "$PKGDIR_REL" |
47 | 47 | echo >&2 "-- end of git diff --" |
48 | 48 | fi |
78 | 78 | any auto-generated hint files. If so, you should make the equivalent changes to |
79 | 79 | the non-hint files, and git-add these too. |
80 | 80 | |
81 | When satisfied with the output, you can commit and push all your changes. Then, | |
82 | ask a Debian Developer to run \`./release.sh $*\` to finalise your changes in | |
83 | the changelog and build a release-ready .dsc in build/. Assuming it runs | |
84 | successfully, they may \`dput\` the results afterwards. If you're not a Debian | |
85 | Developer and are unable to upload, please don't run that script because it | |
86 | will add inaccurate commits to git stating that the package has been uploaded. | |
81 | You can test-build your package by running: | |
82 | ||
83 | cd build && ./build.sh $CRATE $VER | |
84 | ||
85 | This assumes that you have set up sbuild; see "DD instructions" in README.rst | |
86 | for details. Try to fix any lintian errors, but note that some errors are due | |
87 | to lintian being out-of-date and/or are expected at this stage of the process | |
88 | (e.g. bad-distribution-in-changes-file). Ask on IRC when in doubt. | |
89 | ||
90 | When satisfied with the output (both of debcargo after running ./update.sh, and | |
91 | of lintian after running ./build.sh), you can commit and push all your changes. | |
92 | ||
93 | Then, ask a Debian Developer to run \`./release.sh $*\`. This finalises your | |
94 | changes in the changelog, and allows them to build and upload the package. If | |
95 | you're not a Debian Developer and are unable to upload, please don't run that | |
96 | script or else you will need to revert the changes that it makes to your git. | |
87 | 97 | eof |