]>
Commit | Line | Data |
---|---|---|
931eabc0 XL |
1 | set -e |
2 | ||
999f9269 | 3 | abort() { local x=$1; shift; for i in "$@"; do echo >&2 "$0: abort: $i"; done; exit "$x"; } |
88f8e3e6 | 4 | |
23db3623 XL |
5 | if [ -n "$DEBCARGO" ]; then |
6 | true | |
7 | elif which debcargo >/dev/null; then | |
8 | DEBCARGO=$(which debcargo) | |
9 | elif [ -f "$HOME/.cargo/bin/debcargo" ]; then | |
10 | DEBCARGO="$HOME/.cargo/bin/debcargo" | |
11 | else | |
12 | abort 1 "debcargo not found, run \`cargo install debcargo\` or set DEBCARGO to point to it" | |
13 | fi | |
14 | ||
15 | test -x "$DEBCARGO" || abort 1 "debcargo found but not executable: $DEBCARGO" | |
34c68b28 XL |
16 | dcver=$($DEBCARGO --version | sed -ne 's/debcargo //p') |
17 | case $dcver in | |
c69c16a8 XL |
18 | 2.0.*|2.1.0) abort 1 "unsupported debcargo version $dcver. try reinstalling with \`cargo install debcargo --force\`";; |
19 | 2.1.*) true;; | |
34c68b28 XL |
20 | *) abort 1 "unsupported debcargo version: $dcver";; |
21 | esac | |
23db3623 | 22 | |
999f9269 | 23 | CRATE="$1" |
ea9f59b2 | 24 | VER="$2" |
931eabc0 | 25 | |
999f9269 XL |
26 | PKGNAME=$($DEBCARGO deb-src-name "$CRATE" $VER || abort 1 "couldn't find crate $CRATE") |
27 | PKGBASE=$($DEBCARGO deb-src-name "$CRATE" || abort 1 "couldn't find crate $CRATE") | |
931eabc0 XL |
28 | PKGDIR_REL="src/$PKGNAME" |
29 | PKGDIR="$PWD/$PKGDIR_REL" | |
30 | BUILDDIR="$PWD/build/$PKGNAME" | |
31 | PKGCFG="$PKGDIR/debian/debcargo.toml" | |
1230b71f XL |
32 | |
33 | mkdir -p "$(dirname $BUILDDIR)" | |
34 | ||
999f9269 XL |
35 | if [ -z "$CRATE" ]; then |
36 | abort 2 "Usage: $0 <crate> [<version>]" | |
1230b71f | 37 | fi |