File PackageKit-zypp-packagesize.patch of Package PackageKit

From e6191bb910bca7f47726be2ee273b29e9d74442d Mon Sep 17 00:00:00 2001
From: Max Lin <max.lin@gmx.com>
Date: Mon, 18 Jun 2012 15:33:27 +0800
Subject: [PATCH] zypp: Fix calculation of package size with recent versions
 of libzypp

Since the return size no longer is KBytes in libzypp, but Bytes, we do
not need to do size * 1024, starting with libzypp 11.4.0.
---
 backends/zypp/pk-backend-zypp.cpp |    6 ++++++
 configure.ac                      |    4 ++++
 2 files changed, 10 insertions(+)

diff --git a/backends/zypp/pk-backend-zypp.cpp b/backends/zypp/pk-backend-zypp.cpp
index f7398e0..d909b35 100644
--- a/backends/zypp/pk-backend-zypp.cpp
+++ b/backends/zypp/pk-backend-zypp.cpp
@@ -19,6 +19,8 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
+#include "config.h"
+
 #include <gmodule.h>
 #include <glib.h>
 #include <pk-backend.h>
@@ -580,7 +582,11 @@ backend_get_details_thread (PkBackend *backend)
 						    group,
 						    package.lookupStrAttribute (sat::SolvAttr::description).c_str (),
 						    package.lookupStrAttribute (sat::SolvAttr::url).c_str (),
+#ifdef ZYPP_RETURN_BYTES
+						    size);
+#else
 						    size * 1024);
+#endif
 			}
 
 		} catch (const target::rpm::RpmException &ex) {
diff --git a/configure.ac b/configure.ac
index 12a3610..3d9ea64 100644
--- a/configure.ac
+++ b/configure.ac
@@ -742,6 +742,10 @@ fi
 
 if test x$enable_zypp = xyes; then
 	PKG_CHECK_MODULES(ZYPP, libzypp >= 6.16.0)
+	PKG_CHECK_EXISTS(libzypp >= 11.4.0, [ ZYPP_RETURN_BYTES="yes" ], [ ZYPP_RETURN_BYTES="no" ])
+	if test "x$ZYPP_RETURN_BYTES" = "xyes"; then
+	    AC_DEFINE(ZYPP_RETURN_BYTES, 1, [define if libzypp returns package size in bytes])
+	fi
 fi
 
 if test x$enable_slapt = xyes; then
-- 
1.7.10