I MAID a little script. – NEW VERSION.
Also on git: Script for pulling, building and testing MaidSafe code · GitHub
EDIT: Script now logs everything (including errors). You have the option to build and test.
EDIT: updated to add cargo clean and “export RUST_TEST_THREADS=1” - thanks to @eggmunkee
Thanks to everyone who has contributed, especially @philip_rhoades
I’ve added bits from everywhere to make it more functional. If you use ‘roxterm’ the display will be via terminal tabs instead of new terminal windows - or you can set for logOnly and not have any new tabs or windows.
All logs are located in → installDir/logs//logfiles
logfiles are compiled into one file for either cloning or updates and broken down into separate files for building or testing of each library.
Instructions for use:
- open a blank text document, cut/paste code below.
- edit code set installDir
- set-up proxy if you have one
- save the file where-ever convenient e.g. ~/filename or /usr/local/bin/filename or /opt/filename
- open a terminal and go to the folder you saved the file and type sudo chmod +x filename
- run the program by going to the folder and typing → ./filename or just filename if saved in the $PATH
#!/bin/bash
######################################## - USER DEFINITIONS
# if you use a proxy add it here otherwise leave blank
gitProxy=
# make sure there is a slash at the end of your installDir definition
installDir="/opt/safenet/src/"
# do you want to build and test? Leave blank if not
# show build and test output via "xterm" (windows),
# "roxterm" (tabs), or "logOnly" --> note case
buildTest="xterm"
######################################## - PROGRAM DEFINITIONS
safeRepo="https://github.com/maidsafe/"
libraries="crust routing maidsafe_client maidsafe_types maidsafe_vault maidsafe_nfs"
logDir="${installDir}logs/$(date +"%T")/"
######################################## - MAIN
if [ ${gitProxy} ]; then
http_proxy=${gitProxy} && HTTP_PROXY=$http_proxy
export http_proxy HTTP_PROXY
git config --global http.proxy $HTTP_PROXY
fi
[ ! -d ${installDir} ] && mkdir ${installDir} && cd ${installDir}
[ ! -d ${installDir}logs/ ] && mkdir ${installDir}logs/
mkdir ${logDir}
for library in $libraries; do
subFolder=${installDir}${library}
if [ ! -d ${subFolder} ]; then
git clone ${safeRepo}${1} |& tee -a ${logDir}cloning.log
cd ${subFolder}
else
cd ${subFolder}
git pull origin master |& tee -a ${logDir}updating.log
fi
cargo clean
export RUST_TEST_THREADS=1
[ ${buildTest} == "xterm" ] && xterm -hold -title ${library} -e "bash -c 'cargo build |& tee -a ${logDir}building-${library}.log; cargo test |& tee -a ${logDir}testing-${library}.log'" &
[ ${buildTest} == "roxterm" ] && roxterm --tab -f -n ${library} -e "bash -c 'cargo build |& tee -a ${logDir}building-${library}.log; cargo test |& tee -a ${logDir}testing-${library}.log'" &
[ ${buildTest} == "logOnly" ] && cargo build > ${logDir}building-${library}.log 2>&1; cargo test > ${logDir}testing-${library}.log 2>&1 &
done
exit 0