return parser.escape(text);
}
-void render_error( const Edition &version, std::ostream &out, const std::string &reason )
+void render_error( const Edition &version, std::ostream &out )
{
- out << "<update-status op=\"error\">" << std::endl;
- out << "<error>" << reason << "</error>" << std::endl;
+ out << "<?xml version='1.0'?>" << std::endl;
+ out << "<update-status version=\"" << version.asString() << "\">" << std::endl;
+ out << " <errors>" << std::endl;
+ for ( std::list<Error>::const_iterator it = gData.errors.begin(); it != gData.errors.end(); ++it )
+ {
+ out << " <error>" << xml_escape(it->description) << "</error>" << endl;
+ }
+ out << " </errors>" << std::endl;
out << "</update-status>" << std::endl;
}
int security_count = 0;
out << "<?xml version='1.0'?>" << std::endl;
- out << "<update-status op=\"success\">" << std::endl;
+ out << "<update-status version=\"" << version.asString() << "\">" << std::endl;
+
//out << " <metadata token=\"" << token << "\"/>" << std::endl;
+ out << " <errors>" << std::endl;
+ for ( std::list<Error>::const_iterator it = gData.errors.begin(); it != gData.errors.end(); ++it )
+ {
+ out << " <error>" << xml_escape(it->description) << "</error>" << endl;
+ }
+ out << " </errors>" << std::endl;
+
out << " <update-sources>" << std::endl;
for ( std::list<Source_Ref>::const_iterator it = gData.sources.begin(); it != gData.sources.end(); ++it )
{
#include <fstream>
#include <sstream>
+#include <zypp/target/store/PersistentStorage.h>
+
#include "checkpatches-keyring-callbacks.h"
#include "zmart.h"
#include "zmart-updates.h"
#undef ZYPP_BASE_LOGGER_LOGGROUP
#define ZYPP_BASE_LOGGER_LOGGROUP "zypp::CheckPatches"
-#define XML_FORMAT_VERSION "0.3"
+#define XML_FORMAT_VERSION "0.4"
using namespace zypp::detail;
{
ZYPP_CAUGHT (excpt_r);
+ gData.errors.push_back(Error(excpt_r.msg()));
+
std::ofstream os(RESULT_FILE);
if ( os.good() )
{
- render_error( Edition(XML_FORMAT_VERSION), os, "a ZYpp transaction is already in progress.");
- render_error( Edition(XML_FORMAT_VERSION), cout, "a ZYpp transaction is already in progress.");
+ render_error( Edition(XML_FORMAT_VERSION), os );
+ render_error( Edition(XML_FORMAT_VERSION), cout );
os.close();
}
// save a random token so we try again next time
KeyRingCallbacks keyring_callbacks;
DigestCallbacks digest_callbacks;
- try
- {
- manager->restore("/");
- }
- catch (Exception & excpt_r)
- {
- ZYPP_CAUGHT (excpt_r);
-
- std::ofstream os(RESULT_FILE);
- if ( os.good() )
- {
- string error = "Couldn't restore sources" + ( excpt_r.msg().empty() ? "\n" : (":\n" + excpt_r.msg()));
- render_error( Edition(XML_FORMAT_VERSION), os, error);
- render_error( Edition(XML_FORMAT_VERSION), cout, error);
- os.close();
- }
-
- // save a random token so we try again next time
- save_token(utils::randomString(48));
- save_version(Edition(XML_FORMAT_VERSION));
-
- return -1;
- }
-
// dont add rpms
- God->initTarget("/", true);
+ God->initializeTarget("/");
std::string token;
stringstream token_stream;
- for ( SourceManager::Source_const_iterator it = manager->Source_begin(); it != manager->Source_end(); ++it )
+ token_stream << "[" << "target" << "| " << God->target()->timestamp() << "]";
+
+ std::list<source::SourceInfo> new_sources = manager->knownSourceInfos("/");
+ MIL << "Found " << new_sources.size() << " sources." << endl;
+
+ for ( std::list<source::SourceInfo>::iterator it = new_sources.begin(); it != new_sources.end(); ++it)
{
- Source_Ref src = manager->findSource(it->alias());
- src.refresh();
-
- token_stream << "[" << src.alias() << "| " << src.url() << src.timestamp() << "]";
+ Url url = it->url();
+ std::string scheme( url.getScheme());
+
+ if ( (scheme == "cd" || scheme == "dvd") )
+ {
+ MIL << "Skipping CD/DVD source: url:[" << it->url().asString() << "] product_dir:[" << it->path() << "] alias:[" << it->alias() << "] cache_dir:[" << it->cacheDir() << "] auto_refresh:[ " << it->autorefresh() << "]" << endl;
+ continue;
+ }
- MIL << "Source: " << src.alias() << " from " << src.timestamp() << std::endl;
+ if ( ! it->enabled() )
+ {
+ MIL << "Skipping disabled source: url:[" << it->url().asString() << "] product_dir:[" << it->path() << "] alias:[" << it->alias() << "] cache_dir:[" << it->cacheDir() << "] auto_refresh:[ " << it->autorefresh() << "]" << endl;
+ continue;
+ }
+
+ // Note: Url(it->url).asString() to hide password in logs
+ MIL << "Creating source: url:[" << it->url().asString() << "] product_dir:[" << it->path() << "] alias:[" << it->alias() << "] cache_dir:[" << it->cacheDir() << "] auto_refresh:[ " << it->autorefresh() << "]" << endl;
- // skip sources without patches sources for now
- if ( src.hasResolvablesOfKind( ResTraits<zypp::Patch>::kind ) )
+ try
{
- MIL << "Including source " << src.url() << std::endl;
- gData.sources.push_back(src);
+ Source_Ref src = SourceFactory().createFrom(it->type(), it->url(), it->path(), it->alias(), it->cacheDir(), false, it->autorefresh());
+ src.refresh();
+ token_stream << "[" << src.alias() << "| " << src.url() << src.timestamp() << "]";
+
+ MIL << "Source: " << src.alias() << " from " << src.timestamp() << std::endl;
+
+ // skip sources without patches sources for now
+ if ( src.hasResolvablesOfKind( ResTraits<zypp::Patch>::kind ) )
+ {
+ MIL << "Including source " << src.url() << std::endl;
+ gData.sources.push_back(src);
+ }
+ else
+ {
+ MIL << "Excluding source " << src.url() << " ( no patches ) "<< std::endl;
+ }
}
- else
+ catch (const Exception &excpt_r )
{
- MIL << "Excluding source " << src.url() << " ( no patches ) "<< std::endl;
+ gData.errors.push_back("Couldn't restore source" + ( excpt_r.msg().empty() ? "\n" : (":\n" + excpt_r.msg())));
}
}
- token_stream << "[" << "target" << "| " << God->target()->timestamp() << "]";
-
string previous_token;
if ( PathInfo(TOKEN_FILE).isExist() )
previous_token = read_old_token();