Linux运维_Bash脚本_构建安装Ninja-1.11.1(setup.py)
Bash (Bourne Again Shell) 是一个解释器,负责处理 Unix 系统命令行上的命令。它是由 Brian Fox 编写的免费软件,并于 1989 年发布的免费软件,作为 Sh (Bourne Shell) 的替代品。
您可以在 Linux 和 MacOS 机器上使用 Bash,甚至可以通过适用于 Linux 的 Windows 子系统在 Windows 10 机器上使用。
使用方法
- 下载源码包:
cmake-3.28.3.tar.gz
wheel-0.42.0.tar.gz
packaging-23.2.tar.gz
distro-1.9.0.tar.gz
setuptools-41.2.0.zip
setuptools_scm-1.17.0.tar.gz
scikit-build-0.15.0.tar.gz
ninja-1.11.1.tar.gz
- 放于指定路径:
这里 Bash Shell 脚本的全局变量 STORAGE 指定的存放源码包的路径 /home/goufeng 可进行修改。
- 执行 Bash Shell 脚本:
输入 /[路径名]/[脚本名].sh 即可进行自动编译部署,过程中提示输入 (y/n) 输入 y 则进行下一步,这样分阶段确认的原因是为了确保能够看到上一个源码编译结果中可能的错误和提示。
完整脚本
#! /bin/bash
# Create By GF 2024-03-03 00:05
# --------------------- CMake ----------------------
# Need File: cmake-3.28.3.tar.gz
# ------------ Ninja - 1.11.1 - setup.py -----------
# Need File: wheel-0.42.0.tar.gz
# Need File: packaging-23.2.tar.gz
# Need File: distro-1.9.0.tar.gz
# Need File: setuptools-41.2.0.zip
# Need File: setuptools_scm-1.17.0.tar.gz
# Need File: scikit-build-0.15.0.tar.gz
# Need File: ninja-1.11.1.tar.gz
# ##################################################
STORAGE=/home/goufeng
# ############################################## CMake ###############################################
# Function: 编译安装(Compile Install) CMake-3.28.3
# ##################################################
function Compile_Install_CMake_3_28_3() {
if [[ ! -d "/opt/cmake-3.28.3" ]]; then
local VERIFY
local STEP_UNZIPPED=0
local STEP_CONFIGURED=0
local STEP_INSTALLED=0
# ------------------------------------------
echo "[Confirm] Compile and Install ( cmake-3.28.3 )? (y/n)"
# ..........................................
read VERIFY
# ..........................................
if [[ $VERIFY != "y" ]]; then exit 1; fi
# ------------------------------------------
tar -zxvf $STORAGE/cmake-3.28.3.tar.gz && STEP_UNZIPPED=1
# ------------------------------------------
cd $STORAGE/cmake-3.28.3 && ./configure --prefix=/opt/cmake-3.28.3 && STEP_CONFIGURED=1
# ------------------------------------------
make && make install && STEP_INSTALLED=1
# ------------------------------------------
if [[ $STEP_INSTALLED == 1 ]]; then
ln -sf /opt/cmake-3.28.3/bin/cmake /usr/local/bin/cmake
fi
# ------------------------------------------
cd $STORAGE && rm -rf $STORAGE/cmake-3.28.3 && return 0
else
echo "[Caution] Path: ( /opt/cmake-3.28.3 ) Already Exists."
# ------------------------------------------
return 0
fi
}
# ##################################### Ninja - 1.11.1 - setup.py ####################################
# Function: 构建安装(Build Install) Wheel-0.42.0 (by Python3)
# ##################################################
function Build_Install_Wheel_0_42_0_by_Python3() {
# 使用 expr index "$string" "$substring" 来判断字符串 $string 中是否包含子字符串 $substring。
# Use the expr index "$string" and "$substring" to determine whether the string $string contains a substring $substring.
# 如果子字符串存在, 则返回子字符串在原字符串中的位置 (从 1 开始), 否则返回 0。
# If the substring exists, return the position of the substring in the original string (starting from 1), otherwise return 0.
local EXISTS_LINE=$(pip3 list | grep "wheel")
local EXISTS_NAME=$(expr index "$EXISTS_LINE" "wheel")
local EXISTS_VERSION=$(expr index "$EXISTS_LINE" "0.42.0")
if [[ $EXISTS_NAME == 0 && $EXISTS_VERSION == 0 ]]; then
local VERIFY
local STEP_UNZIPPED=0
local STEP_BUILDED=0
local STEP_INSTALLED=0
# ------------------------------------------
read -p "[Confirm] Build and Install ( Wheel-0.42.0 )? (y/n)>" VERIFY
if [[ "

最低0.47元/天 解锁文章

被折叠的 条评论
为什么被折叠?



