From f663736a844a73e13d7cd85bb79a79f2a2bf24e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ladislav=20Slez=C3=A1k?= Date: Tue, 18 Aug 2020 13:41:00 +0200 Subject: [PATCH] Fixed saving service files (bsc#1171977) - Fixed migration from SLE-HPC-12 with activated HPC module to SLE15-SP2 - 4.2.9 --- package/yast2-pkg-bindings-devel-doc.spec | 2 +- package/yast2-pkg-bindings.changes | 7 +++++ package/yast2-pkg-bindings.spec | 2 +- src/ServiceManager.cc | 31 ++++++++++++++++++----- 4 files changed, 34 insertions(+), 8 deletions(-) diff --git a/package/yast2-pkg-bindings-devel-doc.spec b/package/yast2-pkg-bindings-devel-doc.spec index c5e9774b..ed6816b1 100644 --- a/package/yast2-pkg-bindings-devel-doc.spec +++ b/package/yast2-pkg-bindings-devel-doc.spec @@ -16,7 +16,7 @@ # Name: yast2-pkg-bindings-devel-doc -Version: 4.2.8 +Version: 4.2.9 Release: 0 License: GPL-2.0-only Group: Documentation/HTML diff --git a/package/yast2-pkg-bindings.changes b/package/yast2-pkg-bindings.changes index d9ae1bda..41b81bd9 100644 --- a/package/yast2-pkg-bindings.changes +++ b/package/yast2-pkg-bindings.changes @@ -1,3 +1,10 @@ +------------------------------------------------------------------- +Mon Aug 17 07:23:30 UTC 2020 - Ladislav Slezák + +- Fixed migration from SLE-HPC-12 with activated HPC module to + SLE15-SP2 (fixed saving service files) (bsc#1171977) +- 4.2.9 + ------------------------------------------------------------------- Fri Jul 10 09:24:53 CEST 2020 - aschnell@suse.com diff --git a/package/yast2-pkg-bindings.spec b/package/yast2-pkg-bindings.spec index 835630cd..a020c59d 100644 --- a/package/yast2-pkg-bindings.spec +++ b/package/yast2-pkg-bindings.spec @@ -17,7 +17,7 @@ Name: yast2-pkg-bindings -Version: 4.2.8 +Version: 4.2.9 Release: 0 BuildRoot: %{_tmppath}/%{name}-%{version}-build diff --git a/src/ServiceManager.cc b/src/ServiceManager.cc index 9a6a7e9c..5894f469 100644 --- a/src/ServiceManager.cc +++ b/src/ServiceManager.cc @@ -19,6 +19,7 @@ */ #include +#include #include "log.h" #include "ServiceManager.h" @@ -332,14 +333,21 @@ void ServiceManager::SavePkgService(PkgService &s_known, zypp::RepoManager &repo DBG << "Known Service: " << s_known << std::endl; DBG << "Stored Service: " << s_stored << std::endl; + DBG << "orig_alias: " << orig_alias.c_str() << std::endl; + zypp::Pathname file_path = s_stored.filepath(); + DBG << "Service file exists: " << zypp::PathInfo(file_path).isExist() << std::endl; - y2debug("orig_alias: %s", orig_alias.c_str()); - - // already saved? - // Checking if the service file still exists at all. - if (s_stored == zypp::ServiceInfo::noService || - !zypp::PathInfo(s_stored.filepath()).isExist()) + // already defined? + if (s_stored == zypp::ServiceInfo::noService) { + // remove the file if it already exists + // (a corner case, the libzypp loaded is data out of sync with the disk content) + if (zypp::PathInfo(file_path).isExist()) + { + MIL << "removing file " << file_path << std::endl; + zypp::filesystem::unlink(file_path); + } + y2milestone("Adding new service %s", alias.c_str()); // add the service repomgr.addService(s_known); @@ -348,6 +356,17 @@ void ServiceManager::SavePkgService(PkgService &s_known, zypp::RepoManager &repo } else { + // create the file if it is missing + // (a corner case, the libzypp loaded is data out of sync with the disk content) + if (!zypp::PathInfo(file_path).isExist()) + { + MIL << "creating file " << file_path << std::endl; + std::ofstream srv_stream; + srv_stream.open(file_path.asString()); + s_known.dumpAsIniOn(srv_stream); + srv_stream.close(); + } + y2milestone("Saving service %s", alias.c_str()); // use the old alias repomgr.modifyService(orig_alias, s_known);