|
|
844bdb |
From 27112644c0e17510fa8e07ba4949b9fbd89655bc Mon Sep 17 00:00:00 2001
|
|
|
844bdb |
From: Jaroslav Mracek <jmracek@redhat.com>
|
|
|
844bdb |
Date: Thu, 17 Jan 2019 16:04:48 +0100
|
|
|
844bdb |
Subject: [PATCH] Add support for Module advisories
|
|
|
844bdb |
|
|
|
844bdb |
---
|
|
|
844bdb |
libdnf/sack/CMakeLists.txt | 1 +
|
|
|
844bdb |
libdnf/sack/advisory.cpp | 21 +++++++++++++++++++++
|
|
|
844bdb |
libdnf/sack/advisory.hpp | 2 ++
|
|
|
844bdb |
libdnf/sack/advisorymodule.cpp | 113 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
|
844bdb |
libdnf/sack/advisorymodule.hpp | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
|
844bdb |
5 files changed, 195 insertions(+)
|
|
|
844bdb |
create mode 100644 libdnf/sack/advisorymodule.cpp
|
|
|
844bdb |
create mode 100644 libdnf/sack/advisorymodule.hpp
|
|
|
844bdb |
|
|
|
844bdb |
diff --git a/libdnf/sack/CMakeLists.txt b/libdnf/sack/CMakeLists.txt
|
|
|
844bdb |
index e1c6be1..9921c74 100644
|
|
|
844bdb |
--- a/libdnf/sack/CMakeLists.txt
|
|
|
844bdb |
+++ b/libdnf/sack/CMakeLists.txt
|
|
|
844bdb |
@@ -1,6 +1,7 @@
|
|
|
844bdb |
SET (SACK_SOURCES
|
|
|
844bdb |
${SACK_SOURCES}
|
|
|
844bdb |
${CMAKE_CURRENT_SOURCE_DIR}/advisory.cpp
|
|
|
844bdb |
+ ${CMAKE_CURRENT_SOURCE_DIR}/advisorymodule.cpp
|
|
|
844bdb |
${CMAKE_CURRENT_SOURCE_DIR}/advisorypkg.cpp
|
|
|
844bdb |
${CMAKE_CURRENT_SOURCE_DIR}/advisoryref.cpp
|
|
|
844bdb |
${CMAKE_CURRENT_SOURCE_DIR}/packageset.cpp
|
|
|
844bdb |
diff --git a/libdnf/sack/advisory.cpp b/libdnf/sack/advisory.cpp
|
|
|
844bdb |
index d006bcc..bb9e7f4 100644
|
|
|
844bdb |
--- a/libdnf/sack/advisory.cpp
|
|
|
844bdb |
+++ b/libdnf/sack/advisory.cpp
|
|
|
844bdb |
@@ -24,6 +24,7 @@
|
|
|
844bdb |
|
|
|
844bdb |
#include "advisory.hpp"
|
|
|
844bdb |
#include "advisorypkg.hpp"
|
|
|
844bdb |
+#include "advisorymodule.hpp"
|
|
|
844bdb |
#include "advisoryref.hpp"
|
|
|
844bdb |
#include "../dnf-advisory-private.hpp"
|
|
|
844bdb |
#include "../dnf-advisoryref.h"
|
|
|
844bdb |
@@ -133,6 +134,26 @@ Advisory::getPackages(std::vector<AdvisoryPkg> & pkglist, bool withFilemanes) co
|
|
|
844bdb |
dataiterator_free(&di);
|
|
|
844bdb |
}
|
|
|
844bdb |
|
|
|
844bdb |
+std::vector<AdvisoryModule> Advisory::getModules() const
|
|
|
844bdb |
+{
|
|
|
844bdb |
+ std::vector<AdvisoryModule> moduleList;
|
|
|
844bdb |
+ Dataiterator di;
|
|
|
844bdb |
+ Pool *pool = dnf_sack_get_pool(sack);
|
|
|
844bdb |
+
|
|
|
844bdb |
+ dataiterator_init(&di, pool, 0, advisory, UPDATE_MODULE, 0, 0);
|
|
|
844bdb |
+ while (dataiterator_step(&di)) {
|
|
|
844bdb |
+ dataiterator_setpos(&di);
|
|
|
844bdb |
+ Id name = pool_lookup_id(pool, SOLVID_POS, UPDATE_MODULE_NAME);
|
|
|
844bdb |
+ Id stream = pool_lookup_id(pool, SOLVID_POS, UPDATE_MODULE_STREAM);
|
|
|
844bdb |
+ Id version = pool_lookup_id(pool, SOLVID_POS, UPDATE_MODULE_VERSION);
|
|
|
844bdb |
+ Id context = pool_lookup_id(pool, SOLVID_POS, UPDATE_MODULE_CONTEXT);
|
|
|
844bdb |
+ Id arch = pool_lookup_id(pool, SOLVID_POS, UPDATE_MODULE_ARCH);
|
|
|
844bdb |
+ moduleList.emplace_back(sack, advisory, name, stream, version, context, arch);
|
|
|
844bdb |
+ }
|
|
|
844bdb |
+ dataiterator_free(&di);
|
|
|
844bdb |
+ return moduleList;
|
|
|
844bdb |
+}
|
|
|
844bdb |
+
|
|
|
844bdb |
void
|
|
|
844bdb |
Advisory::getReferences(std::vector<AdvisoryRef> & reflist) const
|
|
|
844bdb |
{
|
|
|
844bdb |
diff --git a/libdnf/sack/advisory.hpp b/libdnf/sack/advisory.hpp
|
|
|
844bdb |
index 3771257..5aa8dc6 100644
|
|
|
844bdb |
--- a/libdnf/sack/advisory.hpp
|
|
|
844bdb |
+++ b/libdnf/sack/advisory.hpp
|
|
|
844bdb |
@@ -33,15 +33,17 @@
|
|
|
844bdb |
namespace libdnf {
|
|
|
844bdb |
|
|
|
844bdb |
struct AdvisoryPkg;
|
|
|
844bdb |
+struct AdvisoryModule;
|
|
|
844bdb |
|
|
|
844bdb |
struct Advisory {
|
|
|
844bdb |
public:
|
|
|
844bdb |
Advisory(DnfSack *sack, Id advisory);
|
|
|
844bdb |
bool operator ==(const Advisory & other) const;
|
|
|
844bdb |
const char *getDescription() const;
|
|
|
844bdb |
DnfAdvisoryKind getKind() const;
|
|
|
844bdb |
const char *getName() const;
|
|
|
844bdb |
void getPackages(std::vector<AdvisoryPkg> & pkglist, bool withFilemanes = true) const;
|
|
|
844bdb |
+ std::vector<AdvisoryModule> getModules() const;
|
|
|
844bdb |
void getReferences(std::vector<AdvisoryRef> & reflist) const;
|
|
|
844bdb |
const char *getRights() const;
|
|
|
844bdb |
const char *getSeverity() const;
|
|
|
844bdb |
diff --git a/libdnf/sack/advisorymodule.cpp b/libdnf/sack/advisorymodule.cpp
|
|
|
844bdb |
new file mode 100644
|
|
|
844bdb |
index 0000000..a209b5f
|
|
|
844bdb |
--- /dev/null
|
|
|
844bdb |
+++ b/libdnf/sack/advisorymodule.cpp
|
|
|
844bdb |
@@ -0,0 +1,113 @@
|
|
|
844bdb |
+/*
|
|
|
844bdb |
+ * Copyright (C) 2019 Red Hat, Inc.
|
|
|
844bdb |
+ *
|
|
|
844bdb |
+ * Licensed under the GNU Lesser General Public License Version 2.1
|
|
|
844bdb |
+ *
|
|
|
844bdb |
+ * This library is free software; you can redistribute it and/or
|
|
|
844bdb |
+ * modify it under the terms of the GNU Lesser General Public
|
|
|
844bdb |
+ * License as published by the Free Software Foundation; either
|
|
|
844bdb |
+ * version 2.1 of the License, or (at your option) any later version.
|
|
|
844bdb |
+ *
|
|
|
844bdb |
+ * This library is distributed in the hope that it will be useful,
|
|
|
844bdb |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
844bdb |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
844bdb |
+ * Lesser General Public License for more details.
|
|
|
844bdb |
+ *
|
|
|
844bdb |
+ * You should have received a copy of the GNU Lesser General Public
|
|
|
844bdb |
+ * License along with this library; if not, write to the Free Software
|
|
|
844bdb |
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
844bdb |
+ */
|
|
|
844bdb |
+
|
|
|
844bdb |
+#include <string>
|
|
|
844bdb |
+
|
|
|
844bdb |
+#include <solv/poolid.h>
|
|
|
844bdb |
+
|
|
|
844bdb |
+#include "advisory.hpp"
|
|
|
844bdb |
+#include "advisorymodule.hpp"
|
|
|
844bdb |
+#include "../dnf-sack-private.hpp"
|
|
|
844bdb |
+
|
|
|
844bdb |
+namespace libdnf {
|
|
|
844bdb |
+
|
|
|
844bdb |
+class AdvisoryModule::Impl {
|
|
|
844bdb |
+private:
|
|
|
844bdb |
+ friend AdvisoryModule;
|
|
|
844bdb |
+ DnfSack *sack;
|
|
|
844bdb |
+ Id advisory;
|
|
|
844bdb |
+ Id name;
|
|
|
844bdb |
+ Id stream;
|
|
|
844bdb |
+ Id version;
|
|
|
844bdb |
+ Id context;
|
|
|
844bdb |
+ Id arch;
|
|
|
844bdb |
+};
|
|
|
844bdb |
+
|
|
|
844bdb |
+AdvisoryModule::AdvisoryModule(DnfSack *sack, Id advisory, Id name, Id stream, Id version, Id context, Id arch) : pImpl(new Impl)
|
|
|
844bdb |
+{
|
|
|
844bdb |
+ pImpl->sack = sack;
|
|
|
844bdb |
+ pImpl->advisory = advisory;
|
|
|
844bdb |
+ pImpl->name = name;
|
|
|
844bdb |
+ pImpl->stream = stream;
|
|
|
844bdb |
+ pImpl->version = version;
|
|
|
844bdb |
+ pImpl->context = context;
|
|
|
844bdb |
+ pImpl->arch = arch;
|
|
|
844bdb |
+}
|
|
|
844bdb |
+AdvisoryModule::AdvisoryModule(const AdvisoryModule & src) : pImpl(new Impl) { *pImpl = *src.pImpl; }
|
|
|
844bdb |
+AdvisoryModule::AdvisoryModule(AdvisoryModule && src) : pImpl(new Impl) { pImpl.swap(src.pImpl); }
|
|
|
844bdb |
+AdvisoryModule::~AdvisoryModule() = default;
|
|
|
844bdb |
+
|
|
|
844bdb |
+AdvisoryModule & AdvisoryModule::operator=(const AdvisoryModule & src) { *pImpl = *src.pImpl; return *this; }
|
|
|
844bdb |
+
|
|
|
844bdb |
+AdvisoryModule &
|
|
|
844bdb |
+AdvisoryModule::operator=(AdvisoryModule && src) noexcept
|
|
|
844bdb |
+{
|
|
|
844bdb |
+ pImpl.swap(src.pImpl);
|
|
|
844bdb |
+ return *this;
|
|
|
844bdb |
+}
|
|
|
844bdb |
+
|
|
|
844bdb |
+bool
|
|
|
844bdb |
+AdvisoryModule::nsvcaEQ(AdvisoryModule & other)
|
|
|
844bdb |
+{
|
|
|
844bdb |
+ return other.pImpl->name == pImpl->name &&
|
|
|
844bdb |
+ other.pImpl->stream == pImpl->stream &&
|
|
|
844bdb |
+ other.pImpl->version == pImpl->version &&
|
|
|
844bdb |
+ other.pImpl->context == pImpl->context &&
|
|
|
844bdb |
+ other.pImpl->arch == pImpl->arch;
|
|
|
844bdb |
+}
|
|
|
844bdb |
+
|
|
|
844bdb |
+Advisory * AdvisoryModule::getAdvisory() const
|
|
|
844bdb |
+{
|
|
|
844bdb |
+ return new Advisory(pImpl->sack, pImpl->advisory);
|
|
|
844bdb |
+}
|
|
|
844bdb |
+
|
|
|
844bdb |
+const char *
|
|
|
844bdb |
+AdvisoryModule::getName() const
|
|
|
844bdb |
+{
|
|
|
844bdb |
+ return pool_id2str(dnf_sack_get_pool(pImpl->sack), pImpl->name);
|
|
|
844bdb |
+}
|
|
|
844bdb |
+
|
|
|
844bdb |
+const char *
|
|
|
844bdb |
+AdvisoryModule::getStream() const
|
|
|
844bdb |
+{
|
|
|
844bdb |
+ return pool_id2str(dnf_sack_get_pool(pImpl->sack), pImpl->stream);
|
|
|
844bdb |
+}
|
|
|
844bdb |
+
|
|
|
844bdb |
+const char *
|
|
|
844bdb |
+AdvisoryModule::getVersion() const
|
|
|
844bdb |
+{
|
|
|
844bdb |
+ return pool_id2str(dnf_sack_get_pool(pImpl->sack), pImpl->version);
|
|
|
844bdb |
+}
|
|
|
844bdb |
+
|
|
|
844bdb |
+const char *
|
|
|
844bdb |
+AdvisoryModule::getContext() const
|
|
|
844bdb |
+{
|
|
|
844bdb |
+ return pool_id2str(dnf_sack_get_pool(pImpl->sack), pImpl->context);
|
|
|
844bdb |
+}
|
|
|
844bdb |
+
|
|
|
844bdb |
+const char *
|
|
|
844bdb |
+AdvisoryModule::getArch() const
|
|
|
844bdb |
+{
|
|
|
844bdb |
+ return pool_id2str(dnf_sack_get_pool(pImpl->sack), pImpl->arch);
|
|
|
844bdb |
+}
|
|
|
844bdb |
+
|
|
|
844bdb |
+DnfSack * AdvisoryModule::getSack() { return pImpl->sack; }
|
|
|
844bdb |
+
|
|
|
844bdb |
+}
|
|
|
844bdb |
diff --git a/libdnf/sack/advisorymodule.hpp b/libdnf/sack/advisorymodule.hpp
|
|
|
844bdb |
new file mode 100644
|
|
|
844bdb |
index 0000000..1ad1ea7
|
|
|
844bdb |
--- /dev/null
|
|
|
844bdb |
+++ b/libdnf/sack/advisorymodule.hpp
|
|
|
844bdb |
@@ -0,0 +1,58 @@
|
|
|
844bdb |
+/*
|
|
|
844bdb |
+ * Copyright (C) 2019 Red Hat, Inc.
|
|
|
844bdb |
+ *
|
|
|
844bdb |
+ * Licensed under the GNU Lesser General Public License Version 2.1
|
|
|
844bdb |
+ *
|
|
|
844bdb |
+ * This library is free software; you can redistribute it and/or
|
|
|
844bdb |
+ * modify it under the terms of the GNU Lesser General Public
|
|
|
844bdb |
+ * License as published by the Free Software Foundation; either
|
|
|
844bdb |
+ * version 2.1 of the License, or (at your option) any later version.
|
|
|
844bdb |
+ *
|
|
|
844bdb |
+ * This library is distributed in the hope that it will be useful,
|
|
|
844bdb |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
844bdb |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
844bdb |
+ * Lesser General Public License for more details.
|
|
|
844bdb |
+ *
|
|
|
844bdb |
+ * You should have received a copy of the GNU Lesser General Public
|
|
|
844bdb |
+ * License along with this library; if not, write to the Free Software
|
|
|
844bdb |
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
844bdb |
+ */
|
|
|
844bdb |
+
|
|
|
844bdb |
+
|
|
|
844bdb |
+#ifndef __ADVISORY_MODULE_HPP
|
|
|
844bdb |
+#define __ADVISORY_MODULE_HPP
|
|
|
844bdb |
+
|
|
|
844bdb |
+#include <memory>
|
|
|
844bdb |
+
|
|
|
844bdb |
+#include <solv/pooltypes.h>
|
|
|
844bdb |
+#include <solv/solvable.h>
|
|
|
844bdb |
+
|
|
|
844bdb |
+#include "../dnf-types.h"
|
|
|
844bdb |
+#include "advisory.hpp"
|
|
|
844bdb |
+
|
|
|
844bdb |
+namespace libdnf {
|
|
|
844bdb |
+
|
|
|
844bdb |
+struct AdvisoryModule {
|
|
|
844bdb |
+public:
|
|
|
844bdb |
+ AdvisoryModule(DnfSack *sack, Id advisory, Id name, Id stream, Id version, Id context, Id arch);
|
|
|
844bdb |
+ AdvisoryModule(const AdvisoryModule & src);
|
|
|
844bdb |
+ AdvisoryModule(AdvisoryModule && src);
|
|
|
844bdb |
+ ~AdvisoryModule();
|
|
|
844bdb |
+ AdvisoryModule & operator=(const AdvisoryModule & src);
|
|
|
844bdb |
+ AdvisoryModule & operator=(AdvisoryModule && src) noexcept;
|
|
|
844bdb |
+ bool nsvcaEQ(AdvisoryModule & other);
|
|
|
844bdb |
+ Advisory * getAdvisory() const;
|
|
|
844bdb |
+ const char * getName() const;
|
|
|
844bdb |
+ const char * getStream() const;
|
|
|
844bdb |
+ const char * getVersion() const;
|
|
|
844bdb |
+ const char * getContext() const;
|
|
|
844bdb |
+ const char * getArch() const;
|
|
|
844bdb |
+ DnfSack * getSack();
|
|
|
844bdb |
+private:
|
|
|
844bdb |
+ class Impl;
|
|
|
844bdb |
+ std::unique_ptr<Impl> pImpl;
|
|
|
844bdb |
+};
|
|
|
844bdb |
+
|
|
|
844bdb |
+}
|
|
|
844bdb |
+
|
|
|
844bdb |
+#endif /* __ADVISORY_MODULE_HPP */
|
|
|
844bdb |
--
|
|
|
844bdb |
libgit2 0.27.7
|
|
|
844bdb |
|