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