From 6085b3e0190dbe797970c609a02476d7cc3303f5 Mon Sep 17 00:00:00 2001 From: wangchong1995924 <15229716099@163.com> Date: Wed, 14 Sep 2022 17:02:50 +0800 Subject: [PATCH] modify check_dep.py support set all rpms of exclude rpms list and support exclude specified everything source rpms --- script/config/unable_install_source_list | 0 script/make_version.sh | 1 + script/step/make_iso_everysrc.sh | 5 ++ script/tools/check_dep.py | 69 ++++++++++++++++++++++++ 4 files changed, 75 insertions(+) create mode 100644 script/config/unable_install_source_list diff --git a/script/config/unable_install_source_list b/script/config/unable_install_source_list new file mode 100644 index 0000000..e69de29 diff --git a/script/make_version.sh b/script/make_version.sh index 04e3046..b28d859 100644 --- a/script/make_version.sh +++ b/script/make_version.sh @@ -10,6 +10,7 @@ export OUTPUT_PATH="${BUILD_SCRIPT_DIR}/output" export PROJECT_PATH="${BUILD_SCRIPT_DIR}/../../../../.." export ERROR_LOG="${OUTPUT_PATH}/error_log" export UNABLE_INSTALL_LIST="${BUILD_SCRIPT_DIR}"/config/unable_install_list +export UNABLE_INSTALL_SOURCE_LIST="${BUILD_SCRIPT_DIR}"/config/unable_install_source_list if [ ! -d "${OUTPUT_PATH}" ]; then mkdir -p "${OUTPUT_PATH}" diff --git a/script/step/make_iso_everysrc.sh b/script/step/make_iso_everysrc.sh index 01d1b2f..c0c4eb3 100644 --- a/script/step/make_iso_everysrc.sh +++ b/script/step/make_iso_everysrc.sh @@ -42,6 +42,11 @@ function make_iso_everysrc_inchroot() do sed -i '//a\ '$rpmsname'' config/rpmlist.xml done + rpmsnames=`cat ${UNABLE_INSTALL_SOURCE_LIST}` + for rpmsname in $rpmsnames + do + sed -i '//a\ '$rpmsname'' config/rpmlist.xml + done sed -i '/parse_rpmlist_xml \"conflict\"/d' rpm.sh OBS_STANDARD_REPO_URL=${OBS_STANDARD_REPO_URL%/*} REPOS=`echo "${OBS_STANDARD_REPO_URL}/standard_aarch64 ${OBS_STANDARD_REPO_URL}/standard_x86_64 ${OBS_STANDARD_THIRD_REPO_URL}" | sed 's/[ \t]*$//g'` diff --git a/script/tools/check_dep.py b/script/tools/check_dep.py index 8c69ed8..5847a12 100644 --- a/script/tools/check_dep.py +++ b/script/tools/check_dep.py @@ -5,6 +5,7 @@ import threading import platform import subprocess import argparse +from concurrent.futures import ThreadPoolExecutor def kill_yumdownloader(rpm_path, thr): @@ -123,6 +124,66 @@ def check_dep(rpm_list_file, check_log_file, delete_rpm_list_file, rpm_path, con print("=================== exclude rpm list end ======================") +def get_pkg_rpms(pkg, arch, pkg_rpms_list): + """ + get a package all rpms + """ + cmd = f"osc ls -b {args.project} {pkg} standard_{arch} {arch} 2>/dev/null | grep rpm" + res = os.popen(cmd).read().split() + rpm_list = [x for x in res if x != ''] + new_rpm_list = [] + if rpm_list: + for rpm in rpm_list: + if rpm.endswith(".src.rpm"): + rpm_name = rpm + else: + rpm_name = rpm.rsplit("-", 2)[0] + new_rpm_list.append(rpm_name) + pkg_rpms_list.append(new_rpm_list) + +def set_exclude_pkg_all_rpms(): + """ + get all rpms of exclude rpm list and source rpms + """ + print("=========== start search all rpms of exclude rpm list ===========") + pkg_rpms_list = [] + cmd = "uname -m" + arch = os.popen(cmd).read().strip() + cmd = f"osc list {args.project} 2>/dev/null" + res = os.popen(cmd).read().split() + pkglist = [x for x in res if x != ''] + with ThreadPoolExecutor(100) as executor: + for pkg in pkglist: + executor.submit(get_pkg_rpms, pkg, arch, pkg_rpms_list) + with open(args.exclude_rpm_list_file, "r") as f: + file_content = f.read().strip().splitlines() + if file_content: + final_rpms_list = [] + for rpms in pkg_rpms_list: + for rpm in rpms: + if rpm in file_content: + if rpm not in final_rpms_list: + final_rpms_list.extend(rpms) + if final_rpms_list: + f1 = open(args.final_exclude_rpm_list_file, "w") + f2 = open(args.final_source_exclude_rpm_list_file, "w") + for rpm in final_rpms_list: + if rpm.endswith(".src.rpm"): + if args.project.endswith(":Epol"): + f2.write(rpm) + else: + f2.write(rpm.rsplit("-", 2)[0]) + f2.write("\n") + else: + f1.write(rpm) + f1.write("\n") + f1.close() + f2.close() + print(os.popen(f"cat {args.final_exclude_rpm_list_file}").read()) + print(os.popen(f"cat {args.final_source_exclude_rpm_list_file}").read()) + print("============ end search all rpms of exclude rpm list ============") + + par = argparse.ArgumentParser() par.add_argument("-d", "--dest_rpm_path", help="path for rpm", required=True) par.add_argument("-l", "--rpm_list_file", help="file for rpm list", required=True) @@ -130,9 +191,17 @@ par.add_argument("-f", "--check_log_file", help="file for checking log", require par.add_argument("-e", "--exclude_rpm_list_file", help="file for rpms which are exclude", required=True) par.add_argument("-c", "--config", help="config file repofile", default=None, required=False) par.add_argument("-r", "--repo", help="name of repo", default=None, required=False) +par.add_argument("-sea", "--set_exclude_all_rpms", help="set all rpms of exclude package", default=None, required=False) +par.add_argument("-fe", "--final_exclude_rpm_list_file", help="file for all rpms which are exclude", required=False) +par.add_argument("-fes", "--final_source_exclude_rpm_list_file", help="file for source rpms which are exclude", required=False) +par.add_argument("-p", "--project", help="name of obs project", default=None, required=False) args = par.parse_args() t1 = threading.Thread(target=check_dep, args=(args.rpm_list_file, args.check_log_file, args.exclude_rpm_list_file, args.dest_rpm_path, args.config, args.repo)) t1.start() t2 = threading.Thread(target=kill_yumdownloader, args=(args.dest_rpm_path, t1)) t2.start() +t1.join() +t2.join() +if args.set_exclude_all_rpms: + set_exclude_pkg_all_rpms() -- Gitee