Codebase list rust-libslirp / 1057693
Improve release scripts to make it easier for non-DD contributors to build the packages Ximin Luo 5 years ago
7 changed file(s) with 130 addition(s) and 64 deletion(s). Raw diff Collapse all Expand all
00 Instructions
11 ============
22
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:
49
510 **To package a new crate, or to update an existing crate:**
611
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
77 cut '-d ' -f1 | \
88 while read crate; do
99 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
1111 done
1010
1111 git diff --quiet -- "$PKGDIR_REL" || \
1212 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."
1316
1417 RELBRANCH="pending-$PKGNAME"
1518 git fetch origin --prune
5861 abort 1 "Release attempt resulted in git diffs to $PKGDIR_REL, probably the package needs updating (./update.sh $*)"
5962 fi
6063
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
7465 revert_git_changes
7566 abort 1 "Release attempt detected build-dependencies not in Debian (see messages above), release those first."
7667 fi
7768
7869 git commit -m "Release package $PKGNAME"
7970
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)
11673 DEB_HOST_ARCH=$(dpkg-architecture -q DEB_HOST_ARCH)
11774 cat >&2 <<eof
11875 Release of $CRATE ready as a source package in ${BUILDDIR#$PWD/}. You need to
12481 If the source package is already in Debian and this version does not introduce
12582 new binaries, then you can just go ahead and directly dput the source package.
12683
127 cd build
128 debsign ${DEBSRC}_${DEBVER}_source.changes
129 dput ${DEBSRC}_${DEBVER}_source.changes
84 cd build && dput ${DEBSRC}_${DEBVER}_source.changes
13085
13186 If this is a NEW source package or introduces NEW binary packages not already
13287 in the Debian archive, you will need to build a binary package out of it. The
13388 recommended way is to run something like:
13489
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
13891
13992 This assumes you followed the "DD instructions" in README.rst, for setting up
14093 a build environment for release.
4242 run_debcargo
4343
4444 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
4646 git diff -- "$PKGDIR_REL"
4747 echo >&2 "-- end of git diff --"
4848 fi
7878 any auto-generated hint files. If so, you should make the equivalent changes to
7979 the non-hint files, and git-add these too.
8080
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.
8797 eof
5757 PKGCFG="$PKGDIR/debian/debcargo.toml"
5858
5959 mkdir -p "$(dirname $BUILDDIR)"
60 cp "$PWD/build.sh" "$PWD/build/build.sh"
61 chmod +x "$PWD/build/build.sh"
6062
6163 if [ -z "$CRATE" ]; then
6264 abort 2 "Usage: $0 <crate> [<version>]"