aboutsummaryrefslogtreecommitdiff
path: root/scripts/maint/updateRustDependencies.sh
blob: a5a92579d3e8d4e9b16a15fde59b8070d8bcc3a5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/env bash
#
# Copyright (c) 2018 The Tor Project, Inc.
# Copyright (c) 2018 isis agora lovecruft
# See LICENSE for license information
#
# updateRustDependencies.sh
# -------------------------
# Update our vendored Rust dependencies, either adding/removing
# dependencies and/or upgrading current dependencies to newer
# versions.
#
# To use this script, first add your dependencies, exactly specifying
# their versions, into the appropriate *crate-level* Cargo.toml in
# src/rust/ (i.e. *not* /src/rust/Cargo.toml, but instead the one for
# your crate).
#
# Next, run this script.  Then, go into src/ext/rust and commit the
# changes to the tor-rust-dependencies repo.

set -e

HERE=`dirname $(realpath $0)`
TOPLEVEL=`dirname $(dirname $HERE)`
TOML="$TOPLEVEL/src/rust/Cargo.toml"
VENDORED="$TOPLEVEL/src/ext/rust/crates"
CARGO=`which cargo`

if ! test -f "$TOML"  ; then
    printf "Error: Couldn't find workspace Cargo.toml in expected location: %s\n" "$TOML"
fi

if ! test -d "$VENDORED" ; then
    printf "Error: Couldn't find directory for Rust dependencies! Expected location: %s\n" "$VENDORED"
fi

if test -z "$CARGO" ; then
    printf "Error: cargo must be installed and in your \$PATH\n"
fi

if test -z `cargo --list | grep vendor` ; then
    printf "Error: cargo-vendor not installed\n"
fi

$CARGO vendor -v --locked --explicit-version --no-delete --sync $TOML $VENDORED