首页 > 系统相关 >shell 脚本中利用git下载依赖关系示例

shell 脚本中利用git下载依赖关系示例

时间:2023-01-30 14:47:10浏览次数:35  
标签:git 示例 make FLAG cd PREFIX shell DEPS DIR

#!/usr/bin/env bash # 打开显示调试信息 set -x
######################################## # download & build depend software ########################################
WORK_DIR=`pwd` DEPS_SOURCE=${WORK_DIR}/thirdsrc DEPS_PREFIX=${WORK_DIR}/thirdparty DEPS_CONFIG="--prefix=${DEPS_PREFIX} --disable-shared --with-pic" FLAG_DIR=${WORK_DIR}/.build
export PATH=${DEPS_PREFIX}/bin:$PATH mkdir -p ${DEPS_SOURCE} ${DEPS_PREFIX} ${FLAG_DIR}
if [ ! -f "${FLAG_DIR}/dl_third" ] || [ ! -d "${DEPS_SOURCE}/.git" ]; then     rm -rf ${DEPS_SOURCE}     git clone --depth=1 http://gitlab.baidu.com/baidups/third.git ${DEPS_SOURCE}     touch "${FLAG_DIR}/dl_third" fi
cd ${DEPS_SOURCE}
# boost if [ ! -f "${FLAG_DIR}/boost_1_57_0" ] \     || [ ! -d "${DEPS_PREFIX}/boost_1_57_0/boost" ]; then     tar zxf boost_1_57_0.tar.gz     rm -rf ${DEPS_PREFIX}/boost_1_57_0     mv boost_1_57_0 ${DEPS_PREFIX}     touch "${FLAG_DIR}/boost_1_57_0" fi
# protobuf if [ ! -f "${FLAG_DIR}/protobuf_2_6_1" ] \     || [ ! -f "${DEPS_PREFIX}/lib/libprotobuf.a" ] \     || [ ! -d "${DEPS_PREFIX}/include/google/protobuf" ]; then     tar zxf protobuf-2.6.1.tar.gz     cd protobuf-2.6.1     ./configure ${DEPS_CONFIG}     make -j4     make install     cd -     touch "${FLAG_DIR}/protobuf_2_6_1" fi
#leveldb if [ ! -f "${FLAG_DIR}/leveldb" ] \     || [ ! -f "${DEPS_PREFIX}/lib/libleveldb.a" ] \     || [ ! -d "${DEPS_PREFIX}/include/leveldb" ]; then     rm -rf leveldb     git clone https://github.com/lylei/leveldb.git leveldb     cd leveldb     echo "PREFIX=${DEPS_PREFIX}" > config.mk     make -j4     make install     cd -     touch "${FLAG_DIR}/leveldb" fi
# snappy if [ ! -f "${FLAG_DIR}/snappy_1_1_1" ] \     || [ ! -f "${DEPS_PREFIX}/lib/libsnappy.a" ] \     || [ ! -f "${DEPS_PREFIX}/include/snappy.h" ]; then     tar zxf snappy-1.1.1.tar.gz     cd snappy-1.1.1     ./configure ${DEPS_CONFIG}     make -j4     make install     cd -     touch "${FLAG_DIR}/snappy_1_1_1" fi
# sofa-pbrpc if [ ! -f "${FLAG_DIR}/sofa-pbrpc_1_0_0" ] \     || [ ! -f "${DEPS_PREFIX}/lib/libsofa-pbrpc.a" ] \     || [ ! -d "${DEPS_PREFIX}/include/sofa/pbrpc" ]; then     rm -rf sofa-pbrpc #    git clone --depth=1 https://github.com/cyshi/sofa-pbrpc.git sofa-pbrpc     git clone --depth=1 https://github.com/baidu/sofa-pbrpc.git sofa-pbrpc     cd sofa-pbrpc     sed -i '/BOOST_HEADER_DIR=/ d' depends.mk     sed -i '/PROTOBUF_DIR=/ d' depends.mk     sed -i '/SNAPPY_DIR=/ d' depends.mk     echo "BOOST_HEADER_DIR=${DEPS_PREFIX}/boost_1_57_0" >> depends.mk     echo "PROTOBUF_DIR=${DEPS_PREFIX}" >> depends.mk     echo "SNAPPY_DIR=${DEPS_PREFIX}" >> depends.mk     echo "PREFIX=${DEPS_PREFIX}" >> depends.mk     make -j4     make install     cd -     touch "${FLAG_DIR}/sofa-pbrpc_1_0_0" fi
# cmake for gflags if ! which cmake ; then     tar zxf CMake-3.2.1.tar.gz     cd CMake-3.2.1     ./configure --prefix=${DEPS_PREFIX}     make -j4     make install     cd - fi
# gflags if [ ! -f "${FLAG_DIR}/gflags_2_1_1" ] \     || [ ! -f "${DEPS_PREFIX}/lib/libgflags.a" ] \     || [ ! -d "${DEPS_PREFIX}/include/gflags" ]; then     tar zxf gflags-2.1.1.tar.gz     cd gflags-2.1.1     cmake -DCMAKE_INSTALL_PREFIX=${DEPS_PREFIX} -DGFLAGS_NAMESPACE=google -DCMAKE_CXX_FLAGS=-fPIC     make -j4     make install     cd -     touch "${FLAG_DIR}/gflags_2_1_1" fi
# gtest if [ ! -f "${FLAG_DIR}/gtest_1_7_0" ] \     || [ ! -f "${DEPS_PREFIX}/lib/libgtest.a" ] \     || [ ! -d "${DEPS_PREFIX}/include/gtest" ]; then     unzip gtest-1.7.0.zip     cd gtest-1.7.0     ./configure ${DEPS_CONFIG}     make     cp -a lib/.libs/* ${DEPS_PREFIX}/lib     cp -a include/gtest ${DEPS_PREFIX}/include     cd -     touch "${FLAG_DIR}/gtest_1_7_0" fi
# libunwind for gperftools if [ ! -f "${FLAG_DIR}/libunwind_0_99_beta" ] \     || [ ! -f "${DEPS_PREFIX}/lib/libunwind.a" ] \     || [ ! -f "${DEPS_PREFIX}/include/libunwind.h" ]; then     tar zxf libunwind-0.99-beta.tar.gz     cd libunwind-0.99-beta     ./configure ${DEPS_CONFIG}     make CFLAGS=-fPIC -j4     make CFLAGS=-fPIC install     cd -     touch "${FLAG_DIR}/libunwind_0_99_beta" fi
# gperftools (tcmalloc) if [ ! -f "${FLAG_DIR}/gperftools_2_2_1" ] \     || [ ! -f "${DEPS_PREFIX}/lib/libtcmalloc_minimal.a" ]; then     tar zxf gperftools-2.2.1.tar.gz     cd gperftools-2.2.1     ./configure ${DEPS_CONFIG} CPPFLAGS=-I${DEPS_PREFIX}/include LDFLAGS=-L${DEPS_PREFIX}/lib     make -j4     make install     cd -     touch "${FLAG_DIR}/gperftools_2_2_1" fi
# common if [ ! -f "${FLAG_DIR}/common" ] \     || [ ! -f "${DEPS_PREFIX}/lib/libcommon.a" ]; then     rm -rf common     git clone -b cpp11 https://github.com/baidu/common     cd common     sed -i 's/^PREFIX=.*/PREFIX=..\/..\/thirdparty/' config.mk     make -j4     make install     cd -     touch "${FLAG_DIR}/common" fi

