Skip to content

Commit

Permalink
Merge pull request vmware#57 from ppadmavilasom/dev
Browse files Browse the repository at this point in the history
Support --releasever option
  • Loading branch information
ppadmavilasom committed Mar 23, 2016
2 parents f661166 + 848a4b6 commit 4d991ae
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 30 deletions.
1 change: 1 addition & 0 deletions client/api.c
Original file line number Diff line number Diff line change
Expand Up @@ -1026,6 +1026,7 @@ TDNFFreeCmdArgs(
}
TDNF_SAFE_FREE_MEMORY(pCmdArgs->pszInstallRoot);
TDNF_SAFE_FREE_MEMORY(pCmdArgs->pszConfFile);
TDNF_SAFE_FREE_MEMORY(pCmdArgs->pszReleaseVer);

TDNF_SAFE_FREE_MEMORY(pCmdArgs->pSetOpt);
TDNF_SAFE_FREE_MEMORY(pCmdArgs);
Expand Down
9 changes: 9 additions & 0 deletions client/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,15 @@ TDNFConfigExpandVars(
}
pConf = pTdnf->pConf;

//Allow --releasever overrides
if(!pConf->pszVarReleaseVer &&
!IsNullOrEmptyString(pTdnf->pArgs->pszReleaseVer))
{
dwError = TDNFAllocateString(pTdnf->pArgs->pszReleaseVer,
&pConf->pszVarReleaseVer);
BAIL_ON_TDNF_ERROR(dwError);
}

if(!pConf->pszVarReleaseVer &&
!IsNullOrEmptyString(pConf->pszDistroVerPkg))
{
Expand Down
7 changes: 7 additions & 0 deletions client/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,13 @@ TDNFCloneCmdArgs(
BAIL_ON_TDNF_ERROR(dwError);
}

if(!IsNullOrEmptyString(pCmdArgsIn->pszReleaseVer))
{
dwError = TDNFAllocateString(
pCmdArgsIn->pszReleaseVer,
&pCmdArgs->pszReleaseVer);
BAIL_ON_TDNF_ERROR(dwError);
}

pCmdArgs->nCmdCount = pCmdArgsIn->nCmdCount;
dwError = TDNFAllocateMemory(
Expand Down
1 change: 1 addition & 0 deletions include/tdnftypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ typedef struct _TDNF_CMD_ARGS
int nIPv6; //resolve to IPv6 addresses only
char* pszInstallRoot; //set install root
char* pszConfFile; //set conf file location
char* pszReleaseVer; //Release version

//Commands and args that do not fall in options
char** ppszCmds;
Expand Down
44 changes: 14 additions & 30 deletions tools/cli/parseargs.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ static struct option pstOptions[] =
{"installroot", required_argument, 0, 'i'}, //--installroot
{"nogpgcheck", no_argument, &_opt.nNoGPGCheck, 1}, //--nogpgcheck
{"refresh", no_argument, &_opt.nRefresh, 1}, //--refresh
{"releasever", required_argument, 0, 0}, //--releasever
{"rpmverbosity", required_argument, 0, 0}, //--rpmverbosity
{"setopt", required_argument, 0, 0}, //--set or override options
{"showduplicates",required_argument, 0, 0}, //--showduplicates
Expand Down Expand Up @@ -93,6 +94,7 @@ TDNFCliParseArgs(
switch (nOption)
{
case 0:
case 'i':
dwError = ParseOption(
pstOptions[nOptionIndex].name,
optarg,
Expand All @@ -110,12 +112,6 @@ TDNFCliParseArgs(
case 'h':
_opt.nShowHelp = 1;
break;
case 'i':
dwError = TDNFAllocateString(
optarg,
&pCmdArgs->pszInstallRoot);
BAIL_ON_CLI_ERROR(dwError);
break;
case 'r':
break;
case 'y':
Expand Down Expand Up @@ -302,42 +298,30 @@ ParseOption(

if(!strcasecmp(pszName, "rpmverbosity"))
{
if(!optarg)
{
dwError = ERROR_TDNF_CLI_OPTION_ARG_REQUIRED;
BAIL_ON_CLI_ERROR(dwError);
}
dwError = ParseRpmVerbosity(
optarg,
pszArg,
&pCmdArgs->nRpmVerbosity);
BAIL_ON_CLI_ERROR(dwError);
}
else if(!strcasecmp(pszName, "enablerepo"))
{
if(!optarg)
{
dwError = ERROR_TDNF_CLI_OPTION_ARG_REQUIRED;
BAIL_ON_CLI_ERROR(dwError);
}
fprintf(stdout, "EnableRepo: %s\n", optarg);
}
else if(!strcasecmp(pszName, "disablerepo"))
{
if(!optarg)
{
dwError = ERROR_TDNF_CLI_OPTION_ARG_REQUIRED;
BAIL_ON_CLI_ERROR(dwError);
}
fprintf(stdout, "DisableRepo: %s\n", optarg);
}
else if(!strcasecmp(pszName, "installroot"))
{
if(!optarg)
{
dwError = ERROR_TDNF_CLI_OPTION_ARG_REQUIRED;
BAIL_ON_CLI_ERROR(dwError);
}
fprintf(stdout, "InstallRoot: %s\n", optarg);
dwError = TDNFAllocateString(
optarg,
&pCmdArgs->pszInstallRoot);
BAIL_ON_CLI_ERROR(dwError);
}
else if(!strcasecmp(pszName, "releasever"))
{
dwError = TDNFAllocateString(
optarg,
&pCmdArgs->pszReleaseVer);
BAIL_ON_CLI_ERROR(dwError);
}
else if(!strcasecmp(pszName, "setopt"))
{
Expand Down

0 comments on commit 4d991ae

Please sign in to comment.