From 851c3f9e84f150acdb279f81e772ced140a0e6ef Mon Sep 17 00:00:00 2001 From: Oliver Kurth Date: Fri, 7 Oct 2022 13:14:52 -0700 Subject: [PATCH] add --installtodir option --- client/api.c | 12 ++++++++++-- client/init.c | 1 + include/tdnftypes.h | 1 + tools/cli/lib/parseargs.c | 2 ++ 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/client/api.c b/client/api.c index c75a2edf..f698b796 100644 --- a/client/api.c +++ b/client/api.c @@ -700,10 +700,18 @@ TDNFOpenHandle( pTdnf->pArgs->pszInstallRoot); BAIL_ON_TDNF_ERROR(dwError); - if(!pArgs->nAllDeps) - { + if(!pArgs->nAllDeps) { dwError = SolvReadInstalledRpms(pSack->pPool->installed, pszCacheDir); BAIL_ON_TDNF_LIBSOLV_ERROR(dwError); + } else if (pArgs->nInstallToDir) { + if (pArgs->nDownloadOnly && !IsNullOrEmptyString(pArgs->pszDownloadDir)) { + dwError = SolvReadRpmsFromDirectory(pSack->pPool->installed, pArgs->pszDownloadDir); + BAIL_ON_TDNF_ERROR(dwError); + } else { + pr_err("--installtodir requires --downloadonly and --downloaddir"); + dwError = ERROR_TDNF_INVALID_PARAMETER; + BAIL_ON_TDNF_ERROR(dwError); + } } dwError = TDNFLoadRepoData( diff --git a/client/init.c b/client/init.c index 7053e9ca..d0acc9ef 100644 --- a/client/init.c +++ b/client/init.c @@ -64,6 +64,7 @@ TDNFCloneCmdArgs( pCmdArgs->nSkipBroken = pCmdArgsIn->nSkipBroken; pCmdArgs->nSource = pCmdArgsIn->nSource; pCmdArgs->nBuildDeps = pCmdArgsIn->nBuildDeps; + pCmdArgs->nInstallToDir = pCmdArgsIn->nInstallToDir; pCmdArgs->nArgc = pCmdArgsIn->nArgc; pCmdArgs->ppszArgv = pCmdArgsIn->ppszArgv; diff --git a/include/tdnftypes.h b/include/tdnftypes.h index 2d9e8005..c02d6465 100644 --- a/include/tdnftypes.h +++ b/include/tdnftypes.h @@ -231,6 +231,7 @@ typedef struct _TDNF_CMD_ARGS int nSkipBroken; int nSource; int nBuildDeps; + int nInstallToDir; char* pszDownloadDir; //directory for download, if nDownloadOnly is set char* pszInstallRoot; //set install root char* pszConfFile; //set conf file location diff --git a/tools/cli/lib/parseargs.c b/tools/cli/lib/parseargs.c index ccda8571..905cd9f9 100644 --- a/tools/cli/lib/parseargs.c +++ b/tools/cli/lib/parseargs.c @@ -47,6 +47,7 @@ static struct option pstOptions[] = {"exclude", required_argument, 0, 0}, //--exclude {"help", no_argument, 0, 'h'}, //-h --help {"installroot", required_argument, 0, 'i'}, //--installroot + {"installtodir", no_argument, &_opt.nInstallToDir, 1}, {"json", no_argument, &_opt.nJsonOutput, 1}, {"noautoremove", no_argument, &_opt.nNoAutoRemove, 1}, {"nodeps", no_argument, &_opt.nNoDeps, 1}, @@ -352,6 +353,7 @@ TDNFCopyOptions( pArgs->nSkipBroken = pOptionArgs->nSkipBroken; pArgs->nSource = pOptionArgs->nSource; pArgs->nBuildDeps = pOptionArgs->nBuildDeps; + pArgs->nInstallToDir = pOptionArgs->nInstallToDir; cleanup: return dwError;