diff --git a/CMakeLists.txt b/CMakeLists.txt index 5b84fb5d..9f0abf98 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright (C) 2019-2022 VMware, Inc. All Rights Reserved. +# Copyright (C) 2019-2023 VMware, Inc. All Rights Reserved. # # Licensed under the GNU General Public License v2 (the "License"); # you may not use this file except in compliance with the License. The terms @@ -8,7 +8,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 3.0 FATAL_ERROR) -project(tdnf VERSION 3.5.1 LANGUAGES C) +project(tdnf VERSION 3.5.2 LANGUAGES C) set(VERSION ${PROJECT_VERSION}) set(PROJECT_YEAR 2023) diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index 5043a0f0..106e5d53 100644 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright (C) 2020-2022 VMware, Inc. All Rights Reserved. +# Copyright (C) 2020-2023 VMware, Inc. All Rights Reserved. # # Licensed under the GNU General Public License v2 (the "License"); # you may not use this file except in compliance with the License. The terms diff --git a/client/api.c b/client/api.c index 4cee118a..8b134e82 100644 --- a/client/api.c +++ b/client/api.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015-2022 VMware, Inc. All Rights Reserved. + * Copyright (C) 2015-2023 VMware, Inc. All Rights Reserved. * * Licensed under the GNU Lesser General Public License v2.1 (the "License"); * you may not use this file except in compliance with the License. The terms @@ -1675,9 +1675,6 @@ TDNFResolve( } BAIL_ON_TDNF_ERROR(dwError); - dwError = TDNFCheckProtectedPkgs(pSolvedPkgInfo); - BAIL_ON_TDNF_ERROR(dwError); - pSolvedPkgInfo->nNeedAction = pSolvedPkgInfo->pPkgsToInstall || pSolvedPkgInfo->pPkgsToUpgrade || diff --git a/client/client.c b/client/client.c index 3eb1a8fb..c96733f2 100644 --- a/client/client.c +++ b/client/client.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015-2020 VMware, Inc. All Rights Reserved. + * Copyright (C) 2015-2022 VMware, Inc. All Rights Reserved. * * Licensed under the GNU Lesser General Public License v2.1 (the "License"); * you may not use this file except in compliance with the License. The terms diff --git a/client/config.c b/client/config.c index 7bf82075..4152d367 100644 --- a/client/config.c +++ b/client/config.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015-2022 VMware, Inc. All Rights Reserved. + * Copyright (C) 2015-2023 VMware, Inc. All Rights Reserved. * * Licensed under the GNU Lesser General Public License v2.1 (the "License"); * you may not use this file except in compliance with the License. The terms @@ -53,10 +53,10 @@ TDNFReadConfig( { uint32_t dwError = 0; PTDNF_CONF pConf = NULL; - char *pszConfFileCopy = NULL; + char *pszConfDir = NULL; char *pszMinVersionsDir = NULL; - char *pszConfFileCopy2 = NULL; char *pszPkgLocksDir = NULL; + char *pszProtectedDir = NULL; const char *pszProxyUser = NULL; const char *pszProxyPass = NULL; @@ -239,33 +239,35 @@ TDNFReadConfig( if (pConf->pszPersistDir == NULL) pConf->pszPersistDir = strdup(TDNF_DEFAULT_DB_LOCATION); - /* We need a copy of pszConfFile because dirname() modifies its argument */ - dwError = TDNFAllocateString(pszConfFile, &pszConfFileCopy); + dwError = TDNFDirName(pszConfFile, &pszConfDir); BAIL_ON_TDNF_ERROR(dwError); - dwError = TDNFJoinPath(&pszMinVersionsDir, dirname(pszConfFileCopy), "minversions.d", NULL); + dwError = TDNFJoinPath(&pszMinVersionsDir, pszConfDir, "minversions.d", NULL); BAIL_ON_TDNF_ERROR(dwError); dwError = TDNFReadConfFilesFromDir(pszMinVersionsDir, &pConf->ppszMinVersions); BAIL_ON_TDNF_ERROR(dwError); - dwError = TDNFAllocateString(pszConfFile, &pszConfFileCopy2); + dwError = TDNFJoinPath(&pszPkgLocksDir, pszConfDir, "locks.d", NULL); BAIL_ON_TDNF_ERROR(dwError); - dwError = TDNFJoinPath(&pszPkgLocksDir, dirname(pszConfFileCopy2), "locks.d", NULL); + dwError = TDNFReadConfFilesFromDir(pszPkgLocksDir, &pConf->ppszPkgLocks); BAIL_ON_TDNF_ERROR(dwError); - dwError = TDNFReadConfFilesFromDir(pszPkgLocksDir, &pConf->ppszPkgLocks); + dwError = TDNFJoinPath(&pszProtectedDir, pszConfDir, "protected.d", NULL); + BAIL_ON_TDNF_ERROR(dwError); + + dwError = TDNFReadConfFilesFromDir(pszProtectedDir, &pConf->ppszProtectedPkgs); BAIL_ON_TDNF_ERROR(dwError); pTdnf->pConf = pConf; cleanup: destroy_cnftree(cn_conf); - TDNF_SAFE_FREE_MEMORY(pszConfFileCopy); - TDNF_SAFE_FREE_MEMORY(pszConfFileCopy2); + TDNF_SAFE_FREE_MEMORY(pszConfDir); TDNF_SAFE_FREE_MEMORY(pszMinVersionsDir); TDNF_SAFE_FREE_MEMORY(pszPkgLocksDir); + TDNF_SAFE_FREE_MEMORY(pszProtectedDir); return dwError; error: @@ -345,6 +347,7 @@ TDNFFreeConfig( TDNF_SAFE_FREE_STRINGARRAY(pConf->ppszExcludes); TDNF_SAFE_FREE_STRINGARRAY(pConf->ppszMinVersions); TDNF_SAFE_FREE_STRINGARRAY(pConf->ppszPkgLocks); + TDNF_SAFE_FREE_STRINGARRAY(pConf->ppszProtectedPkgs); TDNFFreeMemory(pConf); } } diff --git a/client/defines.h b/client/defines.h index 593e6955..602b2498 100644 --- a/client/defines.h +++ b/client/defines.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015-2022 VMware, Inc. All Rights Reserved. + * Copyright (C) 2015-2023 VMware, Inc. All Rights Reserved. * * Licensed under the GNU Lesser General Public License v2.1 (the "License"); * you may not use this file except in compliance with the License. The terms @@ -234,7 +234,7 @@ typedef enum {ERROR_TDNF_RPM_CHECK, "ERROR_TDNF_RPM_CHECK", "rpm check reported errors"}, \ {ERROR_TDNF_RPMTS_BAD_ROOT_DIR, "ERROR_TDNF_RPMTS_BAD_ROOT_DIR", "Bad root directory"}, \ {ERROR_TDNF_METADATA_EXPIRE_PARSE, "ERROR_TDNF_METADATA_EXPIRE_PARSE", "metadata_expire value could not be parsed. Check your repo files."},\ - {ERROR_TDNF_SELF_ERASE, "ERROR_TDNF_SELF_ERASE", "The operation would result in removing the protected package : tdnf"},\ + {ERROR_TDNF_PROTECTED, "ERROR_TDNF_PROTECTED", "The operation would result in removing a protected package."},\ {ERROR_TDNF_DOWNGRADE_NOT_ALLOWED,\ "ERROR_TDNF_DOWNGRADE_NOT_ALLOWED",\ "a downgrade is not allowed below the minimal version. Check 'minversions' in the configuration."},\ diff --git a/client/goal.c b/client/goal.c index f02b5a8b..f1fb2447 100644 --- a/client/goal.c +++ b/client/goal.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015-2022 VMware, Inc. All Rights Reserved. + * Copyright (C) 2015-2023 VMware, Inc. All Rights Reserved. * * Licensed under the GNU Lesser General Public License v2.1 (the "License"); * you may not use this file except in compliance with the License. The terms @@ -355,7 +355,12 @@ TDNFSolv( if(nAllowErasing) { - solver_set_flag(pSolv, SOLVER_FLAG_ALLOW_UNINSTALL, 1); + if (pTdnf->pConf->ppszProtectedPkgs) { + dwError = TDNFSolvAddProtectPkgs(pTdnf, pQueueJobs, pTdnf->pSack->pPool); + BAIL_ON_TDNF_ERROR(dwError); + } else { + solver_set_flag(pSolv, SOLVER_FLAG_ALLOW_UNINSTALL, 1); + } } solver_set_flag(pSolv, SOLVER_FLAG_BEST_OBEY_POLICY, 1); solver_set_flag(pSolv, SOLVER_FLAG_ALLOW_VENDORCHANGE, 1); @@ -387,6 +392,12 @@ TDNFSolv( BAIL_ON_TDNF_ERROR(dwError); } + if (pTdnf->pConf->ppszProtectedPkgs) { + /* catch protected obsoleted packages, and double check for removals */ + dwError = TDNFSolvCheckProtectPkgsInTrans(pTdnf, pTrans, pTdnf->pSack->pPool); + BAIL_ON_TDNF_ERROR(dwError); + } + dwError = TDNFGoalGetAllResultsIgnoreNoData( pTrans, pSolv, @@ -1037,3 +1048,138 @@ TDNFSolvAddMinVersions( goto cleanup; } +uint32_t +TDNFSolvAddProtectPkgs( + PTDNF pTdnf, + Queue* pQueueJobs, + Pool *pPool + ) +{ + uint32_t dwError = 0; + char **ppszProtectedPkgs = NULL; + int i, j; + Queue qPkgs = {0}; + Id p; + Solvable *s; + + if(!pTdnf || !pQueueJobs || !pPool || !pTdnf->pConf) + { + dwError = ERROR_TDNF_INVALID_PARAMETER; + BAIL_ON_TDNF_ERROR(dwError); + } + + ppszProtectedPkgs = pTdnf->pConf->ppszProtectedPkgs; + queue_init(&qPkgs); + for (i = 0; ppszProtectedPkgs[i]; i++) { + Id idPkg = pool_str2id(pPool, ppszProtectedPkgs[i], 1); + if (idPkg) { + queue_push(&qPkgs, idPkg); + } + } + + /* Not setting SOLVER_ALLOWUNINSTALL will not prevent a package from being + uninstalled if it's going to be removed directly. */ + for (j = 0; j < pQueueJobs->count; j += 2) { + Id how = pQueueJobs->elements[j]; + /* assuming that all erase jobs that we added use SOLVER_SOLVABLE */ + if (((how & SOLVER_JOBMASK) == SOLVER_ERASE) && (how & SOLVER_SOLVABLE)) { + Id what = pQueueJobs->elements[j+1]; + Solvable *s = pool_id2solvable(pPool, what); + for (i = 0; i < qPkgs.count; i++) { + if (qPkgs.elements[i] == s->name) + break; + } + if (i < qPkgs.count) { + pr_err("package %s is protected\n", ppszProtectedPkgs[i]); + dwError = ERROR_TDNF_PROTECTED; + BAIL_ON_TDNF_ERROR(dwError); + } + } + } + + /* There is no "SOLVER_PROTECTED" flag, so we allow + all pkgs that are not protected to be removed. */ + FOR_REPO_SOLVABLES(pPool->installed, p, s) + { + for (i = 0; i < qPkgs.count; i++) { + if (qPkgs.elements[i] == s->name) + break; + } + if (i == qPkgs.count) { + queue_push2(pQueueJobs, SOLVER_SOLVABLE|SOLVER_ALLOWUNINSTALL, p); + } else { + /* autoerase would remove this, even if we do not set + SOLVER_ALLOWUNINSTALL for it */ + queue_push2(pQueueJobs, SOLVER_SOLVABLE|SOLVER_USERINSTALLED, p); + } + } + +cleanup: + queue_free(&qPkgs); + return dwError; +error: + goto cleanup; +} + +uint32_t +TDNFSolvCheckProtectPkgsInTrans( + PTDNF pTdnf, + Transaction *pTrans, + Pool *pPool + ) +{ + uint32_t dwError = 0; + char **ppszProtectedPkgs = NULL; + int i; + Queue qPkgs = {0}; + + if(!pTdnf || !pTrans || !pPool || !pTdnf->pConf) + { + dwError = ERROR_TDNF_INVALID_PARAMETER; + BAIL_ON_TDNF_ERROR(dwError); + } + + ppszProtectedPkgs = pTdnf->pConf->ppszProtectedPkgs; + queue_init(&qPkgs); + for (i = 0; ppszProtectedPkgs[i]; i++) { + Id idPkg = pool_str2id(pPool, ppszProtectedPkgs[i], 1); + if (idPkg) { + queue_push(&qPkgs, idPkg); + } + } + + for (i = 0; i < pTrans->steps.count; i++) { + Id idType; + Id idPkg = pTrans->steps.elements[i]; + + idType = transaction_type(pTrans, idPkg, + SOLVER_TRANSACTION_SHOW_OBSOLETES); + if (idType != SOLVER_TRANSACTION_OBSOLETED) { + idType = transaction_type(pTrans, idPkg, + SOLVER_TRANSACTION_SHOW_ACTIVE| + SOLVER_TRANSACTION_SHOW_ALL); + } + if (idType == SOLVER_TRANSACTION_OBSOLETED || + idType == SOLVER_TRANSACTION_ERASE) { + int j; + Solvable *s = pool_id2solvable(pPool, idPkg); + for (j = 0; j < qPkgs.count; j++) { + if (qPkgs.elements[j] == s->name) { + pr_err("package %s would be %s but it is protected\n", + ppszProtectedPkgs[j], + idType == SOLVER_TRANSACTION_OBSOLETED ? + "obsoleted" : "removed"); + dwError = ERROR_TDNF_PROTECTED; + BAIL_ON_TDNF_ERROR(dwError); + } + } + } + } + +cleanup: + queue_free(&qPkgs); + return dwError; +error: + goto cleanup; +} + diff --git a/client/gpgcheck.c b/client/gpgcheck.c index 094379b9..c1de60bb 100644 --- a/client/gpgcheck.c +++ b/client/gpgcheck.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015-2021 VMware, Inc. All Rights Reserved. + * Copyright (C) 2015-2023 VMware, Inc. All Rights Reserved. * * Licensed under the GNU Lesser General Public License v2.1 (the "License"); * you may not use this file except in compliance with the License. The terms @@ -516,7 +516,6 @@ TDNFFetchRemoteGPGKey( uint32_t dwError = 0; char* pszFilePath = NULL; char* pszNormalPath = NULL; - char* pszFilePathCopy = NULL; char* pszTopKeyCacheDir = NULL; char* pszRealTopKeyCacheDir = NULL; char* pszDownloadCacheDir = NULL; @@ -562,16 +561,8 @@ TDNFFetchRemoteGPGKey( BAIL_ON_TDNF_ERROR(dwError); } - // dirname() may modify the contents of path, so it may be desirable to - // pass a copy when calling this function. - dwError = TDNFAllocateString(pszNormalPath, &pszFilePathCopy); + dwError = TDNFDirName(pszNormalPath, &pszDownloadCacheDir); BAIL_ON_TDNF_ERROR(dwError); - pszDownloadCacheDir = dirname(pszFilePathCopy); - if(!pszDownloadCacheDir) - { - dwError = ENOENT; - BAIL_ON_TDNF_SYSTEM_ERROR(dwError); - } if(access(pszDownloadCacheDir, F_OK)) { @@ -595,7 +586,7 @@ TDNFFetchRemoteGPGKey( TDNF_SAFE_FREE_MEMORY(pszFilePath); TDNF_SAFE_FREE_MEMORY(pszRealTopKeyCacheDir); TDNF_SAFE_FREE_MEMORY(pszTopKeyCacheDir); - TDNF_SAFE_FREE_MEMORY(pszFilePathCopy); + TDNF_SAFE_FREE_MEMORY(pszDownloadCacheDir); TDNF_SAFE_FREE_MEMORY(pszKeyLocation); return dwError; diff --git a/client/includes.h b/client/includes.h index 470f3ba9..93fee6e9 100644 --- a/client/includes.h +++ b/client/includes.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015-2022 VMware, Inc. All Rights Reserved. + * Copyright (C) 2015-2023 VMware, Inc. All Rights Reserved. * * Licensed under the GNU Lesser General Public License v2.1 (the "License"); * you may not use this file except in compliance with the License. The terms diff --git a/client/init.c b/client/init.c index 8ccc27ad..7053e9ca 100644 --- a/client/init.c +++ b/client/init.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015-2022 VMware, Inc. All Rights Reserved. + * Copyright (C) 2015-2023 VMware, Inc. All Rights Reserved. * * Licensed under the GNU Lesser General Public License v2.1 (the "License"); * you may not use this file except in compliance with the License. The terms diff --git a/client/packageutils.c b/client/packageutils.c index 57202f36..adc38707 100644 --- a/client/packageutils.c +++ b/client/packageutils.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015-2022 VMware, Inc. All Rights Reserved. + * Copyright (C) 2015-2023 VMware, Inc. All Rights Reserved. * * Licensed under the GNU Lesser General Public License v2.1 (the "License"); * you may not use this file except in compliance with the License. The terms @@ -854,60 +854,6 @@ TDNFAddPackagesForDowngrade( 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; -} - uint32_t TDNFGetAvailableCacheBytes( PTDNF_CONF pConf, diff --git a/client/plugins.c b/client/plugins.c index bcbe1345..05a87f23 100644 --- a/client/plugins.c +++ b/client/plugins.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020-2022 VMware, Inc. All Rights Reserved. + * Copyright (C) 2020-2023 VMware, Inc. All Rights Reserved. * * Licensed under the GNU Lesser General Public License v2.1 (the "License"); * you may not use this file except in compliance with the License. The terms diff --git a/client/prototypes.h b/client/prototypes.h index 2c6a2b20..9ff3e7d0 100644 --- a/client/prototypes.h +++ b/client/prototypes.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015-2022 VMware, Inc. All Rights Reserved. + * Copyright (C) 2015-2023 VMware, Inc. All Rights Reserved. * * Licensed under the GNU Lesser General Public License v2.1 (the "License"); * you may not use this file except in compliance with the License. The terms @@ -377,11 +377,6 @@ TDNFAddPackagesForDowngrade( const char* pszPkgName ); -uint32_t -TDNFCheckProtectedPkgs( - PTDNF_SOLVED_PKG_INFO pSolvedPkgInfo - ); - uint32_t TDNFGetAvailableCacheBytes( PTDNF_CONF pConf, @@ -535,6 +530,20 @@ TDNFSolvAddMinVersions( Pool *pPool ); +uint32_t +TDNFSolvAddProtectPkgs( + PTDNF pTdnf, + Queue* pQueueJobs, + Pool *pPool + ); + +uint32_t +TDNFSolvCheckProtectPkgsInTrans( + PTDNF pTdnf, + Transaction *pTrans, + Pool *pPool + ); + //config.c int TDNFConfGetRpmVerbosity( diff --git a/client/remoterepo.c b/client/remoterepo.c index bef3046d..60adbb03 100644 --- a/client/remoterepo.c +++ b/client/remoterepo.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015-2022 VMware, Inc. All Rights Reserved. + * Copyright (C) 2015-2023 VMware, Inc. All Rights Reserved. * * Licensed under the GNU Lesser General Public License v2.1 (the "License"); * you may not use this file except in compliance with the License. The terms @@ -487,7 +487,6 @@ TDNFDownloadPackageToTree( uint32_t dwError = 0; char* pszFilePath = NULL; char* pszNormalPath = NULL; - char* pszFilePathCopy = NULL; char* pszDownloadCacheDir = NULL; char* pszRemotePath = NULL; @@ -524,16 +523,8 @@ TDNFDownloadPackageToTree( BAIL_ON_TDNF_ERROR(dwError); } - // dirname() may modify the contents of path, so it may be desirable to - // pass a copy when calling this function. - dwError = TDNFAllocateString(pszNormalPath, &pszFilePathCopy); + dwError = TDNFDirName(pszNormalPath, &pszDownloadCacheDir); BAIL_ON_TDNF_ERROR(dwError); - pszDownloadCacheDir = dirname(pszFilePathCopy); - if(!pszDownloadCacheDir) - { - dwError = ENOENT; - BAIL_ON_TDNF_SYSTEM_ERROR(dwError); - } if(access(pszDownloadCacheDir, F_OK)) { @@ -562,7 +553,7 @@ TDNFDownloadPackageToTree( *ppszFilePath = pszNormalPath; cleanup: TDNF_SAFE_FREE_MEMORY(pszFilePath); - TDNF_SAFE_FREE_MEMORY(pszFilePathCopy); + TDNF_SAFE_FREE_MEMORY(pszDownloadCacheDir); TDNF_SAFE_FREE_MEMORY(pszRemotePath); return dwError; diff --git a/client/repo.c b/client/repo.c index 9fd69fdc..9e910cd2 100644 --- a/client/repo.c +++ b/client/repo.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015-2022 VMware, Inc. All Rights Reserved. + * Copyright (C) 2015-2023 VMware, Inc. All Rights Reserved. * * Licensed under the GNU Lesser General Public License v2.1 (the "License"); * you may not use this file except in compliance with the License. The terms diff --git a/client/repolist.c b/client/repolist.c index ef087b57..b1d48b9d 100644 --- a/client/repolist.c +++ b/client/repolist.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015-2022 VMware, Inc. All Rights Reserved. + * Copyright (C) 2015-2023 VMware, Inc. All Rights Reserved. * * Licensed under the GNU Lesser General Public License v2.1 (the "License"); * you may not use this file except in compliance with the License. The terms diff --git a/client/repoutils.c b/client/repoutils.c index 42a3bef6..6a9d1f5e 100644 --- a/client/repoutils.c +++ b/client/repoutils.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015-2021 VMware, Inc. All Rights Reserved. + * Copyright (C) 2015-2022 VMware, Inc. All Rights Reserved. * * Licensed under the GNU Lesser General Public License v2.1 (the "License"); * you may not use this file except in compliance with the License. The terms diff --git a/client/resolve.c b/client/resolve.c index 9f5ac5bf..cb7ca0f1 100644 --- a/client/resolve.c +++ b/client/resolve.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015-2022 VMware, Inc. All Rights Reserved. + * Copyright (C) 2015-2023 VMware, Inc. All Rights Reserved. * * Licensed under the GNU Lesser General Public License v2.1 (the "License"); * you may not use this file except in compliance with the License. The terms diff --git a/client/rpmtrans.c b/client/rpmtrans.c index 6f415e85..7e78b4fa 100644 --- a/client/rpmtrans.c +++ b/client/rpmtrans.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015-2022 VMware, Inc. All Rights Reserved. + * Copyright (C) 2015-2023 VMware, Inc. All Rights Reserved. * * Licensed under the GNU Lesser General Public License v2.1 (the "License"); * you may not use this file except in compliance with the License. The terms diff --git a/client/utils.c b/client/utils.c index d5ae62b1..2de40763 100644 --- a/client/utils.c +++ b/client/utils.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015-2022 VMware, Inc. All Rights Reserved. + * Copyright (C) 2015-2023 VMware, Inc. All Rights Reserved. * * Licensed under the GNU Lesser General Public License v2.1 (the "License"); * you may not use this file except in compliance with the License. The terms diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index d73aefe0..079b09ae 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright (C) 2020-2022 VMware, Inc. All Rights Reserved. +# Copyright (C) 2020-2023 VMware, Inc. All Rights Reserved. # # Licensed under the GNU General Public License v2 (the "License"); # you may not use this file except in compliance with the License. The terms diff --git a/common/defines.h b/common/defines.h index 550d1bd9..e2969b21 100644 --- a/common/defines.h +++ b/common/defines.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015-2021 VMware, Inc. All Rights Reserved. + * Copyright (C) 2015-2023 VMware, Inc. All Rights Reserved. * * Licensed under the GNU Lesser General Public License v2.1 (the "License"); * you may not use this file except in compliance with the License. The terms diff --git a/common/includes.h b/common/includes.h index 1aab326c..02e5abdf 100644 --- a/common/includes.h +++ b/common/includes.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015-2022 VMware, Inc. All Rights Reserved. + * Copyright (C) 2015-2023 VMware, Inc. All Rights Reserved. * * Licensed under the GNU Lesser General Public License v2.1 (the "License"); * you may not use this file except in compliance with the License. The terms @@ -20,6 +20,7 @@ #include #include #include +#include #include #include diff --git a/common/lock.c b/common/lock.c index 3ba2250a..a0cecf71 100644 --- a/common/lock.c +++ b/common/lock.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021-2022 VMware, Inc. All Rights Reserved. + * Copyright (C) 2021-2023 VMware, Inc. All Rights Reserved. * * Licensed under the GNU Lesser General Public License v2.1 (the "License"); * you may not use this file except in compliance with the License. The terms diff --git a/common/log.c b/common/log.c index 0e5c74fa..cf91ded3 100644 --- a/common/log.c +++ b/common/log.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019-2022 VMware, Inc. All Rights Reserved. + * Copyright (C) 2019-2023 VMware, Inc. All Rights Reserved. * * Licensed under the GNU Lesser General Public License v2.1 (the "License"); * you may not use this file except in compliance with the License. The terms @@ -83,7 +83,7 @@ void log_console(int32_t loglevel, const char *format, ...) } vfprintf(stream, format, args); - + fflush(stream); end: va_end(args); } diff --git a/common/prototypes.h b/common/prototypes.h index e7d54dd5..6747240b 100644 --- a/common/prototypes.h +++ b/common/prototypes.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015-2022 VMware, Inc. All Rights Reserved. + * Copyright (C) 2015-2023 VMware, Inc. All Rights Reserved. * * Licensed under the GNU Lesser General Public License v2.1 (the "License"); * you may not use this file except in compliance with the License. The terms @@ -223,6 +223,12 @@ TDNFIsDir( int* pnPathIsDir ); +uint32_t +TDNFDirName( + const char *pszPath, + char **ppszDirName +); + //setopt.c uint32_t AddSetOpt( diff --git a/common/strings.c b/common/strings.c index 3740bd76..4c37292a 100644 --- a/common/strings.c +++ b/common/strings.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015-2022 VMware, Inc. All Rights Reserved. + * Copyright (C) 2015-2023 VMware, Inc. All Rights Reserved. * * Licensed under the GNU Lesser General Public License v2.1 (the "License"); * you may not use this file except in compliance with the License. The terms @@ -143,7 +143,7 @@ TDNFSplitStringToArray( size_t nCount = 0; size_t nIndex = 0; - if (!pszBuf || IsNullOrEmptyString(pszSep)) + if (!pszBuf || IsNullOrEmptyString(pszSep) || !pppszTokens) { dwError = ERROR_TDNF_INVALID_PARAMETER; BAIL_ON_TDNF_ERROR(dwError); diff --git a/common/utils.c b/common/utils.c index 0da70b6d..2fef6963 100644 --- a/common/utils.c +++ b/common/utils.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015-2022 VMware, Inc. All Rights Reserved. + * Copyright (C) 2015-2023 VMware, Inc. All Rights Reserved. * * Licensed under the GNU Lesser General Public License v2.1 (the "License"); * you may not use this file except in compliance with the License. The terms @@ -37,6 +37,11 @@ TDNFFileReadAllText( fseek(fp, 0, SEEK_END); nLength = ftell(fp); + if (nLength < 0) { + dwError = errno; + BAIL_ON_TDNF_SYSTEM_ERROR(dwError); + } + dwError = TDNFAllocateMemory(1, nLength + 1, (void **)&pszText); BAIL_ON_TDNF_ERROR(dwError); @@ -428,13 +433,24 @@ TDNFYesOrNo( if(!pArgs->nAssumeYes && !pArgs->nAssumeNo) { - pr_crit("%s", pszQuestion); - while ((opt = getchar()) == '\n' || opt == '\r'); - opt = tolower(opt); - if (opt != 'y' && opt != 'n') - { - dwError = ERROR_TDNF_INVALID_INPUT; - BAIL_ON_TDNF_ERROR(dwError); + while(1) { + pr_crit("%s", pszQuestion); + char buf[256] = {0}; + char *ret; + + ret = fgets(buf, sizeof(buf)-1, stdin); + if (ret != buf || buf[0] == 0) { + /* should not happen */ + dwError = ERROR_TDNF_INVALID_INPUT; + BAIL_ON_TDNF_ERROR(dwError); + } + buf[strlen(buf)-1] = 0; + if (strcasecmp(buf, "yes") == 0 || strcasecmp(buf, "y") == 0 || + strcasecmp(buf, "n") == 0 || strcasecmp(buf, "no") == 0 || + buf[0] == 0) { + opt = tolower(buf[0]); + break; + } } } @@ -785,9 +801,9 @@ TDNFJoinPath(char **ppszPath, ...) dwError = TDNFAllocateString(pszNode, &pszNodeCopy); BAIL_ON_TDNF_ERROR(dwError); pszNodeTmp = pszNodeCopy; - /* if the first node is an absolute path, the result should be absolute - - * safe this by initializing with a '/' if absolute, otherwise with an empty string - * before stripping all leading slashes */ + /* if the first node is an absolute path, the result should be absolute - + * safe this by initializing with a '/' if absolute, otherwise with an empty string + * before stripping all leading slashes */ if (i == 0) { if (*pszNodeTmp == '/') @@ -801,10 +817,10 @@ TDNFJoinPath(char **ppszPath, ...) } BAIL_ON_TDNF_ERROR(dwError); } - /* now strip leading slashes */ + /* now strip leading slashes */ while(*pszNodeTmp == '/') pszNodeTmp++; - /* strip trailing slashes */ + /* strip trailing slashes */ nLengthTmp = strlen(pszNodeTmp); pszTmp = pszNodeTmp + nLengthTmp - 1; while(pszTmp >= pszNodeTmp && *pszTmp == '/') @@ -818,7 +834,7 @@ TDNFJoinPath(char **ppszPath, ...) BAIL_ON_TDNF_ERROR(dwError); strcat(pszResult, pszNodeTmp); - /* put new slashes between nodes, except for the end */ + /* put new slashes between nodes, except for the end */ if (i != nCount-1) { strcat(pszResult, "/"); @@ -906,3 +922,36 @@ TDNFIsDir( } goto cleanup; } + +uint32_t +TDNFDirName( + const char *pszPath, + char **ppszDirName +) +{ + uint32_t dwError = 0; + char *pszDirName = NULL; + char *pszPathCopy = NULL; + + if(!pszPath || IsNullOrEmptyString(pszPath) || !ppszDirName) + { + dwError = ERROR_TDNF_INVALID_PARAMETER; + BAIL_ON_TDNF_ERROR(dwError); + } + + dwError = TDNFAllocateString(pszPath, &pszPathCopy); + BAIL_ON_TDNF_ERROR(dwError); + + dwError = TDNFAllocateString(dirname(pszPathCopy), &pszDirName); + BAIL_ON_TDNF_ERROR(dwError); + + *ppszDirName = pszDirName; + +cleanup: + TDNF_SAFE_FREE_MEMORY(pszPathCopy); + return dwError; + +error: + TDNF_SAFE_FREE_MEMORY(pszDirName); + goto cleanup; +} \ No newline at end of file diff --git a/etc/tdnf/CMakeLists.txt b/etc/tdnf/CMakeLists.txt index f24d8ec8..3fd0e1a1 100644 --- a/etc/tdnf/CMakeLists.txt +++ b/etc/tdnf/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright (C) 2020 VMware, Inc. All Rights Reserved. +# Copyright (C) 2020-2022 VMware, Inc. All Rights Reserved. # # Licensed under the GNU General Public License v2 (the "License"); # you may not use this file except in compliance with the License. The terms diff --git a/etc/tdnf/pluginconf.d/CMakeLists.txt b/etc/tdnf/pluginconf.d/CMakeLists.txt index ed6ecf77..dc5b4048 100644 --- a/etc/tdnf/pluginconf.d/CMakeLists.txt +++ b/etc/tdnf/pluginconf.d/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright (C) 2020 VMware, Inc. All Rights Reserved. +# Copyright (C) 2020-2022 VMware, Inc. All Rights Reserved. # # Licensed under the GNU General Public License v2 (the "License"); # you may not use this file except in compliance with the License. The terms diff --git a/history/history.c b/history/history.c index 92597fee..bf652930 100644 --- a/history/history.c +++ b/history/history.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 VMware, Inc. All Rights Reserved. + * Copyright (C) 2022-2023 VMware, Inc. All Rights Reserved. * * Licensed under the GNU Lesser General Public License v2.1 (the "License"); * you may not use this file except in compliance with the License. The terms diff --git a/history/main.c b/history/main.c index e6bb4ae3..633b27de 100644 --- a/history/main.c +++ b/history/main.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 VMware, Inc. All Rights Reserved. + * Copyright (C) 2022-2023 VMware, Inc. All Rights Reserved. * * Licensed under the GNU Lesser General Public License v2.1 (the "License"); * you may not use this file except in compliance with the License. The terms diff --git a/include/tdnf-common-defines.h b/include/tdnf-common-defines.h index 0ea78d8a..1afe8c7b 100644 --- a/include/tdnf-common-defines.h +++ b/include/tdnf-common-defines.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020-2021 VMware, Inc. All Rights Reserved. + * Copyright (C) 2020-2022 VMware, Inc. All Rights Reserved. * * Licensed under the GNU Lesser General Public License v2.1 (the "License"); * you may not use this file except in compliance with the License. The terms diff --git a/include/tdnf.h b/include/tdnf.h index d9b2847a..76910ec9 100644 --- a/include/tdnf.h +++ b/include/tdnf.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015-2021 VMware, Inc. All Rights Reserved. + * Copyright (C) 2015-2022 VMware, Inc. All Rights Reserved. * * Licensed under the GNU Lesser General Public License v2.1 (the "License"); * you may not use this file except in compliance with the License. The terms diff --git a/include/tdnfclierror.h b/include/tdnfclierror.h index 45ed6521..38559d7f 100644 --- a/include/tdnfclierror.h +++ b/include/tdnfclierror.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017-2021 VMware, Inc. All Rights Reserved. + * Copyright (C) 2017-2023 VMware, Inc. All Rights Reserved. * * Licensed under the GNU Lesser General Public License v2.1 (the "License"); * you may not use this file except in compliance with the License. The terms diff --git a/include/tdnfclitypes.h b/include/tdnfclitypes.h index 3e3f4574..a1bc91eb 100644 --- a/include/tdnfclitypes.h +++ b/include/tdnfclitypes.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017-2021 VMware, Inc. All Rights Reserved. + * Copyright (C) 2017-2022 VMware, Inc. All Rights Reserved. * * Licensed under the GNU Lesser General Public License v2.1 (the "License"); * you may not use this file except in compliance with the License. The terms diff --git a/include/tdnferror.h b/include/tdnferror.h index d8b08d31..4ff7b40a 100644 --- a/include/tdnferror.h +++ b/include/tdnferror.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015-2021 VMware, Inc. All Rights Reserved. + * Copyright (C) 2015-2023 VMware, Inc. All Rights Reserved. * * Licensed under the GNU Lesser General Public License v2.1 (the "License"); * you may not use this file except in compliance with the License. The terms @@ -61,6 +61,7 @@ extern "C" { #define ERROR_TDNF_NO_DOWNGRADE_PATH 1028 // #define ERROR_TDNF_METADATA_EXPIRE_PARSE 1029 +#define ERROR_TDNF_PROTECTED 1030 #define ERROR_TDNF_SELF_ERASE 1030 #define ERROR_TDNF_ERASE_NEEDS_INSTALL 1031 #define ERROR_TDNF_OPERATION_ABORTED 1032 diff --git a/include/tdnfplugineventmap.h b/include/tdnfplugineventmap.h index 415cd721..551c3193 100644 --- a/include/tdnfplugineventmap.h +++ b/include/tdnfplugineventmap.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020 VMware, Inc. All Rights Reserved. + * Copyright (C) 2020-2022 VMware, Inc. All Rights Reserved. * * Licensed under the GNU Lesser General Public License v2.1 (the "License"); * you may not use this file except in compliance with the License. The terms diff --git a/include/tdnftypes.h b/include/tdnftypes.h index cca054cf..2d9e8005 100644 --- a/include/tdnftypes.h +++ b/include/tdnftypes.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015-2022 VMware, Inc. All Rights Reserved. + * Copyright (C) 2015-2023 VMware, Inc. All Rights Reserved. * * Licensed under the GNU Lesser General Public License v2.1 (the "License"); * you may not use this file except in compliance with the License. The terms @@ -266,6 +266,7 @@ typedef struct _TDNF_CONF char** ppszExcludes; char** ppszMinVersions; char** ppszPkgLocks; + char** ppszProtectedPkgs; }TDNF_CONF, *PTDNF_CONF; typedef struct _TDNF_REPO_DATA diff --git a/jsondump/jsondump.c b/jsondump/jsondump.c index 85e9b51d..00a95a18 100644 --- a/jsondump/jsondump.c +++ b/jsondump/jsondump.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 VMware, Inc. All Rights Reserved. + * Copyright (C) 2022-2023 VMware, Inc. All Rights Reserved. * * Licensed under the GNU General Public License v2 (the "License"); * you may not use this file except in compliance with the License. The terms diff --git a/jsondump/jsondump.h b/jsondump/jsondump.h index 04cf8e5b..30a320bc 100644 --- a/jsondump/jsondump.h +++ b/jsondump/jsondump.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 VMware, Inc. All Rights Reserved. + * Copyright (C) 2022-2023 VMware, Inc. All Rights Reserved. * * Licensed under the GNU General Public License v2 (the "License"); * you may not use this file except in compliance with the License. The terms diff --git a/llconf/CMakeLists.txt b/llconf/CMakeLists.txt index a15a649b..23a1b5e5 100644 --- a/llconf/CMakeLists.txt +++ b/llconf/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright (C) 2022 VMware, Inc. All Rights Reserved. +# Copyright (C) 2022-2023 VMware, Inc. All Rights Reserved. # # Licensed under the GNU General Public License v2 (the "License"); # you may not use this file except in compliance with the License. The terms diff --git a/plugins/metalink/includes.h b/plugins/metalink/includes.h index d0728d4b..585790d0 100644 --- a/plugins/metalink/includes.h +++ b/plugins/metalink/includes.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020 VMware, Inc. All Rights Reserved. + * Copyright (C) 2020-2022 VMware, Inc. All Rights Reserved. * * Licensed under the GNU Lesser General Public License v2.1 (the "License"); * you may not use this file except in compliance with the License. The terms diff --git a/plugins/metalink/list.c b/plugins/metalink/list.c index 9af8728b..c540ae22 100644 --- a/plugins/metalink/list.c +++ b/plugins/metalink/list.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 VMware, Inc. All Rights Reserved. + * Copyright (C) 2021-2022 VMware, Inc. All Rights Reserved. * * Licensed under the GNU Lesser General Public License v2.1 (the "License"); * you may not use this file except in compliance with the License. The terms diff --git a/plugins/metalink/metalink.c b/plugins/metalink/metalink.c index 2545e776..4a5383ca 100644 --- a/plugins/metalink/metalink.c +++ b/plugins/metalink/metalink.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 VMware, Inc. All Rights Reserved. + * Copyright (C) 2022-2023 VMware, Inc. All Rights Reserved. * * Licensed under the GNU Lesser General Public License v2.1 (the "License"); * you may not use this file except in compliance with the License. The terms diff --git a/plugins/metalink/prototypes.h b/plugins/metalink/prototypes.h index 7a48c24e..f311a0be 100644 --- a/plugins/metalink/prototypes.h +++ b/plugins/metalink/prototypes.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020 VMware, Inc. All Rights Reserved. + * Copyright (C) 2020-2022 VMware, Inc. All Rights Reserved. * * Licensed under the GNU Lesser General Public License v2.1 (the "License"); * you may not use this file except in compliance with the License. The terms diff --git a/plugins/metalink/utils.c b/plugins/metalink/utils.c index 709f0665..8e9761e9 100644 --- a/plugins/metalink/utils.c +++ b/plugins/metalink/utils.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 VMware, Inc. All Rights Reserved. + * Copyright (C) 2021-2023 VMware, Inc. All Rights Reserved. * * Licensed under the GNU Lesser General Public License v2.1 (the "License"); * you may not use this file except in compliance with the License. The terms diff --git a/plugins/repogpgcheck/CMakeLists.txt b/plugins/repogpgcheck/CMakeLists.txt index c6e8a374..f9af7b81 100644 --- a/plugins/repogpgcheck/CMakeLists.txt +++ b/plugins/repogpgcheck/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright (C) 2020 VMware, Inc. All Rights Reserved. +# Copyright (C) 2020-2022 VMware, Inc. All Rights Reserved. # # Licensed under the GNU General Public License v2 (the "License"); # you may not use this file except in compliance with the License. The terms diff --git a/plugins/repogpgcheck/api.c b/plugins/repogpgcheck/api.c index 6f7332c3..20053213 100644 --- a/plugins/repogpgcheck/api.c +++ b/plugins/repogpgcheck/api.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020 VMware, Inc. All Rights Reserved. + * Copyright (C) 2020-2022 VMware, Inc. All Rights Reserved. * * Licensed under the GNU Lesser General Public License v2.1 (the "License"); * you may not use this file except in compliance with the License. The terms diff --git a/plugins/repogpgcheck/prototypes.h b/plugins/repogpgcheck/prototypes.h index 201467dc..f9d09afc 100644 --- a/plugins/repogpgcheck/prototypes.h +++ b/plugins/repogpgcheck/prototypes.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020 VMware, Inc. All Rights Reserved. + * Copyright (C) 2020-2022 VMware, Inc. All Rights Reserved. * * Licensed under the GNU Lesser General Public License v2.1 (the "License"); * you may not use this file except in compliance with the License. The terms diff --git a/plugins/repogpgcheck/repogpgcheck.c b/plugins/repogpgcheck/repogpgcheck.c index 9e3c6046..4e99d66c 100644 --- a/plugins/repogpgcheck/repogpgcheck.c +++ b/plugins/repogpgcheck/repogpgcheck.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020-2021 VMware, Inc. All Rights Reserved. + * Copyright (C) 2020-2023 VMware, Inc. All Rights Reserved. * * Licensed under the GNU Lesser General Public License v2.1 (the "License"); * you may not use this file except in compliance with the License. The terms diff --git a/pytests/CMakeLists.txt b/pytests/CMakeLists.txt index 3d81adbd..fb8c32bf 100644 --- a/pytests/CMakeLists.txt +++ b/pytests/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright (C) 2020 VMware, Inc. All Rights Reserved. +# Copyright (C) 2020-2022 VMware, Inc. All Rights Reserved. # # Licensed under the GNU General Public License v2 (the "License"); # you may not use this file except in compliance with the License. The terms diff --git a/pytests/conftest.py b/pytests/conftest.py index cb00f89a..90a3c8ee 100644 --- a/pytests/conftest.py +++ b/pytests/conftest.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2019-2022 VMware, Inc. All Rights Reserved. +# Copyright (C) 2019-2023 VMware, Inc. All Rights Reserved. # # Licensed under the GNU General Public License v2 (the "License"); # you may not use this file except in compliance with the License. The terms diff --git a/pytests/repo/setup-repo.sh b/pytests/repo/setup-repo.sh index 1c1fa6a0..1a1bc90b 100755 --- a/pytests/repo/setup-repo.sh +++ b/pytests/repo/setup-repo.sh @@ -1,6 +1,6 @@ #!/bin/bash # -# Copyright (C) 2020-2021 VMware, Inc. All Rights Reserved. +# Copyright (C) 2020-2023 VMware, Inc. All Rights Reserved. # # Licensed under the GNU Lesser General Public License v2.1 (the "License"); # you may not use this file except in compliance with the License. The terms diff --git a/pytests/repo/tdnf-test-dummy-obsoleting2.spec b/pytests/repo/tdnf-test-dummy-obsoleting2.spec deleted file mode 100644 index 4a0a9537..00000000 --- a/pytests/repo/tdnf-test-dummy-obsoleting2.spec +++ /dev/null @@ -1,27 +0,0 @@ -Summary: Dummy obsoletes spec 2 -Name: tdnf-test-dummy-obsoleting2 -Version: 0.1 -Release: 1 -Vendor: VMware, Inc. -Distribution: Photon -License: VMware -Url: http://www.vmware.com -Group: Applications/tdnftest - -#Provides: tdnf-test-dummy-obsoleted -Obsoletes: tdnf-test-dummy-obsoleted - -%description -Part of tdnf test spec. This is another package that obsoletes the -obsoleted package. - -%prep - -%build - -%install - -%files - -%changelog -* Fri Aug 07 2020 Shreenidhi Shedi 0.1-1 -- First version diff --git a/pytests/tests/test_check_update.py b/pytests/tests/test_check_update.py index bed9e4e3..90e619c4 100644 --- a/pytests/tests/test_check_update.py +++ b/pytests/tests/test_check_update.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2019-2022 VMware, Inc. All Rights Reserved. +# Copyright (C) 2019-2023 VMware, Inc. All Rights Reserved. # # Licensed under the GNU General Public License v2 (the "License"); # you may not use this file except in compliance with the License. The terms diff --git a/pytests/tests/test_config.py b/pytests/tests/test_config.py index 222d03f8..d2eb6863 100644 --- a/pytests/tests/test_config.py +++ b/pytests/tests/test_config.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2019-2022 VMware, Inc. All Rights Reserved. +# Copyright (C) 2019-2023 VMware, Inc. All Rights Reserved. # # Licensed under the GNU General Public License v2 (the "License"); # you may not use this file except in compliance with the License. The terms diff --git a/pytests/tests/test_configutil.py b/pytests/tests/test_configutil.py index 3158d65b..c89fd768 100644 --- a/pytests/tests/test_configutil.py +++ b/pytests/tests/test_configutil.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2022 VMware, Inc. All Rights Reserved. +# Copyright (C) 2022-2023 VMware, Inc. All Rights Reserved. # # Licensed under the GNU General Public License v2 (the "License"); # you may not use this file except in compliance with the License. The terms diff --git a/pytests/tests/test_install.py b/pytests/tests/test_install.py index 018d5580..29589687 100644 --- a/pytests/tests/test_install.py +++ b/pytests/tests/test_install.py @@ -117,6 +117,16 @@ def test_install_missing_dep(utils): assert not utils.check_package(pkgname) +# install an obsoleting package, expect the obsoleted package to be removed +def test_install_obsoleting(utils): + utils.erase_package(PKGNAME_OBSING) + utils.run(['tdnf', 'install', '-y', '--nogpgcheck', PKGNAME_OBSED_VER]) + assert utils.check_package(PKGNAME_OBSED) + + utils.run(['tdnf', 'install', '-y', '--nogpgcheck', PKGNAME_OBSING]) + assert not utils.check_package(PKGNAME_OBSED) + + # install an obsoleted package, expect the obsoleting package to be installed # the obsoleting package must also provide the obsoleted one def test_install_obsoletes(utils): @@ -132,7 +142,8 @@ def test_install_obsoleted_version(utils): utils.erase_package(PKGNAME_OBSED_VER) utils.erase_package(PKGNAME_OBSING) - utils.run(['tdnf', 'install', '-y', '--nogpgcheck', PKGNAME_OBSED_VER]) + ret = utils.run(['tdnf', 'install', '-y', '--nogpgcheck', PKGNAME_OBSED_VER]) + print(ret) assert utils.check_package(PKGNAME_OBSED) diff --git a/pytests/tests/test_protected.py b/pytests/tests/test_protected.py new file mode 100644 index 00000000..d99790ac --- /dev/null +++ b/pytests/tests/test_protected.py @@ -0,0 +1,111 @@ +# +# Copyright (C) 2021-2022 VMware, Inc. All Rights Reserved. +# +# Licensed under the GNU General Public License v2 (the "License"); +# you may not use this file except in compliance with the License. The terms +# of the License are located in the COPYING file of this distribution. +# + +import os +import pytest +import errno +import shutil + +TESTREPO = 'photon-test' + +PKGNAME_OBSED_VER = "tdnf-test-dummy-obsoleted=0.1" +PKGNAME_OBSED = "tdnf-test-dummy-obsoleted" +PKGNAME_OBSING = "tdnf-test-dummy-obsoleting" + + +@pytest.fixture(scope='function', autouse=True) +def setup_test(utils): + yield + teardown_test(utils) + + +def teardown_test(utils): + dirname = os.path.join(utils.config['repo_path'], 'protected.d') + if os.path.isdir(dirname): + shutil.rmtree(dirname) + + utils.erase_package('tdnf-test-cleanreq-required') + utils.erase_package('tdnf-test-cleanreq-leaf1') + + +# helper to create directory tree without complains when it exists: +def makedirs(d): + try: + os.makedirs(d) + except OSError as e: + if e.errno != errno.EEXIST: + raise + + +def set_protected_file(utils, value): + dirname = os.path.join(utils.config['repo_path'], 'protected.d') + makedirs(dirname) + filename = os.path.join(dirname, 'test.conf') + with open(filename, 'w') as f: + f.write(value) + + +def test_protected_conf_erase(utils): + pkgname = utils.config["sglversion_pkgname"] + set_protected_file(utils, pkgname) + utils.install_package(pkgname) + + # sanity check + assert utils.check_package(pkgname) + + # test - uninstalling should fail + utils.run(['tdnf', '-y', '--nogpgcheck', 'remove', pkgname]) + assert utils.check_package(pkgname) + + +def test_protected_required(utils): + pkgname = 'tdnf-test-cleanreq-leaf1' + pkgname_req = 'tdnf-test-cleanreq-required' + + utils.install_package(pkgname) + assert utils.check_package(pkgname) + assert utils.check_package(pkgname_req) + + set_protected_file(utils, pkgname) + + # would erase pkgname: + ret = utils.run(['tdnf', '-y', '--nogpgcheck', 'remove', pkgname_req]) + assert ret['retval'] != 0 + assert utils.check_package(pkgname) + assert utils.check_package(pkgname_req) + + +def test_protected_autoerase(utils): + pkgname = 'tdnf-test-cleanreq-leaf1' + pkgname_req = 'tdnf-test-cleanreq-required' + + utils.install_package(pkgname) + assert utils.check_package(pkgname) + assert utils.check_package(pkgname_req) + + set_protected_file(utils, pkgname_req) + + # would erase pkgname_req if not protected: + ret = utils.run(['tdnf', '-y', '--nogpgcheck', 'autoremove', pkgname]) + assert ret['retval'] == 0 + assert utils.check_package(pkgname_req) + + +# install an obsoleting package, but the obsoleted package to be +# removed is protected +def test_protected_obsoleted(utils): + utils.erase_package(PKGNAME_OBSING) + utils.run(['tdnf', 'install', '-y', '--nogpgcheck', PKGNAME_OBSED_VER]) + assert utils.check_package(PKGNAME_OBSED) + + set_protected_file(utils, PKGNAME_OBSED) + + # expected fail + ret = utils.run(['tdnf', 'install', '-y', '--nogpgcheck', PKGNAME_OBSING]) + assert ret['retval'] == 1030 + assert utils.check_package(PKGNAME_OBSED) diff --git a/pytests/tests/test_provides.py b/pytests/tests/test_provides.py index 18b1f957..ad6344a8 100644 --- a/pytests/tests/test_provides.py +++ b/pytests/tests/test_provides.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2019-2020 VMware, Inc. All Rights Reserved. +# Copyright (C) 2019-2022 VMware, Inc. All Rights Reserved. # # Licensed under the GNU General Public License v2 (the "License"); # you may not use this file except in compliance with the License. The terms diff --git a/python/includes.h b/python/includes.h index 35b34911..0ffb5f33 100644 --- a/python/includes.h +++ b/python/includes.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019-2020 VMware, Inc. All Rights Reserved. + * Copyright (C) 2019-2022 VMware, Inc. All Rights Reserved. * * Licensed under the GNU Lesser General Public License v2.1 (the "License"); * you may not use this file except in compliance with the License. The terms diff --git a/python/tdnfpyrepodata.c b/python/tdnfpyrepodata.c index ea5e9030..d955a19b 100644 --- a/python/tdnfpyrepodata.c +++ b/python/tdnfpyrepodata.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019-2021 VMware, Inc. All Rights Reserved. + * Copyright (C) 2019-2022 VMware, Inc. All Rights Reserved. * * Licensed under the GNU General Public License v2 (the "License"); * you may not use this file except in compliance with the License. The terms diff --git a/scripts/fix-copyright.py b/scripts/fix-copyright.py index 75677378..4c4581e9 100755 --- a/scripts/fix-copyright.py +++ b/scripts/fix-copyright.py @@ -21,6 +21,8 @@ import re from datetime import datetime +IGNORE_COMMITS = ['38fa1f466b86ffdf550b17461b2722b4ddc07a85'] + class Commit: def __init__(self, id): self.id = id @@ -41,7 +43,7 @@ def get_latest_commit(file): stream = os.popen('git log --pretty=fuller {}'.format(file)) for line in stream.readlines(): if line.startswith('commit'): - commit = Commit(line.split(' ')[1]).strip() + commit = Commit(line.strip().split(' ')[1]) # We use the commit date, not the author date # see https://stackoverflow.com/questions/11856983/why-git-authordate-is-different-from-commitdate elif line.startswith('CommitDate:'): @@ -89,5 +91,6 @@ def fix_file(file, actual_year): files = get_files() for f in files: commit = get_latest_commit(f) - year = str(commit.date.year) - fix_file(f, year) + if commit.id not in IGNORE_COMMITS: + year = str(commit.date.year) + fix_file(f, year) diff --git a/solv/CMakeLists.txt b/solv/CMakeLists.txt index d5c330ed..316c7868 100644 --- a/solv/CMakeLists.txt +++ b/solv/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright (C) 2020 VMware, Inc. All Rights Reserved. +# Copyright (C) 2020-2022 VMware, Inc. All Rights Reserved. # # Licensed under the GNU General Public License v2 (the "License"); # you may not use this file except in compliance with the License. The terms diff --git a/solv/prototypes.h b/solv/prototypes.h index b1289b62..a7b2d46c 100644 --- a/solv/prototypes.h +++ b/solv/prototypes.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015-2022 VMware, Inc. All Rights Reserved. + * Copyright (C) 2015-2023 VMware, Inc. All Rights Reserved. * * Licensed under the GNU Lesser General Public License v2.1 (the "License"); * you may not use this file except in compliance with the License. The terms diff --git a/solv/simplequery.c b/solv/simplequery.c index 77162fea..080e41e7 100644 --- a/solv/simplequery.c +++ b/solv/simplequery.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 VMware, Inc. All Rights Reserved. + * Copyright (C) 2022-2023 VMware, Inc. All Rights Reserved. * * Licensed under the GNU Lesser General Public License v2.1 (the "License"); * you may not use this file except in compliance with the License. The terms diff --git a/solv/tdnfpackage.c b/solv/tdnfpackage.c index b98165d3..cfa66e14 100644 --- a/solv/tdnfpackage.c +++ b/solv/tdnfpackage.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015-2022 VMware, Inc. All Rights Reserved. + * Copyright (C) 2015-2023 VMware, Inc. All Rights Reserved. * * Licensed under the GNU Lesser General Public License v2.1 (the "License"); * you may not use this file except in compliance with the License. The terms diff --git a/solv/tdnfpool.c b/solv/tdnfpool.c index 3087d520..3fa90af3 100644 --- a/solv/tdnfpool.c +++ b/solv/tdnfpool.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015-2019 VMware, Inc. All Rights Reserved. + * Copyright (C) 2015-2023 VMware, Inc. All Rights Reserved. * * Licensed under the GNU Lesser General Public License v2.1 (the "License"); * you may not use this file except in compliance with the License. The terms diff --git a/solv/tdnfquery.c b/solv/tdnfquery.c index c573662e..e5d9144b 100644 --- a/solv/tdnfquery.c +++ b/solv/tdnfquery.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015-2022 VMware, Inc. All Rights Reserved. + * Copyright (C) 2015-2023 VMware, Inc. All Rights Reserved. * * Licensed under the GNU Lesser General Public License v2.1 (the "License"); * you may not use this file except in compliance with the License. The terms @@ -106,7 +106,7 @@ SolvAddUserInstalledToJobs( } if (nFlag == 0) { - queue_push2(pQueueJobs, SOLVER_SOLVABLE_NAME|SOLVER_USERINSTALLED, s->name); + queue_push2(pQueueJobs, SOLVER_SOLVABLE|SOLVER_USERINSTALLED, p); } } @@ -176,25 +176,6 @@ SolvAddPkgEraseJob( goto cleanup; } -uint32_t -SolvAddPkgUserInstalledJob( - Queue* pQueueJobs, - Id dwId) -{ - uint32_t dwError = 0; - if(!pQueueJobs) - { - dwError = ERROR_TDNF_INVALID_PARAMETER; - BAIL_ON_TDNF_LIBSOLV_ERROR(dwError); - } - queue_push2(pQueueJobs, SOLVER_SOLVABLE|SOLVER_USERINSTALLED, dwId); -cleanup: - return dwError; - -error: - goto cleanup; -} - uint32_t SolvCreateQuery( PSolvSack pSack, diff --git a/solv/tdnfrepo.c b/solv/tdnfrepo.c index 0210e284..c27b907e 100644 --- a/solv/tdnfrepo.c +++ b/solv/tdnfrepo.c @@ -1,6 +1,6 @@ /* - * Copyright (C) 2015-2021 VMware, Inc. All Rights Reserved. + * Copyright (C) 2015-2023 VMware, Inc. All Rights Reserved. * * Licensed under the GNU Lesser General Public License v2.1 (the "License"); * you may not use this file except in compliance with the License. The terms diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index 5c5be013..6e4c9e73 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright (C) 2020 VMware, Inc. All Rights Reserved. +# Copyright (C) 2020-2023 VMware, Inc. All Rights Reserved. # # Licensed under the GNU General Public License v2 (the "License"); # you may not use this file except in compliance with the License. The terms diff --git a/tools/cli/defines.h b/tools/cli/defines.h index 5b715522..35114cb5 100644 --- a/tools/cli/defines.h +++ b/tools/cli/defines.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015-2022 VMware, Inc. All Rights Reserved. + * Copyright (C) 2015-2023 VMware, Inc. All Rights Reserved. * * Licensed under the GNU General Public License v2 (the "License"); * you may not use this file except in compliance with the License. The terms diff --git a/tools/cli/lib/api.c b/tools/cli/lib/api.c index 2d20ff52..c58c8909 100644 --- a/tools/cli/lib/api.c +++ b/tools/cli/lib/api.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017-2022 VMware, Inc. All Rights Reserved. + * Copyright (C) 2017-2023 VMware, Inc. All Rights Reserved. * * Licensed under the GNU Lesser General Public License v2.1 (the "License"); * you may not use this file except in compliance with the License. The terms diff --git a/tools/cli/lib/installcmd.c b/tools/cli/lib/installcmd.c index 62fd1789..da98d855 100644 --- a/tools/cli/lib/installcmd.c +++ b/tools/cli/lib/installcmd.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015-2022 VMware, Inc. All Rights Reserved. + * Copyright (C) 2015-2023 VMware, Inc. All Rights Reserved. * * Licensed under the GNU General Public License v2 (the "License"); * you may not use this file except in compliance with the License. The terms diff --git a/tools/cli/lib/options.c b/tools/cli/lib/options.c index 444445a2..953d213e 100644 --- a/tools/cli/lib/options.c +++ b/tools/cli/lib/options.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015-2017 VMware, Inc. All Rights Reserved. + * Copyright (C) 2015-2022 VMware, Inc. All Rights Reserved. * * Licensed under the GNU General Public License v2 (the "License"); * you may not use this file except in compliance with the License. The terms diff --git a/tools/cli/lib/parseargs.c b/tools/cli/lib/parseargs.c index 4adb9a33..ccda8571 100644 --- a/tools/cli/lib/parseargs.c +++ b/tools/cli/lib/parseargs.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015-2022 VMware, Inc. All Rights Reserved. + * Copyright (C) 2015-2023 VMware, Inc. All Rights Reserved. * * Licensed under the GNU General Public License v2 (the "License"); * you may not use this file except in compliance with the License. The terms diff --git a/tools/cli/lib/parsecleanargs.c b/tools/cli/lib/parsecleanargs.c index da428c9d..97548561 100644 --- a/tools/cli/lib/parsecleanargs.c +++ b/tools/cli/lib/parsecleanargs.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015-2020 VMware, Inc. All Rights Reserved. + * Copyright (C) 2015-2022 VMware, Inc. All Rights Reserved. * * Licensed under the GNU General Public License v2 (the "License"); * you may not use this file except in compliance with the License. The terms diff --git a/tools/cli/lib/parselistargs.c b/tools/cli/lib/parselistargs.c index 3cdfd58e..3f9cb082 100644 --- a/tools/cli/lib/parselistargs.c +++ b/tools/cli/lib/parselistargs.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015-2022 VMware, Inc. All Rights Reserved. + * Copyright (C) 2015-2023 VMware, Inc. All Rights Reserved. * * Licensed under the GNU General Public License v2 (the "License"); * you may not use this file except in compliance with the License. The terms diff --git a/tools/cli/lib/parseupdateinfo.c b/tools/cli/lib/parseupdateinfo.c index 43e1fc0a..963a6655 100644 --- a/tools/cli/lib/parseupdateinfo.c +++ b/tools/cli/lib/parseupdateinfo.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015-2022 VMware, Inc. All Rights Reserved. + * Copyright (C) 2015-2023 VMware, Inc. All Rights Reserved. * * Licensed under the GNU General Public License v2 (the "License"); * you may not use this file except in compliance with the License. The terms diff --git a/tools/cli/lib/prototypes.h b/tools/cli/lib/prototypes.h index d70591bd..2b2e5977 100644 --- a/tools/cli/lib/prototypes.h +++ b/tools/cli/lib/prototypes.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015-2019 VMware, Inc. All Rights Reserved. + * Copyright (C) 2015-2023 VMware, Inc. All Rights Reserved. * * Licensed under the GNU General Public License v2 (the "License"); * you may not use this file except in compliance with the License. The terms diff --git a/tools/cli/main.c b/tools/cli/main.c index 7b9c5a12..bd6db22e 100644 --- a/tools/cli/main.c +++ b/tools/cli/main.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015-2022 VMware, Inc. All Rights Reserved. + * Copyright (C) 2015-2023 VMware, Inc. All Rights Reserved. * * Licensed under the GNU General Public License v2 (the "License"); * you may not use this file except in compliance with the License. The terms diff --git a/tools/cli/prototypes.h b/tools/cli/prototypes.h index b6b74e7d..2f2ecf8e 100644 --- a/tools/cli/prototypes.h +++ b/tools/cli/prototypes.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015-2022 VMware, Inc. All Rights Reserved. + * Copyright (C) 2015-2023 VMware, Inc. All Rights Reserved. * * Licensed under the GNU General Public License v2 (the "License"); * you may not use this file except in compliance with the License. The terms diff --git a/tools/config/CMakeLists.txt b/tools/config/CMakeLists.txt index 8039e5bc..9d703d79 100644 --- a/tools/config/CMakeLists.txt +++ b/tools/config/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright (C) 2020 VMware, Inc. All Rights Reserved. +# Copyright (C) 2020-2023 VMware, Inc. All Rights Reserved. # # Licensed under the GNU General Public License v2 (the "License"); # you may not use this file except in compliance with the License. The terms