std::string Package::buildhost() const
{ return pimpl().buildhost(); }
+ CheckSum Package::checksum() const
+ { return pimpl().checksum(); }
+
/** */
std::string Package::distribution() const
{ return pimpl().distribution(); }
{ return pimpl().licenseToConfirm(); }
/** */
- Pathname Package::plainRpm() const
- { return pimpl().location(); }
+ //Pathname Package::plainRpm() const
+ //{ return pimpl().location(); }
/** */
std::list<PatchRpm> Package::patchRpms() const
{ return pimpl().deltaRpms(); }
/** */
- Pathname Package::getPlainRpm() const
- { return source().provideFile(plainRpm(), mediaId()); }
+ //Pathname Package::getPlainRpm() const
+ //{ return source().provideFile(plainRpm(), mediaId()); }
/** */
Pathname Package::getDeltaRpm(BaseVersion & base_r) const
return source().provideFile(it->filename());
}
ZYPP_THROW(Exception("No matching delta RPM found"));
- return source().provideFile(plainRpm()); // never reached
+ return source().provideFile(location()); // never reached
}
/** */
}
}
ZYPP_THROW(Exception("No matching patch RPM found"));
- return source().provideFile(plainRpm()); // never reached
+ return source().provideFile(location()); // never reached
}
bool Package::installOnly() const
typedef TraitsType::constPtrType constPtr;
public:
+ /**
+ * Checksum the source says this package should have
+ */
+ CheckSum checksum() const;
/** Time of package installation */
Date installtime() const;
/** Get the package change log */
/** */
License licenseToConfirm() const;
/** */
- Pathname plainRpm() const;
+ //Pathname plainRpm() const;
/** */
std::list<PatchRpm> patchRpms() const;
/** */
/**
* \throws Exception
*/
- Pathname getPlainRpm() const;
+ //Pathname getPlainRpm() const;
/**
* \throws Exception
*/
{ return _pimpl->provideFile(file_r, media_nr); }
const Pathname Source_Ref::provideDirTree(const Pathname & dir_r,
- const unsigned media_nr)
-
+ const unsigned media_nr)
{ return _pimpl->provideDirTree(dir_r, media_nr); }
+ const Pathname Source_Ref::providePackage( Package::constPtr package )
+ { return _pimpl->providePackage( package ); }
+
const void Source_Ref::releaseFile(const Pathname & file_r,
const unsigned media_nr)
{ _pimpl->releaseFile(file_r, media_nr); }
#include "zypp/base/PtrTypes.h"
#include "zypp/base/SafeBool.h"
+#include "zypp/Package.h"
#include "zypp/Pathname.h"
#include "zypp/Url.h"
#include "zypp/Resolvable.h"
/** All resolvables of a given kind provided by this source. */
const ResStore resolvables(zypp::Resolvable::Kind kind) const;
+ const Pathname providePackage( Package::constPtr package );
+
/** Provide a file to local filesystem */
const Pathname provideFile(const Pathname & file_r,
const unsigned media_nr = 1);
Date PackageImplIf::buildtime() const
{ return Date(); }
+ CheckSum PackageImplIf::checksum() const
+ { return CheckSum(); }
+
std::string PackageImplIf::buildhost() const
{ return std::string(); }
#include <set>
#include "zypp/detail/ResObjectImplIf.h"
+#include "zypp/CheckSum.h"
#include "zypp/Edition.h"
#include "zypp/Arch.h"
#include "zypp/Changelog.h"
public:
/** \name Rpm Package Attributes. */
//@{
+
+ virtual CheckSum checksum() const PURE_VIRTUAL;
/** */
virtual Date buildtime() const PURE_VIRTUAL;
/** */
*
*/
#include <iostream>
+#include <fstream>
#include "zypp/base/Logger.h"
-
+#include "zypp/Digest.h"
#include "zypp/SourceFactory.h"
#include "zypp/source/SourceImpl.h"
#include "zypp/ZYppCallbacks.h"
media_mgr.dirInfo( _media, retlist, path_r, dots );
}
+ const Pathname SourceImpl::providePackage( Package::constPtr package )
+ {
+#warning FIXME: error handling
+#warning FIXME: Url
+ callback::SendReport<source::DownloadResolvableReport> report;
+ report->start( package, package->source().url() );
+ Pathname file = package->source().provideFile( package->location(), package->mediaId());
+ CheckSum checksum = package->checksum();
+ std::string calculated_digest;
+ // check digest
+ try
+ {
+ std::ifstream is(file.asString().c_str(), std::ifstream::binary);
+ calculated_digest = Digest::digest(checksum.type(), is);
+ is.close();
+ }
+ catch (std::exception &e)
+ {
+ ERR << "Can't open " << file << " for integrity check." << std::endl;
+ }
+
+ if ( checksum.checksum() != calculated_digest )
+ {
+ ZYPP_THROW(Exception("Package " + package->location().asString() + " fails integrity check. Expected: [" + checksum.checksum() + "] Read: [" + calculated_digest + "]"));
+ }
+ else
+ {
+ MIL << package->location() << " ok. [" << calculated_digest << "]" << std::endl;
+ }
+
+
+ report->finish( package, source::DownloadResolvableReport::NO_ERROR, "" );
+ return file;
+ }
+
const Pathname SourceImpl::provideFile(const Pathname & file_r,
const unsigned media_nr,
bool cached,
const unsigned media_nr = 1,
const bool recursive = false);
+ const Pathname providePackage( Package::constPtr package );
+ const Pathname providePackageInteractive( Package::constPtr package );
+
/**
* Provide info about a directory
*
SuseTagsPackageImpl::~SuseTagsPackageImpl()
{}
-
+ CheckSum SuseTagsPackageImpl::checksum() const
+ { return _checksum; }
+
TranslatedText SuseTagsPackageImpl::summary() const
{ return _summary; }
//@{
virtual TranslatedText summary() const;
virtual TranslatedText description() const;
-
+ virtual CheckSum checksum() const;
/** */
virtual Date buildtime() const;
/** */
return _store;
}
-
- Pathname TargetImpl::getRpmFile(Package::constPtr package)
- {
- callback::SendReport<source::DownloadResolvableReport> report;
-
-#warning FIXME: error handling
-#warning FIXME: Url
- report->start( package, package->source().url() );
-
- Pathname file = package->getPlainRpm();
-
- report->finish( package, source::DownloadResolvableReport::NO_ERROR, "" );
-
- return file;
- }
-
int TargetImpl::commit( ResPool pool_r, unsigned int medianr,
TargetImpl::PoolItemList & errors_r, TargetImpl::PoolItemList & remaining_r,
Package::constPtr p = dynamic_pointer_cast<const Package>(it->resolvable());
if (it->status().isToBeInstalled())
{
- Pathname localfile = getRpmFile( p );
+ Pathname localfile = p->source().providePackage(p);
lastUsedSource = p->source(); // remember the package source
#warning Exception handling
it->status().setTransact( false, ResStatus::USER );
}
progress.disconnect();
- p->source().releaseFile( p->plainRpm(), p->mediaId() );
+ p->source().releaseFile( p->location(), p->mediaId() );
}
else
{
private:
/** Null implementation */
static TargetImpl_Ptr _nullimpl;
-
- /** wrapper with callback around getPlainRpm */
- Pathname getRpmFile(Package::constPtr package);
};
///////////////////////////////////////////////////////////////////
std::string filename = fullPathForResolvable(resolvable);
try
{
- remove(path(filename));
+ int ret = filesystem::unlink(Pathname(filename));
+ if ( ret != 0 )
+ {
+ ERR << "Error removing resolvable " << resolvable << std::endl;
+ ZYPP_THROW(Exception("Error deleting " + filename));
+ }
}
catch(std::exception &e)
{