From 191c336b0b6b7a5c5035802eba9e6dd640c89aa0 Mon Sep 17 00:00:00 2001 From: Priyesh Padmavilasom Date: Sat, 5 Nov 2016 01:08:04 +0000 Subject: [PATCH] add new options to help. Change-Id: Idccdf856b9c5fa1e7fd0e72ad0f7290522464a7f (cherry picked from commit bc7fb5e040f34a8b12571dac9bdc27a5135dd3c8) --- client/api.c | 6 +----- client/repo.c | 20 ++++++-------------- client/rpmtrans.c | 7 +++++-- client/utils.c | 39 ++++++++++++--------------------------- tools/cli/help.c | 5 ++++- 5 files changed, 28 insertions(+), 49 deletions(-) diff --git a/client/api.c b/client/api.c index c40d19f3..d8ba026e 100644 --- a/client/api.c +++ b/client/api.c @@ -80,10 +80,6 @@ TDNFIsInitialized( return dwError; error: - if(pnInitialized) - { - *pnInitialized = 0; - } goto cleanup; } @@ -1079,7 +1075,7 @@ TDNFUpdateInfo( pLocalTime = localtime(&dwUpdated); if(!pLocalTime) { - dwError = errno; + dwError = ERROR_TDNF_INVALID_PARAMETER; BAIL_ON_TDNF_SYSTEM_ERROR(dwError); } memset(szDate, 0, DATELEN); diff --git a/client/repo.c b/client/repo.c index ee858b9b..1cb6870d 100644 --- a/client/repo.c +++ b/client/repo.c @@ -103,21 +103,13 @@ TDNFInitRepo( } else { - //Look for the repo root cache dir. If not there, - //try to create and download into it. - if(access(pszRepoCacheDir, F_OK)) + if(mkdir(pszRepoCacheDir, 755)) { - if(errno != ENOENT) - { - dwError = errno; - } - BAIL_ON_TDNF_SYSTEM_ERROR(dwError); - - if(mkdir(pszRepoCacheDir, 755)) - { - dwError = errno; - BAIL_ON_TDNF_SYSTEM_ERROR(dwError); - } + if(errno != EEXIST) + { + dwError = errno; + BAIL_ON_TDNF_SYSTEM_ERROR(dwError); + } } lr_handle_setopt(hLibRepo, NULL, LRO_URLS, ppszRepoUrls); diff --git a/client/rpmtrans.c b/client/rpmtrans.c index 5629f751..c0a3145e 100644 --- a/client/rpmtrans.c +++ b/client/rpmtrans.c @@ -250,7 +250,10 @@ TDNFRunTransaction( return dwError; error: - doCheck(pTS); + if(pTS) + { + doCheck(pTS); + } goto cleanup; } @@ -750,7 +753,7 @@ TDNFRemoveCachedRpms( for(dwIndex = 0; dwIndex < pCachedRpmsArray->len; ++dwIndex) { pszCachedRpm = g_array_index(pCachedRpmsArray, char*, dwIndex); - if(access(pszCachedRpm, F_OK) != -1) + if(IsNullOrEmptyString(pszCachedRpm)) { if(unlink(pszCachedRpm)) { diff --git a/client/utils.c b/client/utils.c index 812ae3f1..364434e1 100644 --- a/client/utils.c +++ b/client/utils.c @@ -189,15 +189,9 @@ TDNFUtilsMakeDir( BAIL_ON_TDNF_ERROR(dwError); } - if(access(pszDir, F_OK)) + if(mkdir(pszDir, 755)) { - if(errno != ENOENT) - { - dwError = errno; - } - BAIL_ON_TDNF_SYSTEM_ERROR(dwError); - - if(mkdir(pszDir, 755)) + if(errno != EEXIST) { dwError = errno; BAIL_ON_TDNF_SYSTEM_ERROR(dwError); @@ -324,21 +318,18 @@ TDNFTouchFile( BAIL_ON_TDNF_ERROR(dwError); } - if(stat(pszFile, &st) == -1) + fd = creat(pszFile, S_IRUSR | S_IRGRP | S_IROTH); + if(fd == -1) { - if(errno == ENOENT) + if(errno == EEXIST) { - fd = creat(pszFile, - S_IRUSR | S_IRGRP | S_IROTH); - if(fd == -1) + times.actime = st.st_atime; + times.modtime = time(NULL); + if(utime(pszFile, ×)) { dwError = errno; BAIL_ON_TDNF_SYSTEM_ERROR(dwError); } - else - { - close(fd); - } } else { @@ -346,18 +337,12 @@ TDNFTouchFile( BAIL_ON_TDNF_SYSTEM_ERROR(dwError); } } - else - { - times.actime = st.st_atime; - times.modtime = time(NULL); - if(utime(pszFile, ×)) - { - dwError = errno; - BAIL_ON_TDNF_SYSTEM_ERROR(dwError); - } - } cleanup: + if(fd != -1) + { + close(fd); + } return dwError; error: diff --git a/tools/cli/help.c b/tools/cli/help.c index 24cd606f..319d01e8 100644 --- a/tools/cli/help.c +++ b/tools/cli/help.c @@ -38,11 +38,14 @@ TDNFCliShowHelp( printf("options [-c [config file]]\n"); printf(" [--debugsolver]\n"); + printf(" [--disablerepo=]\n"); + printf(" [--enablerepo=]\n"); printf(" [--rpmverbosity [debug level name]] [-v] [-y] [--assumeno]\n"); printf(" [--version] [--installroot [path]]\n"); printf(" [--nogpgcheck]\n"); + printf(" [-q, --quiet]\n"); printf(" [--releasever RELEASEVER] [--setopt SETOPTS]\n"); - printf(" [--refresh] [-4] [-6] [-h]\n"); + printf(" [--refresh]\n"); printf("List of Main Commands\n"); printf("\n");