Change-Id: I486897ad785eed65490e10a02a0f2c125970b6e1
Reviewed-on: http://photon-jenkins.eng.vmware.com:8082/4032
Tested-by: gerrit-photon <photon-checkins@vmware.com>
Reviewed-by: Vinay Kulkarni <kulkarniv@vmware.com>
Reviewed-by: Sharath George
| ... | ... |
@@ -4,7 +4,7 @@ |
| 4 | 4 |
Summary: dnf/yum equivalent using C libs |
| 5 | 5 |
Name: tdnf |
| 6 | 6 |
Version: 1.1.0 |
| 7 |
-Release: 2%{?dist}
|
|
| 7 |
+Release: 3%{?dist}
|
|
| 8 | 8 |
Vendor: VMware, Inc. |
| 9 | 9 |
Distribution: Photon |
| 10 | 10 |
License: VMware |
| ... | ... |
@@ -20,6 +20,7 @@ BuildRequires: openssl-devel |
| 20 | 20 |
BuildRequires: librepo-devel |
| 21 | 21 |
Source0: %{name}-%{version}.tar.gz
|
| 22 | 22 |
%define sha1 tdnf=15544a87ea01d6215fed35bd2d1299776f7daca1 |
| 23 |
+Patch0: tdnf_print_curl_error.patch |
|
| 23 | 24 |
|
| 24 | 25 |
%description |
| 25 | 26 |
tdnf is a yum/dnf equivalent |
| ... | ... |
@@ -35,6 +36,7 @@ Development files for tdnf |
| 35 | 35 |
|
| 36 | 36 |
%prep |
| 37 | 37 |
%setup -q |
| 38 |
+%patch0 -p1 |
|
| 38 | 39 |
|
| 39 | 40 |
%build |
| 40 | 41 |
autoreconf -i |
| ... | ... |
@@ -91,6 +93,8 @@ ln -sf %{_bindir}/tdnf %{buildroot}%{_bindir}/tyum
|
| 91 | 91 |
%{_libdir}/pkgconfig/tdnf.pc
|
| 92 | 92 |
|
| 93 | 93 |
%changelog |
| 94 |
+* Wed Oct 11 2017 Priyesh Padmavilasom <ppadmavilasom@vmware.com> 1.1.0-3 |
|
| 95 |
+- Patch to report curl error for repo sync or download |
|
| 94 | 96 |
* Fri Sep 29 2017 Alexey Makhalov <amakhalov@vmware.com> 1.1.0-2 |
| 95 | 97 |
- rpm version update |
| 96 | 98 |
* Thu Dec 08 2016 Priyesh Padmavilasom <ppadmavilasom@vmware.com> 1.1.0-1 |
| 97 | 99 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,168 @@ |
| 0 |
+diff --git a/client/prototypes.h b/client/prototypes.h |
|
| 1 |
+index 2076972..4619615 100644 |
|
| 2 |
+--- a/client/prototypes.h |
|
| 3 |
+@@ -805,6 +805,11 @@ TDNFShouldSyncMetadata( |
|
| 4 |
+ int* pnShouldSync |
|
| 5 |
+ ); |
|
| 6 |
+ |
|
| 7 |
++void |
|
| 8 |
++print_curl_error( |
|
| 9 |
++ const char *pszUrl |
|
| 10 |
++ ); |
|
| 11 |
++ |
|
| 12 |
+ //validate.c |
|
| 13 |
+ uint32_t |
|
| 14 |
+ TDNFValidateCmdArgs( |
|
| 15 |
+diff --git a/client/remoterepo.c b/client/remoterepo.c |
|
| 16 |
+index 72bf268..e72e854 100644 |
|
| 17 |
+--- a/client/remoterepo.c |
|
| 18 |
+@@ -179,6 +179,22 @@ cleanup: |
|
| 19 |
+ error: |
|
| 20 |
+ if(pError) |
|
| 21 |
+ {
|
|
| 22 |
++ if(!IsNullOrEmptyString(pszBaseUrl) || |
|
| 23 |
++ !IsNullOrEmptyString(pszHyPackage)) |
|
| 24 |
++ {
|
|
| 25 |
++ char *pszUrl = NULL; |
|
| 26 |
++ dwError = TDNFAllocateStringPrintf( |
|
| 27 |
++ &pszUrl, |
|
| 28 |
++ "%s/%s", |
|
| 29 |
++ pszBaseUrl, |
|
| 30 |
++ pszHyPackage |
|
| 31 |
++ ); |
|
| 32 |
++ if(dwError == 0) |
|
| 33 |
++ {
|
|
| 34 |
++ print_curl_error(pszUrl); |
|
| 35 |
++ } |
|
| 36 |
++ TDNF_SAFE_FREE_MEMORY(pszUrl); |
|
| 37 |
++ } |
|
| 38 |
+ fprintf( |
|
| 39 |
+ stderr, |
|
| 40 |
+ "Error during download: %d: %s\n", |
|
| 41 |
+diff --git a/client/repo.c b/client/repo.c |
|
| 42 |
+index 1cb6870..eecb285 100644 |
|
| 43 |
+--- a/client/repo.c |
|
| 44 |
+@@ -45,6 +45,7 @@ TDNFInitRepo( |
|
| 45 |
+ PTDNF_CONF pConf = NULL; |
|
| 46 |
+ |
|
| 47 |
+ HyRepo hRepo = NULL; |
|
| 48 |
++ GError *pError = NULL; |
|
| 49 |
+ |
|
| 50 |
+ if(!pTdnf || !pTdnf->pConf || !pRepoData || !phRepo) |
|
| 51 |
+ {
|
|
| 52 |
+@@ -141,7 +142,7 @@ TDNFInitRepo( |
|
| 53 |
+ lr_handle_setopt(hLibRepo, NULL, LRO_LOCAL, nLocalOnly); |
|
| 54 |
+ |
|
| 55 |
+ |
|
| 56 |
+- bRet = lr_handle_perform(hLibRepo, pResult, NULL); |
|
| 57 |
++ bRet = lr_handle_perform(hLibRepo, pResult, &pError); |
|
| 58 |
+ if(!bRet) |
|
| 59 |
+ {
|
|
| 60 |
+ dwError = ERROR_TDNF_REPO_PERFORM; |
|
| 61 |
+@@ -196,6 +197,10 @@ cleanup: |
|
| 62 |
+ {
|
|
| 63 |
+ lr_handle_free(hLibRepo); |
|
| 64 |
+ } |
|
| 65 |
++ if(pError) |
|
| 66 |
++ {
|
|
| 67 |
++ g_error_free(pError); |
|
| 68 |
++ } |
|
| 69 |
+ return dwError; |
|
| 70 |
+ |
|
| 71 |
+ error: |
|
| 72 |
+@@ -203,6 +208,10 @@ error: |
|
| 73 |
+ //remove any cache data that could be potentially corrupt. |
|
| 74 |
+ if(pRepoData) |
|
| 75 |
+ {
|
|
| 76 |
++ if(pError && !IsNullOrEmptyString(pRepoData->pszBaseUrl)) |
|
| 77 |
++ {
|
|
| 78 |
++ print_curl_error(pRepoData->pszBaseUrl); |
|
| 79 |
++ } |
|
| 80 |
+ fprintf( |
|
| 81 |
+ stderr, |
|
| 82 |
+ "Error: Failed to synchronize cache for repo '%s' from '%s'\n", |
|
| 83 |
+diff --git a/client/rpmtrans.c b/client/rpmtrans.c |
|
| 84 |
+index c0a3145..7cae5a8 100644 |
|
| 85 |
+--- a/client/rpmtrans.c |
|
| 86 |
+@@ -753,7 +753,7 @@ TDNFRemoveCachedRpms( |
|
| 87 |
+ for(dwIndex = 0; dwIndex < pCachedRpmsArray->len; ++dwIndex) |
|
| 88 |
+ {
|
|
| 89 |
+ pszCachedRpm = g_array_index(pCachedRpmsArray, char*, dwIndex); |
|
| 90 |
+- if(IsNullOrEmptyString(pszCachedRpm)) |
|
| 91 |
++ if(!IsNullOrEmptyString(pszCachedRpm)) |
|
| 92 |
+ {
|
|
| 93 |
+ if(unlink(pszCachedRpm)) |
|
| 94 |
+ {
|
|
| 95 |
+diff --git a/client/utils.c b/client/utils.c |
|
| 96 |
+index 364434e..d9eb758 100644 |
|
| 97 |
+--- a/client/utils.c |
|
| 98 |
+@@ -603,3 +603,64 @@ error: |
|
| 99 |
+ } |
|
| 100 |
+ goto cleanup; |
|
| 101 |
+ } |
|
| 102 |
++ |
|
| 103 |
++void |
|
| 104 |
++print_curl_error( |
|
| 105 |
++ const char *pszUrl |
|
| 106 |
++ ) |
|
| 107 |
++{
|
|
| 108 |
++ CURLcode dwError = 0; |
|
| 109 |
++ CURL *pCurl = NULL; |
|
| 110 |
++ long nStatus = 0; |
|
| 111 |
++ |
|
| 112 |
++ if(IsNullOrEmptyString(pszUrl)) |
|
| 113 |
++ {
|
|
| 114 |
++ dwError = ERROR_TDNF_INVALID_PARAMETER; |
|
| 115 |
++ BAIL_ON_TDNF_ERROR(dwError); |
|
| 116 |
++ } |
|
| 117 |
++ |
|
| 118 |
++ pCurl = curl_easy_init(); |
|
| 119 |
++ if(IsNullOrEmptyString(pszUrl)) |
|
| 120 |
++ {
|
|
| 121 |
++ dwError = ERROR_TDNF_OUT_OF_MEMORY; |
|
| 122 |
++ BAIL_ON_TDNF_ERROR(dwError); |
|
| 123 |
++ } |
|
| 124 |
++ |
|
| 125 |
++ dwError = curl_easy_setopt(pCurl, CURLOPT_URL, pszUrl); |
|
| 126 |
++ BAIL_ON_TDNF_ERROR(dwError); |
|
| 127 |
++ |
|
| 128 |
++ dwError = curl_easy_setopt(pCurl, CURLOPT_NOBODY, 1); |
|
| 129 |
++ BAIL_ON_TDNF_ERROR(dwError); |
|
| 130 |
++ |
|
| 131 |
++ dwError = curl_easy_setopt(pCurl, CURLOPT_FOLLOWLOCATION, 1L); |
|
| 132 |
++ BAIL_ON_TDNF_ERROR(dwError); |
|
| 133 |
++ |
|
| 134 |
++ dwError = curl_easy_perform(pCurl); |
|
| 135 |
++ if(dwError) |
|
| 136 |
++ {
|
|
| 137 |
++ const char *pszError = curl_easy_strerror(dwError); |
|
| 138 |
++ fprintf(stderr, "curl#%d: %s\n", dwError, pszError); |
|
| 139 |
++ } |
|
| 140 |
++ else |
|
| 141 |
++ {
|
|
| 142 |
++ dwError = curl_easy_getinfo( |
|
| 143 |
++ pCurl, |
|
| 144 |
++ CURLINFO_RESPONSE_CODE, |
|
| 145 |
++ &nStatus); |
|
| 146 |
++ BAIL_ON_TDNF_ERROR(dwError); |
|
| 147 |
++ if(nStatus >= 400) |
|
| 148 |
++ {
|
|
| 149 |
++ fprintf( |
|
| 150 |
++ stderr, |
|
| 151 |
++ "Error: %ld when downloading %s\n. Please check repo url.\n", |
|
| 152 |
++ nStatus, |
|
| 153 |
++ pszUrl); |
|
| 154 |
++ } |
|
| 155 |
++ } |
|
| 156 |
++error: |
|
| 157 |
++ if(pCurl) |
|
| 158 |
++ {
|
|
| 159 |
++ curl_easy_cleanup(pCurl); |
|
| 160 |
++ } |
|
| 161 |
++ return; |
|
| 162 |
++} |