Skip to content

Commit

Permalink
setopt: Support rpm transactions noscripts
Browse files Browse the repository at this point in the history
sudo tdnf install --setopt=tsflags=noscripts
  • Loading branch information
ssahani authored and oliverkurth committed Apr 6, 2021
1 parent 08ee998 commit d26b490
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
20 changes: 18 additions & 2 deletions client/rpmtrans.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ TDNFRpmExecTransaction(
int nKeepCachedRpms = 0;
int nDownloadOnly = 0;
TDNFRPMTS ts = {0};
PTDNF_CMD_OPT pSetOpt = NULL;

if(!pTdnf || !pTdnf->pArgs || !pTdnf->pConf || !pSolvedInfo)
{
Expand Down Expand Up @@ -64,7 +65,22 @@ TDNFRpmExecTransaction(
BAIL_ON_TDNF_ERROR(dwError);
}

ts.nTransFlags = rpmtsSetFlags (ts.pTS, RPMTRANS_FLAG_NONE);
/* parse transaction flags - so far only tsflags=noscripts is
supported. */
ts.nTransFlags = RPMTRANS_FLAG_NONE;
for (pSetOpt = pTdnf->pArgs->pSetOpt; pSetOpt; pSetOpt = pSetOpt->pNext)
{
if (pSetOpt->nType != CMDOPT_KEYVALUE ||
strcasecmp(pSetOpt->pszOptName, "tsflags"))
{
continue;
}

if (!strcasecmp(pSetOpt->pszOptValue, "noscripts"))
{
ts.nTransFlags |= RPMTRANS_FLAG_NOSCRIPTS;
}
}

if(rpmtsSetRootDir (ts.pTS, pTdnf->pArgs->pszInstallRoot))
{
Expand Down Expand Up @@ -412,7 +428,7 @@ TDNFRunTransaction(
//TODO do callbacks for output
pr_info("Running transaction\n");

rpmtsSetFlags(pTS->pTS, RPMTRANS_FLAG_NONE);
rpmtsSetFlags(pTS->pTS, pTS->nTransFlags);
rc = rpmtsRun(pTS->pTS, NULL, pTS->nProbFilterFlags);
if (rc != 0)
{
Expand Down
3 changes: 3 additions & 0 deletions common/setopt.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ AddSetOpt(
BAIL_ON_TDNF_ERROR(dwError);
}

dwError = AddSetOptWithValues(pCmdArgs, CMDOPT_KEYVALUE, pCmdOpt->pszOptName, pCmdOpt->pszOptValue);
BAIL_ON_TDNF_ERROR(dwError);

cleanup:
if(pCmdOpt)
{
Expand Down

0 comments on commit d26b490

Please sign in to comment.