2015-04-02 09:59:27 +08:00
|
|
|
/*
|
2023-04-01 03:41:34 +08:00
|
|
|
* Copyright (C) 2015-2023 VMware, Inc. All Rights Reserved.
|
2015-04-16 05:10:08 +08:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* of the License are located in the COPYING file of this distribution.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Module : repolist.c
|
|
|
|
*
|
|
|
|
* Abstract :
|
|
|
|
*
|
|
|
|
* tdnfclientlib
|
|
|
|
*
|
|
|
|
* client library
|
|
|
|
*
|
|
|
|
* Authors : Priyesh Padmavilasom (ppadmavilasom@vmware.com)
|
|
|
|
*/
|
|
|
|
|
2015-04-02 09:59:27 +08:00
|
|
|
#include "includes.h"
|
|
|
|
|
2022-04-01 07:59:34 +08:00
|
|
|
#include "../llconf/nodes.h"
|
|
|
|
#include "../llconf/modules.h"
|
|
|
|
#include "../llconf/entry.h"
|
|
|
|
#include "../llconf/ini.h"
|
2015-04-02 09:59:27 +08:00
|
|
|
|
|
|
|
uint32_t
|
|
|
|
TDNFLoadRepoData(
|
2015-12-13 05:30:40 +08:00
|
|
|
PTDNF pTdnf,
|
2022-03-19 04:57:18 +08:00
|
|
|
PTDNF_REPO_DATA* ppReposAll
|
2015-04-02 09:59:27 +08:00
|
|
|
)
|
|
|
|
{
|
|
|
|
uint32_t dwError = 0;
|
|
|
|
char* pszRepoFilePath = NULL;
|
2022-03-19 04:57:18 +08:00
|
|
|
PTDNF_REPO_DATA pReposAll = NULL;
|
2022-10-26 08:54:23 +08:00
|
|
|
PTDNF_REPO_DATA *ppRepoNext = NULL;
|
2015-12-13 05:30:40 +08:00
|
|
|
PTDNF_CONF pConf = NULL;
|
2021-06-24 08:34:06 +08:00
|
|
|
PTDNF_CMD_OPT pSetOpt = NULL;
|
2016-11-30 02:41:51 +08:00
|
|
|
DIR *pDir = NULL;
|
|
|
|
struct dirent *pEnt = NULL;
|
2021-06-24 08:34:06 +08:00
|
|
|
char **ppszUrlIdTuple = NULL;
|
2015-04-02 09:59:27 +08:00
|
|
|
|
2021-06-24 08:34:06 +08:00
|
|
|
if(!pTdnf || !pTdnf->pConf || !pTdnf->pArgs || !ppReposAll)
|
2015-04-02 09:59:27 +08:00
|
|
|
{
|
|
|
|
dwError = ERROR_TDNF_INVALID_PARAMETER;
|
|
|
|
BAIL_ON_TDNF_ERROR(dwError);
|
|
|
|
}
|
2015-12-13 05:30:40 +08:00
|
|
|
pConf = pTdnf->pConf;
|
2015-04-02 09:59:27 +08:00
|
|
|
|
2022-10-26 08:54:23 +08:00
|
|
|
ppRepoNext = &pReposAll;
|
|
|
|
|
|
|
|
dwError = TDNFCreateCmdLineRepo(ppRepoNext);
|
2020-09-22 08:37:47 +08:00
|
|
|
BAIL_ON_TDNF_ERROR(dwError);
|
|
|
|
|
2022-10-26 08:54:23 +08:00
|
|
|
ppRepoNext = &((*ppRepoNext)->pNext);
|
|
|
|
|
2021-06-24 08:34:06 +08:00
|
|
|
for(pSetOpt = pTdnf->pArgs->pSetOpt;
|
|
|
|
pSetOpt;
|
|
|
|
pSetOpt = pSetOpt->pNext)
|
|
|
|
{
|
|
|
|
if(strcmp(pSetOpt->pszOptName, "repofrompath") == 0)
|
|
|
|
{
|
2022-07-23 02:36:08 +08:00
|
|
|
dwError = TDNFSplitStringToArray(pSetOpt->pszOptValue, ",", &ppszUrlIdTuple);
|
|
|
|
BAIL_ON_TDNF_ERROR(dwError);
|
2021-06-24 08:34:06 +08:00
|
|
|
if ((ppszUrlIdTuple[0] == NULL) || ppszUrlIdTuple[1] == NULL)
|
|
|
|
{
|
|
|
|
dwError = ERROR_TDNF_INVALID_PARAMETER;
|
|
|
|
BAIL_ON_TDNF_ERROR(dwError);
|
|
|
|
}
|
2022-10-26 08:54:23 +08:00
|
|
|
|
|
|
|
dwError = TDNFCreateRepoFromPath(ppRepoNext,
|
2021-06-24 08:34:06 +08:00
|
|
|
ppszUrlIdTuple[0],
|
|
|
|
ppszUrlIdTuple[1]);
|
|
|
|
BAIL_ON_TDNF_ERROR(dwError);
|
|
|
|
|
2022-10-26 08:54:23 +08:00
|
|
|
ppRepoNext = &((*ppRepoNext)->pNext);
|
|
|
|
|
2022-10-07 02:09:06 +08:00
|
|
|
TDNF_SAFE_FREE_STRINGARRAY(ppszUrlIdTuple);
|
|
|
|
ppszUrlIdTuple = NULL;
|
|
|
|
}
|
|
|
|
else if(strcmp(pSetOpt->pszOptName, "repofromdir") == 0)
|
|
|
|
{
|
|
|
|
dwError = TDNFSplitStringToArray(pSetOpt->pszOptValue, ",", &ppszUrlIdTuple);
|
|
|
|
BAIL_ON_TDNF_ERROR(dwError);
|
|
|
|
if ((ppszUrlIdTuple[0] == NULL) || ppszUrlIdTuple[1] == NULL)
|
|
|
|
{
|
|
|
|
dwError = ERROR_TDNF_INVALID_PARAMETER;
|
|
|
|
BAIL_ON_TDNF_ERROR(dwError);
|
|
|
|
}
|
|
|
|
dwError = TDNFCreateRepoFromDirectory(&pReposAll,
|
|
|
|
ppszUrlIdTuple[0],
|
|
|
|
ppszUrlIdTuple[1]);
|
|
|
|
BAIL_ON_TDNF_ERROR(dwError);
|
|
|
|
|
2021-06-24 08:34:06 +08:00
|
|
|
TDNF_SAFE_FREE_STRINGARRAY(ppszUrlIdTuple);
|
|
|
|
ppszUrlIdTuple = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-11-30 02:41:51 +08:00
|
|
|
pDir = opendir(pConf->pszRepoDir);
|
|
|
|
if(pDir == NULL)
|
2015-04-02 09:59:27 +08:00
|
|
|
{
|
|
|
|
dwError = ERROR_TDNF_REPO_DIR_OPEN;
|
2020-02-07 19:03:08 +08:00
|
|
|
BAIL_ON_TDNF_ERROR(dwError);
|
2015-04-02 09:59:27 +08:00
|
|
|
}
|
|
|
|
|
2016-11-30 02:41:51 +08:00
|
|
|
while ((pEnt = readdir (pDir)) != NULL )
|
2015-04-02 09:59:27 +08:00
|
|
|
{
|
2022-01-15 15:54:01 +08:00
|
|
|
int nLen = strlen(pEnt->d_name);
|
|
|
|
int nLenRepoExt = strlen(TDNF_REPO_EXT);
|
2016-11-30 02:41:51 +08:00
|
|
|
if (nLen <= nLenRepoExt ||
|
|
|
|
strcmp(pEnt->d_name + nLen - nLenRepoExt, TDNF_REPO_EXT))
|
2015-04-02 09:59:27 +08:00
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
2016-11-30 02:41:51 +08:00
|
|
|
|
2021-09-24 06:15:56 +08:00
|
|
|
dwError = TDNFJoinPath(
|
2016-11-30 02:41:51 +08:00
|
|
|
&pszRepoFilePath,
|
|
|
|
pConf->pszRepoDir,
|
2021-09-24 06:15:56 +08:00
|
|
|
pEnt->d_name,
|
|
|
|
NULL);
|
2016-11-30 02:41:51 +08:00
|
|
|
BAIL_ON_TDNF_ERROR(dwError);
|
2015-04-02 09:59:27 +08:00
|
|
|
|
2022-10-26 08:54:23 +08:00
|
|
|
dwError = TDNFLoadReposFromFile(pTdnf, pszRepoFilePath, ppRepoNext);
|
2015-04-02 09:59:27 +08:00
|
|
|
BAIL_ON_TDNF_ERROR(dwError);
|
|
|
|
|
2016-11-30 02:41:51 +08:00
|
|
|
TDNF_SAFE_FREE_MEMORY(pszRepoFilePath);
|
2015-04-02 09:59:27 +08:00
|
|
|
pszRepoFilePath = NULL;
|
|
|
|
|
2022-11-22 02:39:32 +08:00
|
|
|
/* may have added multiple repos, go to last one */
|
2022-11-22 02:39:32 +08:00
|
|
|
while (*ppRepoNext)
|
|
|
|
ppRepoNext = &((*ppRepoNext)->pNext);
|
2015-04-02 09:59:27 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
*ppReposAll = pReposAll;
|
|
|
|
cleanup:
|
|
|
|
if(pDir)
|
|
|
|
{
|
2016-11-30 02:41:51 +08:00
|
|
|
closedir(pDir);
|
2015-04-02 09:59:27 +08:00
|
|
|
}
|
2016-11-30 02:41:51 +08:00
|
|
|
TDNF_SAFE_FREE_MEMORY(pszRepoFilePath);
|
2021-06-24 08:34:06 +08:00
|
|
|
TDNF_SAFE_FREE_STRINGARRAY(ppszUrlIdTuple);
|
2015-04-02 09:59:27 +08:00
|
|
|
|
2016-11-30 02:41:51 +08:00
|
|
|
return dwError;
|
2015-04-02 09:59:27 +08:00
|
|
|
error:
|
|
|
|
if(ppReposAll)
|
|
|
|
{
|
|
|
|
*ppReposAll = NULL;
|
|
|
|
}
|
|
|
|
if(pReposAll)
|
|
|
|
{
|
2017-02-19 14:18:44 +08:00
|
|
|
TDNFFreeReposInternal(pReposAll);
|
2015-04-02 09:59:27 +08:00
|
|
|
}
|
2020-01-29 09:30:07 +08:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2020-09-22 08:37:47 +08:00
|
|
|
uint32_t
|
|
|
|
TDNFCreateCmdLineRepo(
|
2022-03-19 04:57:18 +08:00
|
|
|
PTDNF_REPO_DATA* ppRepo
|
2020-09-22 08:37:47 +08:00
|
|
|
)
|
|
|
|
{
|
|
|
|
uint32_t dwError;
|
2022-03-19 04:57:18 +08:00
|
|
|
PTDNF_REPO_DATA pRepo = NULL;
|
2020-09-22 08:37:47 +08:00
|
|
|
|
|
|
|
if(!ppRepo)
|
|
|
|
{
|
|
|
|
dwError = ERROR_TDNF_INVALID_PARAMETER;
|
|
|
|
BAIL_ON_TDNF_ERROR(dwError);
|
|
|
|
}
|
|
|
|
|
2021-06-24 08:34:06 +08:00
|
|
|
dwError = TDNFCreateRepo(&pRepo, CMDLINE_REPO_NAME);
|
|
|
|
BAIL_ON_TDNF_ERROR(dwError);
|
2022-10-07 02:09:06 +08:00
|
|
|
pRepo->nHasMetaData = 0;
|
2021-06-24 08:34:06 +08:00
|
|
|
|
|
|
|
dwError = TDNFSafeAllocateString(CMDLINE_REPO_NAME, &pRepo->pszName);
|
|
|
|
BAIL_ON_TDNF_ERROR(dwError);
|
|
|
|
|
|
|
|
*ppRepo = pRepo;
|
|
|
|
cleanup:
|
|
|
|
return dwError;
|
|
|
|
error:
|
|
|
|
if(pRepo)
|
|
|
|
{
|
|
|
|
TDNFFreeReposInternal(pRepo);
|
|
|
|
}
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2022-10-07 02:09:06 +08:00
|
|
|
uint32_t
|
|
|
|
TDNFCreateRepoFromDirectory(
|
|
|
|
PTDNF_REPO_DATA* ppRepo,
|
|
|
|
const char *pszId,
|
|
|
|
const char *pszPath
|
|
|
|
)
|
|
|
|
{
|
|
|
|
uint32_t dwError = 0;
|
|
|
|
PTDNF_REPO_DATA pRepo = NULL;
|
|
|
|
int nIsDir = 0;
|
|
|
|
|
|
|
|
if(!ppRepo || !pszId || !pszPath)
|
|
|
|
{
|
|
|
|
dwError = ERROR_TDNF_INVALID_PARAMETER;
|
|
|
|
BAIL_ON_TDNF_ERROR(dwError);
|
|
|
|
}
|
|
|
|
|
|
|
|
dwError = TDNFCreateRepo(&pRepo, pszId);
|
|
|
|
BAIL_ON_TDNF_ERROR(dwError);
|
|
|
|
pRepo->nHasMetaData = 0;
|
|
|
|
|
|
|
|
/* we want it enabled, or there was no point in adding it */
|
|
|
|
pRepo->nEnabled = 1;
|
|
|
|
|
|
|
|
dwError = TDNFSafeAllocateString(pszId, &pRepo->pszName);
|
|
|
|
BAIL_ON_TDNF_ERROR(dwError);
|
|
|
|
|
|
|
|
dwError = TDNFIsDir(pszPath, &nIsDir);
|
|
|
|
BAIL_ON_TDNF_ERROR(dwError);
|
|
|
|
|
|
|
|
if (!nIsDir)
|
|
|
|
{
|
|
|
|
pr_err("%s is not a directory\n", pszPath);
|
|
|
|
dwError = ERROR_TDNF_INVALID_PARAMETER;
|
|
|
|
BAIL_ON_TDNF_ERROR(dwError);
|
|
|
|
}
|
|
|
|
|
|
|
|
dwError = TDNFAllocateMemory(sizeof(char **), 2, (void **)&pRepo->ppszBaseUrls);
|
|
|
|
BAIL_ON_TDNF_ERROR(dwError);
|
|
|
|
|
|
|
|
dwError = TDNFSafeAllocateString(pszPath, &pRepo->ppszBaseUrls[0]);
|
|
|
|
BAIL_ON_TDNF_ERROR(dwError);
|
|
|
|
|
|
|
|
*ppRepo = pRepo;
|
|
|
|
cleanup:
|
|
|
|
return dwError;
|
|
|
|
error:
|
|
|
|
if(ppRepo)
|
|
|
|
{
|
|
|
|
*ppRepo = NULL;
|
|
|
|
}
|
|
|
|
if(pRepo)
|
|
|
|
{
|
|
|
|
TDNFFreeReposInternal(pRepo);
|
|
|
|
}
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2021-06-24 08:34:06 +08:00
|
|
|
uint32_t
|
|
|
|
TDNFCreateRepoFromPath(
|
2022-03-19 04:57:18 +08:00
|
|
|
PTDNF_REPO_DATA* ppRepo,
|
2021-06-24 08:34:06 +08:00
|
|
|
const char *pszId,
|
|
|
|
const char *pszPath
|
|
|
|
)
|
|
|
|
{
|
|
|
|
uint32_t dwError = 0;
|
2022-03-19 04:57:18 +08:00
|
|
|
PTDNF_REPO_DATA pRepo = NULL;
|
2021-06-24 08:34:06 +08:00
|
|
|
int nIsDir = 0;
|
|
|
|
int nDummy = 0;
|
|
|
|
|
|
|
|
if(!ppRepo || !pszId || !pszPath)
|
|
|
|
{
|
|
|
|
dwError = ERROR_TDNF_INVALID_PARAMETER;
|
|
|
|
BAIL_ON_TDNF_ERROR(dwError);
|
|
|
|
}
|
|
|
|
|
|
|
|
dwError = TDNFCreateRepo(&pRepo, pszId);
|
|
|
|
BAIL_ON_TDNF_ERROR(dwError);
|
|
|
|
|
|
|
|
/* we want it enabled, or there was no point in adding it */
|
|
|
|
pRepo->nEnabled = 1;
|
|
|
|
|
|
|
|
dwError = TDNFSafeAllocateString(pszId, &pRepo->pszName);
|
|
|
|
BAIL_ON_TDNF_ERROR(dwError);
|
|
|
|
|
2022-09-22 07:09:37 +08:00
|
|
|
dwError = TDNFAllocateMemory(sizeof(char **), 2, (void **)&pRepo->ppszBaseUrls);
|
|
|
|
BAIL_ON_TDNF_ERROR(dwError);
|
|
|
|
|
2021-06-24 08:34:06 +08:00
|
|
|
/* '/some/dir' => 'file:///some/dir */
|
|
|
|
if (pszPath[0] == '/')
|
|
|
|
{
|
|
|
|
dwError = TDNFIsDir(pszPath, &nIsDir);
|
|
|
|
BAIL_ON_TDNF_ERROR(dwError);
|
|
|
|
|
|
|
|
if (nIsDir)
|
|
|
|
{
|
2022-09-22 07:09:37 +08:00
|
|
|
dwError = TDNFAllocateStringPrintf(&pRepo->ppszBaseUrls[0], "file://%s", pszPath);
|
2021-06-24 08:34:06 +08:00
|
|
|
BAIL_ON_TDNF_ERROR(dwError);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* valid prefixes including file:// will not return an error */
|
|
|
|
dwError = TDNFUriIsRemote(pszPath, &nDummy);
|
|
|
|
BAIL_ON_TDNF_ERROR(dwError);
|
|
|
|
|
2022-09-22 07:09:37 +08:00
|
|
|
dwError = TDNFSafeAllocateString(pszPath, &pRepo->ppszBaseUrls[0]);
|
2021-06-24 08:34:06 +08:00
|
|
|
BAIL_ON_TDNF_ERROR(dwError);
|
|
|
|
}
|
|
|
|
*ppRepo = pRepo;
|
|
|
|
cleanup:
|
|
|
|
return dwError;
|
|
|
|
error:
|
|
|
|
if(ppRepo)
|
|
|
|
{
|
|
|
|
*ppRepo = NULL;
|
|
|
|
}
|
|
|
|
if(pRepo)
|
|
|
|
{
|
|
|
|
TDNFFreeReposInternal(pRepo);
|
|
|
|
}
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t
|
|
|
|
TDNFCreateRepo(
|
2022-03-19 04:57:18 +08:00
|
|
|
PTDNF_REPO_DATA* ppRepo,
|
2021-06-24 08:34:06 +08:00
|
|
|
const char *pszId
|
|
|
|
)
|
|
|
|
{
|
|
|
|
uint32_t dwError = 0;
|
2022-03-19 04:57:18 +08:00
|
|
|
PTDNF_REPO_DATA pRepo = NULL;
|
2021-06-24 08:34:06 +08:00
|
|
|
|
|
|
|
if(!ppRepo || !pszId)
|
|
|
|
{
|
|
|
|
dwError = ERROR_TDNF_INVALID_PARAMETER;
|
|
|
|
BAIL_ON_TDNF_ERROR(dwError);
|
|
|
|
}
|
|
|
|
|
2020-09-22 08:37:47 +08:00
|
|
|
dwError = TDNFAllocateMemory(
|
|
|
|
1,
|
2022-03-19 04:57:18 +08:00
|
|
|
sizeof(TDNF_REPO_DATA),
|
2020-09-22 08:37:47 +08:00
|
|
|
(void**)&pRepo);
|
|
|
|
BAIL_ON_TDNF_ERROR(dwError);
|
|
|
|
|
2021-06-24 08:34:06 +08:00
|
|
|
dwError = TDNFSafeAllocateString(pszId, &pRepo->pszId);
|
2020-09-22 08:37:47 +08:00
|
|
|
BAIL_ON_TDNF_ERROR(dwError);
|
|
|
|
|
2021-06-24 08:34:06 +08:00
|
|
|
pRepo->nEnabled = TDNF_REPO_DEFAULT_ENABLED;
|
2022-10-07 02:09:06 +08:00
|
|
|
pRepo->nHasMetaData = 1;
|
2021-06-24 08:34:06 +08:00
|
|
|
pRepo->nSkipIfUnavailable = TDNF_REPO_DEFAULT_SKIP;
|
|
|
|
pRepo->nGPGCheck = TDNF_REPO_DEFAULT_GPGCHECK;
|
|
|
|
pRepo->nSSLVerify = TDNF_REPO_DEFAULT_SSLVERIFY;
|
|
|
|
pRepo->lMetadataExpire = TDNF_REPO_DEFAULT_METADATA_EXPIRE;
|
|
|
|
pRepo->nPriority = TDNF_REPO_DEFAULT_PRIORITY;
|
|
|
|
pRepo->nTimeout = TDNF_REPO_DEFAULT_TIMEOUT;
|
|
|
|
pRepo->nMinrate = TDNF_REPO_DEFAULT_MINRATE;
|
|
|
|
pRepo->nThrottle = TDNF_REPO_DEFAULT_THROTTLE;
|
|
|
|
pRepo->nRetries = TDNF_REPO_DEFAULT_RETRIES;
|
2022-02-05 04:17:37 +08:00
|
|
|
pRepo->nSkipMDFileLists = TDNF_REPO_DEFAULT_SKIP_MD_FILELISTS;
|
|
|
|
pRepo->nSkipMDUpdateInfo = TDNF_REPO_DEFAULT_SKIP_MD_UPDATEINFO;
|
|
|
|
pRepo->nSkipMDOther = TDNF_REPO_DEFAULT_SKIP_MD_OTHER;
|
2020-09-22 08:37:47 +08:00
|
|
|
|
|
|
|
*ppRepo = pRepo;
|
|
|
|
cleanup:
|
|
|
|
return dwError;
|
|
|
|
error:
|
|
|
|
if(ppRepo)
|
|
|
|
{
|
|
|
|
*ppRepo = NULL;
|
|
|
|
}
|
|
|
|
if(pRepo)
|
|
|
|
{
|
|
|
|
TDNFFreeReposInternal(pRepo);
|
|
|
|
}
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2020-01-29 09:30:07 +08:00
|
|
|
uint32_t
|
|
|
|
TDNFEventRepoReadConfigEnd(
|
|
|
|
PTDNF pTdnf,
|
2022-04-01 07:59:34 +08:00
|
|
|
struct cnfnode *cn_section
|
2020-01-29 09:30:07 +08:00
|
|
|
)
|
|
|
|
{
|
|
|
|
uint32_t dwError = 0;
|
|
|
|
TDNF_EVENT_CONTEXT stContext = {0};
|
|
|
|
|
2022-04-01 07:59:34 +08:00
|
|
|
if (!pTdnf || !cn_section)
|
2020-01-29 09:30:07 +08:00
|
|
|
{
|
|
|
|
dwError = ERROR_TDNF_INVALID_PARAMETER;
|
|
|
|
BAIL_ON_TDNF_ERROR(dwError);
|
|
|
|
}
|
|
|
|
|
|
|
|
stContext.nEvent = MAKE_PLUGIN_EVENT(
|
|
|
|
TDNF_PLUGIN_EVENT_TYPE_REPO,
|
|
|
|
TDNF_PLUGIN_EVENT_STATE_READCONFIG,
|
|
|
|
TDNF_PLUGIN_EVENT_PHASE_END);
|
|
|
|
dwError = TDNFAddEventDataPtr(&stContext,
|
|
|
|
TDNF_EVENT_ITEM_REPO_SECTION,
|
2022-04-01 07:59:34 +08:00
|
|
|
cn_section);
|
2020-01-29 09:30:07 +08:00
|
|
|
BAIL_ON_TDNF_ERROR(dwError);
|
|
|
|
|
|
|
|
dwError = TDNFPluginRaiseEvent(pTdnf, &stContext);
|
|
|
|
BAIL_ON_TDNF_ERROR(dwError);
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
TDNFFreeEventData(stContext.pData);
|
|
|
|
return dwError;
|
|
|
|
error:
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t
|
|
|
|
TDNFEventRepoReadConfigStart(
|
|
|
|
PTDNF pTdnf,
|
2022-04-01 07:59:34 +08:00
|
|
|
struct cnfnode *cn_section
|
2020-01-29 09:30:07 +08:00
|
|
|
)
|
|
|
|
{
|
|
|
|
uint32_t dwError = 0;
|
|
|
|
TDNF_EVENT_CONTEXT stContext = {0};
|
|
|
|
|
2022-04-01 07:59:34 +08:00
|
|
|
if (!pTdnf || !cn_section)
|
2020-01-29 09:30:07 +08:00
|
|
|
{
|
|
|
|
dwError = ERROR_TDNF_INVALID_PARAMETER;
|
|
|
|
BAIL_ON_TDNF_ERROR(dwError);
|
|
|
|
}
|
|
|
|
|
|
|
|
stContext.nEvent = MAKE_PLUGIN_EVENT(
|
|
|
|
TDNF_PLUGIN_EVENT_TYPE_REPO,
|
|
|
|
TDNF_PLUGIN_EVENT_STATE_READCONFIG,
|
|
|
|
TDNF_PLUGIN_EVENT_PHASE_START);
|
|
|
|
dwError = TDNFAddEventDataPtr(&stContext,
|
|
|
|
TDNF_EVENT_ITEM_REPO_SECTION,
|
2022-04-01 07:59:34 +08:00
|
|
|
cn_section);
|
2020-01-29 09:30:07 +08:00
|
|
|
BAIL_ON_TDNF_ERROR(dwError);
|
|
|
|
|
|
|
|
dwError = TDNFPluginRaiseEvent(pTdnf, &stContext);
|
|
|
|
BAIL_ON_TDNF_ERROR(dwError);
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
TDNFFreeEventData(stContext.pData);
|
|
|
|
return dwError;
|
|
|
|
error:
|
|
|
|
goto cleanup;
|
|
|
|
}
|
2015-04-02 09:59:27 +08:00
|
|
|
|
2022-04-01 07:59:34 +08:00
|
|
|
static
|
|
|
|
int isTrue(const char *str)
|
|
|
|
{
|
|
|
|
return strcasecmp(str, "true") == 0 || atoi(str) != 0;
|
|
|
|
}
|
|
|
|
|
2015-04-02 09:59:27 +08:00
|
|
|
uint32_t
|
|
|
|
TDNFLoadReposFromFile(
|
2020-01-29 09:30:07 +08:00
|
|
|
PTDNF pTdnf,
|
2015-04-02 09:59:27 +08:00
|
|
|
char* pszRepoFile,
|
2022-03-19 04:57:18 +08:00
|
|
|
PTDNF_REPO_DATA* ppRepos
|
2015-04-02 09:59:27 +08:00
|
|
|
)
|
|
|
|
{
|
|
|
|
uint32_t dwError = 0;
|
2019-10-08 14:53:42 +08:00
|
|
|
char *pszMetadataExpire = NULL;
|
2015-04-02 09:59:27 +08:00
|
|
|
|
2022-03-19 04:57:18 +08:00
|
|
|
PTDNF_REPO_DATA pRepos = NULL;
|
|
|
|
PTDNF_REPO_DATA pRepo = NULL;
|
2015-04-02 09:59:27 +08:00
|
|
|
|
2023-03-25 02:23:32 +08:00
|
|
|
struct cnfnode *cn_conf = NULL, *cn_section, *cn;
|
2022-04-01 07:59:34 +08:00
|
|
|
struct cnfmodule *mod_ini;
|
2020-10-24 03:05:59 +08:00
|
|
|
|
2022-04-01 07:59:34 +08:00
|
|
|
mod_ini = find_cnfmodule("ini");
|
|
|
|
if (mod_ini == NULL) {
|
|
|
|
dwError = ERROR_TDNF_INVALID_PARAMETER;
|
2016-06-24 16:20:53 +08:00
|
|
|
BAIL_ON_TDNF_ERROR(dwError);
|
2022-04-01 07:59:34 +08:00
|
|
|
}
|
2016-06-24 16:20:53 +08:00
|
|
|
|
2022-04-01 07:59:34 +08:00
|
|
|
cn_conf = cnfmodule_parse_file(mod_ini, pszRepoFile);
|
|
|
|
if (cn_conf == NULL)
|
|
|
|
{
|
|
|
|
if (errno != 0)
|
|
|
|
{
|
|
|
|
dwError = errno;
|
|
|
|
BAIL_ON_TDNF_SYSTEM_ERROR(dwError);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
dwError = ERROR_TDNF_CONF_FILE_LOAD;
|
|
|
|
BAIL_ON_TDNF_ERROR(dwError);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* cn_conf == NULL => we will not reach here */
|
|
|
|
/* coverity[var_deref_op] */
|
|
|
|
for(cn_section = cn_conf->first_child; cn_section; cn_section = cn_section->next)
|
|
|
|
{
|
|
|
|
if ((cn_section->name[0] == '.'))
|
|
|
|
continue;
|
2016-06-24 16:20:53 +08:00
|
|
|
|
2022-04-01 07:59:34 +08:00
|
|
|
dwError = TDNFCreateRepo(&pRepo, cn_section->name);
|
2022-02-05 04:17:37 +08:00
|
|
|
BAIL_ON_TDNF_ERROR(dwError);
|
|
|
|
|
2022-04-01 07:59:34 +08:00
|
|
|
/* plugin event repo readconfig start */
|
|
|
|
dwError = TDNFEventRepoReadConfigStart(pTdnf, cn_section);
|
2022-02-05 04:17:37 +08:00
|
|
|
BAIL_ON_TDNF_ERROR(dwError);
|
|
|
|
|
2022-04-01 07:59:34 +08:00
|
|
|
for(cn = cn_section->first_child; cn; cn = cn->next)
|
|
|
|
{
|
|
|
|
if ((cn->name[0] == '.') || (cn->value == NULL))
|
|
|
|
continue;
|
2022-02-05 04:17:37 +08:00
|
|
|
|
2022-04-01 07:59:34 +08:00
|
|
|
if (strcmp(cn->name, TDNF_REPO_KEY_ENABLED) == 0)
|
|
|
|
{
|
|
|
|
pRepo->nEnabled = isTrue(cn->value);
|
|
|
|
}
|
|
|
|
else if (strcmp(cn->name, TDNF_REPO_KEY_NAME) == 0)
|
|
|
|
{
|
|
|
|
pRepo->pszName = strdup(cn->value);
|
|
|
|
}
|
|
|
|
else if (strcmp(cn->name, TDNF_REPO_KEY_BASEURL) == 0)
|
|
|
|
{
|
|
|
|
dwError = TDNFSplitStringToArray(cn->value,
|
|
|
|
" ", &pRepo->ppszBaseUrls);
|
2023-03-25 02:23:32 +08:00
|
|
|
BAIL_ON_TDNF_ERROR(dwError);
|
2022-04-01 07:59:34 +08:00
|
|
|
}
|
|
|
|
else if (strcmp(cn->name, TDNF_REPO_KEY_METALINK) == 0)
|
|
|
|
{
|
|
|
|
pRepo->pszMetaLink = strdup(cn->value);
|
|
|
|
}
|
2023-03-25 02:23:32 +08:00
|
|
|
else if (strcmp(cn->name, TDNF_REPO_KEY_SKIP) == 0)
|
2022-04-01 07:59:34 +08:00
|
|
|
{
|
|
|
|
pRepo->nSkipIfUnavailable = isTrue(cn->value);
|
|
|
|
}
|
2023-03-25 02:23:32 +08:00
|
|
|
else if (strcmp(cn->name, TDNF_REPO_KEY_GPGCHECK) == 0)
|
2022-04-01 07:59:34 +08:00
|
|
|
{
|
|
|
|
pRepo->nGPGCheck = isTrue(cn->value);
|
|
|
|
}
|
|
|
|
else if (strcmp(cn->name, TDNF_REPO_KEY_GPGKEY) == 0)
|
|
|
|
{
|
|
|
|
dwError = TDNFSplitStringToArray(cn->value,
|
|
|
|
" ", &pRepo->ppszUrlGPGKeys);
|
|
|
|
BAIL_ON_TDNF_ERROR(dwError);
|
|
|
|
}
|
|
|
|
else if (strcmp(cn->name, TDNF_REPO_KEY_USERNAME) == 0)
|
|
|
|
{
|
|
|
|
pRepo->pszUser = strdup(cn->value);
|
|
|
|
}
|
|
|
|
else if (strcmp(cn->name, TDNF_REPO_KEY_PASSWORD) == 0)
|
|
|
|
{
|
|
|
|
pRepo->pszPass = strdup(cn->value);
|
|
|
|
}
|
|
|
|
else if (strcmp(cn->name, TDNF_REPO_KEY_PRIORITY) == 0)
|
|
|
|
{
|
|
|
|
pRepo->nPriority = atoi(cn->value);
|
|
|
|
}
|
|
|
|
else if (strcmp(cn->name, TDNF_REPO_KEY_TIMEOUT) == 0)
|
|
|
|
{
|
|
|
|
pRepo->nTimeout = atoi(cn->value);
|
|
|
|
}
|
|
|
|
else if (strcmp(cn->name, TDNF_REPO_KEY_RETRIES) == 0)
|
|
|
|
{
|
|
|
|
pRepo->nRetries = atoi(cn->value);
|
|
|
|
}
|
|
|
|
else if (strcmp(cn->name, TDNF_REPO_KEY_MINRATE) == 0)
|
|
|
|
{
|
|
|
|
pRepo->nMinrate = atoi(cn->value);
|
|
|
|
}
|
|
|
|
else if (strcmp(cn->name, TDNF_REPO_KEY_THROTTLE) == 0)
|
|
|
|
{
|
|
|
|
pRepo->nThrottle = atoi(cn->value);
|
|
|
|
}
|
2023-03-25 02:23:32 +08:00
|
|
|
else if (strcmp(cn->name, TDNF_REPO_KEY_SSL_VERIFY) == 0)
|
2022-04-01 07:59:34 +08:00
|
|
|
{
|
|
|
|
pRepo->nSSLVerify = isTrue(cn->value);
|
|
|
|
}
|
|
|
|
else if (strcmp(cn->name, TDNF_REPO_KEY_SSL_CA_CERT) == 0)
|
|
|
|
{
|
|
|
|
pRepo->pszSSLCaCert = strdup(cn->value);
|
|
|
|
}
|
|
|
|
else if (strcmp(cn->name, TDNF_REPO_KEY_SSL_CLI_CERT) == 0)
|
|
|
|
{
|
|
|
|
pRepo->pszSSLClientCert = strdup(cn->value);
|
|
|
|
}
|
|
|
|
else if (strcmp(cn->name, TDNF_REPO_KEY_SSL_CLI_KEY) == 0)
|
|
|
|
{
|
|
|
|
pRepo->pszSSLClientKey = strdup(cn->value);
|
|
|
|
}
|
|
|
|
else if (strcmp(cn->name, TDNF_REPO_KEY_METADATA_EXPIRE) == 0)
|
|
|
|
{
|
|
|
|
dwError = TDNFParseMetadataExpire(
|
|
|
|
cn->value,
|
|
|
|
&pRepo->lMetadataExpire);
|
|
|
|
BAIL_ON_TDNF_ERROR(dwError);
|
|
|
|
}
|
2023-03-25 02:23:32 +08:00
|
|
|
else if (strcmp(cn->name, TDNF_REPO_KEY_SKIP_MD_FILELISTS) == 0)
|
2022-04-01 07:59:34 +08:00
|
|
|
{
|
|
|
|
pRepo->nSkipMDFileLists = isTrue(cn->value);
|
|
|
|
}
|
2023-03-25 02:23:32 +08:00
|
|
|
else if (strcmp(cn->name, TDNF_REPO_KEY_SKIP_MD_UPDATEINFO) == 0)
|
2022-04-01 07:59:34 +08:00
|
|
|
{
|
|
|
|
pRepo->nSkipMDUpdateInfo = isTrue(cn->value);
|
|
|
|
}
|
2023-03-25 02:23:32 +08:00
|
|
|
else if (strcmp(cn->name, TDNF_REPO_KEY_SKIP_MD_OTHER) == 0)
|
2022-04-01 07:59:34 +08:00
|
|
|
{
|
|
|
|
pRepo->nSkipMDOther = isTrue(cn->value);
|
|
|
|
}
|
|
|
|
}
|
2020-01-29 09:30:07 +08:00
|
|
|
/* plugin event repo readconfig end */
|
2022-04-01 07:59:34 +08:00
|
|
|
dwError = TDNFEventRepoReadConfigEnd(pTdnf, cn_section);
|
2020-01-29 09:30:07 +08:00
|
|
|
BAIL_ON_TDNF_ERROR(dwError);
|
|
|
|
|
2023-03-15 03:10:46 +08:00
|
|
|
/* default to repo id if name isn't set */
|
|
|
|
if (pRepo->pszName == NULL)
|
|
|
|
pRepo->pszName = strdup(pRepo->pszId);
|
|
|
|
|
2016-06-03 15:36:56 +08:00
|
|
|
pRepo->pNext = pRepos;
|
|
|
|
pRepos = pRepo;
|
|
|
|
pRepo = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
*ppRepos = pRepos;
|
2022-04-01 07:59:34 +08:00
|
|
|
|
2016-06-03 15:36:56 +08:00
|
|
|
cleanup:
|
2023-03-25 02:23:32 +08:00
|
|
|
destroy_cnftree(cn_conf);
|
2016-06-24 16:20:53 +08:00
|
|
|
TDNF_SAFE_FREE_MEMORY(pszMetadataExpire);
|
2016-06-03 15:36:56 +08:00
|
|
|
return dwError;
|
|
|
|
|
|
|
|
error:
|
|
|
|
if(ppRepos)
|
|
|
|
{
|
|
|
|
*ppRepos = NULL;
|
|
|
|
}
|
|
|
|
TDNF_SAFE_FREE_MEMORY(pRepo);
|
|
|
|
if(pRepos)
|
|
|
|
{
|
2017-02-19 14:18:44 +08:00
|
|
|
TDNFFreeReposInternal(pRepos);
|
2016-06-03 15:36:56 +08:00
|
|
|
}
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t
|
|
|
|
TDNFRepoListFinalize(
|
|
|
|
PTDNF pTdnf
|
|
|
|
)
|
|
|
|
{
|
|
|
|
uint32_t dwError = 0;
|
|
|
|
PTDNF_CMD_OPT pSetOpt = NULL;
|
2022-03-19 04:57:18 +08:00
|
|
|
PTDNF_REPO_DATA pRepo = NULL;
|
2021-06-24 08:34:06 +08:00
|
|
|
int nRepoidSeen = 0;
|
2016-06-03 15:36:56 +08:00
|
|
|
|
|
|
|
if(!pTdnf || !pTdnf->pArgs || !pTdnf->pRepos)
|
|
|
|
{
|
|
|
|
dwError = ERROR_TDNF_INVALID_PARAMETER;
|
|
|
|
BAIL_ON_TDNF_ERROR(dwError);
|
|
|
|
}
|
|
|
|
|
2022-03-30 02:32:09 +08:00
|
|
|
/* There could be overrides to enable/disable
|
|
|
|
repo such as cmdline args, api overrides */
|
|
|
|
for (pSetOpt = pTdnf->pArgs->pSetOpt; pSetOpt; pSetOpt = pSetOpt->pNext)
|
2016-06-03 15:36:56 +08:00
|
|
|
{
|
2022-03-30 02:32:09 +08:00
|
|
|
if(strcmp(pSetOpt->pszOptName, "enablerepo") == 0)
|
2016-06-03 15:36:56 +08:00
|
|
|
{
|
|
|
|
dwError = TDNFAlterRepoState(
|
|
|
|
pTdnf->pRepos,
|
2022-03-30 02:32:09 +08:00
|
|
|
1,
|
|
|
|
pSetOpt->pszOptValue);
|
|
|
|
}
|
|
|
|
else if(strcmp(pSetOpt->pszOptName, "disablerepo") == 0)
|
|
|
|
{
|
|
|
|
dwError = TDNFAlterRepoState(
|
|
|
|
pTdnf->pRepos,
|
|
|
|
0,
|
2016-06-03 15:36:56 +08:00
|
|
|
pSetOpt->pszOptValue);
|
2021-06-24 08:34:06 +08:00
|
|
|
}
|
2022-10-08 01:30:33 +08:00
|
|
|
else if((strcmp(pSetOpt->pszOptName, "repo") == 0) ||
|
|
|
|
(strcmp(pSetOpt->pszOptName, "repoid") == 0))
|
2021-06-24 08:34:06 +08:00
|
|
|
{
|
|
|
|
if (!nRepoidSeen)
|
|
|
|
{
|
|
|
|
dwError = TDNFAlterRepoState(
|
|
|
|
pTdnf->pRepos, 0, "*");
|
|
|
|
BAIL_ON_TDNF_ERROR(dwError);
|
|
|
|
nRepoidSeen = 1;
|
|
|
|
}
|
|
|
|
dwError = TDNFAlterRepoState(
|
|
|
|
pTdnf->pRepos,
|
|
|
|
1,
|
|
|
|
pSetOpt->pszOptValue);
|
|
|
|
}
|
2022-03-30 02:32:09 +08:00
|
|
|
BAIL_ON_TDNF_ERROR(dwError);
|
2016-06-03 15:36:56 +08:00
|
|
|
}
|
|
|
|
|
2022-03-30 02:32:09 +08:00
|
|
|
/* Now that the overrides are applied, replace config vars
|
2022-07-06 02:13:40 +08:00
|
|
|
for all repos. */
|
2022-03-30 02:32:09 +08:00
|
|
|
for(pRepo = pTdnf->pRepos; pRepo; pRepo = pRepo->pNext)
|
2016-06-03 15:36:56 +08:00
|
|
|
{
|
2022-07-06 02:13:40 +08:00
|
|
|
if(pRepo->pszName)
|
2015-12-13 05:30:40 +08:00
|
|
|
{
|
2022-07-06 02:13:40 +08:00
|
|
|
dwError = TDNFConfigReplaceVars(pTdnf, &pRepo->pszName);
|
|
|
|
BAIL_ON_TDNF_ERROR(dwError);
|
|
|
|
}
|
2022-09-22 07:09:37 +08:00
|
|
|
if(pRepo->ppszBaseUrls)
|
2022-07-06 02:13:40 +08:00
|
|
|
{
|
2022-09-22 07:09:37 +08:00
|
|
|
for (int i = 0; pRepo->ppszBaseUrls[i]; i++)
|
|
|
|
{
|
|
|
|
dwError = TDNFConfigReplaceVars(pTdnf, &(pRepo->ppszBaseUrls[i]));
|
|
|
|
BAIL_ON_TDNF_ERROR(dwError);
|
|
|
|
}
|
2022-07-06 02:13:40 +08:00
|
|
|
}
|
|
|
|
if(pRepo->pszMetaLink)
|
|
|
|
{
|
|
|
|
dwError = TDNFConfigReplaceVars(pTdnf, &pRepo->pszMetaLink);
|
2022-07-01 07:25:58 +08:00
|
|
|
BAIL_ON_TDNF_ERROR(dwError);
|
2015-12-13 05:30:40 +08:00
|
|
|
}
|
2022-07-06 02:13:40 +08:00
|
|
|
|
|
|
|
if (pRepo->pszMetaLink)
|
|
|
|
{
|
|
|
|
dwError = SolvCreateRepoCacheName(pRepo->pszId,
|
|
|
|
pRepo->pszMetaLink,
|
|
|
|
&pRepo->pszCacheName);
|
|
|
|
}
|
2022-09-22 07:09:37 +08:00
|
|
|
else if (pRepo->ppszBaseUrls && pRepo->ppszBaseUrls[0])
|
2022-07-06 02:13:40 +08:00
|
|
|
{
|
|
|
|
dwError = SolvCreateRepoCacheName(pRepo->pszId,
|
2022-09-22 07:09:37 +08:00
|
|
|
pRepo->ppszBaseUrls[0],
|
2022-07-06 02:13:40 +08:00
|
|
|
&pRepo->pszCacheName);
|
|
|
|
}
|
|
|
|
BAIL_ON_TDNF_ERROR(dwError);
|
2016-06-03 15:36:56 +08:00
|
|
|
}
|
|
|
|
cleanup:
|
|
|
|
return dwError;
|
|
|
|
error:
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t
|
|
|
|
TDNFAlterRepoState(
|
2022-03-19 04:57:18 +08:00
|
|
|
PTDNF_REPO_DATA pRepos,
|
2016-06-03 15:36:56 +08:00
|
|
|
int nEnable,
|
|
|
|
const char* pszId
|
|
|
|
)
|
|
|
|
{
|
|
|
|
uint32_t dwError = 0;
|
|
|
|
int nIsGlob = 0;
|
|
|
|
if(!pRepos && IsNullOrEmptyString(pszId))
|
|
|
|
{
|
|
|
|
dwError = ERROR_TDNF_INVALID_PARAMETER;
|
|
|
|
BAIL_ON_TDNF_ERROR(dwError);
|
2015-04-02 09:59:27 +08:00
|
|
|
}
|
|
|
|
|
2016-06-03 15:36:56 +08:00
|
|
|
nIsGlob = TDNFIsGlob(pszId);
|
|
|
|
|
2022-01-15 15:54:01 +08:00
|
|
|
for (int nMatch = 0; pRepos; pRepos = pRepos->pNext)
|
2016-06-03 15:36:56 +08:00
|
|
|
{
|
|
|
|
if(nIsGlob)
|
|
|
|
{
|
|
|
|
if(!fnmatch(pszId, pRepos->pszId, 0))
|
|
|
|
{
|
|
|
|
nMatch = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(!strcmp(pRepos->pszId, pszId))
|
|
|
|
{
|
|
|
|
nMatch = 1;
|
|
|
|
}
|
|
|
|
if(nMatch)
|
|
|
|
{
|
|
|
|
pRepos->nEnabled = nEnable;
|
|
|
|
if(!nIsGlob)
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-04-02 09:59:27 +08:00
|
|
|
cleanup:
|
2016-06-03 15:36:56 +08:00
|
|
|
return dwError;
|
|
|
|
|
|
|
|
error:
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t
|
|
|
|
TDNFCloneRepo(
|
2022-03-19 04:57:18 +08:00
|
|
|
PTDNF_REPO_DATA pRepoIn,
|
2016-06-03 15:36:56 +08:00
|
|
|
PTDNF_REPO_DATA* ppRepo
|
|
|
|
)
|
|
|
|
{
|
|
|
|
uint32_t dwError = 0;
|
|
|
|
PTDNF_REPO_DATA pRepo = NULL;
|
|
|
|
|
|
|
|
if(!pRepoIn || !ppRepo)
|
2015-04-02 09:59:27 +08:00
|
|
|
{
|
2016-06-03 15:36:56 +08:00
|
|
|
dwError = ERROR_TDNF_INVALID_PARAMETER;
|
|
|
|
BAIL_ON_TDNF_ERROR(dwError);
|
2015-04-02 09:59:27 +08:00
|
|
|
}
|
2016-06-03 15:36:56 +08:00
|
|
|
|
2017-05-16 08:32:45 +08:00
|
|
|
dwError = TDNFAllocateMemory(1, sizeof(TDNF_REPO_DATA), (void**)&pRepo);
|
2016-06-03 15:36:56 +08:00
|
|
|
BAIL_ON_TDNF_ERROR(dwError);
|
|
|
|
|
2022-03-19 04:57:18 +08:00
|
|
|
/* cli needs just nEnabled, pszId, pszName */
|
2016-06-03 15:36:56 +08:00
|
|
|
pRepo->nEnabled = pRepoIn->nEnabled;
|
|
|
|
|
|
|
|
dwError = TDNFSafeAllocateString(pRepoIn->pszId, &pRepo->pszId);
|
|
|
|
BAIL_ON_TDNF_ERROR(dwError);
|
|
|
|
|
|
|
|
dwError = TDNFSafeAllocateString(pRepoIn->pszName, &pRepo->pszName);
|
|
|
|
BAIL_ON_TDNF_ERROR(dwError);
|
|
|
|
|
2022-03-19 04:57:18 +08:00
|
|
|
/* python needs also pszBaseUrl and pszMetaLink */
|
2022-09-22 07:09:37 +08:00
|
|
|
if (pRepoIn->ppszBaseUrls && pRepoIn->ppszBaseUrls[0]) {
|
|
|
|
dwError = TDNFAllocateStringArray(pRepoIn->ppszBaseUrls, &pRepo->ppszBaseUrls);
|
|
|
|
BAIL_ON_TDNF_ERROR(dwError);
|
|
|
|
}
|
2016-06-03 15:36:56 +08:00
|
|
|
|
2017-05-16 08:32:45 +08:00
|
|
|
dwError = TDNFSafeAllocateString(
|
|
|
|
pRepoIn->pszMetaLink,
|
|
|
|
&pRepo->pszMetaLink);
|
2016-06-03 15:36:56 +08:00
|
|
|
BAIL_ON_TDNF_ERROR(dwError);
|
|
|
|
|
|
|
|
*ppRepo = pRepo;
|
|
|
|
|
|
|
|
cleanup:
|
2015-04-02 09:59:27 +08:00
|
|
|
return dwError;
|
|
|
|
|
|
|
|
error:
|
2016-06-03 15:36:56 +08:00
|
|
|
if(ppRepo)
|
2015-04-02 09:59:27 +08:00
|
|
|
{
|
2016-06-03 15:36:56 +08:00
|
|
|
*ppRepo = NULL;
|
2015-04-02 09:59:27 +08:00
|
|
|
}
|
2016-06-03 15:36:56 +08:00
|
|
|
if(pRepo)
|
2015-04-02 09:59:27 +08:00
|
|
|
{
|
2016-06-03 15:36:56 +08:00
|
|
|
TDNFFreeRepos(pRepo);
|
2015-04-02 09:59:27 +08:00
|
|
|
}
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2017-02-19 14:18:44 +08:00
|
|
|
TDNFFreeReposInternal(
|
2022-03-19 04:57:18 +08:00
|
|
|
PTDNF_REPO_DATA pRepos
|
2017-02-19 14:18:44 +08:00
|
|
|
)
|
2015-04-02 09:59:27 +08:00
|
|
|
{
|
2022-03-19 04:57:18 +08:00
|
|
|
PTDNF_REPO_DATA pRepo = NULL;
|
2017-02-19 14:18:44 +08:00
|
|
|
while(pRepos)
|
2015-04-02 09:59:27 +08:00
|
|
|
{
|
2017-02-19 14:18:44 +08:00
|
|
|
pRepo = pRepos;
|
|
|
|
TDNF_SAFE_FREE_MEMORY(pRepo->pszId);
|
|
|
|
TDNF_SAFE_FREE_MEMORY(pRepo->pszName);
|
2022-09-22 07:09:37 +08:00
|
|
|
TDNF_SAFE_FREE_STRINGARRAY(pRepo->ppszBaseUrls);
|
2017-02-19 14:18:44 +08:00
|
|
|
TDNF_SAFE_FREE_MEMORY(pRepo->pszMetaLink);
|
2020-09-19 04:27:24 +08:00
|
|
|
TDNF_SAFE_FREE_STRINGARRAY(pRepo->ppszUrlGPGKeys);
|
2017-02-19 14:18:44 +08:00
|
|
|
TDNF_SAFE_FREE_MEMORY(pRepo->pszUser);
|
|
|
|
TDNF_SAFE_FREE_MEMORY(pRepo->pszPass);
|
2022-07-01 08:44:22 +08:00
|
|
|
TDNF_SAFE_FREE_MEMORY(pRepo->pszCacheName);
|
2017-02-19 14:18:44 +08:00
|
|
|
pRepos = pRepo->pNext;
|
|
|
|
TDNF_SAFE_FREE_MEMORY(pRepo);
|
2015-04-02 09:59:27 +08:00
|
|
|
}
|
|
|
|
}
|