]> git.proxmox.com Git - debcargo-conf.git/blame - vars.sh.frag
When checking build-deps, use the exact same version of the crate that is already...
[debcargo-conf.git] / vars.sh.frag
CommitLineData
9cfc4370 1# -*- mode: sh -*-
931eabc0
XL
2set -e
3
999f9269 4abort() { local x=$1; shift; for i in "$@"; do echo >&2 "$0: abort: $i"; done; exit "$x"; }
88f8e3e6 5
cfc28aec 6mkdir -p "$(dirname "$0")/.git/hooks"
b6a1d240
XL
7HOOK_COMMIT="$(dirname "$0")/.git/hooks/pre-commit"
8if [ ! -x "$HOOK_COMMIT" ]; then
9cat <<'eof' >"$HOOK_COMMIT"
10#!/bin/sh
11if git rev-parse -q --verify MERGE_HEAD; then exit; fi
12case $(git rev-parse --abbrev-ref HEAD) in
13pending-*) true;;
14*) if git diff --cached --name-only | \
15 grep '^src/.*/debian/changelog$' | \
16 while read x; do echo "$x: $(head -n1 $x)"; done | \
17 grep -v UNRELEASED-FIXME-AUTOGENERATED-DEBCARGO; then
18 echo >&2 "please don't finalise changelogs directly on the master branch, use ./release.sh instead"; exit 1;
19 fi;;
20esac
21eof
22chmod +x "$HOOK_COMMIT"
23fi
24
23db3623
XL
25if [ -n "$DEBCARGO" ]; then
26 true
27elif which debcargo >/dev/null; then
28 DEBCARGO=$(which debcargo)
29elif [ -f "$HOME/.cargo/bin/debcargo" ]; then
30 DEBCARGO="$HOME/.cargo/bin/debcargo"
31else
32 abort 1 "debcargo not found, run \`cargo install debcargo\` or set DEBCARGO to point to it"
33fi
34
35test -x "$DEBCARGO" || abort 1 "debcargo found but not executable: $DEBCARGO"
34c68b28
XL
36dcver=$($DEBCARGO --version | sed -ne 's/debcargo //p')
37case $dcver in
5c044e0d 382.0.*|2.1.*|2.2.[0123]|2.2.[0123]-*) abort 1 "unsupported debcargo version $dcver. try reinstalling with \`cargo install debcargo --force\`";;
c452f0f4 392.2.*) true;;
34c68b28
XL
40*) abort 1 "unsupported debcargo version: $dcver";;
41esac
23db3623 42
32fc064c
XL
43if [ $# -ne 1 -a $# -ne 2 ]; then
44 echo >&2 "Usage: $0 <rust-crate-name>"
45 echo >&2 " $0 <rust-crate-name> <old-version>"
46 echo >&2 "See README.rst for more details on usage."
47 exit 2
48fi
49
999f9269 50CRATE="$1"
ea9f59b2 51VER="$2"
931eabc0 52
999f9269
XL
53PKGNAME=$($DEBCARGO deb-src-name "$CRATE" $VER || abort 1 "couldn't find crate $CRATE")
54PKGBASE=$($DEBCARGO deb-src-name "$CRATE" || abort 1 "couldn't find crate $CRATE")
931eabc0
XL
55PKGDIR_REL="src/$PKGNAME"
56PKGDIR="$PWD/$PKGDIR_REL"
57BUILDDIR="$PWD/build/$PKGNAME"
58PKGCFG="$PKGDIR/debian/debcargo.toml"
1230b71f
XL
59
60mkdir -p "$(dirname $BUILDDIR)"
1057693c
XL
61cp "$PWD/build.sh" "$PWD/build/build.sh"
62chmod +x "$PWD/build/build.sh"
1230b71f 63
999f9269
XL
64if [ -z "$CRATE" ]; then
65 abort 2 "Usage: $0 <crate> [<version>]"
1230b71f 66fi
cc003c95
XL
67
68run_debcargo() {
69 rm -rf "$BUILDDIR" "$(dirname "$BUILDDIR")/rust-${PKGNAME}_$VER"*.orig.tar.*
ba393157 70 $DEBCARGO package --config "$PKGCFG" --directory "$BUILDDIR" "$@" "$CRATE" "${REALVER:-$VER}"
cc003c95 71}