Author: lslezak
Date: Wed Aug 29 10:06:12 2007
New Revision: 40550
URL: http://svn.opensuse.org/viewcvs/yast?rev=40550&view=rev
Log:
- reimplemented Pkg::SourceCacheCopyTo() - copy zypp cache from the
installation system to the target (#304310)
- 2.15.46
Modified:
trunk/pkg-bindings/VERSION
trunk/pkg-bindings/package/yast2-pkg-bindings.changes
trunk/pkg-bindings/src/Source.cc
Modified: trunk/pkg-bindings/VERSION
URL: http://svn.opensuse.org/viewcvs/yast/trunk/pkg-bindings/VERSION?rev=40550&r1=40549&r2=40550&view=diff
==============================================================================
--- trunk/pkg-bindings/VERSION (original)
+++ trunk/pkg-bindings/VERSION Wed Aug 29 10:06:12 2007
@@ -1 +1 @@
-2.15.45
+2.15.46
Modified: trunk/pkg-bindings/package/yast2-pkg-bindings.changes
URL: http://svn.opensuse.org/viewcvs/yast/trunk/pkg-bindings/package/yast2-pkg-bindings.changes?rev=40550&r1=40549&r2=40550&view=diff
==============================================================================
--- trunk/pkg-bindings/package/yast2-pkg-bindings.changes (original)
+++ trunk/pkg-bindings/package/yast2-pkg-bindings.changes Wed Aug 29 10:06:12 2007
@@ -1,4 +1,11 @@
-------------------------------------------------------------------
+Wed Aug 29 09:36:00 CEST 2007 - lslezak@suse.cz
+
+- reimplemented Pkg::SourceCacheCopyTo() - copy zypp cache from the
+ installation system to the target (#304310)
+- 2.15.46
+
+-------------------------------------------------------------------
Thu Aug 23 14:03:19 CEST 2007 - lslezak@suse.cz
- Pkg::SourceLoad() - load resolvables from all working
Modified: trunk/pkg-bindings/src/Source.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/pkg-bindings/src/Source.cc?rev=40550&r1=40549&r2=40550&view=diff
==============================================================================
--- trunk/pkg-bindings/src/Source.cc (original)
+++ trunk/pkg-bindings/src/Source.cc Wed Aug 29 10:06:12 2007
@@ -45,6 +45,7 @@
#include
#include
#include
+#include
#include
@@ -1774,14 +1775,81 @@
* To be called at end of initial installation.
*
* @param string dir Root directory of target.
- * @return boolean
+ * @return boolean true on success
**/
YCPValue
PkgModuleFunctions::SourceCacheCopyTo (const YCPString& dir)
{
- y2warning( "Pkg::SourceCacheCopyTo is obsolete now, it does nothing" );
+ // error message (followed by detailed description)
+ const std::string msg = _("Error: Cannot copy the cache to the target directory\n");
- return YCPBoolean( true );
+ std::string d = dir->value();
+ y2milestone("Copying source cache to '%s'...", d.c_str());
+
+ if (d.empty())
+ {
+ y2error("Empty parameter in Pkg::SourceCacheCopyTo()!");
+ return YCPBoolean(false);
+ }
+
+ std::string target = d + "/var/cache";
+
+ // create the target dir
+ const char* argv[] =
+ {
+ "mkdir",
+ // create parent dir
+ "-p",
+ // finish parameter list
+ "--",
+ // target
+ target.c_str(),
+ NULL
+ };
+
+ // discard stderr, no pty, stderr_fd = -1, use the default locale
+ zypp::ExternalProgram prog(argv, zypp::ExternalProgram::Discard_Stderr, false, -1, true);
+
+ int code = prog.close();
+
+ if (code)
+ {
+ // error message (followed by directory name)
+ _last_error.setLastError(msg + _("Cannot create directory ") + target);
+ y2error("Cannot create target directory %s", target.c_str());
+ return YCPBoolean(false);
+ }
+
+ // copy /var/cache/zypp to the target system
+ const char* argv2[] =
+ {
+ "cp",
+ // preserve time stamps
+ "-a",
+ // recursive
+ "-r",
+ // finish parameter list
+ "--",
+ // source
+ "/var/cache/zypp",
+ // target
+ target.c_str(),
+ NULL
+ };
+
+ // discard stderr, no pty, stderr_fd = -1, use the default locale
+ zypp::ExternalProgram prog2(argv2, zypp::ExternalProgram::Discard_Stderr, false, -1, true);
+
+ int code2 = prog2.close();
+
+ if (code2)
+ {
+ // error message
+ _last_error.setLastError(msg + _("Copying failed"));
+ y2error("Cannot copy /var/cache/zypp to %s", d.c_str());
+ }
+
+ return YCPBoolean(!code2);
}
/****************************************************************************************
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org