From cca5ea360defa8992666a9ecfeeb2f3e1388f3c2 Mon Sep 17 00:00:00 2001 From: Jaroslav Mracek Date: Tue, 19 Feb 2019 15:00:17 +0100 Subject: [PATCH] Backport patches for improvement of Zchunk --- ...ckwards-so-setting-zchunkfalse-would.patch | 34 +++++++ ...y-when-using-zchunk-metadata-so-this.patch | 90 +++++++++++++++++++ libdnf.spec | 7 +- 3 files changed, 130 insertions(+), 1 deletion(-) create mode 100644 0002-Zchunk-configuration-flags-were-backwards-so-setting-zchunkfalse-would.patch create mode 100644 0003-hy_repos-werent-being-filled-properly-when-using-zchunk-metadata-so-this.patch diff --git a/0002-Zchunk-configuration-flags-were-backwards-so-setting-zchunkfalse-would.patch b/0002-Zchunk-configuration-flags-were-backwards-so-setting-zchunkfalse-would.patch new file mode 100644 index 0000000..8ef6123 --- /dev/null +++ b/0002-Zchunk-configuration-flags-were-backwards-so-setting-zchunkfalse-would.patch @@ -0,0 +1,34 @@ +From d696a96249a7bf2e71977594a278a86b06e50cb6 Mon Sep 17 00:00:00 2001 +From: Jonathan Dieter +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 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 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 + diff --git a/0003-hy_repos-werent-being-filled-properly-when-using-zchunk-metadata-so-this.patch b/0003-hy_repos-werent-being-filled-properly-when-using-zchunk-metadata-so-this.patch new file mode 100644 index 0000000..15cc807 --- /dev/null +++ b/0003-hy_repos-werent-being-filled-properly-when-using-zchunk-metadata-so-this.patch @@ -0,0 +1,90 @@ +From d5e661a8eae27fb6108f54d924ac0af709696c60 Mon Sep 17 00:00:00 2001 +From: Jonathan Dieter +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(g_hash_table_lookup(priv->filenames_md, "primary")); +- hy_repo_set_string(priv->repo, HY_REPO_PRIMARY_FN, tmp); +- tmp = static_cast(g_hash_table_lookup(priv->filenames_md, "filelists")); +- hy_repo_set_string(priv->repo, HY_REPO_FILELISTS_FN, tmp); +- tmp = static_cast(g_hash_table_lookup(priv->filenames_md, "updateinfo")); +- hy_repo_set_string(priv->repo, HY_REPO_UPDATEINFO_FN, tmp); +- tmp = static_cast(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(g_hash_table_lookup(priv->filenames_md, "primary_zck")); ++ if(!tmp) ++ tmp = static_cast(g_hash_table_lookup(priv->filenames_md, "primary")); ++ hy_repo_set_string(priv->repo, HY_REPO_PRIMARY_FN, tmp); ++ tmp = static_cast(g_hash_table_lookup(priv->filenames_md, "filelists_zck")); ++ if(!tmp) ++ tmp = static_cast(g_hash_table_lookup(priv->filenames_md, "filelists")); ++ hy_repo_set_string(priv->repo, HY_REPO_FILELISTS_FN, tmp); ++ tmp = static_cast(g_hash_table_lookup(priv->filenames_md, "updateinfo_zck")); ++ if(!tmp) ++ tmp = static_cast(g_hash_table_lookup(priv->filenames_md, "updateinfo")); ++ hy_repo_set_string(priv->repo, HY_REPO_UPDATEINFO_FN, tmp); ++ tmp = static_cast(g_hash_table_lookup(priv->filenames_md, "modules_zck")); ++ if(!tmp) ++ tmp = static_cast(g_hash_table_lookup(priv->filenames_md, "modules")); ++ hy_repo_set_string(priv->repo, MODULES_FN, tmp); ++ } else { ++ tmp = static_cast(g_hash_table_lookup(priv->filenames_md, "primary")); ++ hy_repo_set_string(priv->repo, HY_REPO_PRIMARY_FN, tmp); ++ tmp = static_cast(g_hash_table_lookup(priv->filenames_md, "filelists")); ++ hy_repo_set_string(priv->repo, HY_REPO_FILELISTS_FN, tmp); ++ tmp = static_cast(g_hash_table_lookup(priv->filenames_md, "updateinfo")); ++ hy_repo_set_string(priv->repo, HY_REPO_UPDATEINFO_FN, tmp); ++ tmp = static_cast(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 + diff --git a/libdnf.spec b/libdnf.spec index 836e54d..692a1e1 100644 --- a/libdnf.spec +++ b/libdnf.spec @@ -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 - 0.26.0-2 +- Backport patches for zchunk + * Wed Feb 13 2019 Pavla Kratochvilova - 0.26.0-1 - Update to 0.26.0-1 - Enhance modular solver to handle enabled and default module streams differently (RhBug:1648839)