Skip to content

Commit

Permalink
added mirrorlist repo config option
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan Silhan committed Nov 7, 2016
1 parent bf4826d commit 3d714e2
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 2 deletions.
1 change: 1 addition & 0 deletions client/defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ typedef enum
#define TDNF_REPO_KEY_BASEURL "baseurl"
#define TDNF_REPO_KEY_ENABLED "enabled"
#define TDNF_REPO_KEY_METALINK "metalink"
#define TDNF_REPO_KEY_MIRRORLIST "mirrorlist"
#define TDNF_REPO_KEY_NAME "name"
#define TDNF_REPO_KEY_SKIP "skip_if_unavailable"
#define TDNF_REPO_KEY_GPGCHECK "gpgcheck"
Expand Down
9 changes: 8 additions & 1 deletion client/repo.c
Original file line number Diff line number Diff line change
Expand Up @@ -203,11 +203,18 @@ TDNFInitRepo(
//remove any cache data that could be potentially corrupt.
if(pRepoData)
{
const char* url;
if (pRepoData->pszBaseUrl)
url = pRepoData->pszBaseUrl;
else if (pRepoData->pszMirrorList)
url = pRepoData->pszMirrorList;
else
url = pRepoData->pszMetaLink;
fprintf(
stderr,
"Error: Failed to synchronize cache for repo '%s' from '%s'\n",
pRepoData->pszName,
pRepoData->pszBaseUrl);
url);

if(pTdnf)
{
Expand Down
17 changes: 16 additions & 1 deletion client/repolist.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ TDNFLoadReposFromFile(
if((nFilter == REPOLISTFILTER_ENABLED && !pRepo->nEnabled) ||
(nFilter == REPOLISTFILTER_DISABLED && pRepo->nEnabled))
{
TDNFFreeRepos(pRepo);
TDNF_SAFE_FREE_MEMORY(pRepo);
pRepo = NULL;
i++;
continue;
Expand Down Expand Up @@ -201,6 +201,14 @@ TDNFLoadReposFromFile(
&pRepo->pszMetaLink);
BAIL_ON_TDNF_ERROR(dwError);

dwError = TDNFRepoGetKeyValue(
pKeyFile,
pszRepo,
TDNF_REPO_KEY_MIRRORLIST,
NULL,
&pRepo->pszMirrorList);
BAIL_ON_TDNF_ERROR(dwError);

dwError = TDNFRepoGetKeyValueBoolean(
pKeyFile,
pszRepo,
Expand Down Expand Up @@ -255,6 +263,12 @@ TDNFLoadReposFromFile(
BAIL_ON_TDNF_ERROR(dwError);
}

if(pRepo->pszMirrorList)
{
dwError = TDNFConfigReplaceVars(pTdnf, &pRepo->pszMirrorList);
BAIL_ON_TDNF_ERROR(dwError);
}

if(pRepo->pszName)
{
dwError = TDNFConfigReplaceVars(pTdnf, &pRepo->pszName);
Expand Down Expand Up @@ -507,6 +521,7 @@ TDNFFreeRepos(
TDNF_SAFE_FREE_MEMORY(pRepo->pszName);
TDNF_SAFE_FREE_MEMORY(pRepo->pszBaseUrl);
TDNF_SAFE_FREE_MEMORY(pRepo->pszMetaLink);
TDNF_SAFE_FREE_MEMORY(pRepo->pszMirrorList);
TDNF_SAFE_FREE_MEMORY(pRepo->pszUrlGPGKey);
TDNF_SAFE_FREE_MEMORY(pRepo->pszUser);
TDNF_SAFE_FREE_MEMORY(pRepo->pszPass);
Expand Down
1 change: 1 addition & 0 deletions include/tdnftypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ typedef struct _TDNF_REPO_DATA
char* pszName;
char* pszBaseUrl;
char* pszMetaLink;
char* pszMirrorList;
char* pszUrlGPGKey;
char* pszUser;
char* pszPass;
Expand Down

0 comments on commit 3d714e2

Please sign in to comment.