From 24265a094113d8ffc2da15b775538abe243d0218 Mon Sep 17 00:00:00 2001 From: Oliver Kurth Date: Fri, 12 Jul 2024 21:25:50 +0000 Subject: [PATCH 1/5] show repo name in json output when installing --- tools/cli/lib/installcmd.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/cli/lib/installcmd.c b/tools/cli/lib/installcmd.c index da98d855..dc581e61 100644 --- a/tools/cli/lib/installcmd.c +++ b/tools/cli/lib/installcmd.c @@ -386,6 +386,7 @@ JDPkgList( CHECK_JD_RC(jd_map_add_string(jd_pkg, "Arch", pPkgInfo->pszArch)); CHECK_JD_RC(jd_map_add_fmt(jd_pkg, "Evr", "%s-%s", pPkgInfo->pszVersion, pPkgInfo->pszRelease)); CHECK_JD_RC(jd_map_add_int(jd_pkg, "InstallSize", pPkgInfo->dwInstallSizeBytes)); + CHECK_JD_RC(jd_map_add_string(jd_pkg, "Repo", pPkgInfo->pszRepoName)); CHECK_JD_RC(jd_list_add_child(jd_list, jd_pkg)); JD_SAFE_DESTROY(jd_pkg); From 34d955c480ba085c631f128700a97007403668a4 Mon Sep 17 00:00:00 2001 From: Oliver Kurth Date: Thu, 11 Jul 2024 22:12:36 +0000 Subject: [PATCH 2/5] add a test for the repo priority option --- pytests/tests/test_priority.py | 60 ++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 pytests/tests/test_priority.py diff --git a/pytests/tests/test_priority.py b/pytests/tests/test_priority.py new file mode 100644 index 00000000..a3e7913c --- /dev/null +++ b/pytests/tests/test_priority.py @@ -0,0 +1,60 @@ +# +# Copyright (C) 2024 Broadcom, Inc. All Rights Reserved. +# +# Licensed under the GNU General Public License v2 (the "License"); +# you may not use this file except in compliance with the License. The terms +# of the License are located in the COPYING file of this distribution. +# + +import os +import shutil +import pytest + +REPODIR = "/root/priority/repo" +REPONAME = "priority-test" +REPOFILENAME = f"{REPONAME}.repo" + + +@pytest.fixture(scope='function', autouse=True) +def setup_test(utils): + + os.makedirs(REPODIR, exist_ok=True) + + yield + teardown_test(utils) + + +def teardown_test(utils): + if os.path.isdir(REPODIR): + shutil.rmtree(REPODIR) + filename = os.path.join(utils.config['repo_path'], "yum.repos.d", REPOFILENAME) + if os.path.isfile(filename): + os.remove(filename) + + +def test_priority(utils): + pkgname = utils.config['mulversion_pkgname'] + pkgname_low = pkgname + "=" + utils.config['mulversion_lower'] + ret = utils.run(["tdnf", + "-y", "--nogpgcheck", + "--downloadonly", f"--downloaddir={REPODIR}", + "install", pkgname_low], + ) + assert ret['retval'] == 0 + + ret = utils.run(["createrepo", "."], cwd=REPODIR) + assert ret['retval'] == 0 + + filename = os.path.join(utils.config['repo_path'], "yum.repos.d", REPOFILENAME) + baseurl = "file://{}".format(REPODIR) + + utils.create_repoconf(filename, baseurl, REPONAME) + utils.edit_config({'priority': "25"}, repo=REPONAME) + + ret = utils.run(["tdnf", + "-y", "--nogpgcheck", + "install", pkgname], + cwd=REPODIR) + assert ret['retval'] == 0 + + utils.check_package(pkgname, version=utils.config['mulversion_lower']) From 911ea0e2f750e945d3f4207df7fc1f3d6c1a98f7 Mon Sep 17 00:00:00 2001 From: Oliver Kurth Date: Thu, 11 Jul 2024 21:14:15 +0000 Subject: [PATCH 3/5] set libsolv repo priority with (negated) value from repo config --- client/repo.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/client/repo.c b/client/repo.c index b6073e26..809c39d8 100644 --- a/client/repo.c +++ b/client/repo.c @@ -77,6 +77,13 @@ TDNFInitRepo( dwError = ERROR_TDNF_INVALID_PARAMETER; BAIL_ON_TDNF_ERROR(dwError); } + + /* tdnf (and dnf) have an opposite sense of priority, therefore negate it. + tdnf/dnf: lower value prefered + libsolv: higher value prefered + */ + pRepo->priority = -pRepoData->nPriority; + pSolvRepoInfo->pRepo = pRepo; pSolvRepoInfo->pszRepoCacheDir = pszRepoCacheDir; pRepo->appdata = pSolvRepoInfo; From 2f3fe0c3b54d70a0c1193623abac2093114a6f9a Mon Sep 17 00:00:00 2001 From: Oliver Kurth Date: Mon, 15 Jul 2024 20:16:06 +0000 Subject: [PATCH 4/5] add sqlite-devel to BuildRequires in spec file --- tdnf.spec.in | 1 + 1 file changed, 1 insertion(+) diff --git a/tdnf.spec.in b/tdnf.spec.in index 01759f9e..b87b7224 100644 --- a/tdnf.spec.in +++ b/tdnf.spec.in @@ -26,6 +26,7 @@ BuildRequires: curl-devel BuildRequires: libxml2-devel BuildRequires: zlib-devel BuildRequires: systemd +BuildRequires: sqlite-devel #metalink plugin BuildRequires: libxml2-devel From ebd15f4487707e8bd4ea84897b540bb5c98860a2 Mon Sep 17 00:00:00 2001 From: Oliver Kurth Date: Tue, 16 Jul 2024 00:22:13 +0000 Subject: [PATCH 5/5] bump version to 3.5.8 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 97cf278e..0b069178 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,7 +8,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 3.0 FATAL_ERROR) -project(tdnf VERSION 3.5.7 LANGUAGES C) +project(tdnf VERSION 3.5.8 LANGUAGES C) set(VERSION ${PROJECT_VERSION}) set(PROJECT_YEAR 2024)