由于github环境不稳定,建立该仓库直接存储代码环境的源码,提供快速下载。
LiuZe 73b6a436cb 添加protobuf3.17版本源码及opencv源码 | 1 year ago | |
---|---|---|
ceres-solver | 1 year ago | |
cmake | 1 year ago | |
gflags | 1 year ago | |
glog | 1 year ago | |
googletest | 1 year ago | |
gtsam-4.1.1 | 1 year ago | |
nanomsg | 1 year ago | |
nanomsgxx | 1 year ago | |
opencv-4.8.0 | 1 year ago | |
paho | 1 year ago | |
protobuf | 1 year ago | |
protobuf-3.17.0 | 1 year ago | |
rabbitmq-c | 1 year ago | |
snap7-full-1.4.2 | 1 year ago | |
yaml-cpp | 1 year ago | |
.gitignore | 1 year ago | |
README.md | 1 year ago | |
config.txt | 1 year ago | |
install.sh | 1 year ago | |
ltmain.sh | 1 year ago | |
test.sh | 1 year ago |
由于github环境不稳定,建立该仓库直接存储代码环境的源码,提供快速下载。
1、git 克隆代码,指定源码网站和下载目录,将代码克隆下来,会尝试三次。
# 克隆代码
function git_clone {
local repo_url=$1
local target_dir=$2
local max_attempts=3
echo "Cloning $repo_url to $target_dir..."
# 初始化计数器
attempt=1
# 循环尝试克隆
while [ $attempt -le $max_attempts ]; do
# 如果目标目录存在,则删除它
if [ -d "$target_dir" ]; then
echo "Clone successful!"
return
fi
# 克隆代码
git clone "$repo_url" "$target_dir"
# 检查克隆是否成功
if [ $? -eq 0 ]; then
echo "Clone successful!"
# 如果克隆成功,则退出循环
break
else
rm -rf "$target_dir"
echo "Clone attempt $attempt failed."
attempt=$((attempt+1))
if [ $attempt -gt $max_attempts ]; then
echo "Max attempts reached. Continue..."
else
echo "Retrying in 5 seconds..."
sleep 5
fi
fi
done
}
2、进入某个目录,如果目录不存在则新建并进入
function cd_dir {
local dir_path=$1
# 检查目录是否存在
if [ ! -d "$dir_path" ]; then
echo "Directory $dir_path does not exist. Creating..."
mkdir -p "$dir_path"
fi
cd "$dir_path" || exit
}
3、软件检测,如果软件没有安装就通过apt安装
# 安装包检测
function check_and_install {
for package_name in "$@"
do
if ! command -v $package_name &> /dev/null
then
echo "$package_name not found. Installing..."
sudo apt-get update
sudo apt-get install $package_name -y
else
echo "$package_name already installed."
fi
done
}