Backport patches for improvement of Zchunk

This commit is contained in:
Jaroslav Mracek 2019-02-19 15:00:17 +01:00
parent 93a6b2d244
commit cca5ea360d
3 changed files with 130 additions and 1 deletions

View File

@ -0,0 +1,34 @@
From d696a96249a7bf2e71977594a278a86b06e50cb6 Mon Sep 17 00:00:00 2001
From: Jonathan Dieter <jdieter@gmail.com>
Date: Sat, 22 Dec 2018 16:56:59 +0000
Subject: [PATCH] Zchunk configuration flags were backwards, so setting zchunk=false would
---
libdnf/repo/Repo.cpp | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/libdnf/repo/Repo.cpp b/libdnf/repo/Repo.cpp
index 42823e7..7c0e464 100644
--- a/libdnf/repo/Repo.cpp
+++ b/libdnf/repo/Repo.cpp
@@ -575,7 +575,7 @@ std::unique_ptr<LrHandle> Repo::Impl::lrHandleInitLocal()
handleSetOpt(h.get(), LRO_LOCAL, 1L);
#ifdef LRO_SUPPORTS_CACHEDIR
/* If zchunk is enabled, set librepo cache dir */
- if (!conf->getMasterConfig().zchunk().getValue())
+ if (conf->getMasterConfig().zchunk().getValue())
handleSetOpt(h.get(), LRO_CACHEDIR, conf->basecachedir().getValue().c_str());
#endif
return h;
@@ -662,7 +662,7 @@ std::unique_ptr<LrHandle> Repo::Impl::lrHandleInitRemote(const char *destdir, bo
#ifdef LRO_SUPPORTS_CACHEDIR
/* If zchunk is enabled, set librepo cache dir */
- if (!conf->getMasterConfig().zchunk().getValue())
+ if (conf->getMasterConfig().zchunk().getValue())
handleSetOpt(h.get(), LRO_CACHEDIR, conf->basecachedir().getValue().c_str());
#endif
--
libgit2 0.27.7

View File

@ -0,0 +1,90 @@
From d5e661a8eae27fb6108f54d924ac0af709696c60 Mon Sep 17 00:00:00 2001
From: Jonathan Dieter <jdieter@gmail.com>
Date: Sat, 22 Dec 2018 17:01:13 +0000
Subject: [PATCH] hy_repos weren't being filled properly when using zchunk metadata, so this
---
libdnf/dnf-repo.cpp | 35 +++++++++++++++++++++++++++--------
libdnf/repo/Repo.cpp | 17 ++++++++++++++++-
2 files changed, 43 insertions(+), 9 deletions(-)
diff --git a/libdnf/dnf-repo.cpp b/libdnf/dnf-repo.cpp
index 1cf762b..3357af2 100644
--- a/libdnf/dnf-repo.cpp
+++ b/libdnf/dnf-repo.cpp
@@ -1439,14 +1439,33 @@ dnf_repo_check_internal(DnfRepo *repo,
hy_repo_free(priv->repo);
priv->repo = hy_repo_create(priv->id);
hy_repo_set_string(priv->repo, HY_REPO_MD_FN, yum_repo->repomd);
- tmp = static_cast<const gchar *>(g_hash_table_lookup(priv->filenames_md, "primary"));
- hy_repo_set_string(priv->repo, HY_REPO_PRIMARY_FN, tmp);
- tmp = static_cast<const gchar *>(g_hash_table_lookup(priv->filenames_md, "filelists"));
- hy_repo_set_string(priv->repo, HY_REPO_FILELISTS_FN, tmp);
- tmp = static_cast<const gchar *>(g_hash_table_lookup(priv->filenames_md, "updateinfo"));
- hy_repo_set_string(priv->repo, HY_REPO_UPDATEINFO_FN, tmp);
- tmp = static_cast<const gchar *>(g_hash_table_lookup(priv->filenames_md, "modules"));
- hy_repo_set_string(priv->repo, MODULES_FN, tmp);
+ if (dnf_context_get_zchunk(priv->context)) {
+ tmp = static_cast<const gchar *>(g_hash_table_lookup(priv->filenames_md, "primary_zck"));
+ if(!tmp)
+ tmp = static_cast<const gchar *>(g_hash_table_lookup(priv->filenames_md, "primary"));
+ hy_repo_set_string(priv->repo, HY_REPO_PRIMARY_FN, tmp);
+ tmp = static_cast<const gchar *>(g_hash_table_lookup(priv->filenames_md, "filelists_zck"));
+ if(!tmp)
+ tmp = static_cast<const gchar *>(g_hash_table_lookup(priv->filenames_md, "filelists"));
+ hy_repo_set_string(priv->repo, HY_REPO_FILELISTS_FN, tmp);
+ tmp = static_cast<const gchar *>(g_hash_table_lookup(priv->filenames_md, "updateinfo_zck"));
+ if(!tmp)
+ tmp = static_cast<const gchar *>(g_hash_table_lookup(priv->filenames_md, "updateinfo"));
+ hy_repo_set_string(priv->repo, HY_REPO_UPDATEINFO_FN, tmp);
+ tmp = static_cast<const gchar *>(g_hash_table_lookup(priv->filenames_md, "modules_zck"));
+ if(!tmp)
+ tmp = static_cast<const gchar *>(g_hash_table_lookup(priv->filenames_md, "modules"));
+ hy_repo_set_string(priv->repo, MODULES_FN, tmp);
+ } else {
+ tmp = static_cast<const gchar *>(g_hash_table_lookup(priv->filenames_md, "primary"));
+ hy_repo_set_string(priv->repo, HY_REPO_PRIMARY_FN, tmp);
+ tmp = static_cast<const gchar *>(g_hash_table_lookup(priv->filenames_md, "filelists"));
+ hy_repo_set_string(priv->repo, HY_REPO_FILELISTS_FN, tmp);
+ tmp = static_cast<const gchar *>(g_hash_table_lookup(priv->filenames_md, "updateinfo"));
+ hy_repo_set_string(priv->repo, HY_REPO_UPDATEINFO_FN, tmp);
+ tmp = static_cast<const gchar *>(g_hash_table_lookup(priv->filenames_md, "modules"));
+ hy_repo_set_string(priv->repo, MODULES_FN, tmp);
+ }
/* ensure we reset the values from the keyfile */
if (!dnf_repo_set_keyfile_data(repo, error))
diff --git a/libdnf/repo/Repo.cpp b/libdnf/repo/Repo.cpp
index 7c0e464..98279e6 100644
--- a/libdnf/repo/Repo.cpp
+++ b/libdnf/repo/Repo.cpp
@@ -275,10 +275,25 @@ private:
delete[] *item;
delete[] ptr;
}};
+ bool endsWith(std::string const &str, std::string const &ending) const;
};
+bool Repo::Impl::endsWith(const std::string &str, const std::string &ending) const {
+ if (str.length() >= ending.length())
+ return (str.compare(str.length() - ending.length(), ending.length(), ending) == 0);
+ else
+ return false;
+}
+
std::string Repo::Impl::getMetadataPath(const std::string &metadataType) const {
- auto it = metadataPaths.find(metadataType);
+ std::string lookupMetadataType = metadataType;
+ if (conf->getMasterConfig().zchunk().getValue()) {
+ if(!endsWith(metadataType, "_zck"))
+ lookupMetadataType = metadataType + "_zck";
+ }
+ auto it = metadataPaths.find(lookupMetadataType);
+ if(it == metadataPaths.end() && lookupMetadataType != metadataType)
+ it = metadataPaths.find(metadataType);
return (it != metadataPaths.end()) ? it->second : "";
}
--
libgit2 0.27.7

View File

@ -31,12 +31,14 @@
Name: libdnf
Version: 0.26.0
Release: 1%{?dist}
Release: 2%{?dist}
Summary: Library providing simplified C and Python API to libsolv
License: LGPLv2+
URL: https://github.com/rpm-software-management/libdnf
Source0: %{url}/archive/%{version}/%{name}-%{version}.tar.gz
Patch0001: 0001-Revert-9309e92332241ff1113433057c969cebf127734e.patch
Patch0002: 0002-Zchunk-configuration-flags-were-backwards-so-setting-zchunkfalse-would.patch
Patch0003: 0003-hy_repos-werent-being-filled-properly-when-using-zchunk-metadata-so-this.patch
BuildRequires: cmake
BuildRequires: gcc
@ -246,6 +248,9 @@ popd
%endif
%changelog
* Tue Feb 19 2019 Jaroslav Mracek <jmracek@redhat.com> - 0.26.0-2
- Backport patches for zchunk
* Wed Feb 13 2019 Pavla Kratochvilova <pkratoch@redhat.com> - 0.26.0-1
- Update to 0.26.0-1
- Enhance modular solver to handle enabled and default module streams differently (RhBug:1648839)