diff --git a/client/goal.c b/client/goal.c index ae5725bd..2e5ac3eb 100644 --- a/client/goal.c +++ b/client/goal.c @@ -106,19 +106,6 @@ TDNFGetReinstallPackages( SOLVER_TRANSACTION_REINSTALL); } -uint32_t -TDNFGetUpgradePackages( - Transaction* pTrans, - PTDNF pTdnf, - PTDNF_PKG_INFO* pPkgInfo) -{ - return TDNFGetPackagesWithSpecifiedType( - pTrans, - pTdnf, - pPkgInfo, - SOLVER_TRANSACTION_UPGRADE); -} - uint32_t TDNFGetErasePackages( Transaction* pTrans, @@ -146,11 +133,12 @@ TDNFGetObsoletedPackages( } uint32_t -TDNFGetDownGradePackages( +TDNFGetUpDowngradePackages( Transaction* pTrans, PTDNF pTdnf, PTDNF_PKG_INFO* pPkgInfo, - PTDNF_PKG_INFO* pRemovePkgInfo) + PTDNF_PKG_INFO* pRemovePkgInfo, + int nIsUpgrade) { uint32_t dwError = 0; PSolvPackageList pInstalledPkgList = NULL; @@ -170,7 +158,7 @@ TDNFGetDownGradePackages( pTrans, pTdnf, pPkgInfo, - SOLVER_TRANSACTION_DOWNGRADE); + nIsUpgrade ? SOLVER_TRANSACTION_UPGRADE : SOLVER_TRANSACTION_DOWNGRADE); BAIL_ON_TDNF_ERROR(dwError); pInfo = *pPkgInfo; if(!pInfo) @@ -869,17 +857,20 @@ TDNFGoalGetAllResultsIgnoreNoData( &pInfo->pPkgsToInstall); BAIL_ON_TDNF_ERROR(dwError); - dwError = TDNFGetUpgradePackages( + dwError = TDNFGetUpDowngradePackages( pTrans, pTdnf, - &pInfo->pPkgsToUpgrade); + &pInfo->pPkgsToUpgrade, + &pInfo->pPkgsRemovedByUpgrade, + 1); BAIL_ON_TDNF_ERROR(dwError); - dwError = TDNFGetDownGradePackages( + dwError = TDNFGetUpDowngradePackages( pTrans, pTdnf, &pInfo->pPkgsToDowngrade, - &pInfo->pPkgsRemovedByDowngrade); + &pInfo->pPkgsRemovedByDowngrade, + 0); BAIL_ON_TDNF_ERROR(dwError); dwError = TDNFGetErasePackages( diff --git a/client/prototypes.h b/client/prototypes.h index 4e52f3ab..c555035c 100644 --- a/client/prototypes.h +++ b/client/prototypes.h @@ -491,10 +491,13 @@ TDNFGetReinstallPackages( ); uint32_t -TDNFGetUpgradePackages( +TDNFGetUpDowngradePackages( Transaction* pTrans, PTDNF pTdnf, - PTDNF_PKG_INFO* pPkgInfo); + PTDNF_PKG_INFO* pPkgInfo, + PTDNF_PKG_INFO* pRemovePkgInfo, + int nIsUpgrade +); uint32_t TDNFGetErasePackages( @@ -510,14 +513,6 @@ TDNFGetObsoletedPackages( PTDNF_PKG_INFO* pPkgInfo ); -uint32_t -TDNFGetDownGradePackages( - Transaction* pTrans, - PTDNF pTdnf, - PTDNF_PKG_INFO* pPkgInfo, - PTDNF_PKG_INFO* pRemovePkgInfo - ); - uint32_t TDNFPkgsToExclude( PTDNF pTdnf, diff --git a/client/rpmtrans.c b/client/rpmtrans.c index f5d122ed..8752669c 100644 --- a/client/rpmtrans.c +++ b/client/rpmtrans.c @@ -365,6 +365,29 @@ TDNFRpmExecHistoryTransaction( goto cleanup; } +static +uint32_t +TDNFDeletePackages(PTDNF_PKG_INFO pInfoList) +{ + uint32_t dwError = 0; + PTDNF_PKG_INFO pInfo = NULL; + + for (pInfo = pInfoList; + pInfo; + pInfo = pInfo->pNext) { + if (pInfo->pszLocation) { + if(unlink(pInfo->pszLocation)) { + dwError = errno; + BAIL_ON_TDNF_SYSTEM_ERROR(dwError); + } + } + } +cleanup: + return dwError; +error: + goto cleanup; +} + uint32_t TDNFPopulateTransaction( PTDNFRPMTS pTS, @@ -430,9 +453,17 @@ TDNFPopulateTransaction( } } + if (pTdnf->pArgs->nInstallToDir) { + dwError = TDNFDeletePackages(pSolvedInfo->pPkgsRemovedByUpgrade); + BAIL_ON_TDNF_ERROR(dwError); + dwError = TDNFDeletePackages(pSolvedInfo->pPkgsRemovedByDowngrade); + BAIL_ON_TDNF_ERROR(dwError); + dwError = TDNFDeletePackages(pSolvedInfo->pPkgsObsoleted); + BAIL_ON_TDNF_ERROR(dwError); + } + cleanup: return dwError; - error: goto cleanup; } diff --git a/common/utils.c b/common/utils.c index 46595541..bc00406c 100644 --- a/common/utils.c +++ b/common/utils.c @@ -291,6 +291,7 @@ TDNFFreeSolvedPackageInfo( TDNF_SAFE_FREE_PKGINFO(pSolvedPkgInfo->pPkgsToReinstall); TDNF_SAFE_FREE_PKGINFO(pSolvedPkgInfo->pPkgsObsoleted); TDNF_SAFE_FREE_PKGINFO(pSolvedPkgInfo->pPkgsRemovedByDowngrade); + TDNF_SAFE_FREE_PKGINFO(pSolvedPkgInfo->pPkgsRemovedByUpgrade); TDNF_SAFE_FREE_STRINGARRAY(pSolvedPkgInfo->ppszPkgsNotResolved); TDNF_SAFE_FREE_STRINGARRAY(pSolvedPkgInfo->ppszPkgsUserInstall); diff --git a/include/tdnftypes.h b/include/tdnftypes.h index 5c64c07c..77e8bd5c 100644 --- a/include/tdnftypes.h +++ b/include/tdnftypes.h @@ -187,6 +187,7 @@ typedef struct _TDNF_SOLVED_PKG_INFO PTDNF_PKG_INFO pPkgsUnNeeded; PTDNF_PKG_INFO pPkgsToReinstall; PTDNF_PKG_INFO pPkgsObsoleted; + PTDNF_PKG_INFO pPkgsRemovedByUpgrade; PTDNF_PKG_INFO pPkgsRemovedByDowngrade; char** ppszPkgsNotResolved; char** ppszPkgsUserInstall; diff --git a/solv/tdnfpackage.c b/solv/tdnfpackage.c index e5d95133..060a5d1b 100644 --- a/solv/tdnfpackage.c +++ b/solv/tdnfpackage.c @@ -792,7 +792,7 @@ SolvGetPkgLocationFromId( } if(ppszLocation) { - ppszLocation = NULL; + *ppszLocation = NULL; } TDNF_SAFE_FREE_MEMORY(pszLocation); goto cleanup;