#include "zypp/source/SourceImpl.h"
#include "zypp/SourceCache.h"
#include "zypp/Package.h"
+#include "zypp/Message.h"
using namespace std;
using namespace zypp;
SourceFactory _f;
Pathname p = "/";
// Url url = Url("ftp://cml.suse.cz/netboot/find/SUSE-10.1-CD-OSS-i386-Beta1-CD1");
- Url url = Url("http://lide.suse.cz/~~jsrain/devel.jsrain");
+// Url url = Url("http://users.suse.cz/~jsrain/devel.jsrain");
// Url url = Url("dir:/local/zypp/libzypp/devel/devel.jsrain");
+ Url url = Url("http://armstrong.suse.de/download/Code/10/update/i386/");
Source_Ref s = _f.createFrom( url, p );
ResStore store = s.resolvables();
for (ResStore::const_iterator it = store.begin();
it != store.end(); it++)
{
ERR << **it << endl;
- if (isKind<Package>(*it))
+ if (isKind<Message>(*it))
{
- ERR << "Package" << endl;
- Package::constPtr pkg = boost::dynamic_pointer_cast<const Package>( *it );
- ERR << "License: " << pkg->licenseToConfirm() << endl;
+ ERR << "Message" << endl;
+ Message::constPtr pkg = boost::dynamic_pointer_cast<const Message>( *it );
+ ERR << "Patch PTR: " << pkg->patch() << endl;
+ if (pkg->patch())
+ ERR << "Patch: " << *(pkg->patch()) << endl;
}
}
// SourceCache().storeSource(s);
- ERR << store << endl;
+// ERR << store << endl;
INT << "===[END]============================================" << endl;
return 0;
}
{
string filename = (*patch)->location;
src = provideFile(_path + filename);
- if (! checkCheckSum(provideFile(_path + filename), (*patch)->checksumType, (*patch)->checksum))
+ if (! checkCheckSum(src, (*patch)->checksumType, (*patch)->checksum))
{
ZYPP_THROW(Exception(N_("Failed check for the metadata file check sum")));
}
: _cache_dir + (*it)->location;
if (_cache_dir.empty())
{
- if (! checkCheckSum((*it)->location, (*it)->checksumType, (*it)->checksum))
+ if (! checkCheckSum(filename, (*it)->checksumType, (*it)->checksum))
{
ZYPP_THROW(Exception(N_("Failed check for the metadata file check sum")));
}
: _cache_dir + (*it)->location;
if (_cache_dir.empty())
{
- if (! checkCheckSum((*it)->location, (*it)->checksumType, (*it)->checksum))
+ if (! checkCheckSum(filename, (*it)->checksumType, (*it)->checksum))
{
ZYPP_THROW(Exception(N_("Failed check for the metadata file check sum")));
}
: _cache_dir + (*it)->location;
if (_cache_dir.empty())
{
- if (! checkCheckSum((*it)->location, (*it)->checksumType, (*it)->checksum))
+ if (! checkCheckSum(filename, (*it)->checksumType, (*it)->checksum))
{
ZYPP_THROW(Exception(N_("Failed check for the metadata file check sum")));
}
: _cache_dir + (*it)->location;
if (_cache_dir.empty())
{
- if (! checkCheckSum((*it)->location, (*it)->checksumType, (*it)->checksum))
+ if (! checkCheckSum(filename, (*it)->checksumType, (*it)->checksum))
{
ZYPP_THROW(Exception(N_("Failed check for the metadata file check sum")));
}
: _cache_dir + (*it)->location;
if (_cache_dir.empty())
{
- if (! checkCheckSum((*it)->location, (*it)->checksumType, (*it)->checksum))
+ if (! checkCheckSum(filename, (*it)->checksumType, (*it)->checksum))
{
ZYPP_THROW(Exception(N_("Failed check for the metadata file check sum")));
}
: _cache_dir + (*it)->location;
if (_cache_dir.empty())
{
- if (! checkCheckSum((*it)->location, (*it)->checksumType, (*it)->checksum))
+ if (! checkCheckSum(filename, (*it)->checksumType, (*it)->checksum))
{
ZYPP_THROW(Exception(N_("Failed check for the metadata file check sum")));
}
: _cache_dir + (*it)->location;
if (_cache_dir.empty())
{
- if (! checkCheckSum((*it)->location, (*it)->checksumType, (*it)->checksum))
+ if (! checkCheckSum(filename, (*it)->checksumType, (*it)->checksum))
{
ZYPP_THROW(Exception(N_("Failed check for the metadata file check sum")));
}
string filename = (*patch)->location;
if (_cache_dir.empty())
{
- if (! checkCheckSum(filename, (*patch)->checksumType, (*patch)->checksum))
+ if (! checkCheckSum(provideFile(_path + filename), (*patch)->checksumType, (*patch)->checksum))
{
ZYPP_THROW(Exception(N_("Failed check for the metadata file check sum")));
}
}
return cap;
}
- bool YUMSourceImpl::checkCheckSum (const Pathname & filename, const std::string & csum_type, const std::string & csum)
+ bool YUMSourceImpl::checkCheckSum (const Pathname & filename, std::string csum_type, const std::string & csum)
{
MIL << "Checking checksum for " << filename << " as type: " << csum_type << "; value: " << csum << endl;
+ if (str::toLower(csum_type) == "sha")
+ {
+ if (csum.size() == 40)
+ csum_type = "sha1";
+ else if (csum.size() == 64)
+ csum_type = "sha256";
+ DBG << "Checksum size is " << csum.size() << ", checksum type set to " << csum_type << endl;
+ }
ifstream st(filename.asString().c_str());
std::string dig = Digest::digest (csum_type, st, 4096);
if (dig == "")