5 Star 0 Fork 11

OpenCloudOS Stream/python-cryptography

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
gen_tarball.sh 2.14 KB
一键复制 编辑 原始数据 按行查看 历史
Jackey_1024 提交于 2024-11-04 16:12 . correct the source package path
#!/bin/bash
#########################################################
# Function :Generate tarball for upgrade #
# Platform :Linux Platform #
# Version :1.0 #
# Date :2024-08-21 #
# Author :gordonwwang #
#########################################################
# Function to handle errors
handle_error() {
echo "$1"
exit "$2"
}
# Function to check and install tools
check_tools() {
if ! command -v rpmspec &> /dev/null; then
dnf install /usr/bin/rpmspec -yq || handle_error 'Failed to install rpmspec' 1
fi
# cargo only for rust
if ! command -v cargo &> /dev/null; then
dnf install cargo -yq || handle_error 'Failed to install cargo' 1
fi
}
# Function tears down
tear_down() {
cd "$cur_dir"
rm -rf "$dir_name"
rm -f ./tmp_spec
echo "tears down before script exit."
}
# Function to generate the tarball
generate_tarball() {
# Get name, version, and source from spec
specname=$(basename "$PWD")
rpmspec -P "${specname}.spec" > ./tmp_spec
[ $? -eq 0 ] || handle_error "spec parse failed" 2
name=$(grep '^Name:' ./tmp_spec | awk '{print $2}')
version=$(grep '^Version:' ./tmp_spec | awk '{print $2}')
source0=$(grep '^Source0:' ./tmp_spec | awk '{print $2}')
source1=$(grep '^Source1:' ./tmp_spec | awk '{print $2}')
cur_dir=$(pwd)
# Download and unzip tarball
tarball_name=$(basename "${source0}")
wget "${source0}" -q --show-progress -O "${tarball_name}"
[ $? -eq 0 ] || handle_error "Failed to download source" 3
tar -xzf "${tarball_name}"
dir_name="cryptography-${version}"
cd "$dir_name"/src/rust
# Run cargo vendor
cargo vendor
[ $? -eq 0 ] || handle_error "cargo vendor failed" 4
# Tar and compress
echo "Generate vendor ..."
vendor_file=$(basename "${source1}") # e.g., "${name}-${version}-vendor.tar.bz2"
tar -cjf "${vendor_file}" vendor
mv "${vendor_file}" "$cur_dir"
}
# Ensure tear_down is called on script exit
trap tear_down EXIT
check_tools
generate_tarball
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/opencloudos-stream/python-cryptography.git
[email protected]:opencloudos-stream/python-cryptography.git
opencloudos-stream
python-cryptography
python-cryptography
master

搜索帮助