targetstoreincludedir = $(pkgincludedir)/target/store
-targetstoreinclude_HEADERS = PersistentStorage.h Backend.h XMLFilesBackend.h serialize.h xml_escape_parser.hpp parser_utils.hpp md5.h
+targetstoreinclude_HEADERS = PersistentStorage.h Backend.h XMLFilesBackend.h serialize.h xml_escape_parser.hpp parser_utils.hpp
noinst_LTLIBRARIES = lib@PACKAGE@_target_store.la
## ##################################################
-lib@PACKAGE@_target_store_la_SOURCES = PersistentStorage.cc Backend.cc XMLFilesBackend.cc serialize.cc xml_escape_parser.cpp md5.cc
+lib@PACKAGE@_target_store_la_SOURCES = PersistentStorage.cc Backend.cc XMLFilesBackend.cc serialize.cc xml_escape_parser.cpp
lib@PACKAGE@_target_store_la_LIBADD = -lboost_regex -lboost_filesystem \
xml/lib@PACKAGE@_target_xml.la
| /_____||_| |_| |_| |
| |
\---------------------------------------------------------------------*/
-/** \file devel/devel.dmacvicar/PersistentStorage.cc
+/** \file zypp/target/store/PersistentStorage.cc
*
*/
#include <iostream>
#include "PersistentStorage.h"
#include "Backend.h"
#include "XMLFilesBackend.h"
-//#include "devel/devel.dmacvicar/BDBBackend.h"
using std::endl;
#include "zypp/base/Exception.h"
#include "zypp/CapFactory.h"
+#include "zypp/Digest.h"
+
#include "zypp/target/store/xml/XMLPatchImpl.h"
#include "zypp/target/store/xml/XMLMessageImpl.h"
#include "XMLFilesBackend.h"
#include "serialize.h"
-#include "md5.h"
-
#define ZYPP_DB_DIR "/var/lib/zypp_db"
using std::endl;
}
-static std::string hexDigest(const std::string &message)
-{
- md5_state_t state;
- md5_byte_t digest[16];
-
- md5_init(&state);
- /* Append a string to the message. */
- md5_append(&state, (md5_byte_t*) message.c_str(), message.size()); /* Finish the message and return the digest. */
- md5_finish(&state, digest);
-
- char s[33];
- int i;
- for (i=0; i<16; i++)
- sprintf(s+i*2, "%02x", digest[i]);
-
- s[32]='\0';
- return std::string(s);
-}
-
void
XMLFilesBackend::storeSource(const PersistentStorage::SourceData &data)
{
//DBG << filename << std::endl;
try
{
- std::string full_path = (source_p / hexDigest(data.alias)).string();
+ std::stringstream message_stream(data.alias);
+ std::string full_path = (source_p / Digest::digest("MD5", message_stream)).string();
file.open(full_path.c_str());
file << xml;
path source_p = path(d->root.asString()) / path(ZYPP_DB_DIR) / path ("source-cache");
try
{
- std::string full_path = (source_p / hexDigest(alias)).string();
+ std::stringstream message_stream(alias);
+ std::string full_path = (source_p / Digest::digest("MD5", message_stream)).string();
remove(full_path);
}
catch ( std::exception &e )
std::string toXML( const Pattern::constPtr &obj )
{
stringstream out;
- /*
- out << "<message type=\"" << obj->type() << "\">" << std::endl;
- // reuse Resolvable information serialize function
- out << toXML(static_cast<Resolvable::constPtr>(obj));
- out << " <text>" << obj->text() << "</text>" << std::endl;
- out << "</message>" << std::endl;
- */
+ out << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" << std::endl;
+ out << "<pattern" << std::endl;
+ out << " xmlns=\"http://novell.com/package/metadata/suse/pattern\"" << std::endl;
+ out << " xmlns:yum=\"http://linux.duke.edu/metadata/common\"" << std::endl;
+ out << " xmlns:rpm=\"http://linux.duke.edu/metadata/rpm\"" << std::endl;
+ out << " xmlns:suse=\"http://novell.com/package/metadata/suse/common\">" << std::endl;
+ out << " <patternid>" << obj->patternId() << "</patternid>" << std::endl;
+ out << " <name>" << obj->name() << "</name>" << std::endl;
+ //out << " <name lang='en.US'>foobar</name>" << std::endl;
+ out << " <default>" << (obj->isDefault() ? "true" : "false" ) << "</default>" << std::endl;
+ out << " <uservisible>" << (obj->userVisible() ? "true" : "false" ) << "</uservisible>" << std::endl;
+ out << " <category>" << obj->category() << "</category>" << std::endl;
+ out << " <icon>" << obj->icon() << "</icon>" << std::endl;
+ out << " <script>" << obj->script() << "</script>" << std::endl;
+ //out << " <description lang='cs.CZ'>This is my pattern, it is soooooooo coool!</description>" << std::endl;
+ //out << " <description lang='en.US'>Duh</description>" << std::endl;
+ out << toXML(obj->deps()) << std::endl;
+ out << "</pattern>" << std::endl;
return out.str();
}