diff --git a/client/api.c b/client/api.c index 85517357..3860ed5e 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 9a45b00c..5c64c07c 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 9029c1bc..eb765586 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}, @@ -355,6 +356,7 @@ TDNFCopyOptions( pArgs->nSkipBroken = pOptionArgs->nSkipBroken; pArgs->nSource = pOptionArgs->nSource; pArgs->nBuildDeps = pOptionArgs->nBuildDeps; + pArgs->nInstallToDir = pOptionArgs->nInstallToDir; cleanup: return dwError;