From 15b5ed513e854c1233465a3a862113402092a800 Mon Sep 17 00:00:00 2001 From: Oliver Kurth Date: Mon, 14 Nov 2022 14:27:50 -0800 Subject: [PATCH 1/4] don't ovwerrite 'considered' map when using minversions (fixes: #367) --- client/goal.c | 8 ++------ solv/tdnfpackage.c | 16 +++++----------- 2 files changed, 7 insertions(+), 17 deletions(-) diff --git a/client/goal.c b/client/goal.c index 2a12f0f3..06a1d38a 100644 --- a/client/goal.c +++ b/client/goal.c @@ -959,14 +959,10 @@ TDNFSolvAddMinVersions( sizeof(Map), (void**)&pPool->considered); map_init(pPool->considered, pPool->nsolvables); + map_setall(pPool->considered); } - else - { - map_grow(pPool->considered, pPool->nsolvables); - } - - map_setall(pPool->considered); map_subtract(pPool->considered, pMapMinVersions); + cleanup: if(pMapMinVersions) { diff --git a/solv/tdnfpackage.c b/solv/tdnfpackage.c index bedb3054..48e56879 100644 --- a/solv/tdnfpackage.c +++ b/solv/tdnfpackage.c @@ -1754,12 +1754,8 @@ SolvAddExcludes( sizeof(Map), (void**)&pPool->considered); map_init(pPool->considered, pPool->nsolvables); + map_setall(pPool->considered); } - else - { - map_grow(pPool->considered, pPool->nsolvables); - } - map_setall(pPool->considered); map_subtract(pPool->considered, pExcludes); cleanup: @@ -1778,7 +1774,7 @@ SolvDataIterator( { Dataiterator di; Id keyname = SOLVABLE_NAME; - char **ppszPackagesTemp = NULL; + char **ppszPkg = NULL; uint32_t dwError = 0; if (!pPool || !ppszExcludes || !pMap) @@ -1787,22 +1783,20 @@ SolvDataIterator( BAIL_ON_TDNF_ERROR(dwError); } - ppszPackagesTemp = ppszExcludes; - while(ppszPackagesTemp && *ppszPackagesTemp) + for (ppszPkg = ppszExcludes; ppszPkg && *ppszPkg; ppszPkg++) { int flags = SEARCH_STRING; - if (SolvIsGlob(*ppszPackagesTemp)) + if (SolvIsGlob(*ppszPkg)) { flags = SEARCH_GLOB; } - dwError = dataiterator_init(&di, pPool, 0, 0, keyname, *ppszPackagesTemp, flags); + dwError = dataiterator_init(&di, pPool, 0, 0, keyname, *ppszPkg, flags); BAIL_ON_TDNF_ERROR(dwError); while (dataiterator_step(&di)) { MAPSET(pMap, di.solvid); } dataiterator_free(&di); - ++ppszPackagesTemp; } cleanup: return dwError; From df0e40fa5bbcb80fca70ff1b17c869be9ff33417 Mon Sep 17 00:00:00 2001 From: Oliver Kurth Date: Mon, 14 Nov 2022 15:44:51 -0800 Subject: [PATCH 2/4] add test for issue #367 --- pytests/tests/test_excludes.py | 43 ++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/pytests/tests/test_excludes.py b/pytests/tests/test_excludes.py index 958bb226..25bce5e5 100644 --- a/pytests/tests/test_excludes.py +++ b/pytests/tests/test_excludes.py @@ -7,6 +7,8 @@ # import pytest +import os +import shutil @pytest.fixture(scope='module', autouse=True) @@ -20,6 +22,23 @@ def teardown_test(utils): pkgname = utils.config[pkg] utils.run(['tdnf', 'erase', '-y', pkgname]) + dirname = os.path.join(utils.config['repo_path'], 'minversions.d') + if os.path.isdir(dirname): + shutil.rmtree(dirname) + + utils.tdnf_config.remove_option('main', 'minversions') + filename = os.path.join(utils.config['repo_path'], 'tdnf.conf') + with open(filename, 'w') as f: + utils.tdnf_config.write(f, space_around_delimiters=False) + + +def set_minversions_file(utils, value): + dirname = os.path.join(utils.config['repo_path'], 'minversions.d') + utils.makedirs(dirname) + filename = os.path.join(dirname, 'test.conf') + with open(filename, 'w') as f: + f.write(value) + # specifying the version should not override the exclude (negative test) def test_install_package_with_version_suffix(utils): @@ -79,3 +98,27 @@ def test_remove_package(utils): utils.run(['tdnf', 'remove', '--exclude=', pkgname, '-y', '--nogpgcheck', pkgname]) # package should still be there assert utils.check_package(pkgname) + + +# test for issue #367 +def test_with_minversion_existing(utils): + mverpkg = utils.config["sglversion_pkgname"] + set_minversions_file(utils, mverpkg + "=1.0.1-2\n") + + pkgname = utils.config["mulversion_pkgname"] + pkgversion1 = utils.config["mulversion_lower"] + pkgversion2 = utils.config["mulversion_higher"] + + if '-' in pkgversion1: + pkgversion1 = pkgversion1.split('-')[0] + if '-' in pkgversion2: + pkgversion2 = pkgversion2.split('-')[0] + + utils.erase_package(pkgname) + + utils.run(['tdnf', 'install', '-y', '--nogpgcheck', pkgname + '-' + pkgversion1]) + assert utils.check_package(pkgname, pkgversion1) + + utils.run(['tdnf', 'update', '--exclude=', '-y', '--nogpgcheck', pkgname + '-' + pkgversion2]) + assert not utils.check_package(pkgname, pkgversion2) + assert utils.check_package(pkgname, pkgversion1) From d1b6d8b2ca7a6b1ded27910f358aa1353b630023 Mon Sep 17 00:00:00 2001 From: Oliver Kurth Date: Wed, 16 Nov 2022 14:00:37 -0800 Subject: [PATCH 3/4] bump version to 3.4.3 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7a29caec..79f56800 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,7 +8,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 3.0 FATAL_ERROR) -project(tdnf VERSION 3.4.2 LANGUAGES C) +project(tdnf VERSION 3.4.3 LANGUAGES C) set(VERSION ${PROJECT_VERSION}) set(PROJECT_YEAR 2022) From 8327b66a486d749d4c18c78b3159cb5ccd437954 Mon Sep 17 00:00:00 2001 From: Oliver Kurth Date: Thu, 10 Nov 2022 14:40:53 -0800 Subject: [PATCH 4/4] add a few commands and options to help text, plus URL to wiki --- tools/cli/lib/help.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/tools/cli/lib/help.c b/tools/cli/lib/help.c index ae20aba8..bc4cf83e 100644 --- a/tools/cli/lib/help.c +++ b/tools/cli/lib/help.c @@ -32,10 +32,14 @@ static const char *help_msg = " [--reboot-required]\n" " [--refresh]\n" " [--releasever RELEASEVER]\n" + " [--repo=]\n" + " [--repofrompath=,]\n" + " [--repoid=]\n" " [--rpmverbosity [debug level name]]\n" " [--security]\n" " [--sec-severity CVSS_v3.0_Severity]\n" " [--setopt SETOPTS]\n" + " [--skip-broken]\n" " [--skipconflicts]\n" " [--skipdigest]\n" " [--skipsignature]\n" @@ -67,6 +71,7 @@ static const char *help_msg = " [--requires]\n" " [--requires-pre]\n" " [--suggests]\n" + " [--source]\n" " [--supplements]\n\n" "reposync options:\n" " [--arch= [--arch= [..]]\n" @@ -80,7 +85,9 @@ static const char *help_msg = " [--source]\n" " [--urls]\n\n" "List of Main Commands\n\n" - "autoremove Remove a package and its automatic dependencies\n" + "autoerase same as 'autoremove'\n" + "autoremove Remove a package and its automatic dependencies or all auto installed packages\n" + "check Checks repositories for problems\n" "check-local Checks local rpm folder for problems\n" "check-update Check for available package upgrades\n" "clean Remove cached data\n" @@ -88,21 +95,27 @@ static const char *help_msg = "downgrade Downgrade a package\n" "erase Remove a package or packages from your system\n" "help Display a helpful usage message\n" + "history History Commands\n" "info Display details about a package or group of packages\n" "install Install a package or packages on your system\n" "list List a package or groups of packages\n" "makecache Generate the metadata cache\n" - "provides Find what package provides the given value\n" - "remove Remove a package or packages from your system\n" + "mark Mark package(s)\n" + "provides same as 'whatprovides'\n" + "whatprovides Find what package provides the given value\n" "reinstall Reinstall a package\n" + "remove Remove a package or packages from your system\n" "repolist Display the configured software repositories\n" "repoquery Query repositories\n" "reposync Download all packages from one or more repositories to a directory\n" "search Search package details for the given string\n" "update Upgrade a package or packages on your system (same as 'upgrade')\n" + "update-to same as 'upgrade-to'\n" "updateinfo Display advisories about packages\n" "upgrade Upgrade a package or packages on your system\n" - "upgrade-to Upgrade a package on your system to the specified version\n"; + "upgrade-to Upgrade a package on your system to the specified version\n" + "\n" + "Please refer to https://github.com/vmware/tdnf/wiki for documentation."; void TDNFCliShowUsage(