Hello community,

here is the log from the commit of package libzypp for openSUSE:Factory checked 
in at 2013-01-22 15:56:24
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/libzypp (Old)
 and      /work/SRC/openSUSE:Factory/.libzypp.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "libzypp", Maintainer is "[email protected]"

Changes:
--------
--- /work/SRC/openSUSE:Factory/libzypp/libzypp.changes  2013-01-20 
08:04:35.000000000 +0100
+++ /work/SRC/openSUSE:Factory/.libzypp.new/libzypp.changes     2013-01-22 
15:56:25.000000000 +0100
@@ -1,0 +2,8 @@
+Tue Jan 22 11:06:55 CET 2013 - [email protected]
+
+- make multicurl suppress progress reports for the metalink download
+- work around libcurl bug that sometimes gives us old values in the 
+  progress callback
+- version 12.8.0 (0)
+
+-------------------------------------------------------------------

Old:
----
  libzypp-12.7.0.tar.bz2

New:
----
  libzypp-12.8.0.tar.bz2

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ libzypp.spec ++++++
--- /var/tmp/diff_new_pack.8KariD/_old  2013-01-22 15:56:26.000000000 +0100
+++ /var/tmp/diff_new_pack.8KariD/_new  2013-01-22 15:56:26.000000000 +0100
@@ -24,7 +24,7 @@
 Group:          System/Packages
 BuildRoot:      %{_tmppath}/%{name}-%{version}-build
 Summary:        Package, Patch, Pattern, and Product Management
-Version:        12.7.0
+Version:        12.8.0
 Release:        1
 Source:         %{name}-%{version}.tar.bz2
 Source1:        %{name}-rpmlintrc

++++++ libzypp-12.7.0.tar.bz2 -> libzypp-12.8.0.tar.bz2 ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libzypp-12.7.0/VERSION.cmake 
new/libzypp-12.8.0/VERSION.cmake
--- old/libzypp-12.7.0/VERSION.cmake    2013-01-18 21:22:25.000000000 +0100
+++ new/libzypp-12.8.0/VERSION.cmake    2013-01-22 11:34:48.000000000 +0100
@@ -60,9 +60,9 @@
 #
 SET(LIBZYPP_MAJOR "12")
 SET(LIBZYPP_COMPATMINOR "0")
-SET(LIBZYPP_MINOR "7")
+SET(LIBZYPP_MINOR "8")
 SET(LIBZYPP_PATCH "0")
 #
-# LAST RELEASED: 12.7.0 (0)
+# LAST RELEASED: 12.8.0 (0)
 # (The number in parenthesis is LIBZYPP_COMPATMINOR)
 #=======
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libzypp-12.7.0/package/libzypp.changes 
new/libzypp-12.8.0/package/libzypp.changes
--- old/libzypp-12.7.0/package/libzypp.changes  2013-01-18 21:22:25.000000000 
+0100
+++ new/libzypp-12.8.0/package/libzypp.changes  2013-01-22 11:34:48.000000000 
+0100
@@ -1,4 +1,12 @@
 -------------------------------------------------------------------
