diff --git a/auto_release_increases/README.md b/auto_release_increases/README.md
index c23f60ed07eb104ba610fd4f7c5bd5665c894f8f..1290eb76d707a59f96106ad8c4d9489fdd98fdfc 100644
--- a/auto_release_increases/README.md
+++ b/auto_release_increases/README.md
@@ -18,10 +18,14 @@
#### 使用说明
-1. 新建一个rpm包名单,用于查询哪些包依赖到了名单中的rpm。例如升级了llvm, 而它的rpm子包有llvm-devel、llvm-libs、llvm-test,则新建rpm_list0,逐行填入这仨rpm包;
-2. sh auto_release.sh rpm_list0;
-3. 如果已经rpm-dep查询过,得到了pkg_name.log文件。则无需传参rpm_list0,直接执行sh auto_release.sh;
-4. 如果不需要提PR,请注释handle_pkgs中的PR_repo函数。
+1. 新建一个rpm子包名单,用于查询哪些包依赖到了名单中的rpm。例如升级了llvm, 而它的rpm子包有llvm-devel、llvm-libs、llvm-test,则新建rpm_list0,逐行填入这仨rpm包;
+2. `sh auto_dep.sh rpm_list0`; 根据步骤1名单,查询得到**待重编的软件包名单 pkg_name.log**.
+3. `sh auto_release.sh`; 对pkg_name.log中所有的软件包,一键重编并提PR。**使用此脚本前,请仔细确认pkg_name.log!!!避免提交不合理的PR。**
+
+ 执行`sh auto_release.sh`后,若中途失败,**pkg_success中是重编成功的包**;**pkg_name.log是重编失败/尚未重编的包**。
+
+ 重新执行`sh auto_release.sh`命令,即可继续对**pkg_name.log中重编失败/尚未重编的包**进行重编。若一直失败,请检查该软件包!
+
#### 参与贡献
diff --git a/auto_release_increases/auto_dep.sh b/auto_release_increases/auto_dep.sh
new file mode 100755
index 0000000000000000000000000000000000000000..78991743cd2a27c61581fc8b6fe3bdc1f2cbdd46
--- /dev/null
+++ b/auto_release_increases/auto_dep.sh
@@ -0,0 +1,68 @@
+#!/bin/bash
+
+file_in=$1
+file_out="pkg_name.log"
+file_tmp="tmp.log"
+# 初始化一个空数组用于存储 "level: 1" 的包名
+src_names=()
+
+function rpm_dep_list()
+{
+ if [ $(cat "$file_in" | wc -l) -eq 0 ]; then
+ echo "WARNNING: input file rpm_list is NULL."
+ exit 1
+ fi
+ cat $file_in | xargs -I {} rpm-dep -B {} -t yaml -l 2
+ # 单纯的安装依赖,应该无需重编
+ # cat $file_in | xargs -I {} rpm-dep -I {}
+
+ if [ $? -eq 0 ]; then
+ echo "====== rpm_dep successful ======"
+ fi
+}
+
+function rpm_dep_list_clean()
+{
+ rm dep*
+}
+
+function get_list()
+{
+ # 清空或创建 file_out 文件
+ rm -f $file_out
+ :> $file_out
+ :> $file_tmp
+
+ # 查找 yaml
+ yaml_files=$(ls | grep -E '\.yaml$')
+
+ # 遍历 yaml
+ for file in $yaml_files; do
+ # 提取 "level: 1" 的包名
+ level1_package=$(cat $file | grep -A 2 "level: 1" | grep "src_name:" | awk '{print $2}')
+ src_names+=("$level1_package")
+ # 提取 "level: 2" 的包名
+ cat $file | grep -A 2 "level: 2" | grep "src_name:" | awk '{print $2}' >> $file_tmp
+ done
+ # cat $file_tmp | sort -u > $file_out
+ sort -u $file_tmp -o $file_tmp
+
+ # 过滤掉 "level: 1" 的包名,源码包本身 无需重编
+ for src_name in "${src_names[@]}"; do
+ grep -v "^$src_name$" $file_tmp > $file_out
+ done
+
+ rm -f $file_tmp
+}
+
+# 如果传入参数1,需要执行rpm_dep查询,得到file_out(待release +1软件包名单)
+if [ "$#" -ge 1 ]; then
+ rpm_dep_list
+ get_list
+ rpm_dep_list_clean
+ echo -e "\033[1;31m [Note: Before using auto_release.sh, please check pkg_name.log!!!] \033[0m"
+elif [ $(cat "$file_out" | wc -l) -eq 0 ]; then
+ echo "WARNNING: $file_out is NULL, no package."
+else
+ echo "ERROR: No arguments provided. Skipping rpm_dep function."
+fi
diff --git a/auto_release_increases/auto_release.sh b/auto_release_increases/auto_release.sh
index 6926773b1771149d86c9f4cfa6b78ca2490d7172..6abf5c523dcaca7dc84ce215bafd9112baf18665 100755
--- a/auto_release_increases/auto_release.sh
+++ b/auto_release_increases/auto_release.sh
@@ -17,57 +17,28 @@ gitee_api="https://gitee.com/api/v5"
file_in=$1
file_out="pkg_name.log"
file_tmp="tmp.log"
-# 初始化一个空数组用于存储 "level: 1" 的包名
-src_names=()
+file_success="pkg_success"
-function rpm_dep_list()
+## 1. 从ocs代码仓,fork仓库并clone到本地
+function fork_clone_repo()
{
- if [ $(cat "$file_in" | wc -l) -eq 0 ]; then
- echo "WARNNING: input file rpm_list is NULL."
- exit 1
- fi
- cat $file_in | xargs -I {} rpm-dep -B {} -t yaml
- # 单纯的安装依赖,应该无需重编
- # cat $file_in | xargs -I {} rpm-dep -I {}
-
- if [ $? -eq 0 ]; then
- echo "====== rpm_dep successful ======"
- fi
-}
+ gitee_repo=$1
+ gitee_api="https://gitee.com/api/v5"
-function rpm_dep_list_clean()
-{
- rm dep*
-}
+ # Fork repo
+ fork_result=$(curl -s -X POST -u "${gitee_username}:${gitee_tocken}" "${gitee_api}/repos/opencloudos-stream/${gitee_repo}/forks")
-function get_list()
-{
- # 清空或创建 file_out 文件
- :> $file_out
- :> $file_tmp
-
- # 查找 yaml
- yaml_files=$(ls | grep -E '\.yaml$')
-
- # 遍历 yaml
- for file in $yaml_files; do
- # 提取 "level: 1" 的包名
- level1_package=$(cat $file | grep -A 2 "level: 1" | grep "src_name:" | awk '{print $2}')
- src_names+=("$level1_package")
- # 提取 "level: 2" 的包名
- cat $file | grep -A 2 "level: 2" | grep "src_name:" | awk '{print $2}' >> $file_tmp
- done
- # cat $file_tmp | sort -u > $file_out
- sort -u $file_tmp -o $file_tmp
-
- # 过滤掉 "level: 1" 的包名,源码包本身 无需重编
- for src_name in "${src_names[@]}"; do
- grep -v "^$src_name$" $file_tmp > $file_out
- done
-
- rm $file_tmp
+ # check Fork
+ if echo "$fork_result" | grep -q "\"path\":\"${gitee_repo}\""; then
+ echo "====== Forked repository successfully.${gitee_repo} ======"
+ else
+ echo "###### Failed to fork repository.${gitee_repo}.$fork_result ######"
+ fi
+
+ git clone "https://gitee.com/${gitee_username}/${gitee_repo}.git" --quiet
}
+## 2. 修改spec文件,Release+1和changelog
function modi_spec()
{
pkg_name="$1"
@@ -93,30 +64,9 @@ function modi_spec()
spec_version=$(rpmspec -P $pkg_spec | grep -iw "version:" | awk '{print $2}' | awk 'NR==1{print}')
sed -i "s/%changelog/%changelog\n* $week_num $month_num $date_num $year_num $commit_auth - $spec_version-$new_release\n- $commit_info\n/g" $pkg_spec
fi
-
- if [ $? -eq 0 ]; then
- echo "====== modi_spec successful.${gitee_repo} ======"
- fi
-}
-
-function fork_clone_repo()
-{
- gitee_repo=$1
- gitee_api="https://gitee.com/api/v5"
-
- # Fork repo
- fork_result=$(curl -X POST -u "${gitee_username}:${gitee_tocken}" "${gitee_api}/repos/opencloudos-stream/${gitee_repo}/forks")
-
- # check Fork
- if echo "$fork_result" | grep -q "\"path\":\"${gitee_repo}\""; then
- echo "====== Forked repository successfully.${gitee_repo} ======"
- else
- echo "###### Failed to fork repository.${gitee_repo}.$fork_result ######"
- fi
-
- git clone "https://gitee.com/${gitee_username}/${gitee_repo}.git"
}
+## 3. commit、push本地代码到远端
function push_repo()
{
gitee_repo=$1
@@ -125,8 +75,8 @@ function push_repo()
git config credential.helper "store --file=.git/gitee_credentials"
echo "https://${gitee_username}:${gitee_tocken}@gitee.com" > .git/gitee_credentials
- git commit -am "$commit_info"
- git push origin master
+ git commit -am "$commit_info" --quiet
+ git push origin master --quiet
if [ $? -eq 0 ]; then
echo "====== git push successful.${gitee_repo} ======"
@@ -136,6 +86,7 @@ function push_repo()
fi
}
+## 4. 提Pull Requests
function PR_repo() {
gitee_repo=$1
@@ -146,7 +97,7 @@ function PR_repo() {
pr_base="master"
pr_url="${gitee_api}/repos/opencloudos-stream/${gitee_repo}/pulls"
- pr_result=$(curl -X POST "$pr_url" \
+ pr_result=$(curl -s -X POST "$pr_url" \
-H "Content-Type: application/json;charset=UTF-8" \
-d '{
"access_token": "'"${gitee_tocken}"'",
@@ -167,9 +118,12 @@ function PR_repo() {
fi
}
-
+## 0. 各函数入口
function handle_pkgs()
{
+ rm -f $file_success
+ :> $file_success
+
# 逐行读取 yaml 文件, 对每个软件包进行fork、clone、Release +1到spec、commit、push、提PR
while IFS= read -r pkg_name; do
fork_clone_repo $pkg_name
@@ -180,18 +134,12 @@ function handle_pkgs()
# 如不需要提PR,请注释下行 PR_repo
PR_repo $pkg_name
cd ..
+
+ # 执行成功的,保存到file_success
+ echo $pkg_name >> $file_success
+ # 使用 sed 从文件中删除已处理的软件包
+ sed -i "/^${pkg_name}$/d" "$file_out"
done < "$file_out"
}
-# 如果传入参数1,需要执行rpm_dep查询,得到file_out(待release +1软件包名单)
-if [ "$#" -ge 1 ]; then
- rpm_dep_list
- get_list
- # rpm_dep_list_clean
-elif [ $(cat "$file_out" | wc -l) -eq 0 ]; then
- echo "WARNNING: $file_out is NULL, no package."
-else
- echo "INFO: No arguments provided. Skipping rpm_dep function."
-fi
-
handle_pkgs