From b9736f6f18d2304e8ee1379bb8c2f364acc641dd Mon Sep 17 00:00:00 2001 From: Iosmanthus Teng Date: Mon, 7 Jun 2021 17:50:51 +0800 Subject: [PATCH] improve build scripts (#186) Signed-off-by: iosmanthus --- scripts/proto.sh | 50 ++++++++++++++++++++++++++++-------------------- shell.nix | 9 +++++++++ 2 files changed, 38 insertions(+), 21 deletions(-) create mode 100644 shell.nix diff --git a/scripts/proto.sh b/scripts/proto.sh index fedb3b81e1..2ddaa1205c 100755 --- a/scripts/proto.sh +++ b/scripts/proto.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/usr/bin/env bash # # Copyright 2017 PingCAP, Inc. # @@ -14,32 +14,40 @@ # limitations under the License. # -CURRENT_DIR=`pwd` -TIKV_CLIENT_HOME="$(cd "`dirname "$0"`"/..; pwd)" -cd $TIKV_CLIENT_HOME - kvproto_hash=6ed99a08e262d8a32d6355dcba91cf99cb92074a - raft_rs_hash=b9891b673573fad77ebcf9bbe0969cf945841926 - tipb_hash=c4d518eb1d60c21f05b028b36729e64610346dac -if [ -d "kvproto" ]; then - cd kvproto; git fetch -p; git checkout ${kvproto_hash}; cd .. -else - git clone https://github.com/pingcap/kvproto; cd kvproto; git checkout ${kvproto_hash}; cd .. -fi +kvproto_dir="kvproto" +raft_rs_dir="raft-rs" +tipb_dir="tipb" -if [ -d "raft-rs" ]; then - cd raft-rs; git fetch -p; git checkout ${raft_rs_hash}; cd .. -else - git clone https://github.com/pingcap/raft-rs; cd raft-rs; git checkout ${raft_rs_hash}; cd .. -fi +CURRENT_DIR=$(pwd) +TIKV_CLIENT_HOME="$( + cd "$(dirname "$0")"/.. || exit + pwd +)" +cd "$TIKV_CLIENT_HOME" || exit -if [ -d "tipb" ]; then - cd tipb; git fetch -p; git checkout ${tipb_hash}; cd .. +if [ -d "$kvproto_dir" ]; then + git -C ${kvproto_dir} fetch -p else - git clone https://github.com/pingcap/tipb; cd tipb; git checkout ${tipb_hash}; cd .. + git clone https://github.com/pingcap/kvproto ${kvproto_dir} fi +git -C ${kvproto_dir} checkout ${kvproto_hash} -cd $CURRENT_DIR +if [ -d "$raft_rs_dir" ]; then + git -C ${raft_rs_dir} fetch -p +else + git clone https://github.com/pingcap/raft-rs ${raft_rs_dir} +fi +git -C ${raft_rs_dir} checkout ${raft_rs_hash} + +if [ -d "$tipb_dir" ]; then + git -C ${tipb_dir} fetch -p +else + git clone https://github.com/pingcap/tipb ${tipb_dir} +fi +git -C ${tipb_dir} checkout ${tipb_hash} + +cd "$CURRENT_DIR" || exit diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000000..f7b6817bda --- /dev/null +++ b/shell.nix @@ -0,0 +1,9 @@ +{ pkgs ? import {} }: + +( + pkgs.buildFHSUserEnv { + name = "client-java-shell"; + targetPkgs = pkgs: with pkgs;[ maven openjdk8 git ]; + runScript = "bash"; + } +).env