+Tue Jan 22 11:06:55 CET 2013 - [email protected]
+
+- make multicurl suppress progress reports for the metalink download
+- work around libcurl bug that sometimes gives us old values in the 
+  progress callback
+- version 12.8.0 (0)
+
+-------------------------------------------------------------------
 Fri Jan 18 14:07:50 CET 2013 - [email protected]
 
 - Reduce logging
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libzypp-12.7.0/zypp/media/MediaCurl.cc 
new/libzypp-12.8.0/zypp/media/MediaCurl.cc
--- old/libzypp-12.7.0/zypp/media/MediaCurl.cc  2013-01-18 21:22:25.000000000 
+0100
+++ new/libzypp-12.8.0/zypp/media/MediaCurl.cc  2013-01-22 11:34:48.000000000 
+0100
@@ -157,9 +157,10 @@
   namespace {
     struct ProgressData
     {
-      ProgressData(const long _timeout, const zypp::Url &_url = zypp::Url(),
+      ProgressData(CURL *_curl, const long _timeout, const zypp::Url &_url = 
zypp::Url(),
                    callback::SendReport<DownloadProgressReport> *_report=NULL)
-        : timeout(_timeout)
+        : curl(_curl)
+        , timeout(_timeout)
         , reached(false)
         , report(_report)
         , drate_period(-1)
@@ -171,6 +172,7 @@
         , uload( 0)
         , url(_url)
       {}
+      CURL                                         *curl;
       long                                          timeout;
       bool                                          reached;
       callback::SendReport<DownloadProgressReport> *report;
@@ -1397,7 +1399,7 @@
     }
 
     // Set callback and perform.
-    ProgressData progressData(_settings.timeout(), url, &report);
+    ProgressData progressData(_curl, _settings.timeout(), url, &report);
     if (!(options & OPTION_NO_REPORT_START))
       report->start(url, dest);
     if ( curl_easy_setopt( _curl, CURLOPT_PROGRESSDATA, &progressData ) != 0 ) 
{
@@ -1515,6 +1517,11 @@
   ProgressData *pdata = reinterpret_cast<ProgressData *>(clientp);
   if( pdata)
   {
+    // work around curl bug that gives us old data
+    long httpReturnCode = 0; 
+    if (curl_easy_getinfo(pdata->curl, CURLINFO_RESPONSE_CODE, 
&httpReturnCode) != CURLE_OK || httpReturnCode == 0)
+      return 0;
+
     time_t now   = time(NULL);
     if( now > 0)
     {
@@ -1597,6 +1604,12 @@
   return 0;
 }
 
+CURL *MediaCurl::progressCallback_getcurl( void *clientp )
+{
+  ProgressData *pdata = reinterpret_cast<ProgressData *>(clientp);
+  return pdata ? pdata->curl : 0;
+}
+
 ///////////////////////////////////////////////////////////////////
 
 string MediaCurl::getAuthHint() const
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libzypp-12.7.0/zypp/media/MediaCurl.h 
new/libzypp-12.8.0/zypp/media/MediaCurl.h
--- old/libzypp-12.7.0/zypp/media/MediaCurl.h   2013-01-18 21:22:25.000000000 
+0100
+++ new/libzypp-12.8.0/zypp/media/MediaCurl.h   2013-01-22 11:34:48.000000000 
+0100
@@ -116,6 +116,7 @@
 
     static int progressCallback( void *clientp, double dltotal, double dlnow,
                                  double ultotal, double ulnow );
+    static CURL *progressCallback_getcurl( void *clientp );
     /**
      * check the url is supported by the curl library
      * \throws MediaBadUrlException if there is a problem
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libzypp-12.7.0/zypp/media/MediaMultiCurl.cc 
new/libzypp-12.8.0/zypp/media/MediaMultiCurl.cc
--- old/libzypp-12.7.0/zypp/media/MediaMultiCurl.cc     2013-01-18 
21:22:25.000000000 +0100
+++ new/libzypp-12.8.0/zypp/media/MediaMultiCurl.cc     2013-01-22 
11:34:48.000000000 +0100
@@ -1199,15 +1199,12 @@
   _customHeadersMetalink = curl_slist_append(_customHeadersMetalink, "Accept: 
*/*, application/metalink+xml, application/metalink4+xml");
 }
 
-static bool looks_like_metalink(const Pathname & file)
+static bool looks_like_metalink_fd(int fd)
 {
   char buf[256], *p;
-  int fd, l;
-  if ((fd = open(file.asString().c_str(), O_RDONLY|O_CLOEXEC)) == -1)
-    return false;
-  while ((l = read(fd, buf, sizeof(buf) - 1)) == -1 && errno == EINTR)
+  int l;
+  while ((l = pread(fd, buf, sizeof(buf) - 1, (off_t)0)) == -1 && errno == 
EINTR)
     ;
-  close(fd);
   if (l == -1)
     return 0;
   buf[l] = 0;
@@ -1224,10 +1221,66 @@
        p++;
     }
   bool ret = !strncasecmp(p, "<metalink", 9) ? true : false;
+  return ret;
+}
+
+static bool looks_like_metalink(const Pathname & file)
+{
+  int fd;
+  if ((fd = open(file.asString().c_str(), O_RDONLY|O_CLOEXEC)) == -1)
+    return false;
+  bool ret = looks_like_metalink_fd(fd);
+  close(fd);
   DBG << "looks_like_metalink(" << file << "): " << ret << endl;
   return ret;
 }
 
+// here we try to suppress all progress coming from a metalink download
+int MediaMultiCurl::progressCallback( void *clientp, double dltotal, double 
dlnow, double ultotal, double ulnow)
+{
+  CURL *_curl = MediaCurl::progressCallback_getcurl(clientp);
+  if (!_curl)
+    return 0;
+
+  // work around curl bug that gives us old data
+  long httpReturnCode = 0;
+  if (curl_easy_getinfo(_curl, CURLINFO_RESPONSE_CODE, &httpReturnCode ) != 
CURLE_OK || httpReturnCode == 0)
+    return 0;
+
+  char *ptr = NULL;
+  bool ismetalink = false;
+  if (curl_easy_getinfo(_curl, CURLINFO_CONTENT_TYPE, &ptr) == CURLE_OK && 
ptr) 
+    {    
+      string ct = string(ptr);
+      if (ct.find("application/metalink+xml") == 0 || 
ct.find("application/metalink4+xml") == 0)
+        ismetalink = true;
+    }    
+  if (!ismetalink && dlnow < 256)
+    {
+      // can't tell yet, suppress callback
+      return 0;
+    }
+  if (!ismetalink)
+    {
+      FILE *fp = 0;
+      if (curl_easy_getinfo(_curl, CURLINFO_PRIVATE, &fp) != CURLE_OK)
+       return 0;
+      if (!fp)
+       return 0;       /* hmm */
+      fflush(fp);
+      ismetalink = looks_like_metalink_fd(fileno(fp));
+      DBG << "looks_like_metalink_fd: " << ismetalink << endl;
+    }
+  if (ismetalink)
+    {
+      // we're downloading the metalink file. no progress please.
+      curl_easy_setopt(_curl, CURLOPT_NOPROGRESS, 1L);
+      return 0;
+    }
+  curl_easy_setopt(_curl, CURLOPT_PROGRESSFUNCTION, 
&MediaCurl::progressCallback);
+  return MediaCurl::progressCallback(clientp, dltotal, dlnow, ultotal, ulnow);
+}
+
 void MediaMultiCurl::doGetFileCopy( const Pathname & filename , const Pathname 
& target, callback::SendReport<DownloadProgressReport> & report, RequestOptions 
options ) const
 {
   Pathname dest = target.absolutename();
@@ -1279,6 +1332,9 @@
   }
   // change header to include Accept: metalink
   curl_easy_setopt(_curl, CURLOPT_HTTPHEADER, _customHeadersMetalink);
+  // change to our own progress funcion
+  curl_easy_setopt(_curl, CURLOPT_PROGRESSFUNCTION, &progressCallback);
+  curl_easy_setopt(_curl, CURLOPT_PRIVATE, file);
   try
     {
       MediaCurl::doGetFileCopyFile(filename, dest, file, report, options);
@@ -1290,11 +1346,13 @@
       curl_easy_setopt(_curl, CURLOPT_TIMECONDITION, CURL_TIMECOND_NONE);
       curl_easy_setopt(_curl, CURLOPT_TIMEVALUE, 0L);
       curl_easy_setopt(_curl, CURLOPT_HTTPHEADER, _customHeaders);
+      curl_easy_setopt(_curl, CURLOPT_PRIVATE, (void *)0);
       ZYPP_RETHROW(ex);
     }
   curl_easy_setopt(_curl, CURLOPT_TIMECONDITION, CURL_TIMECOND_NONE);
   curl_easy_setopt(_curl, CURLOPT_TIMEVALUE, 0L);
   curl_easy_setopt(_curl, CURLOPT_HTTPHEADER, _customHeaders);
+  curl_easy_setopt(_curl, CURLOPT_PRIVATE, (void *)0);
   long httpReturnCode = 0;
   CURLcode infoRet = curl_easy_getinfo(_curl, CURLINFO_RESPONSE_CODE, 
&httpReturnCode);
   if (infoRet == CURLE_OK)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libzypp-12.7.0/zypp/media/MediaMultiCurl.h 
new/libzypp-12.8.0/zypp/media/MediaMultiCurl.h
--- old/libzypp-12.7.0/zypp/media/MediaMultiCurl.h      2013-01-18 
21:22:25.000000000 +0100
+++ new/libzypp-12.8.0/zypp/media/MediaMultiCurl.h      2013-01-22 
11:34:48.000000000 +0100
@@ -59,6 +59,7 @@
 
   virtual void setupEasy();
   void checkFileDigest(Url &url, FILE *fp, MediaBlockList *blklist) const;
+  static int progressCallback( void *clientp, double dltotal, double dlnow, 
double ultotal, double ulnow );
 
 private:
   // the custom headers from MediaCurl plus a "Accept: metalink" header

-- 
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to