Skip to content

Commit

Permalink
Merge pull request #311 from oliverkurth/topic/okurth/cleanups
Browse files Browse the repository at this point in the history
cleanups
  • Loading branch information
oliverkurth authored Apr 28, 2022
2 parents adf68b3 + cf8a27d commit dd2e8bb
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 128 deletions.
1 change: 0 additions & 1 deletion client/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ add_library(${LIB_TDNF} SHARED
rpmtrans.c
updateinfo.c
utils.c
validate.c
metalink.c
list.c
)
Expand Down
47 changes: 18 additions & 29 deletions client/api.c
Original file line number Diff line number Diff line change
Expand Up @@ -769,7 +769,8 @@ TDNFOpenHandle(

uint32_t
TDNFAddCmdLinePackages(
PTDNF pTdnf
PTDNF pTdnf,
Queue *pQueueGoal
)
{
uint32_t dwError = 0;
Expand All @@ -789,8 +790,6 @@ TDNFAddCmdLinePackages(
BAIL_ON_TDNF_ERROR(dwError);
}

queue_init(&pTdnf->queueCmdLinePkgs);

pCmdArgs = pTdnf->pArgs;
pSack = pTdnf->pSack;

Expand Down Expand Up @@ -847,7 +846,7 @@ TDNFAddCmdLinePackages(
BAIL_ON_TDNF_ERROR(dwError);

TDNF_SAFE_FREE_MEMORY(pszCopyOfPkgName);
}
}
}
id = repo_add_rpm(pTdnf->pSolvCmdLineRepo, pszRPMPath,
REPO_REUSE_REPODATA|REPO_NO_INTERNALIZE|RPM_ADD_WITH_HDRID|RPM_ADD_WITH_SHA256SUM);
Expand All @@ -857,7 +856,7 @@ TDNFAddCmdLinePackages(
dwError = ERROR_TDNF_INVALID_PARAMETER;
BAIL_ON_TDNF_ERROR(dwError);
}
queue_push(&pTdnf->queueCmdLinePkgs, id);
queue_push(pQueueGoal, id);
}
pool_createwhatprovides(pSack->pPool);
repo_internalize(pTdnf->pSolvCmdLineRepo);
Expand Down Expand Up @@ -1556,32 +1555,34 @@ TDNFResolve(
uint32_t dwError = 0;
Queue queueGoal = {0};
char** ppszPkgsNotResolved = NULL;

PTDNF_SOLVED_PKG_INFO pSolvedPkgInfo = NULL;
PTDNF_PKG_INFO pPkgInfo = NULL;

if(!pTdnf || !ppSolvedPkgInfo)
{
dwError = ERROR_TDNF_INVALID_PARAMETER;
BAIL_ON_TDNF_ERROR(dwError);
}

dwError = TDNFAddCmdLinePackages(pTdnf);
BAIL_ON_TDNF_ERROR(dwError);
if (nAlterType == ALTER_INSTALL ||
nAlterType == ALTER_REINSTALL ||
nAlterType == ALTER_ERASE)
{
if(pTdnf->pArgs->nCmdCount <= 1)
{
dwError = ERROR_TDNF_PACKAGE_REQUIRED;
BAIL_ON_TDNF_ERROR(dwError);
}
}

dwError = TDNFRefresh(pTdnf);
BAIL_ON_TDNF_ERROR(dwError);
queue_init(&queueGoal);

if(nAlterType == ALTER_INSTALL || nAlterType == ALTER_REINSTALL)
{
queue_init_clone(&queueGoal, &pTdnf->queueCmdLinePkgs);
}
else
{
queue_init(&queueGoal);
dwError = TDNFAddCmdLinePackages(pTdnf, &queueGoal);
BAIL_ON_TDNF_ERROR(dwError);
}

dwError = TDNFValidateCmdArgs(pTdnf);
dwError = TDNFRefresh(pTdnf);
BAIL_ON_TDNF_ERROR(dwError);

dwError = TDNFAllocateMemory(
Expand All @@ -1604,18 +1605,6 @@ TDNFResolve(
nAlterType);
BAIL_ON_TDNF_ERROR(dwError);

pPkgInfo = pSolvedPkgInfo->pPkgsToRemove;
while(pPkgInfo != NULL)
{
if(pPkgInfo->pszName != NULL &&
strcmp(pPkgInfo->pszName, TDNF_NAME) == 0)
{
dwError = ERROR_TDNF_SELF_ERASE;
BAIL_ON_TDNF_ERROR(dwError);
}
pPkgInfo = pPkgInfo->pNext;
}

dwError = TDNFCheckProtectedPkgs(pSolvedPkgInfo);
BAIL_ON_TDNF_ERROR(dwError);

Expand Down
41 changes: 4 additions & 37 deletions client/resolve.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ TDNFPrepareAllPackages(
BAIL_ON_TDNF_ERROR(dwError);
for(nPkgIndex = 0; (uint32_t)nPkgIndex < dwCount; ++nPkgIndex)
{
dwError = TDNFPrepareAndAddPkg(
dwError = TDNFPrepareSinglePkg(
pTdnf,
ppszPkgArray[nPkgIndex],
*pAlterType,
Expand Down Expand Up @@ -154,7 +154,7 @@ TDNFPrepareAllPackages(
&pszName);
BAIL_ON_TDNF_ERROR(dwError);

dwError = TDNFPrepareAndAddPkg(
dwError = TDNFPrepareSinglePkg(
pTdnf,
pszName,
nAlterType,
Expand Down Expand Up @@ -189,7 +189,7 @@ TDNFPrepareAllPackages(
}
BAIL_ON_TDNF_ERROR(dwError);

dwError = TDNFPrepareAndAddPkg(
dwError = TDNFPrepareSinglePkg(
pTdnf,
pszPkgName,
nAlterType,
Expand Down Expand Up @@ -252,7 +252,7 @@ TDNFFilterPackages(
&pszName);
BAIL_ON_TDNF_ERROR(dwError);

dwError = TDNFPrepareAndAddPkg(
dwError = TDNFPrepareSinglePkg(
pTdnf,
pszName,
nAlterType,
Expand All @@ -275,39 +275,6 @@ TDNFFilterPackages(
goto cleanup;
}

uint32_t
TDNFPrepareAndAddPkg(
PTDNF pTdnf,
const char* pszPkgName,
TDNF_ALTERTYPE nAlterType,
char** ppszPkgsNotResolved,
Queue* queueGoal
)
{
uint32_t dwError = 0;
if( !pTdnf ||
IsNullOrEmptyString(pszPkgName) ||
!ppszPkgsNotResolved ||
!queueGoal)
{
dwError = ERROR_TDNF_INVALID_PARAMETER;
BAIL_ON_TDNF_ERROR(dwError);
}

dwError = TDNFPrepareSinglePkg(
pTdnf,
pszPkgName,
nAlterType,
ppszPkgsNotResolved,
queueGoal);
BAIL_ON_TDNF_ERROR(dwError);

cleanup:
return dwError;
error:
goto cleanup;
}

uint32_t
TDNFPrepareSinglePkg(
PTDNF pTdnf,
Expand Down
1 change: 0 additions & 1 deletion client/structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ typedef struct _TDNF_
PTDNF_CONF pConf;
PTDNF_REPO_DATA pRepos;
Repo *pSolvCmdLineRepo;
Queue queueCmdLinePkgs;
PTDNF_PLUGIN pPlugins;
} TDNF;

Expand Down
54 changes: 0 additions & 54 deletions client/validate.c

This file was deleted.

5 changes: 0 additions & 5 deletions include/tdnf.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,6 @@ TDNFRefresh(
PTDNF pTdnf
);

uint32_t
TDNFAddCmdLinePackages(
PTDNF pTdnf
);

//check for updates
uint32_t
TDNFCheckUpdates(
Expand Down
2 changes: 1 addition & 1 deletion pytests/tests/test_erase.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def teardown_test(utils):

def test_erase_no_arg(utils):
ret = utils.run(['tdnf', 'erase'])
assert(ret['stderr'][0] == 'Nothing to do.')
assert(ret['retval'] == 1001)


def test_erase_invalid_package(utils):
Expand Down

0 comments on commit dd2e8bb

Please sign in to comment.