diff --git a/0027-upgrade-write-efi-vars-for-ecs-firmware.patch b/0027-upgrade-write-efi-vars-for-ecs-firmware.patch new file mode 100644 index 0000000000000000000000000000000000000000..1e27eb6bf6730f50493709fda87f8ba16951777a --- /dev/null +++ b/0027-upgrade-write-efi-vars-for-ecs-firmware.patch @@ -0,0 +1,70 @@ +From ce93e314a66020399c22d6aa574be2b92281b9f3 Mon Sep 17 00:00:00 2001 +From: Liwei Ge +Date: Thu, 1 Sep 2022 15:28:14 +0800 +Subject: [PATCH] upgrade: write efi vars for ecs firmware + +also rebrand grub title for upgrade boot +--- + .../libraries/addupgradebootentry.py | 2 +- + .../tests/unit_test_addupgradebootentry.py | 2 +- + .../dracut/85sys-upgrade-redhat/do-upgrade.sh | 18 ++++++++++++++++++ + 3 files changed, 20 insertions(+), 2 deletions(-) + +diff --git a/repos/system_upgrade/el7toel8/actors/addupgradebootentry/libraries/addupgradebootentry.py b/repos/system_upgrade/el7toel8/actors/addupgradebootentry/libraries/addupgradebootentry.py +index c15dd52..4270bd8 100644 +--- a/repos/system_upgrade/el7toel8/actors/addupgradebootentry/libraries/addupgradebootentry.py ++++ b/repos/system_upgrade/el7toel8/actors/addupgradebootentry/libraries/addupgradebootentry.py +@@ -17,7 +17,7 @@ def add_boot_entry(configs=None): + '/usr/sbin/grubby', + '--add-kernel', '{0}'.format(kernel_dst_path), + '--initrd', '{0}'.format(initram_dst_path), +- '--title', 'RHEL-Upgrade-Initramfs', ++ '--title', 'Anolis-Upgrade-Initramfs', + '--copy-default', + '--make-default', + '--args', '{DEBUG} enforcing=0 rd.plymouth=0 plymouth.enable=0'.format(DEBUG=debug) +diff --git a/repos/system_upgrade/el7toel8/actors/addupgradebootentry/tests/unit_test_addupgradebootentry.py b/repos/system_upgrade/el7toel8/actors/addupgradebootentry/tests/unit_test_addupgradebootentry.py +index bb89c9f..ccc53ae 100644 +--- a/repos/system_upgrade/el7toel8/actors/addupgradebootentry/tests/unit_test_addupgradebootentry.py ++++ b/repos/system_upgrade/el7toel8/actors/addupgradebootentry/tests/unit_test_addupgradebootentry.py +@@ -42,7 +42,7 @@ run_args_add = [ + '/usr/sbin/grubby', + '--add-kernel', '/abc', + '--initrd', '/def', +- '--title', 'RHEL-Upgrade-Initramfs', ++ '--title', 'Anolis-Upgrade-Initramfs', + '--copy-default', + '--make-default', + '--args', +diff --git a/repos/system_upgrade/el7toel8/actors/commonleappdracutmodules/files/dracut/85sys-upgrade-redhat/do-upgrade.sh b/repos/system_upgrade/el7toel8/actors/commonleappdracutmodules/files/dracut/85sys-upgrade-redhat/do-upgrade.sh +index 8729a5d..0b87498 100755 +--- a/repos/system_upgrade/el7toel8/actors/commonleappdracutmodules/files/dracut/85sys-upgrade-redhat/do-upgrade.sh ++++ b/repos/system_upgrade/el7toel8/actors/commonleappdracutmodules/files/dracut/85sys-upgrade-redhat/do-upgrade.sh +@@ -70,6 +70,24 @@ do_upgrade() { + ## install new product id certificates + #chroot $NEWROOT /bin/sh -c 'mv -f /system-upgrade/*.pem /etc/pki/product/' + ++ if [ -d "/sys/firmware/efi/efivars/" ]; then ++ cp $NEWROOT/lib64/libefi* /lib64/ ++ cp $NEWROOT/lib64/libfdisk* /lib64/ ++ if ! $NEWROOT/usr/sbin/efibootmgr | grep -i "Anolis OS"; then ++ efi_device=$($NEWROOT/usr/sbin/fdisk -l -o Device,Type | grep EFI\ System | sed 's/ .*//') ++ if [ "${efi_device}" ]; then ++ efi_part=${efi_device:8} ++ efi_device=${efi_device::8} ++ if [ "$(uname -m)" == "aarch64" ]; then ++ efi_arch="aa64" ++ elif [ "$(uname -m)" == "x86_64" ]; then ++ efi_arch="x64" ++ fi ++ $NEWROOT/usr/sbin/efibootmgr -c -d ${efi_device} -p ${efi_part} -l "/EFI/anolis/shim${efi_arch}.efi" -L "Anolis OS" ++ fi ++ fi ++ fi ++ + # restore things twiddled by workarounds above. TODO: remove! + if [ -f /sys/fs/selinux/enforce ]; then + echo $enforce > /sys/fs/selinux/enforce +-- +2.27.0 + diff --git a/0028-add-disablerepo-option-to-upgrade-kernel-to-RHCK.patch b/0028-add-disablerepo-option-to-upgrade-kernel-to-RHCK.patch new file mode 100644 index 0000000000000000000000000000000000000000..4a5672dde73ab27134fc3501202ae8d8aca74cd5 --- /dev/null +++ b/0028-add-disablerepo-option-to-upgrade-kernel-to-RHCK.patch @@ -0,0 +1,46 @@ +From ad08c0a1c09acdaa5d4999f1f0ae51da4f82e54f Mon Sep 17 00:00:00 2001 +From: mgb01105731 +Date: Fri, 9 Sep 2022 17:52:19 +0800 +Subject: [PATCH] add --disablerepo option to upgrade kernel to RHCK + +--- + .../libraries/scancustomrepofile.py | 18 +++++++++++------- + 1 file changed, 11 insertions(+), 7 deletions(-) + +diff --git a/repos/system_upgrade/el7toel8/actors/scancustomrepofile/libraries/scancustomrepofile.py b/repos/system_upgrade/el7toel8/actors/scancustomrepofile/libraries/scancustomrepofile.py +index c294193..a5a30bd 100644 +--- a/repos/system_upgrade/el7toel8/actors/scancustomrepofile/libraries/scancustomrepofile.py ++++ b/repos/system_upgrade/el7toel8/actors/scancustomrepofile/libraries/scancustomrepofile.py +@@ -3,7 +3,7 @@ import os + from leapp.libraries.common import repofileutils + from leapp.libraries.stdlib import api + from leapp.models import CustomTargetRepository, CustomTargetRepositoryFile +- ++from leapp.libraries.common import config + + CUSTOM_REPO_PATH = "/etc/leapp/files/leapp_upgrade_repositories.repo" + +@@ -26,10 +26,14 @@ def process(): + if not repofile.data: + return + api.produce(CustomTargetRepositoryFile(file=CUSTOM_REPO_PATH)) ++ disablelist=[] ++ if config.get_env('LEAPP_DISABLE_REPOS'): ++ disablelist = [repoid for repoid in config.get_env('LEAPP_DISABLE_REPOS').split(',')] + for repo in repofile.data: +- api.produce(CustomTargetRepository( +- repoid=repo.repoid, +- name=repo.name, +- baseurl=repo.baseurl, +- enabled=repo.enabled, +- )) ++ if repo.enabled and repo.repoid not in disablelist: ++ api.produce(CustomTargetRepository( ++ repoid=repo.repoid, ++ name=repo.name, ++ baseurl=repo.baseurl, ++ enabled=repo.enabled, ++ )) +-- +2.19.2 + diff --git a/0029-Service-configuration-remains-after-migration.patch b/0029-Service-configuration-remains-after-migration.patch new file mode 100644 index 0000000000000000000000000000000000000000..8ff3ed8fdad817a45201cbdd1c9a68b386c420f3 --- /dev/null +++ b/0029-Service-configuration-remains-after-migration.patch @@ -0,0 +1,255 @@ +From 26581abc7eac1dae5bd07380d26703d4f1e0439a Mon Sep 17 00:00:00 2001 +From: Weisson +Date: Thu, 1 Sep 2022 13:16:55 +0800 +Subject: [PATCH] Service configuration should remain the same after migration. + +--- + .../serviceconfigurationcollector/actor.py | 27 +++++ + .../serviceconfigurationsynchronizer/actor.py | 102 ++++++++++++++++++ + .../models/configurationsynchronization.py | 7 ++ + .../tags/configurationcollectionphase.py | 5 + + .../tags/configurationsynchronizationphase.py | 5 + + .../topics/configurationsynchronization.py | 5 + + .../el7toel8/workflows/inplace_upgrade.py | 26 +++++ + 7 files changed, 177 insertions(+) + create mode 100644 repos/system_upgrade/el7toel8/actors/serviceconfigurationcollector/actor.py + create mode 100644 repos/system_upgrade/el7toel8/actors/serviceconfigurationsynchronizer/actor.py + create mode 100644 repos/system_upgrade/el7toel8/models/configurationsynchronization.py + create mode 100644 repos/system_upgrade/el7toel8/tags/configurationcollectionphase.py + create mode 100644 repos/system_upgrade/el7toel8/tags/configurationsynchronizationphase.py + create mode 100644 repos/system_upgrade/el7toel8/topics/configurationsynchronization.py + +diff --git a/repos/system_upgrade/el7toel8/actors/serviceconfigurationcollector/actor.py b/repos/system_upgrade/el7toel8/actors/serviceconfigurationcollector/actor.py +new file mode 100644 +index 0000000..fbee732 +--- /dev/null ++++ b/repos/system_upgrade/el7toel8/actors/serviceconfigurationcollector/actor.py +@@ -0,0 +1,27 @@ ++import subprocess ++import json ++ ++from leapp.actors import Actor ++from leapp.tags import ConfigurationCollectionPhaseTag, IPUWorkflowTag ++from leapp.models import ConfigurationSynchronization ++ ++ ++class ServiceConfigurationCollector(Actor): ++ """ ++ No documentation has been provided for the service_configuration_collector actor. ++ """ ++ ++ name = 'service_configuration_collector' ++ consumes = () ++ produces = (ConfigurationSynchronization, ) ++ tags = (ConfigurationCollectionPhaseTag, IPUWorkflowTag, ) ++ ++ def process(self): ++ self.log.info("Starting to backup service configurations.") ++ services_config_raw = subprocess.check_output("systemctl list-unit-files | egrep 'enabled|disabled'", shell=True).decode("utf-8").strip() ++ services_config = { ++ line.strip().split()[0]: line.strip().split()[1][:-1] ++ for line in services_config_raw.split('\n') ++ } ++ self.produce(ConfigurationSynchronization(services_configuration=json.dumps(services_config))) ++ +diff --git a/repos/system_upgrade/el7toel8/actors/serviceconfigurationsynchronizer/actor.py b/repos/system_upgrade/el7toel8/actors/serviceconfigurationsynchronizer/actor.py +new file mode 100644 +index 0000000..7856bea +--- /dev/null ++++ b/repos/system_upgrade/el7toel8/actors/serviceconfigurationsynchronizer/actor.py +@@ -0,0 +1,102 @@ ++import json ++import subprocess ++ ++from leapp.actors import Actor ++from leapp.tags import ConfigurationSynchronizationPhaseTag, IPUWorkflowTag ++from leapp.models import ConfigurationSynchronization ++ ++ ++class ServiceConfigurationSynchronizer(Actor): ++ """ ++ No documentation has been provided for the service_configuration_synchronizer actor. ++ """ ++ ++ name = 'service_configuration_synchronizer' ++ consumes = (ConfigurationSynchronization, ) ++ produces = () ++ tags = (IPUWorkflowTag, ConfigurationSynchronizationPhaseTag, ) ++ ++ def service_configuration_backup(self): ++ try: ++ self.log.info("backing up service configurations after migration.") ++ services_config_raw = str(subprocess.check_output("systemctl list-unit-files | egrep 'enabled |disabled ' | awk '{print $1,$2}'")).strip() ++ services_config = { ++ line.strip().split()[0]: line.strip().split()[1][:-1] ++ for line in services_config_raw.split('\n') ++ } ++ ++ return services_config ++ except Exception as e: ++ self.log.warning(" fail to backup service, ignore it. " + str(e)) ++ ++ return {} ++ ++ def do_config_services(self, config): ++ config_report = [] ++ for service, status in config.items(): ++ self.log.info("".join((service, " -> ", status))) ++ report = { ++ "service": service, ++ "old status": status, ++ "current status": status, ++ } ++ ++ try: ++ print("systemctl %s %s" % (status, service)) ++ output = str(subprocess.check_call("systemctl %s %s" % (status, service), shell=True)).strip() ++ report.update({ ++ "information": output, ++ "result": "succeed" ++ }) ++ ++ except Exception as e: ++ self.log.warning("fail to %s %s" % (status, service)) ++ ++ report.update({ ++ "information": str(e), ++ "result": "fail", ++ }) ++ ++ config_report += [report] ++ ++ return config_report ++ ++ def config_services(self, config, backup): ++ _config_report = self.do_config_services(config) ++ ++ config_report = [] ++ for line in _config_report: ++ if line["result"] == "fail": ++ line["current status"] = backup.get(line["service"] , "does not exist") ++ ++ config_report += [line] ++ ++ return config_report ++ ++ def service_configuration_restore(self, backup_configuration): ++ try: ++ self.log.info("Starting to roll back services configurations.") ++ self.do_config_services(backup_configuration) ++ ++ except Exception as e: ++ self.log.warning("fail to roll back services configurations: " + str(e)) ++ self.log.warning("default service configuration : " + str(backup_configuration)) ++ with open("/var/log/leapp/service-default.log", "w") as f: ++ json.dump(str(backup_configuration), f, indent=4) ++ ++ def process(self): ++ backup_configuratuon = self.service_configuration_backup() ++ ++ try: ++ self.log.info("Starting to synchronize services configurations.") ++ for configuration in self.consume(ConfigurationSynchronization): ++ services_configuration = json.loads(configuration.services_configuration) ++ config_report = self.config_services(services_configuration, backup_configuratuon) ++ ++ with open("/var/log/leapp/service-configuration-report.json", "w") as f: ++ json.dump(config_report, f, indent=4) ++ print("Service configuration output: /var/log/leapp/service-configuration-report.json") ++ ++ except Exception as e: ++ self.log.warning("fail to synchronize services configurations, rolling back. " + str(e)) ++ +diff --git a/repos/system_upgrade/el7toel8/models/configurationsynchronization.py b/repos/system_upgrade/el7toel8/models/configurationsynchronization.py +new file mode 100644 +index 0000000..349ac3d +--- /dev/null ++++ b/repos/system_upgrade/el7toel8/models/configurationsynchronization.py +@@ -0,0 +1,7 @@ ++from leapp.models import Model, fields ++from leapp.topics import ConfigurationSynchronizationTopic ++ ++class ConfigurationSynchronization(Model): ++ topic = ConfigurationSynchronizationTopic ++ services_configuration = fields.Nullable(fields.String()) ++ +diff --git a/repos/system_upgrade/el7toel8/tags/configurationcollectionphase.py b/repos/system_upgrade/el7toel8/tags/configurationcollectionphase.py +new file mode 100644 +index 0000000..a24ec82 +--- /dev/null ++++ b/repos/system_upgrade/el7toel8/tags/configurationcollectionphase.py +@@ -0,0 +1,5 @@ ++from leapp.tags import Tag ++ ++ ++class ConfigurationCollectionPhaseTag(Tag): ++ name = 'configuration_collection_phase' +diff --git a/repos/system_upgrade/el7toel8/tags/configurationsynchronizationphase.py b/repos/system_upgrade/el7toel8/tags/configurationsynchronizationphase.py +new file mode 100644 +index 0000000..81610a8 +--- /dev/null ++++ b/repos/system_upgrade/el7toel8/tags/configurationsynchronizationphase.py +@@ -0,0 +1,5 @@ ++from leapp.tags import Tag ++ ++ ++class ConfigurationSynchronizationPhaseTag(Tag): ++ name = 'configuration_synchronization_phase' +diff --git a/repos/system_upgrade/el7toel8/topics/configurationsynchronization.py b/repos/system_upgrade/el7toel8/topics/configurationsynchronization.py +new file mode 100644 +index 0000000..8d01b38 +--- /dev/null ++++ b/repos/system_upgrade/el7toel8/topics/configurationsynchronization.py +@@ -0,0 +1,5 @@ ++from leapp.topics import Topic ++ ++ ++class ConfigurationSynchronizationTopic(Topic): ++ name = 'configuration_synchronization' +diff --git a/repos/system_upgrade/el7toel8/workflows/inplace_upgrade.py b/repos/system_upgrade/el7toel8/workflows/inplace_upgrade.py +index 8e48d8c..c0dd27e 100644 +--- a/repos/system_upgrade/el7toel8/workflows/inplace_upgrade.py ++++ b/repos/system_upgrade/el7toel8/workflows/inplace_upgrade.py +@@ -16,6 +16,19 @@ class IPUWorkflow(Workflow): + configuration = IPUConfig + description = """The IPU workflow takes care of an in-place upgrade (IPU) of RHEL 7 to Anolis 8.""" + ++ class ConfigurationCollectionPhase(Phase): ++ """ ++ This phase and ConfigurationSynchronizationPhase must appear in pairs to ensure the configuration ++ before and after migration remains as similar as possible. ++ ++ This part is configuration collection phase. ++ """ ++ name = "ConfigurationCollection" ++ filter = TagFilter(tags.ConfigurationCollectionPhaseTag) ++ policies = Policies(Policies.Errors.FailPhase, ++ Policies.Retry.Phase) ++ flags = Flags() ++ + class FactsCollectionPhase(Phase): + """ + Get information (facts) about the system (e.g. installed packages, configuration, ...). +@@ -210,6 +223,19 @@ class IPUWorkflow(Workflow): + Policies.Retry.Phase) + flags = Flags(restart_after_phase=True) + ++ class ConfigurationSynchronizationPhase(Phase): ++ """ ++ This phase and ConfigurationCollectionPhase must appear in pairs to ensure the configuration ++ before and after migration remains as similar as possible. ++ ++ This part is configuration Synchronization phase. ++ """ ++ name = "ConfigurationSynchronization" ++ filter = TagFilter(tags.ConfigurationSynchronizationPhaseTag) ++ policies = Policies(Policies.Errors.FailPhase, ++ Policies.Retry.Phase) ++ flags = Flags() ++ + class FirstBootPhase(Phase): + """Actions to be done right after booting into the upgraded system.""" + +-- +2.31.1 + diff --git a/0030-fix-subprocess-check_output-method-for-backup-service-configuration.patch b/0030-fix-subprocess-check_output-method-for-backup-service-configuration.patch new file mode 100644 index 0000000000000000000000000000000000000000..4e150311db4fc728fba067653e8ee0e996065c09 --- /dev/null +++ b/0030-fix-subprocess-check_output-method-for-backup-service-configuration.patch @@ -0,0 +1,27 @@ +From 719baceb14cb08659fee61249b0be6b9f96f4b65 Mon Sep 17 00:00:00 2001 +From: wangcichen +Date: Tue, 11 Oct 2022 08:34:37 +0800 +Subject: [PATCH] + 0030-fix-subprocess-check_output-method-for-backup-service-configuration + +Signed-off-by: wangcichen +--- + .../el7toel8/actors/serviceconfigurationsynchronizer/actor.py | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/repos/system_upgrade/el7toel8/actors/serviceconfigurationsynchronizer/actor.py b/repos/system_upgrade/el7toel8/actors/serviceconfigurationsynchronizer/actor.py +index 7856bea..9b45d31 100644 +--- a/repos/system_upgrade/el7toel8/actors/serviceconfigurationsynchronizer/actor.py ++++ b/repos/system_upgrade/el7toel8/actors/serviceconfigurationsynchronizer/actor.py +@@ -19,7 +19,7 @@ class ServiceConfigurationSynchronizer(Actor): + def service_configuration_backup(self): + try: + self.log.info("backing up service configurations after migration.") +- services_config_raw = str(subprocess.check_output("systemctl list-unit-files | egrep 'enabled |disabled ' | awk '{print $1,$2}'")).strip() ++ services_config_raw = str(subprocess.check_output("systemctl list-unit-files | egrep 'enabled |disabled ' | awk '{print $1,$2}'", shell=True)).strip() + services_config = { + line.strip().split()[0]: line.strip().split()[1][:-1] + for line in services_config_raw.split('\n') +-- +2.22.0 + diff --git a/0031-Deal-with-EPEL-repositories-create-by-user-mannally.patch b/0031-Deal-with-EPEL-repositories-create-by-user-mannally.patch new file mode 100644 index 0000000000000000000000000000000000000000..a18f34574bd7f1a1ddf3c7fafb7a58dd8cdb32dc --- /dev/null +++ b/0031-Deal-with-EPEL-repositories-create-by-user-mannally.patch @@ -0,0 +1,103 @@ +From 37ab9cda0fa62dd1526f5fd4f4b1c7f81cbb9dab Mon Sep 17 00:00:00 2001 +From: Weisson +Date: Sun, 16 Oct 2022 18:31:15 +0800 +Subject: [PATCH] Deal with EPEL repositories create by user mannally. + +Signed-off-by: Weisson +--- + .../el7toel8/actors/rpmscanner/actor.py | 67 +++++++++++++++++++ + 1 file changed, 67 insertions(+) + +diff --git a/repos/system_upgrade/el7toel8/actors/rpmscanner/actor.py b/repos/system_upgrade/el7toel8/actors/rpmscanner/actor.py +index 27fe4b3..589e8a6 100644 +--- a/repos/system_upgrade/el7toel8/actors/rpmscanner/actor.py ++++ b/repos/system_upgrade/el7toel8/actors/rpmscanner/actor.py +@@ -4,6 +4,9 @@ from leapp.libraries.common.rpms import get_installed_rpms + from leapp.models import InstalledRPM, RPM + from leapp.tags import IPUWorkflowTag, FactsPhaseTag + ++import os ++from leapp.libraries import stdlib ++ + + class RpmScanner(Actor): + """ +@@ -17,6 +20,14 @@ class RpmScanner(Actor): + produces = (InstalledRPM,) + tags = (IPUWorkflowTag, FactsPhaseTag) + ++ epel_package_name = "epel-release" ++ ++ def epel_but_not_in_source(self): ++ epel_not_from_source = os.system("rpm -q %s" % self.epel_package_name) ++ epel_exists = not os.system("yum repolist | grep -q '^epel'") ++ ++ return epel_not_from_source and epel_exists ++ + def process(self): + output = get_installed_rpms() + pkg_repos = get_package_repository_data() +@@ -37,4 +48,60 @@ class RpmScanner(Actor): + release=release, + pgpsig=pgpsig, + repository=repository)) ++ ++ import subprocess ++ import re ++ ++ if self.epel_but_not_in_source(): ++ # disable epel repository ++ subprocess.check_output("yum install -y yum-utils", shell=True) ++ ++ repos = str(subprocess.check_output("yum repolist | grep -v '^repolist: ' | grep -v '^repo id ' | grep -v '^ * ' |" \ ++ "grep -v '^Loaded plugins: ' | grep -v '^Loading ' | awk '{ print $1 }' | xargs", shell=True)).strip() ++ ++ disable_repo_command = "yum-config-manager --disable " ++ ++ # repos = [ repo.split('/')[0] for repo in repos.split() ] ++ for repo_raw in repos.split(): ++ repo = repo_raw.split('/')[0].replace('!', '').replace('*', '') ++ if re.match(r"^epel", repo): ++ subprocess.check_output(disable_repo_command + repo, shell=True) ++ ++ # epel-release repository file backup ++ repo_paths = str(subprocess.check_output("repoquery -l %s | egrep '\.repo$'" % self.epel_package_name, shell=True)).strip().split() ++ for repo_path in repo_paths: ++ if os.path.exists(repo_path): ++ os.rename(repo_path, repo_path + ".bak") ++ ++ # replace epel repo with yum source to ensure that epel stabe during migration ++ subprocess.check_output("yum install -y %s" % self.epel_package_name, shell=True) ++ ++ rpm_cmd = [ ++ '/bin/rpm', ++ '-q', ++ self.epel_package_name, ++ '--queryformat', ++ r'%{NAME}|%{VERSION}|%{RELEASE}|%|EPOCH?{%{EPOCH}}:{(none)}||%|PACKAGER?{%{PACKAGER}}:{(none)}||%|' ++ r'ARCH?{%{ARCH}}:{}||%|DSAHEADER?{%{DSAHEADER:pgpsig}}:{%|RSAHEADER?{%{RSAHEADER:pgpsig}}:{(none)}|}|\n' ++ ] ++ try: ++ entries = stdlib.run(rpm_cmd, split=True)['stdout'] ++ ++ # append epel-release entry to RPMs ++ for entry in entries: ++ name, version, release, epoch, packager, arch, pgpsig = entry.split('|') ++ result.items.append(RPM( ++ name=name, ++ version=version, ++ epoch=epoch, ++ packager=packager, ++ arch=arch, ++ release=release, ++ pgpsig=pgpsig, ++ repository='', ++ )) ++ ++ except stdlib.CalledProcessError as err: ++ error = 'Execution of {CMD} returned {RC}. Unable to find installed packages.'.format(CMD=err.command, RC=err.exit_code) ++ stdlib.api.current_logger().error(error) + self.produce(result) +-- +2.31.1 + diff --git a/0032-Keep-PermitRootLogin-authentication-behavior-after-m.patch b/0032-Keep-PermitRootLogin-authentication-behavior-after-m.patch new file mode 100644 index 0000000000000000000000000000000000000000..c02f5b120ca0ab2b108176fb64f8af5425201024 --- /dev/null +++ b/0032-Keep-PermitRootLogin-authentication-behavior-after-m.patch @@ -0,0 +1,117 @@ +0032-Keep-PermitRootLogin-authentication-behavior-after-m.patchFrom 64f00d273e2141b58230cce1bb4a68010da4c457 Mon Sep 17 00:00:00 2001 +From: Weisson +Date: Wed, 9 Nov 2022 15:21:29 +0800 +Subject: [PATCH] Keep PermitRootLogin authentication behavior after migration. + +Signed-off-by: Weisson +Signed-off-by: Zhao Mingyue +--- + .../actor.py | 25 +++++++++++++ + .../actor.py | 37 +++++++++++++++++++ + .../serviceconfigurationsynchronizer/actor.py | 3 ++ + .../models/configurationsynchronization.py | 1 + + 4 files changed, 66 insertions(+) + create mode 100644 repos/system_upgrade/el7toel8/actors/authenticationconfigurationcollector/actor.py + create mode 100644 repos/system_upgrade/el7toel8/actors/authenticationconfigurationsynchronizer/actor.py + +diff --git a/repos/system_upgrade/el7toel8/actors/authenticationconfigurationcollector/actor.py b/repos/system_upgrade/el7toel8/actors/authenticationconfigurationcollector/actor.py +new file mode 100644 +index 0000000..ddbdeba +--- /dev/null ++++ b/repos/system_upgrade/el7toel8/actors/authenticationconfigurationcollector/actor.py +@@ -0,0 +1,25 @@ ++from leapp.actors import Actor ++from leapp.tags import IPUWorkflowTag, ConfigurationCollectionPhaseTag ++from leapp.models import ConfigurationSynchronization ++ ++import subprocess ++import json ++ ++ ++class AuthenticationConfigurationCollector(Actor): ++ """ ++ Keep authentication configuration the same after migration. This is collection phase. ++ """ ++ ++ name = 'authentication_configuration_collector' ++ consumes = () ++ produces = (ConfigurationSynchronization, ) ++ tags = (IPUWorkflowTag, ConfigurationCollectionPhaseTag, ) ++ ++ def process(self): ++ PermitRootLogin = subprocess.check_output('cat /etc/ssh/sshd_config | grep "^PermitRootLogin" || echo "DefaultValue"', shell=True) ++ PasswordAuthentication = subprocess.check_output('cat /etc/ssh/sshd_config | egrep "^PasswordAuthentication" || echo "DefaultValue"', shell=True) ++ PermitRootLogin = str(PermitRootLogin).strip() ++ PasswordAuthentication = str(PasswordAuthentication).strip() ++ ++ self.produce(ConfigurationSynchronization(sshd_auth_configuration=json.dumps({"PermitRootLogin": PermitRootLogin, "PasswordAuthentication": PasswordAuthentication, }))) +diff --git a/repos/system_upgrade/el7toel8/actors/authenticationconfigurationsynchronizer/actor.py b/repos/system_upgrade/el7toel8/actors/authenticationconfigurationsynchronizer/actor.py +new file mode 100644 +index 0000000..0c10a0b +--- /dev/null ++++ b/repos/system_upgrade/el7toel8/actors/authenticationconfigurationsynchronizer/actor.py +@@ -0,0 +1,37 @@ ++from leapp.actors import Actor ++from leapp.tags import IPUWorkflowTag, ConfigurationSynchronizationPhaseTag ++from leapp.models import ConfigurationSynchronization ++ ++import subprocess ++import json ++ ++ ++class AuthenticationConfigurationSynchronizer(Actor): ++ """ ++ Keep authentication configuration the same after migration. This is synchronization phase. ++ """ ++ ++ name = 'authentication_configuration_synchronizer' ++ consumes = (ConfigurationSynchronization, ) ++ produces = () ++ tags = (IPUWorkflowTag, ConfigurationSynchronizationPhaseTag, ) ++ ++ def process(self): ++ for configuration in self.consume(ConfigurationSynchronization): ++ if configuration.sshd_auth_configuration is None: ++ continue ++ ++ sshd_auth_configuration = json.loads(configuration.sshd_auth_configuration) ++ PermitRootLogin = sshd_auth_configuration["PermitRootLogin"] ++ PasswordAuthentication = sshd_auth_configuration["PasswordAuthentication"] ++ ++ if PermitRootLogin == "DefaultValue": ++ PermitRootLogin = "PermitRootLogin yes" ++ if PasswordAuthentication == "DefaultValue": ++ PasswordAuthentication = "# PasswordAuthentication yes" ++ ++ subprocess.run("sed -i '/PasswordAuthentication/d' /etc/ssh/sshd_config", shell=True) ++ subprocess.run("sed -i '/PermitRootLogin/d' /etc/ssh/sshd_config", shell=True) ++ subprocess.run("sed -i '$a\%s' /etc/ssh/sshd_config" % PasswordAuthentication, shell=True) ++ subprocess.run("sed -i '$a\%s' /etc/ssh/sshd_config" % PermitRootLogin, shell=True) ++ subprocess.run("systemctl restart sshd", shell=True) +diff --git a/repos/system_upgrade/el7toel8/actors/serviceconfigurationsynchronizer/actor.py b/repos/system_upgrade/el7toel8/actors/serviceconfigurationsynchronizer/actor.py +index 9b45d31..5f57b4b 100644 +--- a/repos/system_upgrade/el7toel8/actors/serviceconfigurationsynchronizer/actor.py ++++ b/repos/system_upgrade/el7toel8/actors/serviceconfigurationsynchronizer/actor.py +@@ -90,6 +90,9 @@ class ServiceConfigurationSynchronizer(Actor): + try: + self.log.info("Starting to synchronize services configurations.") + for configuration in self.consume(ConfigurationSynchronization): ++ if configuration.services_configuration is None: ++ continue ++ + services_configuration = json.loads(configuration.services_configuration) + config_report = self.config_services(services_configuration, backup_configuratuon) + +diff --git a/repos/system_upgrade/el7toel8/models/configurationsynchronization.py b/repos/system_upgrade/el7toel8/models/configurationsynchronization.py +index 349ac3d..1133674 100644 +--- a/repos/system_upgrade/el7toel8/models/configurationsynchronization.py ++++ b/repos/system_upgrade/el7toel8/models/configurationsynchronization.py +@@ -4,4 +4,5 @@ from leapp.topics import ConfigurationSynchronizationTopic + class ConfigurationSynchronization(Model): + topic = ConfigurationSynchronizationTopic + services_configuration = fields.Nullable(fields.String()) ++ sshd_auth_configuration = fields.Nullable(fields.String()) + +-- +2.30.1 (Apple Git-130) + diff --git a/0033-Read-the-driver-list-supported-by-ANCK.patch b/0033-Read-the-driver-list-supported-by-ANCK.patch new file mode 100644 index 0000000000000000000000000000000000000000..0746346a3a6fc033fef4c855107b6bcc510eadf5 --- /dev/null +++ b/0033-Read-the-driver-list-supported-by-ANCK.patch @@ -0,0 +1,134 @@ +From 16314396e430511f4afafba0aff83c54e3220689 Mon Sep 17 00:00:00 2001 +From: Bitao Hu +Date: Tue, 15 Nov 2022 15:28:58 +0800 +Subject: [Patch] Read the driver list supported by ANCK to determine driver compatibility problem, when migrating to Anolis8 with ANCK. + +Signed-off-by: Bitao Hu +--- + .../actors/kernel/checkkerneldrivers/actor.py | 16 ++++- + .../files/removed_drivers_anck.txt | 69 +++++++++++++++++++ + ...d_drivers.txt => removed_drivers_rhck.txt} | 0 + 3 files changed, 82 insertions(+), 3 deletions(-) + create mode 100644 repos/system_upgrade/el7toel8/actors/kernel/checkkerneldrivers/files/removed_drivers_anck.txt + rename repos/system_upgrade/el7toel8/actors/kernel/checkkerneldrivers/files/{removed_drivers.txt => removed_drivers_rhck.txt} (100%) + +diff --git a/repos/system_upgrade/el7toel8/actors/kernel/checkkerneldrivers/actor.py b/repos/system_upgrade/el7toel8/actors/kernel/checkkerneldrivers/actor.py +index 19fefc3..6c4b042 100644 +--- a/repos/system_upgrade/el7toel8/actors/kernel/checkkerneldrivers/actor.py ++++ b/repos/system_upgrade/el7toel8/actors/kernel/checkkerneldrivers/actor.py +@@ -4,7 +4,7 @@ from leapp.libraries.actor.checkkerneldrivers import ( + get_present_drivers, + get_removed_drivers, + ) +-from leapp.models import PCIDevices ++from leapp.models import (PCIDevices, CustomTargetRepository) + from leapp.reporting import Report, create_report + from leapp import reporting + from leapp.tags import ChecksPhaseTag, IPUWorkflowTag +@@ -23,12 +23,22 @@ class CheckKernelDrivers(Actor): + files/removed_drivers.txt file. + """ + name = 'check_kernel_drivers' +- consumes = (PCIDevices,) ++ consumes = (PCIDevices, CustomTargetRepository) + produces = (Report,) + tags = (ChecksPhaseTag, IPUWorkflowTag) + + def process(self): +- removed_file = 'files/removed_drivers.txt' ++ toANCK = False ++ removed_file = '' ++ for repo in self.consume(CustomTargetRepository): ++ if repo.repoid == 'anolis_plus': ++ toANCK = True ++ break ++ if toANCK == True: ++ removed_file = 'files/removed_drivers_anck.txt' ++ else: ++ removed_file = 'files/removed_drivers_rhck.txt' ++ + conflicting = check_drivers(get_removed_drivers(removed_file), get_present_drivers()) + + if conflicting: +diff --git a/repos/system_upgrade/el7toel8/actors/kernel/checkkerneldrivers/files/removed_drivers_anck.txt b/repos/system_upgrade/el7toel8/actors/kernel/checkkerneldrivers/files/removed_drivers_anck.txt +new file mode 100644 +index 0000000..1ab9e3e +--- /dev/null ++++ b/repos/system_upgrade/el7toel8/actors/kernel/checkkerneldrivers/files/removed_drivers_anck.txt +@@ -0,0 +1,69 @@ ++# Support for the following device drivers has been removed in Anolis 8. ++ ++at91_ether ++osdblk ++ebt_ulog ++ablk_helper ++pcompress ++salsa20-x86_64 ++zlib ++gve ++hid-lenovo-tpkbd ++hid-ps3remote ++hmcdrv ++iavf ++idma64 ++igc ++ib_ipath ++ipg ++gpio-ir-recv ++ir-lirc-codec ++ir-rc5-sz-decoder ++dell-led ++rtsx_pci ++rtsx_usb ++nft_meta_bridge ++nft_exthdr ++nft_meta ++nft_rbtree ++pata_arasan_cf ++pata_cs5536 ++pch_dma ++pch_gbe ++pch_phub ++ptp_pch ++rtw88 ++rtwpci ++libsrp ++scsi_tgt ++snd-firewire-speakers ++snd-scs1x ++snd-tea575x-tuner ++wacom ++uio_pdrv_genirq ++vringh ++videobuf-dvb ++btcx-risc ++mt9v011 ++output ++stk1160 ++poseidon ++tvp5150 ++w83697hf_wdt ++w83697ug_wdt ++xen-acpi-processor ++dvb-usb-friio ++dvb-usb-it913x ++ipt_ULOG ++xgmac ++sctp_probe ++nf_conntrack_ipv4 ++nf_conntrack_ipv6 ++nfnetlink_cthelper ++libore ++objlayoutdriver ++snd-soc-sst-baytrail-pcm ++stm_p_basic ++stm_p_sys-t ++i7300_idle ++it913x-fe +diff --git a/repos/system_upgrade/el7toel8/actors/kernel/checkkerneldrivers/files/removed_drivers.txt b/repos/system_upgrade/el7toel8/actors/kernel/checkkerneldrivers/files/removed_drivers_rhck.txt +similarity index 100% +rename from repos/system_upgrade/el7toel8/actors/kernel/checkkerneldrivers/files/removed_drivers.txt +rename to repos/system_upgrade/el7toel8/actors/kernel/checkkerneldrivers/files/removed_drivers_rhck.txt +-- +2.27.0 + diff --git a/0034-migrear-grub2-entry-recovery.patch b/0034-migrear-grub2-entry-recovery.patch new file mode 100644 index 0000000000000000000000000000000000000000..969f5c95a6f42c8c02e4c5fd21b3bb5bdc59d153 --- /dev/null +++ b/0034-migrear-grub2-entry-recovery.patch @@ -0,0 +1,54 @@ +From 525785a2ecda253dbb745a104435edec192ec2f8 Mon Sep 17 00:00:00 2001 +From: Weisson +Date: Thu, 8 Dec 2022 15:47:19 +0800 +Subject: [PATCH] migrear grub2 entry recovery. + +Signed-off-by: Weisson +--- + .../actors/dnfupgradetransaction/actor.py | 19 +++++++++++++++++++ + 1 file changed, 19 insertions(+) + +diff --git a/repos/system_upgrade/el7toel8/actors/dnfupgradetransaction/actor.py b/repos/system_upgrade/el7toel8/actors/dnfupgradetransaction/actor.py +index 73e5a83..63bb273 100644 +--- a/repos/system_upgrade/el7toel8/actors/dnfupgradetransaction/actor.py ++++ b/repos/system_upgrade/el7toel8/actors/dnfupgradetransaction/actor.py +@@ -13,6 +13,8 @@ from leapp.models import ( + UsedTargetRepositories, + ) + from leapp.tags import IPUWorkflowTag, RPMUpgradePhaseTag ++import subprocess ++import re + + + class DnfUpgradeTransaction(Actor): +@@ -47,10 +49,27 @@ class DnfUpgradeTransaction(Actor): + tasks = next(self.consume(FilteredRpmTransactionTasks), FilteredRpmTransactionTasks()) + target_userspace_info = next(self.consume(TargetUserSpaceInfo), None) + ++ output = subprocess.check_output("grubby --info=ALL", shell=True).strip() ++ grub_entries = output.split('index=') ++ ++ migrear_entries = [] ++ for entry in grub_entries: ++ if 'title=MigReaR-' in entry: ++ items = re.findall(r"kernel=(.*)\nargs=(.*)\ninitrd=(.*)\ntitle=(.*)\n", entry) ++ if len(items) == 1: ++ migrear_entries += [dict(zip(("kernel", "args", "initrd", "title"), items[0]))] ++ + dnfplugin.perform_transaction_install( + tasks=tasks, used_repos=used_repos, storage_info=storage_info, target_userspace_info=target_userspace_info, + plugin_info=plugin_info + ) ++ ++ for entry in migrear_entries: ++ try: ++ subprocess.check_call("grubby --add-kernel %s --initrd %s --args=%s --title=%s" % (entry['kernel'], entry['initrd'], entry['args'], entry['title']), shell=True) ++ except Exception as e: ++ self.log.info(" ".join(["Failed restore migrear entry", str(entry), "Exception:", str(e)]), exc_info=True) ++ + self.produce(TransactionCompleted()) + userspace = next(self.consume(TargetUserSpaceInfo), None) + if userspace: +-- +2.30.1 (Apple Git-130) + diff --git a/leapp-repository.spec b/leapp-repository.spec index 45428dd77a535570523859e66ff13674660a67e8..978d3a307c1f4eba163e800ce462b7c52c6b064c 100644 --- a/leapp-repository.spec +++ b/leapp-repository.spec @@ -11,7 +11,7 @@ }\ py2_byte_compile "%1" "%2"} -%define anolis_release 2 +%define anolis_release 10 Name: leapp-repository Version: 0.13.0 @@ -52,6 +52,14 @@ Patch23: 0023-fix-kernel-version-check-of-anolis-kernel.patch Patch24: 0024-remove-unofficial-url.patch Patch25: 0025-add-check-openssl11-libs.patch Patch26: 0026-Add-checkbaota-actor.patch +Patch27: 0027-upgrade-write-efi-vars-for-ecs-firmware.patch +Patch28: 0028-add-disablerepo-option-to-upgrade-kernel-to-RHCK.patch +Patch29: 0029-Service-configuration-remains-after-migration.patch +Patch30: 0030-fix-subprocess-check_output-method-for-backup-service-configuration.patch +Patch31: 0031-Deal-with-EPEL-repositories-create-by-user-mannally.patch +Patch32: 0032-Keep-PermitRootLogin-authentication-behavior-after-m.patch +Patch33: 0033-Read-the-driver-list-supported-by-ANCK.patch +Patch34: 0034-migrear-grub2-entry-recovery.patch BuildArch: noarch BuildRequires: python-devel @@ -174,6 +182,30 @@ done; # no files here %changelog +* Thu Dec 8 2022 Weisson - 0.13.0-2.10 +- Migrear grub2 entry recovery is supported. + +* Thu Nov 15 2022 Bitao Hu - 0.13.0-2.9 +- Read the driver list supported by ANCK to determine driver compatibility problem, when migrating to Anolis8 with ANCK. + +* Sun Nov 13 2022 Weisson - 0.13.0-2.8 +- Keep PermitRootLogin authentication behavior after migration. + +* Thu Sep 29 2022 Weisson - 0.13.0-2.7 +- deal with user create EPEL repository file + +* Tue Sep 13 2022 mgb01105731 - 0.13.0-2.6 +- add disablerepo option to upgrade kernel to RHCK + +* Tue Sep 6 2022 Weisson - 0.13.0-2.5 +- Service configuration remains after migration + +* Tue Sep 6 2022 mgb01105731 - 0.13.0-2.4 +- support upgrade kernel to ANCK + +* Thu Sep 1 2022 Liwei Ge - 0.13.0-2.3 +- Write efi vars for ecs firmware + * Tue Jun 14 2022 Weitao Zhou - 0.13.0-2.2 - Add checkbaota actor diff --git a/leapp_upgrade_repositories.repo b/leapp_upgrade_repositories.repo index 818fcc90f371fac8d0736a74e1e0f7778d1e8e9f..aca4db5b1ef4e22026f9b2cd0e854a1de87621c1 100644 --- a/leapp_upgrade_repositories.repo +++ b/leapp_upgrade_repositories.repo @@ -1,19 +1,31 @@ [anolis_baseos] name=anolis baseos -baseurl=http://mirrors.openanolis.org/anolis/8/BaseOS/$basearch/os +baseurl=https://mirrors.openanolis.cn/anolis/8/BaseOS/$basearch/os gpgcheck=0 [anolis_appstream] name=anolis appstream -baseurl=http://mirrors.openanolis.org/anolis/8/AppStream/$basearch/os +baseurl=https://mirrors.openanolis.cn/anolis/8/AppStream/$basearch/os gpgcheck=0 [anolis_powertools] name=anolis powertools -baseurl=http://mirrors.openanolis.org/anolis/8/PowerTools/$basearch/os +baseurl=https://mirrors.openanolis.cn/anolis/8/PowerTools/$basearch/os gpgcheck=0 [anolis_highavailability] name=anolis highavailability -baseurl=http://mirrors.openanolis.org/anolis/8/HighAvailability/$basearch/os +baseurl=https://mirrors.openanolis.cn/anolis/8/HighAvailability/$basearch/os +gpgcheck=0 + +[anolis_plus] +name=anolis plus +baseurl=https://mirrors.openanolis.cn/anolis/8/Plus/$basearch/os +gpgcheck=0 +enabled=1 + +[anolis_extras] +name=anolis extras +baseurl=http://mirrors.openanolis.cn/anolis/$releasever/Extras/$basearch/os +enabled=1 gpgcheck=0