From c676e050454bbad231c88c7400be0dcd763eb470 Mon Sep 17 00:00:00 2001 From: mgb01105731 Date: Fri, 24 Dec 2021 14:48:40 +0800 Subject: [PATCH] add centos2anolis.spec & modify yumdownloader in centos2anolis.py --- centos2anolis.py | 12 ++++++------ centos2anolis.spec | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 6 deletions(-) create mode 100644 centos2anolis.spec diff --git a/centos2anolis.py b/centos2anolis.py index 50587c2..8e4d980 100644 --- a/centos2anolis.py +++ b/centos2anolis.py @@ -402,6 +402,12 @@ def main(reinstall_all_rpms=False, verify_all_rpms=False, accelerate=False, vers if opt != 'Yes': sys.exit(1) + print("========= Looking for yumdownloader ==========") + if not check_pkg('yumdownloader'): + subprocess.run("yum -y install yum-utils", shell=True) + if not check_pkg('yumdownloader'): + clean_and_exit() + print("========= Finding your repository directory =========") dir = '/etc/yum.repos.d/' if os.path.isdir(dir): @@ -424,12 +430,6 @@ def main(reinstall_all_rpms=False, verify_all_rpms=False, accelerate=False, vers if accelerate: change_repo_mirror(reposdir, 'switch-to-anolis.repo') - print("========= Looking for yumdownloader ==========") - if not check_pkg('yumdownloader'): - subprocess.run("yum -y install yum-utils --disablerepo an* || true", shell=True) - if not check_pkg('yumdownloader'): - clean_and_exit() - print("========= Start converting =========") print("Backing up and removing old repository files...") diff --git a/centos2anolis.spec b/centos2anolis.spec new file mode 100644 index 0000000..8529d62 --- /dev/null +++ b/centos2anolis.spec @@ -0,0 +1,41 @@ +Name: centos2anolis +Version: 0.1 +Release: 1%{?dist} +Summary: Transfer CentOS to Anolis. + +License: MIT +URL: www.openanolis.cn +Source0: %{name}.py +Source1: README.md +Source2: LICENSE.txt + +BuildRequires: python3 +Requires: python3 +Requires: bash + +BuildArch: noarch + +%description +This script is designed to automatically convert a CentOS instance to +Anolis OS in-place. Currently it supports transferring from CentOS 7 +to Anolis OS 7 and from CentOS 8 to Anolis OS 8. + +%prep +cp %{SOURCE1} . +cp %{SOURCE2} . + + +%install +mkdir -p %{buildroot}/%{_sbindir} +install -m 755 %{SOURCE0} %{buildroot}/%{_sbindir} + + +%files +%{_sbindir}/%{name}.py +%doc README.md +%license LICENSE.txt + + +%changelog +* Wed Dec 22 2021 mgb0110571 - 0.1-1 +- First CentOS2Anolis Package -- Gitee