From 0fccc19d34d4482c8d7ba5bd476a5810fc2ec35a Mon Sep 17 00:00:00 2001 From: yuki1109 <750172132@qq.com> Date: Tue, 24 May 2022 22:00:59 +0800 Subject: [PATCH] fix check_dnf_modules --- centos2anolis.py | 44 +++++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/centos2anolis.py b/centos2anolis.py index f35b9c3..eeec5a4 100644 --- a/centos2anolis.py +++ b/centos2anolis.py @@ -380,24 +380,6 @@ def process_yum_utils_install(internal_ecs): if centosversion != 8: return - repostr_centos_vault_8 = '''[c8_vault_baseos] -name=c8_vault - BaseOS -baseurl=http://mirrors.aliyun.com/centos-vault/8.5.2111/BaseOS/$basearch/os/ -gpgcheck=0 -enabled=1 - -[c8_vault_appstream] -name=c8_vault - AppStream -baseurl=http://mirrors.aliyun.com/centos-vault/8.5.2111/AppStream/$basearch/os/ -gpgcheck=0 -enabled=1 -''' - - if internal_ecs: - repostr_centos_vault_8 = repostr_centos_vault_8.replace("mirrors.aliyun.com", "mirrors.cloud.aliyuncs.com") - with open('/tmp/c8_vault.repo', 'w') as f: - f.write(repostr_centos_vault_8) - subprocess.run("yum -y install yum-utils --disablerepo=* -c /tmp/c8_vault.repo --enablerepo=c8_vault*", shell=True) os.remove('/tmp/c8_vault.repo') if not check_pkg('yumdownloader'): @@ -504,14 +486,34 @@ def check_yum_lock(): sys.exit(1) def check_dnf_modules(): + global internal_ecs if centosversion != 8: return # check dnf log_it(logging.INFO, "Checking: dnf modules enable list") log_it(logging.INFO, "Identifying dnf modules that are enabled...") + + repostr_centos_vault_8 = '''[c8_vault_baseos] +name=c8_vault - BaseOS +baseurl=http://mirrors.aliyun.com/centos-vault/8.5.2111/BaseOS/$basearch/os/ +gpgcheck=0 +enabled=1 + +[c8_vault_appstream] +name=c8_vault - AppStream +baseurl=http://mirrors.aliyun.com/centos-vault/8.5.2111/AppStream/$basearch/os/ +gpgcheck=0 +enabled=1 +''' + + if internal_ecs: + repostr_centos_vault_8 = repostr_centos_vault_8.replace("mirrors.aliyun.com", "mirrors.cloud.aliyuncs.com") + with open('/tmp/c8_vault.repo', 'w') as f: + f.write(repostr_centos_vault_8) + enabled_modules = str( - subprocess.check_output("dnf module list --enabled --disablerepo=* | grep rhel | awk '{print $1}'", shell=True), + subprocess.check_output("dnf module list -c /tmp/c8_vault.repo --enabled | grep rhel | awk '{print $1}'", shell=True), 'utf-8') enabled_modules = enabled_modules.split('\n')[:-1] try: @@ -524,7 +526,7 @@ def check_dnf_modules(): if len(enabled_modules) > 0: for mod in enabled_modules: if re.fullmatch('container-tools|llvm-toolset|virt', mod): - subprocess.run('dnf module --disablerepo=* reset -y ' + mod, shell=True) + subprocess.run('dnf module reset -c /tmp/c8_vault.repo -y ' + mod, shell=True) if not re.fullmatch('container-tools|go-toolset|jmc|llvm-toolset|rust-toolset|virt', mod): unknown_mods.append(mod) if len(unknown_mods) > 0: @@ -764,8 +766,8 @@ def main(verify_all_rpms=False, accelerate=False, version=False, continue_after_ verify_before(verify_all_rpms) check_distribution() check_yum_lock() - check_dnf_modules() check_network() + check_dnf_modules() check_yumdownloader() check_mysql(version) check_repodir() -- Gitee