Skip to content

Commit

Permalink
Merge pull request #370 from oliverkurth/stable-3.3
Browse files Browse the repository at this point in the history
Fix minversions overwriting excludes
  • Loading branch information
oliverkurth authored Nov 23, 2022
2 parents 4267d29 + 9c880af commit d432945
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 18 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.3.2 LANGUAGES C)
project(tdnf VERSION 3.3.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 @@ -961,14 +961,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 @@ -1711,12 +1711,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 @@ -1735,7 +1731,7 @@ SolvDataIterator(
{
Dataiterator di;
Id keyname = SOLVABLE_NAME;
char **ppszPackagesTemp = NULL;
char **ppszPkg = NULL;
uint32_t dwError = 0;

if (!pPool || !ppszExcludes || !pMap)
Expand All @@ -1744,22 +1740,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

0 comments on commit d432945

Please sign in to comment.