diff --git a/0002-Reintroduce-hawkeyRepo-deprecated-for-compatibility.patch b/0002-Reintroduce-hawkeyRepo-deprecated-for-compatibility.patch new file mode 100644 index 0000000..1998ab8 --- /dev/null +++ b/0002-Reintroduce-hawkeyRepo-deprecated-for-compatibility.patch @@ -0,0 +1,430 @@ +From ab61bd2cb0ae458aae7c8e4ff7081bd2ab2094f5 Mon Sep 17 00:00:00 2001 +From: Jaroslav Rohel +Date: Thu, 2 May 2019 10:56:04 +0200 +Subject: [PATCH] Reintroduce hawkey.Repo (deprecated, for compatibility) + +--- + python/hawkey/CMakeLists.txt | 1 + + python/hawkey/__init__.py | 5 +++-- + python/hawkey/hawkeymodule.cpp | 8 +++++++- + python/hawkey/repo-py.cpp | 213 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + python/hawkey/repo-py.hpp | 33 +++++++++++++++++++++++++++++++++ + python/hawkey/sack-py.cpp | 48 +++++++++++++++++++++++++++++++----------------- + 6 files changed, 288 insertions(+), 20 deletions(-) + create mode 100644 python/hawkey/repo-py.cpp + create mode 100644 python/hawkey/repo-py.hpp + +diff --git a/python/hawkey/CMakeLists.txt b/python/hawkey/CMakeLists.txt +index 96e9d43..d964534 100644 +--- a/python/hawkey/CMakeLists.txt ++++ b/python/hawkey/CMakeLists.txt +@@ -33,6 +33,7 @@ set(hawkeymodule_SRCS + packagedelta-py.cpp + query-py.cpp + reldep-py.cpp ++ repo-py.cpp + sack-py.cpp + selector-py.cpp + subject-py.cpp +diff --git a/python/hawkey/__init__.py b/python/hawkey/__init__.py +index 7ad77f8..f5f0816 100644 +--- a/python/hawkey/__init__.py ++++ b/python/hawkey/__init__.py +@@ -1,5 +1,5 @@ + # +-# Copyright (C) 2012-2014 Red Hat, Inc. ++# Copyright (C) 2012-2019 Red Hat, Inc. + # + # Licensed under the GNU Lesser General Public License Version 2.1 + # +@@ -52,7 +52,7 @@ __all__ = [ + # functions + 'chksum_name', 'chksum_type', 'split_nevra', 'convert_hawkey_reason', + # classes +- 'Goal', 'NEVRA', 'NSVCAP', 'Package', 'Query', 'Sack', 'Selector', 'Subject'] ++ 'Goal', 'NEVRA', 'NSVCAP', 'Package', 'Query', 'Repo', 'Sack', 'Selector', 'Subject'] + + NEVRA = _hawkey.NEVRA + Query = _hawkey.Query +@@ -131,6 +131,7 @@ REFERENCE_VENDOR = _hawkey.REFERENCE_VENDOR + + Package = _hawkey.Package + Reldep = _hawkey.Reldep ++Repo = _hawkey.Repo + Sack = _hawkey.Sack + + Exception = _hawkey.Exception +diff --git a/python/hawkey/hawkeymodule.cpp b/python/hawkey/hawkeymodule.cpp +index 70659a8..72e7085 100644 +--- a/python/hawkey/hawkeymodule.cpp ++++ b/python/hawkey/hawkeymodule.cpp +@@ -1,5 +1,5 @@ + /* +- * Copyright (C) 2012-2014 Red Hat, Inc. ++ * Copyright (C) 2012-2019 Red Hat, Inc. + * + * Licensed under the GNU Lesser General Public License Version 2.1 + * +@@ -46,6 +46,7 @@ + #include "packagedelta-py.hpp" + #include "query-py.hpp" + #include "reldep-py.hpp" ++#include "repo-py.hpp" + #include "sack-py.hpp" + #include "selector-py.hpp" + #include "subject-py.hpp" +@@ -193,6 +194,11 @@ PYCOMP_MOD_INIT(_hawkey) + return PYCOMP_MOD_ERROR_VAL; + Py_INCREF(&selector_Type); + PyModule_AddObject(m, "Selector", (PyObject *)&selector_Type); ++ /* _hawkey.Repo */ ++ if (PyType_Ready(&repo_Type) < 0) ++ return PYCOMP_MOD_ERROR_VAL; ++ Py_INCREF(&repo_Type); ++ PyModule_AddObject(m, "Repo", (PyObject *)&repo_Type); + /* _hawkey.NEVRA */ + if (PyType_Ready(&nevra_Type) < 0) + return PYCOMP_MOD_ERROR_VAL; +diff --git a/python/hawkey/repo-py.cpp b/python/hawkey/repo-py.cpp +new file mode 100644 +index 0000000..eff32be +--- /dev/null ++++ b/python/hawkey/repo-py.cpp +@@ -0,0 +1,213 @@ ++/* ++ * Copyright (C) 2012-2019 Red Hat, Inc. ++ * ++ * Licensed under the GNU Lesser General Public License Version 2.1 ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ++ */ ++ ++#include ++#include ++ ++// hawkey ++#include "hy-repo.h" ++ ++// pyhawkey ++#include "hawkey-pysys.hpp" ++#include "repo-py.hpp" ++ ++#include "pycomp.hpp" ++ ++typedef struct { ++ PyObject_HEAD ++ HyRepo repo; ++} _RepoObject; ++ ++typedef struct { ++ int (*getter)(HyRepo); ++ void (*setter)(HyRepo, int); ++} IntGetSetter; ++ ++HyRepo repoFromPyObject(PyObject *o) ++{ ++ if (!repoObject_Check(o)) { ++ //PyErr_SetString(PyExc_TypeError, "Expected a Repo object."); ++ return NULL; ++ } ++ return ((_RepoObject *)o)->repo; ++} ++ ++PyObject *repoToPyObject(HyRepo repo) ++{ ++ _RepoObject *self = (_RepoObject *)repo_Type.tp_alloc(&repo_Type, 0); ++ if (self) ++ self->repo = repo; ++ return (PyObject *)self; ++} ++ ++/* functions on the type */ ++ ++static PyObject * ++repo_new(PyTypeObject *type, PyObject *args, PyObject *kwds) ++{ ++ _RepoObject *self = (_RepoObject *)type->tp_alloc(type, 0); ++ if (self) { ++ self->repo = hy_repo_create("(default)"); ++ if (self->repo == NULL) { ++ Py_DECREF(self); ++ return NULL; ++ } ++ } ++ return (PyObject *) self; ++} ++ ++static int ++repo_init(_RepoObject *self, PyObject *args, PyObject *kwds) ++{ ++ const char *name; ++ if (!PyArg_ParseTuple(args, "s", &name)) ++ return -1; ++ hy_repo_set_string(self->repo, HY_REPO_NAME, name); ++ return 0; ++} ++ ++static void ++repo_dealloc(_RepoObject *self) ++{ ++ hy_repo_free(self->repo); ++ Py_TYPE(self)->tp_free(self); ++} ++ ++/* getsetters */ ++ ++static PyObject * ++get_int(_RepoObject *self, void *closure) ++{ ++ IntGetSetter *functions = (IntGetSetter*)closure; ++ return PyLong_FromLong(functions->getter(self->repo)); ++} ++ ++static int ++set_int(_RepoObject *self, PyObject *value, void *closure) ++{ ++ IntGetSetter *functions = (IntGetSetter*)closure; ++ long num = PyLong_AsLong(value); ++ if (PyErr_Occurred()) ++ return -1; ++ if (num > INT_MAX || num < INT_MIN) { ++ PyErr_SetString(PyExc_ValueError, "Value in the integer range expected."); ++ return -1; ++ } ++ functions->setter(self->repo, num); ++ return 0; ++} ++ ++static PyObject * ++get_str(_RepoObject *self, void *closure) ++{ ++ int str_key = (intptr_t)closure; ++ const char *str; ++ PyObject *ret; ++ ++ str = hy_repo_get_string(self->repo, str_key); ++ if (str == NULL) { ++ ret = PyString_FromString(""); ++ } else { ++ ret = PyString_FromString(str); ++ } ++ return ret; // NULL if PyString_FromString failed ++} ++ ++static int ++set_str(_RepoObject *self, PyObject *value, void *closure) ++{ ++ intptr_t str_key = (intptr_t)closure; ++ PycompString str_value(value); ++ if (!str_value.getCString()) ++ return -1; ++ hy_repo_set_string(self->repo, str_key, str_value.getCString()); ++ return 0; ++} ++ ++static IntGetSetter hy_repo_cost{hy_repo_get_cost, hy_repo_set_cost}; ++ ++static IntGetSetter hy_repo_priority{hy_repo_get_priority, hy_repo_set_priority}; ++ ++static PyGetSetDef repo_getsetters[] = { ++ {(char*)"cost", (getter)get_int, (setter)set_int, (char*)"repository cost", ++ (void *)&hy_repo_cost}, ++ {(char*)"name", (getter)get_str, (setter)set_str, NULL, ++ (void *)HY_REPO_NAME}, ++ {(char*)"priority", (getter)get_int, (setter)set_int, (char*)"repository priority", ++ (void *)&hy_repo_priority}, ++ {(char*)"repomd_fn", (getter)get_str, (setter)set_str, NULL, ++ (void *)HY_REPO_MD_FN}, ++ {(char*)"primary_fn", (getter)get_str, (setter)set_str, NULL, ++ (void *)HY_REPO_PRIMARY_FN}, ++ {(char*)"filelists_fn", (getter)get_str, (setter)set_str, NULL, ++ (void *)HY_REPO_FILELISTS_FN}, ++ {(char*)"modules_fn", (getter)get_str, (setter)set_str, NULL, ++ (void *)MODULES_FN}, ++ {(char*)"presto_fn", (getter)get_str, (setter)set_str, NULL, ++ (void *)HY_REPO_PRESTO_FN}, ++ {(char*)"updateinfo_fn", (getter)get_str, (setter)set_str, NULL, ++ (void *)HY_REPO_UPDATEINFO_FN}, ++ {(char*)"other_fn", (getter)get_str, (setter)set_str, NULL, ++ (void *)HY_REPO_OTHER_FN}, ++ {NULL} /* sentinel */ ++}; ++ ++PyTypeObject repo_Type = { ++ PyVarObject_HEAD_INIT(NULL, 0) ++ "_hawkey.Repo", /*tp_name*/ ++ sizeof(_RepoObject), /*tp_basicsize*/ ++ 0, /*tp_itemsize*/ ++ (destructor) repo_dealloc, /*tp_dealloc*/ ++ 0, /*tp_print*/ ++ 0, /*tp_getattr*/ ++ 0, /*tp_setattr*/ ++ 0, /*tp_compare*/ ++ 0, /*tp_repr*/ ++ 0, /*tp_as_number*/ ++ 0, /*tp_as_sequence*/ ++ 0, /*tp_as_mapping*/ ++ 0, /*tp_hash */ ++ 0, /*tp_call*/ ++ 0, /*tp_str*/ ++ 0, /*tp_getattro*/ ++ 0, /*tp_setattro*/ ++ 0, /*tp_as_buffer*/ ++ Py_TPFLAGS_DEFAULT, /*tp_flags*/ ++ "Repo object", /* tp_doc */ ++ 0, /* tp_traverse */ ++ 0, /* tp_clear */ ++ 0, /* tp_richcompare */ ++ 0, /* tp_weaklistoffset */ ++ PyObject_SelfIter, /* tp_iter */ ++ 0, /* tp_iternext */ ++ 0, /* tp_methods */ ++ 0, /* tp_members */ ++ repo_getsetters, /* tp_getset */ ++ 0, /* tp_base */ ++ 0, /* tp_dict */ ++ 0, /* tp_descr_get */ ++ 0, /* tp_descr_set */ ++ 0, /* tp_dictoffset */ ++ (initproc)repo_init, /* tp_init */ ++ 0, /* tp_alloc */ ++ repo_new, /* tp_new */ ++ 0, /* tp_free */ ++ 0, /* tp_is_gc */ ++}; +diff --git a/python/hawkey/repo-py.hpp b/python/hawkey/repo-py.hpp +new file mode 100644 +index 0000000..cb3f014 +--- /dev/null ++++ b/python/hawkey/repo-py.hpp +@@ -0,0 +1,33 @@ ++/* ++ * Copyright (C) 2012-2019 Red Hat, Inc. ++ * ++ * Licensed under the GNU Lesser General Public License Version 2.1 ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ++ */ ++ ++#ifndef REPO_PY_H ++#define REPO_PY_H ++ ++#include "hy-types.h" ++ ++extern PyTypeObject repo_Type; ++ ++#define repoObject_Check(v) ((v)->ob_type == &repo_Type) ++ ++HyRepo repoFromPyObject(PyObject *o); ++PyObject *repoToPyObject(HyRepo repo); ++ ++#endif // REPO_PY_H +diff --git a/python/hawkey/sack-py.cpp b/python/hawkey/sack-py.cpp +index 11f9d7c..63012c7 100644 +--- a/python/hawkey/sack-py.cpp ++++ b/python/hawkey/sack-py.cpp +@@ -1,5 +1,5 @@ + /* +- * Copyright (C) 2012-2015 Red Hat, Inc. ++ * Copyright (C) 2012-2019 Red Hat, Inc. + * + * Licensed under the GNU Lesser General Public License Version 2.1 + * +@@ -37,6 +37,7 @@ + #include "hawkey-pysys.hpp" + #include "iutil-py.hpp" + #include "package-py.hpp" ++#include "repo-py.hpp" + #include "sack-py.hpp" + + #include "pycomp.hpp" +@@ -641,16 +642,23 @@ load_system_repo(_SackObject *self, PyObject *args, PyObject *kwds) + return 0; + + if (repoPyObj) { +- auto repoSwigPyObj = reinterpret_cast(PyObject_GetAttrString(repoPyObj, "this")); +- if (!repoSwigPyObj) { +- PyErr_SetString(PyExc_SystemError, "Unable to parse repoSwigPyObject"); +- return NULL; +- } + +- crepo = repoSwigPyObj->ptr; ++ // Is it old deprecated _hawkey.Repo object? ++ crepo = repoFromPyObject(repoPyObj); ++ ++ // Or is it swig object? + if (!crepo) { +- PyErr_SetString(PyExc_SystemError, "Unable to parse repo swig object"); +- return NULL; ++ auto repoSwigPyObj = reinterpret_cast(PyObject_GetAttrString(repoPyObj, "this")); ++ if (!repoSwigPyObj) { ++ PyErr_SetString(PyExc_SystemError, "Unable to parse repoSwigPyObject"); ++ return NULL; ++ } ++ ++ crepo = repoSwigPyObj->ptr; ++ if (!crepo) { ++ PyErr_SetString(PyExc_SystemError, "Unable to parse repo swig object"); ++ return NULL; ++ } + } + } + +@@ -678,16 +686,22 @@ load_repo(_SackObject *self, PyObject *args, PyObject *kwds) + &load_presto, &load_updateinfo, &load_other)) + return 0; + +- auto repoSwigPyObj = reinterpret_cast(PyObject_GetAttrString(repoPyObj, "this")); +- if (!repoSwigPyObj) { +- PyErr_SetString(PyExc_SystemError, "Unable to parse repoSwigPyObject"); +- return NULL; +- } ++ // Is it old deprecated _hawkey.Repo object? ++ libdnf::Repo * crepo = repoFromPyObject(repoPyObj); + +- libdnf::Repo * crepo = repoSwigPyObj->ptr; ++ // Or is it swig object? + if (!crepo) { +- PyErr_SetString(PyExc_SystemError, "Unable to parse repo swig object"); +- return NULL; ++ auto repoSwigPyObj = reinterpret_cast(PyObject_GetAttrString(repoPyObj, "this")); ++ if (!repoSwigPyObj) { ++ PyErr_SetString(PyExc_SystemError, "Unable to parse repoSwigPyObject"); ++ return NULL; ++ } ++ ++ crepo = repoSwigPyObj->ptr; ++ if (!crepo) { ++ PyErr_SetString(PyExc_SystemError, "Unable to parse repo swig object"); ++ return NULL; ++ } + } + + int flags = 0; +-- +libgit2 0.27.7 + diff --git a/0003-hawkeyRepo-add-deprecation-message.patch b/0003-hawkeyRepo-add-deprecation-message.patch new file mode 100644 index 0000000..af6baf7 --- /dev/null +++ b/0003-hawkeyRepo-add-deprecation-message.patch @@ -0,0 +1,76 @@ +From f054f908e13e1d2c84e8d1b6443629e20500c2c4 Mon Sep 17 00:00:00 2001 +From: Jaroslav Rohel +Date: Thu, 2 May 2019 14:43:22 +0200 +Subject: [PATCH] hawkey.Repo: add deprecation message + +--- + python/hawkey/__init__.py | 11 ++++++++++- + python/hawkey/repo-py.cpp | 5 ++--- + python/hawkey/repo-py.hpp | 2 -- + 3 files changed, 12 insertions(+), 6 deletions(-) + +diff --git a/python/hawkey/__init__.py b/python/hawkey/__init__.py +index f5f0816..597fbbb 100644 +--- a/python/hawkey/__init__.py ++++ b/python/hawkey/__init__.py +@@ -131,7 +131,6 @@ REFERENCE_VENDOR = _hawkey.REFERENCE_VENDOR + + Package = _hawkey.Package + Reldep = _hawkey.Reldep +-Repo = _hawkey.Repo + Sack = _hawkey.Sack + + Exception = _hawkey.Exception +@@ -334,3 +333,13 @@ class Subject(_hawkey.Subject): + def _list_or_query_to_selector(sack, list_or_query): + sltr = Selector(sack) + return sltr.set(pkg=list_or_query) ++ ++ ++class Repo(_hawkey.Repo): ++ ++ def __init__(self, name): ++ warnings.simplefilter('always', DeprecationWarning) ++ msg = "The class hawkey.Repo is deprecated. " \ ++ "Please use dnf.repo.Repo instead. The class will be removed on 2019-12-31." ++ warnings.warn(msg, DeprecationWarning) ++ super(Repo, self).__init__(name) +diff --git a/python/hawkey/repo-py.cpp b/python/hawkey/repo-py.cpp +index eff32be..4e4c045 100644 +--- a/python/hawkey/repo-py.cpp ++++ b/python/hawkey/repo-py.cpp +@@ -42,8 +42,7 @@ typedef struct { + + HyRepo repoFromPyObject(PyObject *o) + { +- if (!repoObject_Check(o)) { +- //PyErr_SetString(PyExc_TypeError, "Expected a Repo object."); ++ if (!PyObject_TypeCheck(o, &repo_Type)) { + return NULL; + } + return ((_RepoObject *)o)->repo; +@@ -189,7 +188,7 @@ PyTypeObject repo_Type = { + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ +- Py_TPFLAGS_DEFAULT, /*tp_flags*/ ++ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /*tp_flags*/ + "Repo object", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ +diff --git a/python/hawkey/repo-py.hpp b/python/hawkey/repo-py.hpp +index cb3f014..f7a449a 100644 +--- a/python/hawkey/repo-py.hpp ++++ b/python/hawkey/repo-py.hpp +@@ -25,8 +25,6 @@ + + extern PyTypeObject repo_Type; + +-#define repoObject_Check(v) ((v)->ob_type == &repo_Type) +- + HyRepo repoFromPyObject(PyObject *o); + PyObject *repoToPyObject(HyRepo repo); + +-- +libgit2 0.27.7 + diff --git a/0004-Unit-tests-for-reintroduced-hawkeyRepo.patch b/0004-Unit-tests-for-reintroduced-hawkeyRepo.patch new file mode 100644 index 0000000..0d673ac --- /dev/null +++ b/0004-Unit-tests-for-reintroduced-hawkeyRepo.patch @@ -0,0 +1,186 @@ +From 0999f890e57e45b0124fe1ddf1c368e63bd5c5c4 Mon Sep 17 00:00:00 2001 +From: Jaroslav Rohel +Date: Thu, 2 May 2019 14:08:06 +0200 +Subject: [PATCH] Unit tests for reintroduced hawkey.Repo + +--- + python/hawkey/tests/module/__init__.py | 2 ++ + python/hawkey/tests/module/hawkey_testmodule.cpp | 16 ++++++++++++++++ + python/hawkey/tests/tests/base.py | 8 +++++++- + python/hawkey/tests/tests/test_repo.py | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ + python/hawkey/tests/tests/test_sack.py | 17 ++++++++++++++++- + 5 files changed, 90 insertions(+), 2 deletions(-) + create mode 100644 python/hawkey/tests/tests/test_repo.py + +diff --git a/python/hawkey/tests/module/__init__.py b/python/hawkey/tests/module/__init__.py +index b41c3cc..b2ccd3d 100644 +--- a/python/hawkey/tests/module/__init__.py ++++ b/python/hawkey/tests/module/__init__.py +@@ -32,6 +32,8 @@ FIXED_ARCH = _hawkey_test.FIXED_ARCH + UNITTEST_DIR = _hawkey_test.UNITTEST_DIR + YUM_DIR_SUFFIX = _hawkey_test.YUM_DIR_SUFFIX + ++glob_for_repofiles = _hawkey_test.glob_for_repofiles ++ + class TestSackMixin(object): + def __init__(self, repo_dir): + self.repo_dir = repo_dir +diff --git a/python/hawkey/tests/module/hawkey_testmodule.cpp b/python/hawkey/tests/module/hawkey_testmodule.cpp +index b705701..9b21ad2 100644 +--- a/python/hawkey/tests/module/hawkey_testmodule.cpp ++++ b/python/hawkey/tests/module/hawkey_testmodule.cpp +@@ -23,6 +23,7 @@ + // hawkey + #include "dnf-sack-private.hpp" + ++#include "python/hawkey/repo-py.hpp" + #include "python/hawkey/sack-py.hpp" + #include "tests/hawkey/testshared.h" + +@@ -53,9 +54,24 @@ py_load_repo(PyObject *unused, PyObject *args) + Py_RETURN_NONE; + } + ++static PyObject * ++py_glob_for_repofiles(PyObject *unused, PyObject *args) ++{ ++ const char *repo_name, *path; ++ DnfSack *sack; ++ ++ if (!PyArg_ParseTuple(args, "O&ss", ++ sack_converter, &sack, &repo_name, &path)) ++ return NULL; ++ HyRepo repo = glob_for_repofiles(dnf_sack_get_pool(sack), repo_name, path); ++ return repoToPyObject(repo); ++} ++ + static struct PyMethodDef testmodule_methods[] = { + {"load_repo", (PyCFunction)py_load_repo, + METH_VARARGS, NULL}, ++ {"glob_for_repofiles", (PyCFunction)py_glob_for_repofiles, ++ METH_VARARGS, NULL}, + {NULL} /* sentinel */ + }; + +diff --git a/python/hawkey/tests/tests/base.py b/python/hawkey/tests/tests/base.py +index 8f1c1af..4d5937b 100644 +--- a/python/hawkey/tests/tests/base.py ++++ b/python/hawkey/tests/tests/base.py +@@ -1,5 +1,5 @@ + # +-# Copyright (C) 2012-2013 Red Hat, Inc. ++# Copyright (C) 2012-2019 Red Hat, Inc. + # + # Licensed under the GNU Lesser General Public License Version 2.1 + # +@@ -72,6 +72,12 @@ class TestSack(hawkey.test.TestSackMixin, hawkey.Sack): + repo.load() + super(TestSack, self).load_repo(repo, **kwargs) + ++ # Loading using hawkey.Repo ++ def load_repo_hawkey_Repo(self, **kwargs): ++ d = os.path.join(self.repo_dir, hawkey.test.YUM_DIR_SUFFIX) ++ repo = hawkey.test.glob_for_repofiles(self, "messerk", d) ++ super(TestSack, self).load_repo(repo, **kwargs) ++ + def by_name(sack, name): + return hawkey.Query(sack).filter(name=name)[0] + +diff --git a/python/hawkey/tests/tests/test_repo.py b/python/hawkey/tests/tests/test_repo.py +new file mode 100644 +index 0000000..8ae0544 +--- /dev/null ++++ b/python/hawkey/tests/tests/test_repo.py +@@ -0,0 +1,49 @@ ++# ++# Copyright (C) 2012-2019 Red Hat, Inc. ++# ++# Licensed under the GNU Lesser General Public License Version 2.1 ++# ++# This library is free software; you can redistribute it and/or ++# modify it under the terms of the GNU Lesser General Public ++# License as published by the Free Software Foundation; either ++# version 2.1 of the License, or (at your option) any later version. ++# ++# This library is distributed in the hope that it will be useful, ++# but WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++# Lesser General Public License for more details. ++# ++# You should have received a copy of the GNU Lesser General Public ++# License along with this library; if not, write to the Free Software ++# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ++# ++ ++import hawkey ++import unittest ++ ++ ++class Package(unittest.TestCase): ++ def test_create(self): ++ r = hawkey.Repo("fog") ++ self.assertIsNotNone(r) ++ self.assertRaises(TypeError, hawkey.Repo); ++ self.assertRaises(TypeError, hawkey.Repo, 3) ++ self.assertRaises(TypeError, hawkey.Repo, rain="pouring") ++ ++ def test_cost_assignment(self): ++ r = hawkey.Repo("fog") ++ r.cost = 300 ++ self.assertEqual(300, r.cost) ++ ++ r2 = hawkey.Repo("blizzard") ++ self.assertEqual(1000, r2.cost) ++ with self.assertRaises(TypeError): ++ r2.cost = '4' ++ ++ def test_str_assignment(self): ++ r = hawkey.Repo('fog') ++ with self.assertRaises(TypeError): ++ r.repomd_fn = 3 ++ r.repomd_fn = 'rain' ++ self.assertEqual(r.repomd_fn, 'rain') ++ +diff --git a/python/hawkey/tests/tests/test_sack.py b/python/hawkey/tests/tests/test_sack.py +index fe36b86..4645b37 100644 +--- a/python/hawkey/tests/tests/test_sack.py ++++ b/python/hawkey/tests/tests/test_sack.py +@@ -1,5 +1,5 @@ + # +-# Copyright (C) 2012-2015 Red Hat, Inc. ++# Copyright (C) 2012-2019 Red Hat, Inc. + # + # Licensed under the GNU Lesser General Public License Version 2.1 + # +@@ -48,6 +48,14 @@ class TestSackTest(base.TestCase): + self.assertEqual(len(sack), hawkey.test.EXPECT_YUM_NSOLVABLES + + hawkey.test.EXPECT_SYSTEM_NSOLVABLES) + ++ # Loading test using hawkey.Repo ++ def test_load_yum_hawkey_Repo(self): ++ sack = base.TestSack(repo_dir=self.repo_dir) ++ sack.load_system_repo() ++ sack.load_repo_hawkey_Repo(build_cache=True) ++ self.assertEqual(len(sack), hawkey.test.EXPECT_YUM_NSOLVABLES + ++ hawkey.test.EXPECT_SYSTEM_NSOLVABLES) ++ + def test_cache_dir(self): + sack = base.TestSack(repo_dir=self.repo_dir) + self.assertTrue(sack.cache_dir.startswith("/tmp/pyhawkey")) +@@ -77,6 +85,13 @@ class BasicTest(unittest.TestCase): + self.assertRaises(IOError, sack.load_repo, repo) + sack = hawkey.Sack() + ++ # Loading test using hawkey.Repo ++ def test_failed_load_hawkey_Repo(self): ++ sack = hawkey.Sack(cachedir=base.cachedir) ++ repo = hawkey.Repo("name") ++ self.assertRaises(IOError, sack.load_repo, repo) ++ sack = hawkey.Sack() ++ + def test_unicoded_cachedir(self): + # does not raise UnicodeEncodeError + hawkey.Sack(cachedir=u"unicod\xe9") +-- +libgit2 0.27.7 + diff --git a/libdnf.spec b/libdnf.spec index 26196c3..bf5518b 100644 --- a/libdnf.spec +++ b/libdnf.spec @@ -32,12 +32,15 @@ Name: libdnf Version: 0.31.0 -Release: 2%{?dist} +Release: 3%{?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-Reintroduce-hawkeyRepo-deprecated-for-compatibility.patch +Patch0003: 0003-hawkeyRepo-add-deprecation-message.patch +Patch0004: 0004-Unit-tests-for-reintroduced-hawkeyRepo.patch BuildRequires: cmake BuildRequires: gcc @@ -248,6 +251,9 @@ popd %endif %changelog +* Thu May 03 2019 Pavla Kratochvilova - 0.31.0-3 +- Backport patches to reintroduce hawkeyRepo + * Thu Apr 25 2019 Pavla Kratochvilova - 0.31.0-1 - Update to 0.31.0 - Installroot now requires absolute path