cd ${WORK_DIR}
######################################## # config depengs.mk ########################################
echo "PBRPC_PATH=./thirdparty" > depends.mk echo "PROTOBUF_PATH=./thirdparty" >> depends.mk echo "PROTOC_PATH=./thirdparty/bin/" >> depends.mk echo 'PROTOC=$(PROTOC_PATH)protoc' >> depends.mk echo "PBRPC_PATH=./thirdparty" >> depends.mk echo "GFLAG_PATH=./thirdparty" >> depends.mk echo "GTEST_PATH=./thirdparty" >> depends.mk echo "COMMON_PATH=./thirdparty" >> depends.mk echo "TCMALLOC_PATH=./thirdparty" >> depends.mk
######################################## # build bfs ########################################
make clean make -j4

标签:git,示例,make,FLAG,cd,PREFIX,shell,DEPS,DIR
From: https://www.cnblogs.com/rohens-hbg/p/17075874.html

相关文章

  • Concourse实战 - 监控GitHub release并自动构建镜像
    背景及需求偶然在网上看到了一个可以多端直播推流的工具,叫AntMediaServer,但是它的安装程序并不支持我正在用的Ubuntu22.04LTS,同时它也没有提供制作好的Docker镜像,只能......
  • Net6/SuperSocket2.0课程1,一个Telnet示例
    十年河东,十年河西,莫欺少年穷学无止境,精益求精1、新建控制台程序并引入包dotnetaddpackageSuperSocket.Server 2、书写代码usingSystem;usingSystem.Text;......
  • Git、GitHub、GitLab
    Git、GitHub与GitLab的区别1、Git是一种版本控制系统,是一种工具,用于代码的存储和版本控制。2、GitHub是一个基于Git实现的在线代码仓库,是目前全球最大的代码托管平台,可以......
  • 多人协作过程中git的使用流程
    大概逻辑:gitclone:从远处仓库拉取代码,默认本地的master分支和远程origin的master相关联gitcheckout-bdevorigin/dev在本地仓库新建一个dev分支与origin的dev......
  • 【Powrershell】-备份/还原/跨域导入组策略
    #1Powershell备份组策略PS脚本代码如下: $a=Get-Date-Format"yyyyMd"#exampleyyymd=2023128$path="D:\GPOBackup"#changeitNew-Item$path-ItemTypeDirectory-Nam......
  • Vulnhub之Christophe靶机测试过程(未能拿到shell)
    Christophe识别目标主机IP地址(kali㉿kali)-[~/Vulnhub/christophe]└─$sudonetdiscover-ieth1-r192.168.56.0/24Currentlyscanning:Finished!|Screen......
  • Shell 摘抄:growpart中的参数处理
    下面这段代码中,变量cur表示这次循环所要处理的参数。如果没有触发前面的选项开关,第一个参数会被赋值给$DISK,第二个参数会赋值给$PART。强无敌!~while[$#-ne0];do......
  • git常用命令
    【切换分支】gitcheckout分支名【创建新分支】gitbranch分支名【创建新分支并且切换到新建的分支】gitcheckout-b分支名【根据git的hash值创建分支并且切换到新......
  • GitLab在项目的环境搭建和基本的使用
    目录gitlab-使用入门1导读本教程主要讲解了GitLab在项目的环境搭建和基本的使用,可以帮助大家在企业中能够自主搭建GitLab服务,并且可以GitLab中的组、权限、项目自主操作Git......
  • Git基础--远程仓库
    Git基础--远程仓库远程仓库是指托管在因特网或其他网络中的你的项目的版本库一、查看和添加远程仓库查看所有的远程仓库命令:gitremote-v添加新的远程仓库并指定......