From 303b82ea727841e5bd6f3013436e9091f8d2fc64 Mon Sep 17 00:00:00 2001 From: Priyesh Padmavilasom <ppadmavilasom@vmware.com> Date: Tue, 10 Oct 2017 00:02:32 +0000 Subject: [PATCH] add protected packages to obsoletes path Change-Id: I599bee849b1dce3a744d2bf0db4bcf270df3df62 (cherry picked from commit 771948ff1cdeb17ef508ac314fec4bc3605b3f79) --- client/api.c | 14 ++----------- client/packageutils.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++ client/prototypes.h | 5 +++++ client/remoterepo.c | 2 +- 4 files changed, 62 insertions(+), 13 deletions(-) diff --git a/client/api.c b/client/api.c index b03916a..e82501c 100644 --- a/client/api.c +++ b/client/api.c @@ -867,7 +867,6 @@ TDNFResolve( HyPackageList hPkgListGoal = NULL; PTDNF_SOLVED_PKG_INFO pSolvedPkgInfo = NULL; - PTDNF_PKG_INFO pPkgInfo = NULL; if(!pTdnf || !ppSolvedPkgInfo) { @@ -916,17 +915,8 @@ TDNFResolve( pSolvedPkgInfo); BAIL_ON_TDNF_ERROR(dwError); - pPkgInfo = pSolvedPkgInfo->pPkgsToRemove; - while(pPkgInfo != NULL) - { - if(pPkgInfo->pszName != NULL && - strcmp(pPkgInfo->pszName, TDNF_NAME) == 0) - { - dwError = ERROR_TDNF_SELF_ERASE; - BAIL_ON_TDNF_ERROR(dwError); - } - pPkgInfo = pPkgInfo->pNext; - } + dwError = TDNFCheckProtectedPkgs(pSolvedPkgInfo); + BAIL_ON_TDNF_ERROR(dwError); pSolvedPkgInfo->nNeedAction = pSolvedPkgInfo->pPkgsToInstall || diff --git a/client/packageutils.c b/client/packageutils.c index b2f6a82..6e3e09b 100644 --- a/client/packageutils.c +++ b/client/packageutils.c @@ -1108,3 +1108,57 @@ TDNFAddPackagesForDowngrade( error: goto cleanup; } + +uint32_t +TDNFHasProtectedPkgsInList( + PTDNF_PKG_INFO pPkgInfo + ) +{ + uint32_t dwError = 0; + + if(!pPkgInfo) + { + dwError = ERROR_TDNF_INVALID_PARAMETER; + BAIL_ON_TDNF_ERROR(dwError); + } + + for(; pPkgInfo; pPkgInfo = pPkgInfo->pNext) + { + if(pPkgInfo->pszName && !strcmp(pPkgInfo->pszName, TDNF_NAME)) + { + dwError = ERROR_TDNF_SELF_ERASE; + BAIL_ON_TDNF_ERROR(dwError); + } + } +error: + return dwError; +} + +uint32_t +TDNFCheckProtectedPkgs( + PTDNF_SOLVED_PKG_INFO pSolvedPkgInfo + ) +{ + uint32_t dwError = 0; + + if(!pSolvedPkgInfo) + { + dwError = ERROR_TDNF_INVALID_PARAMETER; + BAIL_ON_TDNF_ERROR(dwError); + } + + if(pSolvedPkgInfo->pPkgsToRemove) + { + dwError = TDNFHasProtectedPkgsInList(pSolvedPkgInfo->pPkgsToRemove); + BAIL_ON_TDNF_ERROR(dwError); + } + + if(pSolvedPkgInfo->pPkgsObsoleted) + { + dwError = TDNFHasProtectedPkgsInList(pSolvedPkgInfo->pPkgsObsoleted); + BAIL_ON_TDNF_ERROR(dwError); + } + +error: + return dwError; +} diff --git a/client/prototypes.h b/client/prototypes.h index f5cdb2e..4586d3b 100644 --- a/client/prototypes.h +++ b/client/prototypes.h @@ -277,6 +277,11 @@ TDNFAddPackagesForDowngrade( HyPackageList hPkgListGoal ); +uint32_t +TDNFCheckProtectedPkgs( + PTDNF_SOLVED_PKG_INFO pSolvedPkgInfo + ); + //goal.c uint32_t TDNFGoalGetResultsIgnoreNoData( diff --git a/client/remoterepo.c b/client/remoterepo.c index 946aafd..8011a38 100644 --- a/client/remoterepo.c +++ b/client/remoterepo.c @@ -197,7 +197,7 @@ TDNFDownloadFile( { uint32_t nCurlError = dwError - ERROR_TDNF_CURL_BASE; fprintf(stderr, - "download error: %d - %s\n", + "curl#%d: %s\n", nCurlError, curl_easy_strerror(nCurlError)); }