#include <list>
+#include <zypp/TmpPath.h>
#include <zypp/ZYppFactory.h>
#include <zypp/ZYpp.h>
#include <zypp/PathInfo.h>
try
{
detail::ResImplTraits<XMLScriptImpl>::Ptr impl(new XMLScriptImpl());
- impl->_do_script = parsed.do_script;
- impl->_undo_script = parsed.undo_script;
+
+ ofstream file;
+ file.open(impl->_do_script.path().asString().c_str());
+ file << parsed.do_script;;
+ file.close();
+
+ file.open(impl->_undo_script.path().asString().c_str());
+ file << parsed.undo_script;;
+ file.close();
+
// Collect basic Resolvable data
NVRAD dataCollect( parsed.name, Edition( parsed.ver, parsed.rel, parsed.epoch ), Arch_noarch, createDependencies(parsed, ResTraits<Script>::kind));
Script::Ptr script = detail::makeResolvableFromImpl( dataCollect, impl );
ERR << excpt_r << endl;
throw "Cannot create script object";
}
+ catch (const std::exception & excpt_r)
+ {
+ ERR << excpt_r.what() << endl;
+ throw "Cannot create script object";
+ }
}
Language::Ptr
// reuse Resolvable information serialize function
out << toXML(static_cast<Resolvable::constPtr>(obj));
out << " <do>" << std::endl;
- out << " " << xml_escape(obj->do_script().asString()) << std::endl;
-#warning FIXME line above
+ out << " <![CDATA[" << std::endl;
+
+ // read script
+ ifstream infile;
+ infile.open(obj->do_script().asString().c_str());
+ while (infile.good())
+ out << (char) infile.get();
+ infile.close();
+
+ out << " ]]>" << std::endl;
out << " </do>" << std::endl;
+ infile.close();
if ( obj->undo_available() )
{
out << " <undo>" << std::endl;
- out << " " << xml_escape(obj->undo_script().asString()) << std::endl;
-#warning FIXME line above
+ out << " <![CDATA[" << std::endl;
+
+ // read script
+ infile.open(obj->undo_script().asString().c_str());
+ while (infile.good())
+ out << (char) infile.get();
+ infile.close();
+
+ out << " ]]>" << std::endl;
out << " </undo>" << std::endl;
+ infile.close();
}
out << "</script>" << std::endl;
return out.str();
/** Default ctor */
XMLScriptImpl::XMLScriptImpl()
- {}
+ {
+ _do_script = TmpFile( TmpPath::defaultLocation(), "zypp-xmlstore-do-script-");
+ _undo_script = TmpFile( TmpPath::defaultLocation(), "zypp-xmlstore-undo-script-");
+ }
+
/** Dtor */
XMLScriptImpl::~XMLScriptImpl()
{}
Pathname XMLScriptImpl::do_script() const {
- return Pathname();
-#warning FIXME
-// return _do_script;
+ return _do_script.path();
}
Pathname XMLScriptImpl::undo_script() const {
- return Pathname();
-#warning FIXME
-// return _undo_script;
+ return _undo_script.path();
}
bool XMLScriptImpl::undo_available() const {
#ifndef ZYPP_STORE_XMLSCRIPTIMPL_H
#define ZYPP_STORE_XMLSCRIPTIMPL_H
+#include "zypp/TmpPath.h"
#include "zypp/detail/ScriptImplIf.h"
+using namespace zypp::filesystem;
+
///////////////////////////////////////////////////////////////////
namespace zypp
{ /////////////////////////////////////////////////////////////////
Pathname undo_script() const;
/** Check whether script to undo the change is available */
virtual bool undo_available() const;
-
- /** The script to perform the change */
- std::string _do_script;
- /** The script to undo the change */
- std::string _undo_script;
+
+ TmpFile _do_script;
+ TmpFile _undo_script;
};
///////////////////////////////////////////////////////////////////