Skip to content

Commit

Permalink
Merge pull request #369 from oliverkurth/stable-3.4
Browse files Browse the repository at this point in the history
Fix minversions overwriting excludes (PR #368) and improve help text (PR #366)
  • Loading branch information
oliverkurth authored Nov 17, 2022
2 parents 2704c19 + 8327b66 commit 42d0e5c
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 22 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
8 changes: 2 additions & 6 deletions client/goal.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
43 changes: 43 additions & 0 deletions pytests/tests/test_excludes.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#

import pytest
import os
import shutil


@pytest.fixture(scope='module', autouse=True)
Expand All @@ -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):
Expand Down Expand Up @@ -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)
16 changes: 5 additions & 11 deletions solv/tdnfpackage.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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)
Expand All @@ -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;
Expand Down
21 changes: 17 additions & 4 deletions tools/cli/lib/help.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,14 @@ static const char *help_msg =
" [--reboot-required]\n"
" [--refresh]\n"
" [--releasever RELEASEVER]\n"
" [--repo=<repoid>]\n"
" [--repofrompath=<repoid>,<path>]\n"
" [--repoid=<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"
Expand Down Expand Up @@ -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> [--arch=<arch> [..]]\n"
Expand All @@ -80,29 +85,37 @@ 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"
"distro-sync Synchronize installed packages to the latest available versions\n"
"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(
Expand Down

0 comments on commit 42d0e5c

Please sign in to comment.