fix: add solana-bpf-sdk-install command to permit users to easily update their bpf-sdk

This commit is contained in:
Michael Vines
2019-06-18 19:38:01 -07:00
parent 53f2c84fab
commit 9e30c6f827
4 changed files with 43 additions and 17 deletions

29
web3.js/bin/bpf-sdk-install.sh Executable file
View File

@ -0,0 +1,29 @@
#!/usr/bin/env bash
set -e
installDir=$1
if [[ -z $installDir ]]; then
installDir="$(cd "$(dirname "$0")"/..; pwd)"
fi
channel=$("$(dirname "$0")"/testnet-default-channel.js)
if [[ -n $2 ]]; then
channel=$2
fi
[[ $channel = edge || $channel = beta ]] || {
echo "Error: Invalid channel: $channel"
exit 1
}
echo "Installing $channel BPF SDK into $installDir"
set -x
cd "$installDir/"
curl -L --retry 5 --retry-delay 2 -o bpf-sdk.tar.bz2 \
http://solana-sdk.s3.amazonaws.com/"$channel"/bpf-sdk.tar.bz2
rm -rf bpf-sdk
mkdir -p bpf-sdk
tar jxf bpf-sdk.tar.bz2
rm -f bpf-sdk.tar.bz2
cat bpf-sdk/version.txt

View File

@ -1,18 +1,7 @@
#!/usr/bin/env bash
set -e
channel=$(
cd "$(dirname "$0")";
node -p '
let p = [
"../lib/node_modules/@solana/web3.js/package.json",
"../@solana/web3.js/package.json",
"../package.json"
].find(require("fs").existsSync);
if (!p) throw new Error("Unable to locate solana-web3.js directory");
require(p)["testnetDefaultChannel"]
'
)
channel=$("$(dirname "$0")"/testnet-default-channel.js)
usage() {
exitcode=0

View File

@ -0,0 +1,10 @@
#!/usr/bin/env node
let p = [
__dirname + '/../lib/node_modules/@solana/web3.js/package.json',
__dirname + '/../@solana/web3.js/package.json',
__dirname + '/../package.json'
].find(require('fs').existsSync);
if (!p) throw new Error('Unable to locate solana-web3.js directory');
console.log(require(p)['testnetDefaultChannel']);