Skip to content

Commit

Permalink
Merge pull request #135 from yast/bsc_1171977
Browse files Browse the repository at this point in the history
  • Loading branch information
lslezak committed Sep 25, 2020
2 parents 270c83e + 6b17868 commit c5a6fec
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package/yast2-pkg-bindings-devel-doc.spec
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions package/yast2-pkg-bindings.changes
@@ -1,3 +1,10 @@
-------------------------------------------------------------------
Mon Aug 17 07:23:30 UTC 2020 - Ladislav Slezák <lslezak@suse.cz>

- 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

Expand Down
2 changes: 1 addition & 1 deletion package/yast2-pkg-bindings.spec
Expand Up @@ -17,7 +17,7 @@


Name: yast2-pkg-bindings
Version: 4.2.8
Version: 4.2.9
Release: 0

BuildRoot: %{_tmppath}/%{name}-%{version}-build
Expand Down
31 changes: 25 additions & 6 deletions src/ServiceManager.cc
Expand Up @@ -19,6 +19,7 @@
*/

#include <ostream>
#include <fstream>

#include "log.h"
#include "ServiceManager.h"
Expand Down Expand Up @@ -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 data is 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);
Expand All @@ -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 data is 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);
Expand Down

0 comments on commit c5a6fec

Please sign in to comment.