Hello community,

here is the log from the commit of package yast2-pkg-bindings for 
openSUSE:Factory checked in at 2016-04-08 09:39:13
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/yast2-pkg-bindings (Old)
 and      /work/SRC/openSUSE:Factory/.yast2-pkg-bindings.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "yast2-pkg-bindings"

Changes:
--------
--- /work/SRC/openSUSE:Factory/yast2-pkg-bindings/yast2-pkg-bindings.changes    
2016-02-25 21:53:20.000000000 +0100
+++ 
/work/SRC/openSUSE:Factory/.yast2-pkg-bindings.new/yast2-pkg-bindings.changes   
    2016-04-08 09:39:14.000000000 +0200
@@ -1,0 +2,7 @@
+Tue Mar 29 12:32:18 UTC 2016 - [email protected]
+
+- Add a Pkg::ProvidePackage to retrieve a package using
+  PackageProvider (fate#319716).
+- 3.1.33
+
+-------------------------------------------------------------------

Old:
----
  yast2-pkg-bindings-3.1.32.tar.bz2

New:
----
  yast2-pkg-bindings-3.1.33.tar.bz2

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

Other differences:
------------------
++++++ yast2-pkg-bindings-devel-doc.spec ++++++
--- /var/tmp/diff_new_pack.nIdQCU/_old  2016-04-08 09:39:15.000000000 +0200
+++ /var/tmp/diff_new_pack.nIdQCU/_new  2016-04-08 09:39:15.000000000 +0200
@@ -17,7 +17,7 @@
 
 
 Name:           yast2-pkg-bindings-devel-doc
-Version:        3.1.32
+Version:        3.1.33
 Release:        0
 BuildRoot:      %{_tmppath}/%{name}-%{version}-build
 Source0:        yast2-pkg-bindings-%{version}.tar.bz2

++++++ yast2-pkg-bindings.spec ++++++
--- /var/tmp/diff_new_pack.nIdQCU/_old  2016-04-08 09:39:15.000000000 +0200
+++ /var/tmp/diff_new_pack.nIdQCU/_new  2016-04-08 09:39:15.000000000 +0200
@@ -17,7 +17,7 @@
 
 
 Name:           yast2-pkg-bindings
-Version:        3.1.32
+Version:        3.1.33
 Release:        0
 
 BuildRoot:      %{_tmppath}/%{name}-%{version}-build

++++++ yast2-pkg-bindings-3.1.32.tar.bz2 -> yast2-pkg-bindings-3.1.33.tar.bz2 
++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-pkg-bindings-3.1.32/package/yast2-pkg-bindings-devel-doc.spec 
new/yast2-pkg-bindings-3.1.33/package/yast2-pkg-bindings-devel-doc.spec
--- old/yast2-pkg-bindings-3.1.32/package/yast2-pkg-bindings-devel-doc.spec     
2016-02-18 15:35:19.000000000 +0100
+++ new/yast2-pkg-bindings-3.1.33/package/yast2-pkg-bindings-devel-doc.spec     
2016-04-06 15:51:58.000000000 +0200
@@ -16,7 +16,7 @@
 #
 
 Name:           yast2-pkg-bindings-devel-doc
-Version:        3.1.32
+Version:        3.1.33
 Release:        0
 License:        GPL-2.0
 Group:          Documentation/HTML
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-pkg-bindings-3.1.32/package/yast2-pkg-bindings.changes 
new/yast2-pkg-bindings-3.1.33/package/yast2-pkg-bindings.changes
--- old/yast2-pkg-bindings-3.1.32/package/yast2-pkg-bindings.changes    
2016-02-18 15:35:19.000000000 +0100
+++ new/yast2-pkg-bindings-3.1.33/package/yast2-pkg-bindings.changes    
2016-04-06 15:51:58.000000000 +0200
@@ -1,4 +1,11 @@
 -------------------------------------------------------------------
+Tue Mar 29 12:32:18 UTC 2016 - [email protected]
+
+- Add a Pkg::ProvidePackage to retrieve a package using
+  PackageProvider (fate#319716).
+- 3.1.33
+
+-------------------------------------------------------------------
 Mon Feb 15 10:49:39 UTC 2016 - [email protected]
 
 - Expose update notifications through PkgFunctions::CommitHelper
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-pkg-bindings-3.1.32/package/yast2-pkg-bindings.spec 
new/yast2-pkg-bindings-3.1.33/package/yast2-pkg-bindings.spec
--- old/yast2-pkg-bindings-3.1.32/package/yast2-pkg-bindings.spec       
2016-02-18 15:35:19.000000000 +0100
+++ new/yast2-pkg-bindings-3.1.33/package/yast2-pkg-bindings.spec       
2016-04-06 15:51:58.000000000 +0200
@@ -17,7 +17,7 @@
 
 
 Name:           yast2-pkg-bindings
-Version:        3.1.32
+Version:        3.1.33
 Release:        0
 
 BuildRoot:      %{_tmppath}/%{name}-%{version}-build
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yast2-pkg-bindings-3.1.32/src/Callbacks.YCP.cc 
new/yast2-pkg-bindings-3.1.33/src/Callbacks.YCP.cc
--- old/yast2-pkg-bindings-3.1.32/src/Callbacks.YCP.cc  2015-10-09 
09:40:10.000000000 +0200
+++ new/yast2-pkg-bindings-3.1.33/src/Callbacks.YCP.cc  2016-04-06 
15:51:58.000000000 +0200
@@ -104,6 +104,7 @@
        ENUM_OUT( ProblemDeltaApply );
        ENUM_OUT( FinishDeltaDownload );
        ENUM_OUT( FinishDeltaApply );
+       ENUM_OUT( PkgGpgCheck );
        ENUM_OUT( MediaChange );
        ENUM_OUT( SourceChange );
        ENUM_OUT( ResolvableReport );
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yast2-pkg-bindings-3.1.32/src/Package.cc 
new/yast2-pkg-bindings-3.1.33/src/Package.cc
--- old/yast2-pkg-bindings-3.1.32/src/Package.cc        2016-02-18 
15:35:19.000000000 +0100
+++ new/yast2-pkg-bindings-3.1.33/src/Package.cc        2016-04-06 
15:51:58.000000000 +0200
@@ -23,6 +23,7 @@
 
 #include "PkgFunctions.h"
 #include "log.h"
+#include "Callbacks.YCP.h"
 
 #include <ycp/YCPVoid.h>
 #include <ycp/YCPBoolean.h>
@@ -45,6 +46,8 @@
 #include <zypp/base/Regex.h>
 
 #include <zypp/sat/WhatProvides.h>
+#include <zypp/ZYppFactory.h>
+#include <zypp/repo/PackageProvider.h>
 
 #include <fstream>
 #include <sstream>
@@ -2942,3 +2945,58 @@
     return YCPBoolean(success);
 }
 
+/**
+ * Get a package object from a given repository
+ *
+ * @param YCPInteger   repo_id Repository ID (alias)
+ * @param YCPString    name    Package name
+ * @return zypp::Package::constPtr
+ */
+zypp::Package::constPtr PkgFunctions::packageFromRepo(const YCPInteger & 
repo_id, const YCPString & name) {
+  zypp::ResPool pool(zypp::getZYpp()->pool());
+  YRepo_Ptr repo = logFindRepository(repo_id->value());
+  if (!repo) return NULL;
+
+  /* maybe we should use std::find_if */
+  for_(it, pool.byIdentBegin<zypp::Package>(name->value()), 
pool.byIdentEnd<zypp::Package>(name->value())) {
+    if (repo->repoInfo().alias() == (*it)->repository().alias()) {
+      return zypp::asKind<zypp::Package>((*it).resolvable());
+    }
+  }
+  return NULL;
+}
+
+/**
+ * Provide a package using the \c zypp::repo::PackageProvider class
+ *
+ * @param YCPInteger   repo_id Repository ID (alias)
+ * @param YCPString    name    Package name
+ * @param YCPString    path    Path to save the file.
+ * @return YCPValue    If the package was found, it returns true;
+ *                     if it wasn't found, it returns false.
+ */
+YCPValue PkgFunctions::ProvidePackage(const YCPInteger & repo_id, const 
YCPString & name, const YCPString & path) {
+
+  zypp::Package::constPtr package = packageFromRepo(repo_id, name);
+  if (package == NULL) return YCPBoolean(false);
+
+  zypp::repo::RepoMediaAccess access;
+  zypp::repo::PackageProviderPolicy packageProviderPolicy;
+  zypp::repo::DeltaCandidates deltas;
+  zypp::repo::PackageProvider pkgProvider(access, package, deltas, 
packageProviderPolicy);
+
+  try {
+    /* Retrieve the package */
+    zypp::ManagedFile file(pkgProvider.providePackage());
+    /* Copy the managed file to the given path */
+    std::ifstream src(file.value().asString(), std::ios::binary);
+    std::ofstream dest(path->value(), std::ios::binary);
+    dest << src.rdbuf();
+  }
+  catch (...) {
+    y2error("Package %s could not be downloaded", name->value().c_str());
+    return YCPBoolean(false);
+  }
+
+  return YCPBoolean(true);
+}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yast2-pkg-bindings-3.1.32/src/PkgFunctions.h 
new/yast2-pkg-bindings-3.1.33/src/PkgFunctions.h
--- old/yast2-pkg-bindings-3.1.32/src/PkgFunctions.h    2015-10-09 
09:40:10.000000000 +0200
+++ new/yast2-pkg-bindings-3.1.33/src/PkgFunctions.h    2016-04-06 
15:51:58.000000000 +0200
@@ -221,6 +221,8 @@
       // CommitPolicy used for commit
       zypp::ZYppCommitPolicy *commit_policy;
 
+      // getPackageFromRepo used for PkgFunctions::ProvidePackage
+      zypp::Package::constPtr packageFromRepo(const YCPInteger & repo_id, 
const YCPString & name);
     private:
 
       /**
@@ -677,6 +679,8 @@
        YCPValue PkgReset ();
        /* TYPEINFO: boolean()*/
        YCPValue PkgApplReset ();
+        /* TYPEINFO: boolean(integer,string,string) */
+       YCPValue ProvidePackage(const YCPInteger & repo_id, const YCPString & 
name, const YCPString & path);
        /* TYPEINFO: map<string,any>()*/
        YCPValue GetSolverFlags();
        /* TYPEINFO: boolean(map<string,any>)*/


Reply via email to