From: Michael Andres Date: Mon, 30 Jul 2007 12:58:10 +0000 (+0000) Subject: - Fixed wrong media number reported by script, message and patch. X-Git-Tag: BASE-SuSE-Linux-10_3-Branch~449 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=04de979b7deb5c3b32ffa5dd1443d6781aec7c8b;p=platform%2Fupstream%2Flibzypp.git - Fixed wrong media number reported by script, message and patch. - Fixed script API to provide the scripts location on media (if not inlined). - Introduced ScripProvider to make a script available on the local disk. --- diff --git a/VERSION.cmake b/VERSION.cmake index 8eabf11..5c9ee28 100644 --- a/VERSION.cmake +++ b/VERSION.cmake @@ -45,6 +45,6 @@ # SET(LIBZYPP_MAJOR "3") -SET(LIBZYPP_MINOR "12") -SET(LIBZYPP_COMPATMINOR "10") -SET(LIBZYPP_PATCH "1") +SET(LIBZYPP_MINOR "13") +SET(LIBZYPP_COMPATMINOR "13") +SET(LIBZYPP_PATCH "0") diff --git a/zypp/CMakeLists.txt b/zypp/CMakeLists.txt index 2c26fb3..48fc97a 100644 --- a/zypp/CMakeLists.txt +++ b/zypp/CMakeLists.txt @@ -920,6 +920,7 @@ SET( zypp_repo_SRCS repo/RepoException.cc repo/RepoType.cc repo/PackageProvider.cc + repo/ScriptProvider.cc repo/RepoProvideFile.cc repo/DeltaCandidates.cc repo/Applydeltarpm.cc @@ -934,6 +935,7 @@ SET( zypp_repo_HEADERS repo/RepoException.h repo/RepoType.h repo/PackageProvider.h + repo/ScriptProvider.h repo/RepoProvideFile.h repo/DeltaCandidates.h repo/Applydeltarpm.h diff --git a/zypp/Script.cc b/zypp/Script.cc index eba4fc1..560f54f 100644 --- a/zypp/Script.cc +++ b/zypp/Script.cc @@ -40,14 +40,23 @@ namespace zypp // /////////////////////////////////////////////////////////////////// - Pathname Script::do_script() const - { return pimpl().do_script(); } + bool Script::doAvailable() const + { return pimpl().doAvailable(); } - Pathname Script::undo_script() const - { return pimpl().undo_script(); } + std::string Script::doScriptInlined() const + { return pimpl().doScriptInlined(); } - bool Script::undo_available() const - { return pimpl().undo_available(); } + OnMediaLocation Script::doScriptLocation() const + { return pimpl().doScriptLocation(); } + + bool Script::undoAvailable() const + { return pimpl().undoAvailable(); } + + std::string Script::undoScriptInlined() const + { return pimpl().undoScriptInlined(); } + + OnMediaLocation Script::undoScriptLocation() const + { return pimpl().undoScriptLocation(); } ///////////////////////////////////////////////////////////////// } // namespace zypp diff --git a/zypp/Script.h b/zypp/Script.h index 0529b6d..6610440 100644 --- a/zypp/Script.h +++ b/zypp/Script.h @@ -35,12 +35,31 @@ namespace zypp typedef TraitsType::constPtrType constPtr; public: - /** Get the script to perform the change */ - Pathname do_script() const; - /** Get the script to undo the change */ - Pathname undo_script() const ; - /** Check whether script to undo the change is available */ - bool undo_available() const; + /** Check whether a script is available. */ + bool doAvailable() const; + + /** Return an inlined script if available. + * Otherwise it is available at \ref doScriptLocation. + */ + std::string doScriptInlined() const; + + /** Location of the script, unless it is available inlined. + * \see \ref doScriptInlined + */ + OnMediaLocation doScriptLocation() const; + + /** Check whether a script to undo the change is available. */ + bool undoAvailable() const; + + /** Return an inlined undo script if available. + * Otherwise it is available at \ref undoScriptLocation. + */ + std::string undoScriptInlined() const; + + /** Location of the undo script, unless it is available inlined. + * \see \ref undoScriptInlined + */ + OnMediaLocation undoScriptLocation() const; protected: /** Ctor */ diff --git a/zypp/cache/CacheAttributes.h b/zypp/cache/CacheAttributes.h index 3020716..087cb92 100644 --- a/zypp/cache/CacheAttributes.h +++ b/zypp/cache/CacheAttributes.h @@ -14,8 +14,12 @@ #include "zypp/cache/Attribute.h" -/** Define OnMediaLocation attributes using a common prefix for all attributes. */ -#define defineOnMediaLocationAttr(OMLATTRPREFIX,KLASS,ATTRNAMEPREFIX ) \ +/** Define OnMediaLocation attributes using a common prefix for all attributes. + * \code + * defineOnMediaLocationAttr( attrPackageLocation, "Package", "location" ) + * \endcode +*/ +#define defineOnMediaLocationAttr(OMLATTRPREFIX,KLASS,ATTRNAMEPREFIX ) \ inline const Attribute & OMLATTRPREFIX##MediaNr() { static Attribute a(KLASS,#ATTRNAMEPREFIX"MediaNr"); return a; } \ inline const Attribute & OMLATTRPREFIX##Filename() { static Attribute a(KLASS,#ATTRNAMEPREFIX"Filename"); return a; } \ inline const Attribute & OMLATTRPREFIX##DownloadSize() { static Attribute a(KLASS,#ATTRNAMEPREFIX"DownloadSize"); return a; } \ diff --git a/zypp/cache/CacheStore.cc b/zypp/cache/CacheStore.cc index 4e62af9..cedffdc 100644 --- a/zypp/cache/CacheStore.cc +++ b/zypp/cache/CacheStore.cc @@ -22,17 +22,20 @@ using namespace sqlite3x; using zypp::debug::Measure; /** Append OnMediaLocation attributes to resolvable with ID. - * Pass the OnMediaLocation attributes common prefix as 2nd arg. This macro - * assumes that the attribute names follow this schema: + * \code + * appendOnMediaLocation( pkgid, attrPackageLocation, package->repositoryLocation ); + * \endcode + * Pass the OnMediaLocation attributes common prefix as 2nd arg, the OnMediaLocation + * object as third arg. This macro assumes that the attribute names follow this schema: */ -#define appendOnMediaLocation(ID,OMLATTRPREFIX,OML) \ -do { \ - appendNumericAttribute( ID, OMLATTRPREFIX##MediaNr(), OML.medianr() ); \ - appendStringAttribute ( ID, OMLATTRPREFIX##Filename(), OML.filename().asString() ); \ - appendNumericAttribute( ID, OMLATTRPREFIX##DownloadSize(), OML.downloadSize() ); \ - appendStringAttribute ( ID, OMLATTRPREFIX##ChecksumType(), OML.checksum().type() ); \ - appendStringAttribute ( ID, OMLATTRPREFIX##Checksum(), OML.checksum().checksum() ); \ - appendNumericAttribute( ID, OMLATTRPREFIX##OpenSize(), OML.openSize() ); \ +#define appendOnMediaLocation(ID,OMLATTRPREFIX,OML) \ +do { \ + appendNumericAttribute( ID, OMLATTRPREFIX##MediaNr(), OML.medianr() ); \ + appendStringAttribute ( ID, OMLATTRPREFIX##Filename(), OML.filename().asString() ); \ + appendNumericAttribute( ID, OMLATTRPREFIX##DownloadSize(), OML.downloadSize() ); \ + appendStringAttribute ( ID, OMLATTRPREFIX##ChecksumType(), OML.checksum().type() ); \ + appendStringAttribute ( ID, OMLATTRPREFIX##Checksum(), OML.checksum().checksum() ); \ + appendNumericAttribute( ID, OMLATTRPREFIX##OpenSize(), OML.openSize() ); \ appendStringAttribute ( ID, OMLATTRPREFIX##OpenChecksumType(), OML.openChecksum().type() ); \ appendStringAttribute ( ID, OMLATTRPREFIX##OpenChecksum(), OML.openChecksum().checksum() );\ } while(false) diff --git a/zypp/cache/ResolvableQuery.h b/zypp/cache/ResolvableQuery.h index 3985381..e3e8b15 100644 --- a/zypp/cache/ResolvableQuery.h +++ b/zypp/cache/ResolvableQuery.h @@ -11,6 +11,26 @@ #include "zypp/cache/Attribute.h" #include "zypp/ZConfig.h" +/** Query OnMediaLocation attributes for resolvable with ID. + * \code + * queryOnMediaLocation( _repository->resolvableQuery(), pkgid, attrPackageLocation, _location ); + * \endcode + * Passt the ResolvableQuery as 1st arg, the resolvable id as 2nd, the OnMediaLocation attributes + * common prefix as 3nd arg, the OnMediaLocation object as 4th arg. + */ +#define queryOnMediaLocation(RESQUERY,ID,OMLATTRPREFIX,OML) \ +do { \ + OML.setLocation( RESQUERY.queryStringAttribute( ID, OMLATTRPREFIX##Filename() ), \ + RESQUERY.queryNumericAttribute( ID, OMLATTRPREFIX##MediaNr() ) ); \ + OML.setChecksum( CheckSum( RESQUERY.queryStringAttribute( ID, OMLATTRPREFIX##ChecksumType() ), \ + RESQUERY.queryStringAttribute( ID, OMLATTRPREFIX##Checksum() ) ) ); \ + OML.setDownloadSize( RESQUERY.queryNumericAttribute( ID, OMLATTRPREFIX##DownloadSize() ) ); \ + OML.setOpenChecksum( CheckSum( RESQUERY.queryStringAttribute( ID, OMLATTRPREFIX##OpenChecksumType() ), \ + RESQUERY.queryStringAttribute( ID, OMLATTRPREFIX##OpenChecksum() ) ) ); \ + OML.setOpenSize( RESQUERY.queryNumericAttribute( ID, OMLATTRPREFIX##OpenSize() ) ); \ +} while(false) + + /////////////////////////////////////////////////////////////////// namespace zypp { ///////////////////////////////////////////////////////////////// diff --git a/zypp/detail/ScriptImpl.cc b/zypp/detail/ScriptImpl.cc index ba871bc..c81ba66 100644 --- a/zypp/detail/ScriptImpl.cc +++ b/zypp/detail/ScriptImpl.cc @@ -34,19 +34,12 @@ namespace zypp ScriptImpl::~ScriptImpl() {} - Pathname ScriptImpl::do_script() const { - return Pathname(); -// return _do_script; - } - - Pathname ScriptImpl::undo_script() const { - return Pathname(); -// return _undo_script; - } - - bool ScriptImpl::undo_available() const { - return _undo_script != ""; - } + std::string ScriptImpl::doScriptInlined() const + { return _doScript; } + + std::string ScriptImpl::undoScriptInlined() const + { return _undoScript; } + ///////////////////////////////////////////////////////////////// } // namespace detail diff --git a/zypp/detail/ScriptImpl.h b/zypp/detail/ScriptImpl.h index 4ff4593..f87e294 100644 --- a/zypp/detail/ScriptImpl.h +++ b/zypp/detail/ScriptImpl.h @@ -35,17 +35,21 @@ namespace zypp ~ScriptImpl(); public: - /** Get the script to perform the change */ - Pathname do_script() const; - /** Get the script to undo the change */ - Pathname undo_script() const; - /** Check whether script to undo the change is available */ - virtual bool undo_available() const; + /** Return an inlined script if available. + * Otherwise it is available at \ref doScriptLocation. + */ + virtual std::string doScriptInlined() const; + + /** Return an inlined undo script if available. + * Otherwise it is available at \ref undoScriptLocation. + */ + virtual std::string undoScriptInlined() const; + protected: /** The script to perform the change */ - std::string _do_script; + std::string _doScript; /** The script to undo the change */ - std::string _undo_script; + std::string _undoScript; }; /////////////////////////////////////////////////////////////////// diff --git a/zypp/detail/ScriptImplIf.cc b/zypp/detail/ScriptImplIf.cc index d17c619..548d2e2 100644 --- a/zypp/detail/ScriptImplIf.cc +++ b/zypp/detail/ScriptImplIf.cc @@ -23,14 +23,28 @@ namespace zypp // as far as resonable. ///////////////////////////////////////////////////////////////// - Pathname ScriptImplIf::do_script() const - { return Pathname(); } + bool ScriptImplIf::doAvailable() const + { return ! ( doScriptInlined().empty() + && doScriptLocation().filename().empty() ); } - Pathname ScriptImplIf::undo_script() const - { return Pathname(); } + unsigned ScriptImplIf::mediaNr() const + { return( doScriptInlined().empty() ? doScriptLocation().medianr() : 0 ); } - bool ScriptImplIf::undo_available() const - { return false; } + std::string ScriptImplIf::doScriptInlined() const + { return std::string(); } + + OnMediaLocation ScriptImplIf::doScriptLocation() const + { return OnMediaLocation(); } + + bool ScriptImplIf::undoAvailable() const + { return ! ( undoScriptInlined().empty() + && undoScriptLocation().filename().empty() ); } + + std::string ScriptImplIf::undoScriptInlined() const + { return std::string(); } + + OnMediaLocation ScriptImplIf::undoScriptLocation() const + { return OnMediaLocation(); } ///////////////////////////////////////////////////////////////// } // namespace detail diff --git a/zypp/detail/ScriptImplIf.h b/zypp/detail/ScriptImplIf.h index 6e5fbf1..eccf18a 100644 --- a/zypp/detail/ScriptImplIf.h +++ b/zypp/detail/ScriptImplIf.h @@ -37,12 +37,38 @@ namespace zypp typedef Script ResType; public: - /** Get the script to perform the change */ - virtual Pathname do_script() const PURE_VIRTUAL; - /** Get the script to undo the change */ - virtual Pathname undo_script() const PURE_VIRTUAL; - /** Check whether script to undo the change is available */ - virtual bool undo_available() const PURE_VIRTUAL; + /** Overloaded ResObjectImpl attribute. + * \return The \ref doScriptLocation media number + * or \c 0 if do-script is inlined. + */ + virtual unsigned mediaNr() const; + + public: + /** Check whether a script is available. */ + virtual bool doAvailable() const; + + /** Return an inlined script if available. + * Otherwise it is available at \ref doScriptLocation. + */ + virtual std::string doScriptInlined() const; + + /** Location of the script, unless it is available inlined. + * \see \ref doScriptInlined + */ + virtual OnMediaLocation doScriptLocation() const; + + /** Check whether a script to undo the change is available. */ + virtual bool undoAvailable() const; + + /** Return an inlined undo script if available. + * Otherwise it is available at \ref undoScriptLocation. + */ + virtual std::string undoScriptInlined() const; + + /** Location of the undo script, unless it is available inlined. + * \see \ref undoScriptInlined + */ + virtual OnMediaLocation undoScriptLocation() const; }; /////////////////////////////////////////////////////////////////// diff --git a/zypp/parser/xmlstore/XMLParserData.h b/zypp/parser/xmlstore/XMLParserData.h index c18db0d..54b2fc9 100644 --- a/zypp/parser/xmlstore/XMLParserData.h +++ b/zypp/parser/xmlstore/XMLParserData.h @@ -111,7 +111,7 @@ namespace zypp { public: XMLProductData() {}; ~XMLProductData() {}; - + std::string parser_version; std::string type; TranslatedText short_name; @@ -137,8 +137,8 @@ namespace zypp { public: XMLPatchScriptData() {}; virtual AtomType atomType() { return Script; }; - std::string do_script; - std::string undo_script; + std::string doScript; + std::string undoScript; }; class XMLPatchMessageData : public XMLPatchAtomData diff --git a/zypp/parser/xmlstore/XMLPatchParser.cc b/zypp/parser/xmlstore/XMLPatchParser.cc index eef723e..96209ca 100644 --- a/zypp/parser/xmlstore/XMLPatchParser.cc +++ b/zypp/parser/xmlstore/XMLPatchParser.cc @@ -148,11 +148,11 @@ namespace zypp { { string name = _helper.name(child); if (name == "do") { - script->do_script = _helper.content(child); + script->doScript = _helper.content(child); } else if (name == "undo") { - script->undo_script = _helper.content(child); + script->undoScript = _helper.content(child); } } } diff --git a/zypp/repo/RepoProvideFile.h b/zypp/repo/RepoProvideFile.h index f5a0bbb..a7f0ace 100644 --- a/zypp/repo/RepoProvideFile.h +++ b/zypp/repo/RepoProvideFile.h @@ -62,7 +62,7 @@ namespace zypp public: RepoMediaAccess(); ~RepoMediaAccess(); - + /** Provide a file from a Repository. * Let \a source_r provide the file described by \a loc_r. In case * \a loc_r contains a checksum, the file is verified. \a policy_r @@ -70,6 +70,7 @@ namespace zypp * on failed checksum verification. * * \throws Exception + * \todo Investigate why this needs a non-const Repository as arg. */ ManagedFile provideFile( Repository repo_r, const OnMediaLocation & loc_r, @@ -77,9 +78,9 @@ namespace zypp private: class Impl; RW_pointer _impl; - + }; - + ///////////////////////////////////////////////////////////////// } // namespace repo /////////////////////////////////////////////////////////////////// diff --git a/zypp/repo/ScriptProvider.cc b/zypp/repo/ScriptProvider.cc new file mode 100644 index 0000000..5d5b35d --- /dev/null +++ b/zypp/repo/ScriptProvider.cc @@ -0,0 +1,79 @@ +/*---------------------------------------------------------------------\ +| ____ _ __ __ ___ | +| |__ / \ / / . \ . \ | +| / / \ V /| _/ _/ | +| / /__ | | | | | | | +| /_____||_| |_| |_| | +| | +\---------------------------------------------------------------------*/ +/** \file zypp/repo/ScriptProvider.cc + * +*/ +#include +//#include "zypp/base/Logger.h" + +#include "zypp/repo/ScriptProvider.h" + +using std::endl; +#warning IMPLEMENT IT +/////////////////////////////////////////////////////////////////// +namespace zypp +{ ///////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////// + namespace repo + { ///////////////////////////////////////////////////////////////// + + /////////////////////////////////////////////////////////////////// + // + // CLASS NAME : ScriptProvider::Impl + // + /** ScriptProvider implementation. */ + struct ScriptProvider::Impl + { + }; + /////////////////////////////////////////////////////////////////// + + /////////////////////////////////////////////////////////////////// + // + // CLASS NAME : ScriptProvider + // + /////////////////////////////////////////////////////////////////// + + /////////////////////////////////////////////////////////////////// + // + // METHOD NAME : ScriptProvider::ScriptProvider + // METHOD TYPE : Ctor + // + ScriptProvider::ScriptProvider( repo::RepoMediaAccess & access_r, + const Script::constPtr & script_r ) + //: _pimpl( ) + { + // ManagedFile provideFile( Repository repo_r, + // const OnMediaLocation & loc_r, + // const ProvideFilePolicy & policy_r = ProvideFilePolicy() ); + } + + /////////////////////////////////////////////////////////////////// + // + // METHOD NAME : ScriptProvider::~ScriptProvider + // METHOD TYPE : Dtor + // + ScriptProvider::~ScriptProvider() + {} + + ManagedFile ScriptProvider::provideDoScript() const + { + return ManagedFile(); + } + + ManagedFile ScriptProvider::provideUndoScript() const + { + return ManagedFile(); + } + + ///////////////////////////////////////////////////////////////// + } // namespace repo + /////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////// +} // namespace zypp +/////////////////////////////////////////////////////////////////// diff --git a/zypp/repo/ScriptProvider.h b/zypp/repo/ScriptProvider.h new file mode 100644 index 0000000..824f063 --- /dev/null +++ b/zypp/repo/ScriptProvider.h @@ -0,0 +1,76 @@ +/*---------------------------------------------------------------------\ +| ____ _ __ __ ___ | +| |__ / \ / / . \ . \ | +| / / \ V /| _/ _/ | +| / /__ | | | | | | | +| /_____||_| |_| |_| | +| | +\---------------------------------------------------------------------*/ +/** \file zypp/repo/ScriptProvider.h + * +*/ +#ifndef ZYPP_REPO_SCRIPTPROVIDER_H +#define ZYPP_REPO_SCRIPTPROVIDER_H + +#include + +#include "zypp/base/PtrTypes.h" +#include "zypp/repo/RepoProvideFile.h" +#include "zypp/ManagedFile.h" +#include "zypp/Script.h" + +/////////////////////////////////////////////////////////////////// +namespace zypp +{ ///////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////// + namespace repo + { ///////////////////////////////////////////////////////////////// + + class RepoMediaAccess; + + /////////////////////////////////////////////////////////////////// + // + // CLASS NAME : ScriptProvider + // + /** */ + class ScriptProvider + { + public: + /** Implementation */ + class Impl; + + public: + /** Ctor */ + ScriptProvider( repo::RepoMediaAccess & access_r, + const Script::constPtr & script_r ); + /** Dtor */ + ~ScriptProvider(); + + public: + /** Provide a script in a local file.*/ + ManagedFile provideScript( bool do_r ) const + { return( do_r ? provideDoScript() : provideUndoScript() ); } + + /** Provide the do-script in a local file. + * Returns an empty path if no script is available. + */ + ManagedFile provideDoScript() const; + + /** Provide the do-script in a local file. + * Returns an empty path if no script is available. + */ + ManagedFile provideUndoScript() const; + + private: + /** Pointer to implementation */ + RW_pointer _pimpl; + }; + /////////////////////////////////////////////////////////////////// + + ///////////////////////////////////////////////////////////////// + } // namespace repo + /////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////// +} // namespace zypp +/////////////////////////////////////////////////////////////////// +#endif // ZYPP_REPO_SCRIPTPROVIDER_H diff --git a/zypp/repo/cached/AtomImpl.cc b/zypp/repo/cached/AtomImpl.cc index fb07ca4..289c0e8 100644 --- a/zypp/repo/cached/AtomImpl.cc +++ b/zypp/repo/cached/AtomImpl.cc @@ -94,11 +94,6 @@ Date AtomImpl::installtime() const return Date(); } -unsigned AtomImpl::mediaNr() const -{ - return 1; -} - ///////////////////////////////////////////////////////////////// } } } // namespace zypp::repo::cached /////////////////////////////////////////////////////////////////// diff --git a/zypp/repo/cached/AtomImpl.h b/zypp/repo/cached/AtomImpl.h index 4a0a093..91281b5 100644 --- a/zypp/repo/cached/AtomImpl.h +++ b/zypp/repo/cached/AtomImpl.h @@ -30,7 +30,7 @@ namespace cached public: AtomImpl( const data::RecordId &id, repo::cached::RepoImpl::Ptr repository_r ); - + virtual TranslatedText summary() const; virtual TranslatedText description() const; virtual TranslatedText insnotify() const; @@ -41,11 +41,9 @@ namespace cached virtual bool installOnly() const; virtual Date buildtime() const; virtual Date installtime() const; - - virtual unsigned mediaNr() const; virtual Repository repository() const; - + private: repo::cached::RepoImpl::Ptr _repository; data::RecordId _id; diff --git a/zypp/repo/cached/MessageImpl.cc b/zypp/repo/cached/MessageImpl.cc index af58c20..f6c08de 100644 --- a/zypp/repo/cached/MessageImpl.cc +++ b/zypp/repo/cached/MessageImpl.cc @@ -96,11 +96,6 @@ Date MessageImpl::installtime() const return Date(); } -unsigned MessageImpl::mediaNr() const -{ - return 1; -} - ////////////////////////////////////////// // MESSAGE ///////////////////////////////////////// diff --git a/zypp/repo/cached/MessageImpl.h b/zypp/repo/cached/MessageImpl.h index ff7aee9..b11af0d 100644 --- a/zypp/repo/cached/MessageImpl.h +++ b/zypp/repo/cached/MessageImpl.h @@ -30,7 +30,7 @@ namespace cached public: MessageImpl( const data::RecordId &id, repo::cached::RepoImpl::Ptr repository_r ); - + virtual TranslatedText summary() const; virtual TranslatedText description() const; virtual TranslatedText insnotify() const; @@ -41,15 +41,13 @@ namespace cached virtual bool installOnly() const; virtual Date buildtime() const; virtual Date installtime() const; - - virtual unsigned mediaNr() const; - + // MESSAGE virtual TranslatedText text() const; virtual Patch::constPtr patch() const; - + virtual Repository repository() const; - + private: repo::cached::RepoImpl::Ptr _repository; data::RecordId _id; diff --git a/zypp/repo/cached/PackageImpl.cc b/zypp/repo/cached/PackageImpl.cc index 4ef6837..0efe802 100644 --- a/zypp/repo/cached/PackageImpl.cc +++ b/zypp/repo/cached/PackageImpl.cc @@ -136,20 +136,8 @@ Changelog PackageImpl::changelog() const OnMediaLocation PackageImpl::location() const { - OnMediaLocation loc( _repository->resolvableQuery().queryStringAttribute( _id, cache::attrPackageLocationFilename() ), - _repository->resolvableQuery().queryNumericAttribute( _id, cache::attrPackageLocationMediaNr() ) ); - - string chktype = _repository->resolvableQuery().queryStringAttribute( _id, cache::attrPackageLocationChecksumType() ); - string chkvalue = _repository->resolvableQuery().queryStringAttribute( _id, cache::attrPackageLocationChecksum() ); - loc.setChecksum(CheckSum(chktype, chkvalue)); - - loc.setDownloadSize( _repository->resolvableQuery().queryNumericAttribute( _id, cache::attrPackageLocationDownloadSize() ) ); - loc.setOpenSize( _repository->resolvableQuery().queryNumericAttribute( _id, cache::attrPackageLocationOpenSize() ) ); - - chktype = _repository->resolvableQuery().queryStringAttribute( _id, cache::attrPackageLocationOpenChecksumType() ); - chkvalue = _repository->resolvableQuery().queryStringAttribute( _id, cache::attrPackageLocationOpenChecksum() ); - loc.setOpenChecksum(CheckSum(chktype, chkvalue)); - + OnMediaLocation loc; + queryOnMediaLocation( _repository->resolvableQuery(), _id, cache::attrPackageLocation, loc ); return loc; } @@ -205,16 +193,6 @@ std::list PackageImpl::filenames() const return std::list(); } -// std::list PackageImpl::deltaRpms() const -// { -// return std::list(); -// } -// -// std::list PackageImpl::patchRpms() const -// { -// return std::list(); -// } - ///////////////////////////////////////////////////////////////// } } } // namespace zypp::repo::cached /////////////////////////////////////////////////////////////////// diff --git a/zypp/repo/cached/PatchImpl.cc b/zypp/repo/cached/PatchImpl.cc index 49e9d92..3d1cc69 100644 --- a/zypp/repo/cached/PatchImpl.cc +++ b/zypp/repo/cached/PatchImpl.cc @@ -99,11 +99,6 @@ Date PatchImpl::installtime() const return Date(); } -unsigned PatchImpl::mediaNr() const -{ - return 1; -} - ////////////////////////////////////////// // PATCH ///////////////////////////////////////// diff --git a/zypp/repo/cached/PatchImpl.h b/zypp/repo/cached/PatchImpl.h index c0bec9e..ac90d6b 100644 --- a/zypp/repo/cached/PatchImpl.h +++ b/zypp/repo/cached/PatchImpl.h @@ -30,7 +30,7 @@ namespace cached public: PatchImpl( const data::RecordId &id, repo::cached::RepoImpl::Ptr repository_r ); - + virtual TranslatedText summary() const; virtual TranslatedText description() const; virtual TranslatedText insnotify() const; @@ -41,9 +41,7 @@ namespace cached virtual bool installOnly() const; virtual Date buildtime() const; virtual Date installtime() const; - - virtual unsigned mediaNr() const; - + // PATCH virtual std::string id() const; virtual Date timestamp() const; @@ -52,9 +50,9 @@ namespace cached virtual bool affects_pkg_manager() const; virtual bool interactive() const; virtual AtomList all_atoms() const; - + virtual Repository repository() const; - + private: repo::cached::RepoImpl::Ptr _repository; data::RecordId _id; diff --git a/zypp/repo/cached/ScriptImpl.cc b/zypp/repo/cached/ScriptImpl.cc index bf327f3..3f5a797 100644 --- a/zypp/repo/cached/ScriptImpl.cc +++ b/zypp/repo/cached/ScriptImpl.cc @@ -96,32 +96,33 @@ Date ScriptImpl::installtime() const return Date(); } -unsigned ScriptImpl::mediaNr() const -{ - return 1; -} - ////////////////////////////////////////// -// MESSAGE +// SCRIPT ///////////////////////////////////////// -Pathname ScriptImpl::do_script() const +std::string ScriptImpl::doScriptInlined() const { return _repository->resolvableQuery().queryStringAttribute( _id, cache::attrScriptDoScript() ); } -Pathname ScriptImpl::undo_script() const +OnMediaLocation ScriptImpl::doScriptLocation() const { - return _repository->resolvableQuery().queryStringAttribute( _id, cache::attrScriptUndoScript() ); + OnMediaLocation loc; + queryOnMediaLocation( _repository->resolvableQuery(), _id, cache::attrScriptDoScriptLocation, loc ); + return loc; } -bool ScriptImpl::undo_available() const +std::string ScriptImpl::undoScriptInlined() const { -#warning DUBIOUS ATTRIBUTE - return false; - //return _repository->resolvableQuery().queryBooleanAttribute( _id, cache::attrScriptUndoAvailable(), false ); + return _repository->resolvableQuery().queryStringAttribute( _id, cache::attrScriptUndoScript() ); } +OnMediaLocation ScriptImpl::undoScriptLocation() const +{ + OnMediaLocation loc; + queryOnMediaLocation( _repository->resolvableQuery(), _id, cache::attrScriptUndoScriptLocation, loc ); + return loc; +} ///////////////////////////////////////////////////////////////// } } } // namespace zypp::repo::cached diff --git a/zypp/repo/cached/ScriptImpl.h b/zypp/repo/cached/ScriptImpl.h index c001881..b3e9b1b 100644 --- a/zypp/repo/cached/ScriptImpl.h +++ b/zypp/repo/cached/ScriptImpl.h @@ -30,7 +30,7 @@ namespace cached public: ScriptImpl( const data::RecordId &id, repo::cached::RepoImpl::Ptr repository_r ); - + virtual TranslatedText summary() const; virtual TranslatedText description() const; virtual TranslatedText insnotify() const; @@ -41,16 +41,15 @@ namespace cached virtual bool installOnly() const; virtual Date buildtime() const; virtual Date installtime() const; - - virtual unsigned mediaNr() const; - + // SCRIPT - virtual Pathname do_script() const; - virtual Pathname undo_script() const; - virtual bool undo_available() const; - + virtual std::string doScriptInlined() const; + virtual OnMediaLocation doScriptLocation() const; + virtual std::string undoScriptInlined() const; + virtual OnMediaLocation undoScriptLocation() const; + virtual Repository repository() const; - + private: repo::cached::RepoImpl::Ptr _repository; data::RecordId _id; diff --git a/zypp/repo/memory/ScriptImpl.cc b/zypp/repo/memory/ScriptImpl.cc index 391ba02..6f8866f 100644 --- a/zypp/repo/memory/ScriptImpl.cc +++ b/zypp/repo/memory/ScriptImpl.cc @@ -104,24 +104,10 @@ Date ScriptImpl::installtime() const } ////////////////////////////////////////// -// MESSAGE +// SCRIPT ///////////////////////////////////////// -Pathname ScriptImpl::do_script() const -{ - return Pathname(); -} -Pathname ScriptImpl::undo_script() const -{ - return Pathname(); -} - -bool ScriptImpl::undo_available() const -{ - return false; -} - ///////////////////////////////////////////////////////////////// } } } // namespace zypp::repo::memory diff --git a/zypp/repo/memory/ScriptImpl.h b/zypp/repo/memory/ScriptImpl.h index 1cb31eb..e75eb94 100644 --- a/zypp/repo/memory/ScriptImpl.h +++ b/zypp/repo/memory/ScriptImpl.h @@ -30,7 +30,7 @@ namespace memory public: ScriptImpl( memory::RepoImpl::Ptr repo, data::Script_Ptr ptr); - + virtual TranslatedText summary() const; virtual TranslatedText description() const; virtual TranslatedText insnotify() const; @@ -41,17 +41,14 @@ namespace memory virtual bool installOnly() const; virtual Date buildtime() const; virtual Date installtime() const; - - // SCRIPT - virtual Pathname do_script() const; - virtual Pathname undo_script() const; - virtual bool undo_available() const; - + + // SCRIPT: TODO script attr + virtual Repository repository() const; - + protected: repo::memory::RepoImpl::Ptr _repository; - + //ResObject TranslatedText _summary; TranslatedText _description; diff --git a/zypp/target/TargetImpl.cc b/zypp/target/TargetImpl.cc index 9f8ba72..06a70ca 100644 --- a/zypp/target/TargetImpl.cc +++ b/zypp/target/TargetImpl.cc @@ -44,6 +44,7 @@ #include "zypp/repo/DeltaCandidates.h" #include "zypp/repo/PackageProvider.h" +#include "zypp/repo/ScriptProvider.h" using namespace std; using namespace zypp; @@ -60,7 +61,9 @@ namespace zypp /////////////////////////////////////////////////////////////////// namespace { ///////////////////////////////////////////////////////////////// - void ExecuteScriptHelper( Script::constPtr script_r, bool do_r ) + void ExecuteScriptHelper( repo::RepoMediaAccess & access_r, + Script::constPtr script_r, + bool do_r ) { MIL << "Execute script " << script_r << endl; if ( ! script_r ) @@ -69,41 +72,32 @@ namespace zypp return; } - Pathname path; - if ( do_r ) - { - path = script_r->do_script(); - } - else + repo::ScriptProvider prov( access_r, script_r ); + ManagedFile localfile = prov.provideScript( do_r ); + + if ( localfile->empty() ) { - if ( script_r->undo_available() ) - { - path = script_r->undo_script(); - } - else - { - DBG << "No undo script for " << script_r << endl; - return; // success - } + DBG << "No " << (do_r?"do":"undo") << " script for " << script_r << endl; + return; // success } // Go... callback::SendReport report; - report->start( script_r, path, + report->start( script_r, localfile, (do_r ? ScriptResolvableReport::DO : ScriptResolvableReport::UNDO ) ); - PathInfo pi( path ); + PathInfo pi( localfile ); if ( ! pi.isFile() ) { std::ostringstream err; - err << "Script is not a file: " << pi.fileType() << " " << path; + err << "Script is not a file: " << pi.fileType() << " " << localfile; report->problem( err.str() ); ZYPP_THROW(Exception(err.str())); } - filesystem::chmod( path, S_IRUSR|S_IXUSR ); // "r-x------" - ExternalProgram prog( path.asString(), ExternalProgram::Stderr_To_Stdout, false, -1, true ); + filesystem::chmod( localfile, S_IRUSR|S_IXUSR ); // "r-x------" + ExternalProgram prog( localfile->asString(), ExternalProgram::Stderr_To_Stdout, false, -1, true ); for ( std::string output = prog.receiveLine(); output.length(); output = prog.receiveLine() ) { if ( ! report->progress( ScriptResolvableReport::OUTPUT, output ) ) @@ -126,14 +120,14 @@ namespace zypp return; } - inline void ExecuteDoScript( const Script::constPtr & script_r ) + inline void ExecuteDoScript( repo::RepoMediaAccess & access_r, const Script::constPtr & script_r ) { - ExecuteScriptHelper( script_r, true ); + ExecuteScriptHelper( access_r, script_r, true ); } - inline void ExecuteUndoScript( const Script::constPtr & script_r ) + inline void ExecuteUndoScript( repo::RepoMediaAccess & access_r, const Script::constPtr & script_r ) { - ExecuteScriptHelper( script_r, false ); + ExecuteScriptHelper( access_r, script_r, false ); } ///////////////////////////////////////////////////////////////// } // namespace @@ -221,7 +215,7 @@ namespace zypp } }; - /** + /** * \short Let the Source provide the package. * \p pool_r \ref ResPool used to get candidates * \p pi item to be commited @@ -234,29 +228,22 @@ namespace zypp RepoProvidePackage( repo::RepoMediaAccess &access, ResPool pool_r ) : _pool(pool_r), _access(access) { - + } - + ManagedFile operator()( const PoolItem & pi ) { // Redirect PackageProvider queries for installed editions // (in case of patch/delta rpm processing) to rpmDb. repo::PackageProviderPolicy packageProviderPolicy; packageProviderPolicy.queryInstalledCB( QueryInstalledEditionHelper() ); - + Package::constPtr p = asKind(pi.resolvable()); - - + + // Build a repository list for repos // contributing to the pool - std::list repos; - for ( ResPool::repository_iterator it = _pool.knownRepositoriesBegin(); - it != _pool.knownRepositoriesEnd(); - ++it ) - { - repos.push_back(*it); - } - + std::list repos( _pool.knownRepositoriesBegin(), _pool.knownRepositoriesEnd() ); repo::DeltaCandidates deltas(repos); repo::PackageProvider pkgProvider( _access, p, deltas, packageProviderPolicy ); return pkgProvider.providePackage(); @@ -657,7 +644,7 @@ namespace zypp } else if (isKind