Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retain installonlypkg install status on upgrade #514

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions client/goal.c
Original file line number Diff line number Diff line change
Expand Up @@ -754,6 +754,36 @@ TDNFMarkAutoInstalled(
}
}
}
/* During upgrades, ppInfo->pPkgsToInstall contains any packages that are
being installed as a dependency automatically as well as any
ppszInstallOnlyPkgs which are installing a new version. The packages
configured as installonlypkgs need to retain to retain their previous
install status.
*/
if (nFlag == 1 && pTdnf->pConf && pTdnf->pConf->ppszInstallOnlyPkgs)
{
for (int i = 0; pTdnf->pConf->ppszInstallOnlyPkgs[i]; i++)
{
if (strcmp(pTdnf->pConf->ppszInstallOnlyPkgs[i], pszName) == 0)
{
// Lookup current auto install status, ensure matching status
int value = 0;
int rc = history_get_auto_flag(pHistoryCtx, pszName, &value);
if (rc != 0)
{
dwError = ERROR_TDNF_HISTORY_ERROR;
BAIL_ON_TDNF_ERROR(dwError);
}
if (value == 0)
{
// Packages previously marked as user installed should
// remain user installed.
nFlag = 0;
break;
}
}
}
}
if (!nAutoOnly || nFlag == 1)
{
int rc = history_set_auto_flag(pHistoryCtx, pszName, nFlag);
Expand Down
44 changes: 44 additions & 0 deletions pytests/tests/test_multiinstall.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,3 +149,47 @@ def test_install_reinstall(utils):
# both pkgs should remain installed:
assert utils.check_package(pkgname, version=first)
assert utils.check_package(pkgname, version=second)


def test_autoremove_after_upgrade_user_installed(utils):
pkgname = PKGNAME
utils.erase_package(pkgname)

# install first version
first = PKG_VERSIONS[0]
utils.run(['tdnf', 'install', '-y', '--nogpgcheck', f"{pkgname}={first}"])
assert utils.check_package(pkgname, version=first)

# upgrade to latest
upgrade_version = PKG_VERSIONS[3]
utils.run(['tdnf', 'upgrade', '-y', '--nogpgcheck'])
assert utils.check_package(pkgname, version=upgrade_version)

utils.run(['tdnf', 'autoremove', '-y'])
# check both packages remain installed after autoremove
assert utils.check_package(pkgname, version=upgrade_version)
assert utils.check_package(pkgname, version=first)


def test_autoremove_after_upgrade_auto_installed(utils):
pkgname = PKGNAME
utils.erase_package(pkgname)

# install first version
first = PKG_VERSIONS[0]
utils.run(['tdnf', 'install', '-y', '--nogpgcheck', f"{pkgname}={first}"])
assert utils.check_package(pkgname, version=first)

# mark package as autoinstalled
ret = utils.run(['tdnf', 'mark', 'remove', pkgname])
assert ret['retval'] == 0

# upgrade to latest
upgrade_version = PKG_VERSIONS[3]
utils.run(['tdnf', 'upgrade', '-y', '--nogpgcheck'])
assert utils.check_package(pkgname, version=upgrade_version)

utils.run(['tdnf', 'autoremove', '-y'])
# check both packages remain installed after autoremove
assert not utils.check_package(pkgname, version=upgrade_version)
assert not utils.check_package(pkgname, version=first)
Loading