Skip to content

Instantly share code, notes, and snippets.

@philiprhoades
Created September 25, 2015 04:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save philiprhoades/2fab1f08d1c729582166 to your computer and use it in GitHub Desktop.
Save philiprhoades/2fab1f08d1c729582166 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Fedora 23 x86_64
# Always first updating rust and cargo
# If there are pull changes, always doing "cargo clean & update"
safedir=`pwd`
echo ""
echo -n "Have you run rustup.sh today? [y|N]: "
read yorn
if test "$yorn" != "y"
then
curl -sSf https://static.rust-lang.org/rustup.sh | sh -s -- --channel=nightly
rm -fr ./cargo-nightly-x86_64-unknown-linux-gnu*
wget https://static.rust-lang.org/cargo-dist/cargo-nightly-x86_64-unknown-linux-gnu.tar.gz
tar xvfz ./cargo-nightly-x86_64-unknown-linux-gnu.tar.gz
cd ./cargo-nightly-x86_64-unknown-linux-gnu && ./install.sh
fi
cd $safedir
echo ""
echo -n "Hit ENTER to continue: "
read junk
dirs="crust-routing \
routing-safe_client \
safe_client-safe_vault \
safe_vault-safe_nfs \
safe_nfs-finished"
for dir in $dirs
do
currdir="${dir%-*}"
nextdir="${dir#*-}"
cd ${safedir}
clear
echo ""
echo "Pulling dir -->${currdir}"
echo ""
if [ ! -d $currdir ]; then
git clone https://github.com/maidsafe/$currdir
cd $currdir
else
cd $currdir
git pull origin master
fi
echo ""
echo -n "Skip this directory -->${currdir} ? [y|N]: "
read yorn
if test "$yorn" = "y"
then
continue
else
for action in clean \
update \
build \
tst
do
echo ""
echo -n "Directory -->${currdir} Action -->${action} Skip this action? [y|N]: "
read yorn
if test "$yorn" = "y"
then
continue
fi
case "$action" in
clean)
cargo clean
;;
update)
cargo update
;;
build)
cargo build
;;
tst)
# xterm -maximized -hold -e "cd ${dir} && RUST_TEST_THREADS=1 cargo test" &
parms=`grep Features .travis.yml | sed -e 's/^.*F/--f/' -e 's/=/ /'`
RUST_TEST_THREADS=1 cargo test --release $parms
;;
*)
echo "Invalid option, choose again..."
read junk
;;
esac
echo ""
echo -n "Current loop -->${currdir}-->$action Hit ENTER to continue: "
read junk
done
echo ""
echo ""
echo -n "Next loop -->${nextdir}-->pull Hit ENTER to continue: "
read junk
fi
done
@Fraser999
Copy link

  • Line 15 installs Rust (you can append -y to the command by the way to avoid having to enter "y" manually when the script runs), but then the next four lines download, build and install the same version of Rust, so I guess you don't need both options?
  • If you never modify the MaidSafe sources, you could maybe simplify things by always removing the old repo and cloning from scratch every time the script runs. If you do git clone <repo> --depth 1 it's pretty fast, and that would mean you could avoid the cargo clean and cargo update steps.
  • It looks like you're always running the tests with RUST_TEST_THREADS=1 - this will slow down those libs' tests which don't require a single-threaded test environment - but no big deal really.
  • You could speed things up further by running cargo build --release rather than building in Debug then testing in Release.

@philiprhoades
Copy link
Author

  • I know about the "-y" - I routinely don't use it - I think it allows me to pause and think or something . .
  • I sort of knew installing cargo was doing Rust too - I will prob just comment out the first one. Presumably at some stage when things are stable, I could probably comment out all of it . .
  • The plan was that I would get up to speed with Rust and start being useful but I am not making much progress (too many other dramas going on) but I will probably leave it as is for the time being . .
  • I wasn't sure about the threading so I just did it for everything . .
  • There was some problem that needed Debug at some point - I will try your method and keep commented stuff

@philiprhoades
Copy link
Author

The other thing was that if a pull did not get anything new, I would skip doing anything on that dir altogether . .

@Fraser999
Copy link

Presumably at some stage when things are stable, I could probably comment out all of it . .

Yeah - we're keen to be able to move off requiring Rust Nightly. Crust is the only one of our projects which forces us onto the Nightly channel, mainly because of the networking dependencies I think.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment