Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

【包迁移代码合入】autospec包迁移、rpm源码仓迁移、update源仓检查(shell) #22

Merged
merged 1 commit into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions easypackages/autospec_transfer/autospec-mv.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
suite: rpmbuild-autospec-mv
category: functional
rpmbuild:
group_id: rpmbuild-autospec-mv
custom_repo_name: autospec-mv
mount_repo_addr: xxxxxxxx
mount_repo_name: autospec-mv
os: openeuler
os_version: 24.03-LTS
runtime: 1d
sleep: 1h
105 changes: 105 additions & 0 deletions easypackages/autospec_transfer/autospec_rpm_mv.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
#!/bin/bash

# shellcheck disable=SC1091
source ./lib_rpm.sh


base_path="/home/lxb/rpmbuild/work/autospec_rpm_mv"
src_list="${base_path}/data/autospec_rpm_src_list_aarch64"
iterarte_list="${src_list}_iterate"
arch_type="aarch64"

#log_dir_name=$(basename ${src_list})
#project_log_file="${base_path}/log/log-${log_dir_name}"

src_rpm_path_dest="/srv/result/rpmbuild-test-lxb/tmp/"


proc_num=0
iterate_num=1
submit_jobs_flag=1
list_file=""
submit_jobs()
{
if [ 0 -eq "${submit_jobs_flag}" ]; then
return 0
fi

log_msg "[log] iterarte ${iterate_num} submit jobs"

log_dir_name=$(basename ${src_list})
submit_log_dir="${base_path}/log/submit-log-${log_dir_name}"
log_msg "[log] submit log path : ${submit_log_dir}"

command="sh ./submit-repair.sh \
-l ${list_file} \
-h ${arch_type} \
-t vm-2p8g \
-p check_rpm_install=yes \
-y ./autospec-mv.yaml \
-g ${submit_log_dir}"

log_msg "[log] submit content: ${command}"
bash -c "${command}" > /dev/null

submit_jobs_flag=0
}

log_msg "autospec rpm transfer begin ..."
log_msg ""
log_msg "[log] iterater start ${iterate_num} ..."
while read -r line
do
[ -z "$line" ] && continue

line_arr=()
read -ra line_arr <<< "$line"

src_rpm_path_src="${line_arr[1]}"

# 下载源码包
list_file="${iterarte_list}_${iterate_num}"
password="xx"
scp_path="yy@xx.xx.xx.xx:${src_rpm_path_src}"
sshpass -p ${password} scp "${scp_path}" "${src_rpm_path_dest}"

src_rpm_name=$(basename "${src_rpm_path_src}")
if [ ! -f "${src_rpm_path_dest}/${src_rpm_name}" ]; then
log_msg "[error] src_rpm scp fail: ${src_rpm_path_src} ${src_rpm_path_dest}/${src_rpm_name}"
continue
fi

echo "wget:$line" >> "${list_file}"
submit_jobs_flag=1
((proc_num++))

# 拆分批次(一次4000个)
if [[ ${proc_num} != 0 && $((proc_num % 4000)) == 0 ]]; then
# 提交任务
submit_jobs

log_msg "[log] iterarte end ${iterate_num} ..."

((iterate_num++))
while true
do
src_rpm_num_tmp=$(find "${src_rpm_path_dest}" -maxdepth 1 -type f | wc -l)
if [ "${src_rpm_num_tmp}" -eq 0 ]; then
log_msg ""
log_msg "[log] iterarte start ${iterate_num} ..."
break
fi

# 睡眠10分钟,防止当前提交任务抢占机器
log_msg "sleep 600 seconds ..."
sleep 600
done
fi
done < "${src_list}"

# 最后一次提交,防止没有满足4000个
submit_jobs

log_msg "[log] iterarte end ${iterate_num} ..."
log_msg ""
log_msg "autospec rpm transfer success"
22 changes: 22 additions & 0 deletions easypackages/autospec_transfer/filter_autospec_rpm_list.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

# aarch64 x86_64
arch_type="x86_64"
rpm_list_file_src="data/autospec_rpm_binary_list_${arch_type}"
rpm_list_file_des="data/autospec_rpm_src_list_${arch_type}"

echo -n > "${rpm_list_file_des}"
while read -r line
do
[ -z "$line" ] && continue

line_arr=()
read -ra line_arr <<< "$line"

src_rpm="${line_arr[1]}"
src_rpm_name=${src_rpm##*/}

if ! grep -q "${src_rpm}" "${rpm_list_file_des}"; then
echo "${src_rpm_name} ${src_rpm}" >> "${rpm_list_file_des}"
fi
done < "${rpm_list_file_src}"
41 changes: 41 additions & 0 deletions easypackages/autospec_transfer/get_autospec_rpm_list.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/bash
# aarch64
arch_type="x86_64"
rpm_list_file="autospec_rpm_binary_list_${arch_type}"

os_version_dir="openeuler-22.03-LTS-${arch_type}"
rpm_binary_path="/srv/autopkg-rpms/${os_version_dir}"
rpm_src_path="/srv/autopkg-src-rpms/${os_version_dir}"

dir_paths=("${rpm_binary_path}" "${rpm_src_path}")
for path in "${dir_paths[@]}"
do
[ ! -d "${path}" ] && echo "[error] dir not exist: ${path}" && exit 1
done

echo -n > "${rpm_list_file}"
find "${rpm_binary_path}" -type f -name "*.${arch_type}.rpm" -follow | while read -r file
do
rpm_info=$(rpm -qi "$file")
rpm_base_name=$(echo "$rpm_info" | grep -o -E "^Name.*:.*" | awk -F':' '{print $NF}' | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
rpm_version=$(echo "$rpm_info" | grep -o -E "^Version.*:.*" | awk -F':' '{print $NF}' | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
rpm_arch=$(echo "$rpm_info" | grep -o -E "^Architecture.*:.*" | awk -F':' '{print $NF}' | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
rpm_src_rpm=$(echo "$rpm_info" | grep -o -E "^Source RPM.*:.*" | awk -F':' '{print $NF}' | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')

rpm_relative_file=$(echo "${file}" | awk -F"/${os_version_dir}/" '{print $NF}')
rpm_name=${file##*/}
rpm_relative_path=${rpm_relative_file%/*}
rpm_src_rpm_path="${rpm_src_path}/${rpm_relative_path}/${rpm_src_rpm}"

if [ -z "${rpm_src_rpm_path}" ] || [ ! -f "${rpm_src_rpm_path}" ]; then
rpm_src_rpm_path_tmp="${rpm_src_rpm_path}"
rpm_src_rpm_path=$(find "${rpm_src_path}" -name "${rpm_src_rpm}" -follow)
if [ -z "${rpm_src_rpm_path}" ] || [ ! -f "${rpm_src_rpm_path}" ]; then
echo "[error] .src.rpm file not exist: ${file} ${rpm_src_rpm_path_tmp}" && continue
fi
fi

echo "${rpm_name} ${rpm_src_rpm_path} ${rpm_base_name} ${rpm_version} ${rpm_arch}" >> "${rpm_list_file}"
done

# 需要过滤掉重复的源码包用于构建
Loading
Loading