- Fixed wrong media number reported by script, message and patch.
authorMichael Andres <ma@suse.de>
Mon, 30 Jul 2007 12:58:10 +0000 (12:58 +0000)
committerMichael Andres <ma@suse.de>
Mon, 30 Jul 2007 12:58:10 +0000 (12:58 +0000)
- Fixed script API to provide the scripts location on media (if not
  inlined).
- Introduced ScripProvider to make a script available on the local
  disk.

32 files changed:
VERSION.cmake
zypp/CMakeLists.txt
zypp/Script.cc
zypp/Script.h
zypp/cache/CacheAttributes.h
zypp/cache/CacheStore.cc
zypp/cache/ResolvableQuery.h
zypp/detail/ScriptImpl.cc
zypp/detail/ScriptImpl.h
zypp/detail/ScriptImplIf.cc
zypp/detail/ScriptImplIf.h
zypp/parser/xmlstore/XMLParserData.h
zypp/parser/xmlstore/XMLPatchParser.cc
zypp/repo/RepoProvideFile.h
zypp/repo/ScriptProvider.cc [new file with mode: 0644]
zypp/repo/ScriptProvider.h [new file with mode: 0644]
zypp/repo/cached/AtomImpl.cc
zypp/repo/cached/AtomImpl.h
zypp/repo/cached/MessageImpl.cc
zypp/repo/cached/MessageImpl.h
zypp/repo/cached/PackageImpl.cc
zypp/repo/cached/PatchImpl.cc
zypp/repo/cached/PatchImpl.h
zypp/repo/cached/ScriptImpl.cc
zypp/repo/cached/ScriptImpl.h
zypp/repo/memory/ScriptImpl.cc
zypp/repo/memory/ScriptImpl.h
zypp/target/TargetImpl.cc
zypp/target/store/XMLFilesBackend.cc
zypp/target/store/serialize.cc
zypp/target/store/xml/XMLScriptImpl.cc
zypp/target/store/xml/XMLScriptImpl.h

index 8eabf11..5c9ee28 100644 (file)
@@ -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")
index 2c26fb3..48fc97a 100644 (file)
@@ -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
index eba4fc1..560f54f 100644 (file)
@@ -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
index 0529b6d..6610440 100644 (file)
@@ -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 */
index 3020716..087cb92 100644 (file)
 
 #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; } \
index 4e62af9..cedffdc 100644 (file)
@@ -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)
index 3985381..e3e8b15 100644 (file)
 #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
 { /////////////////////////////////////////////////////////////////
index ba871bc..c81ba66 100644 (file)
@@ -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
index 4ff4593..f87e294 100644 (file)
@@ -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;
     };
     ///////////////////////////////////////////////////////////////////
 
index d17c619..548d2e2 100644 (file)
@@ -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
index 6e5fbf1..eccf18a 100644 (file)
@@ -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;
     };
     ///////////////////////////////////////////////////////////////////
 
index c18db0d..54b2fc9 100644 (file)
@@ -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
index eef723e..96209ca 100644 (file)
@@ -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);
             }
           }
         }
index f5a0bbb..a7f0ace 100644 (file)
@@ -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> _impl;
-      
+
     };
-    
+
     /////////////////////////////////////////////////////////////////
   } // namespace repo
   ///////////////////////////////////////////////////////////////////
diff --git a/zypp/repo/ScriptProvider.cc b/zypp/repo/ScriptProvider.cc
new file mode 100644 (file)
index 0000000..5d5b35d
--- /dev/null
@@ -0,0 +1,79 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+\---------------------------------------------------------------------*/
+/** \file      zypp/repo/ScriptProvider.cc
+ *
+*/
+#include <iostream>
+//#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 (file)
index 0000000..824f063
--- /dev/null
@@ -0,0 +1,76 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+\---------------------------------------------------------------------*/
+/** \file      zypp/repo/ScriptProvider.h
+ *
+*/
+#ifndef ZYPP_REPO_SCRIPTPROVIDER_H
+#define ZYPP_REPO_SCRIPTPROVIDER_H
+
+#include <iosfwd>
+
+#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<Impl> _pimpl;
+    };
+    ///////////////////////////////////////////////////////////////////
+
+    /////////////////////////////////////////////////////////////////
+  } // namespace repo
+  ///////////////////////////////////////////////////////////////////
+  /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
+#endif // ZYPP_REPO_SCRIPTPROVIDER_H
index fb07ca4..289c0e8 100644 (file)
@@ -94,11 +94,6 @@ Date AtomImpl::installtime() const
   return Date();
 }
 
-unsigned AtomImpl::mediaNr() const
-{
-  return 1;
-}
-
 /////////////////////////////////////////////////////////////////
 } } } // namespace zypp::repo::cached
 ///////////////////////////////////////////////////////////////////
index 4a0a093..91281b5 100644 (file)
@@ -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;
index af58c20..f6c08de 100644 (file)
@@ -96,11 +96,6 @@ Date MessageImpl::installtime() const
   return Date();
 }
 
-unsigned MessageImpl::mediaNr() const
-{
-  return 1;
-}
-
 //////////////////////////////////////////
 // MESSAGE
 /////////////////////////////////////////
index ff7aee9..b11af0d 100644 (file)
@@ -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;
index 4ef6837..0efe802 100644 (file)
@@ -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<std::string> PackageImpl::filenames() const
   return std::list<std::string>();
 }
 
-// std::list<DeltaRpm> PackageImpl::deltaRpms() const
-// {
-// return std::list<DeltaRpm>();
-// }
-//
-// std::list<PatchRpm> PackageImpl::patchRpms() const
-// {
-//   return std::list<PatchRpm>();
-// }
-
 /////////////////////////////////////////////////////////////////
 } } } // namespace zypp::repo::cached
 ///////////////////////////////////////////////////////////////////
index 49e9d92..3d1cc69 100644 (file)
@@ -99,11 +99,6 @@ Date PatchImpl::installtime() const
   return Date();
 }
 
-unsigned PatchImpl::mediaNr() const
-{
-  return 1;
-}
-
 //////////////////////////////////////////
 // PATCH
 /////////////////////////////////////////
index c0bec9e..ac90d6b 100644 (file)
@@ -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;
index bf327f3..3f5a797 100644 (file)
@@ -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
index c001881..b3e9b1b 100644 (file)
@@ -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;
index 391ba02..6f8866f 100644 (file)
@@ -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
index 1cb31eb..e75eb94 100644 (file)
@@ -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;
index 9f8ba72..06a70ca 100644 (file)
@@ -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<ScriptResolvableReport> 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<Package>(pi.resolvable());
-        
-        
+
+
         // Build a repository list for repos
         // contributing to the pool
-        std::list<Repository> repos;
-        for ( ResPool::repository_iterator it = _pool.knownRepositoriesBegin();
-              it != _pool.knownRepositoriesEnd();
-              ++it )
-        {
-          repos.push_back(*it);
-        }
-  
+        std::list<Repository> 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<Script>(it->resolvable()))
                 {
-                  ExecuteDoScript( asKind<Script>(it->resolvable()) );
+                  ExecuteDoScript( access, asKind<Script>(it->resolvable()) );
                 }
                 else if (!isKind<Atom>(it->resolvable()))      // atoms are re-created from the patch data, no need to save them
                 {
@@ -700,7 +687,7 @@ namespace zypp
                 }
                 else if (isKind<Script>(it->resolvable()))
                 {
-                  ExecuteUndoScript( asKind<Script>(it->resolvable()) );
+                  ExecuteUndoScript( access, asKind<Script>(it->resolvable()) );
                 }
                 else
                 {
index 98fa7de..2d07868 100644 (file)
@@ -71,7 +71,7 @@ namespace storage
 
 /**
  * the following hardcoded table fixes a bug where Product was
- *  serialized to the store using distproduct and distversion 
+ *  serialized to the store using distproduct and distversion
  *  in the name/version fields.
  *  Those products have missing distversion.
  *  The trick is to see the version of the xml format, if it is
@@ -90,8 +90,8 @@ struct PRODUCT_TABLE_ENTRY
 };
 
 /**
- * create the map on demand so we 
- * create it once and only when 
+ * create the map on demand so we
+ * create it once and only when
  * needed
  */
 PRODUCT_TABLE_ENTRY* products_table()
@@ -128,7 +128,7 @@ PRODUCT_TABLE_ENTRY* products_table()
     { "SUSE-Linux-Enterprise-RT", "10-0", "SLE RT", "10" },
     { 0L, 0L, 0L, 0L }
   };
-  
+
   return products;
 }
 
@@ -756,7 +756,7 @@ XMLFilesBackend::storedObjects(const Resolvable::Kind kind) const
 
   list<string> files;
   filesystem::readdir( files, dir_path, false /* ignore hidden .name files */ );
-  
+
   for ( list<string>::const_iterator it = files.begin(); it != files.end(); ++it )
   {
     Pathname curr_file = dir_path + (*it);
@@ -766,7 +766,7 @@ XMLFilesBackend::storedObjects(const Resolvable::Kind kind) const
     for ( std::list<ResObject::Ptr>::iterator it = objects_for_file.begin(); it != objects_for_file.end(); ++it)
       objects.push_back(*it);
   }
-  
+
   MIL << "done reading " <<  objects.size() << " stored objects for file of kind " << resolvableKindToString(kind) << std::endl;
   return objects;
 }
@@ -958,21 +958,8 @@ XMLFilesBackend::createScript(const zypp::parser::xmlstore::XMLPatchScriptData &
   {
     detail::ResImplTraits<XMLScriptImpl>::Ptr impl(new XMLScriptImpl());
 
-    ofstream file;
-    file.open(impl->_do_script->path().asString().c_str());
-
-    if ( ! file )
-      ZYPP_THROW(Exception(N_("Cannot create a file needed to perform update installation.")));
-
-    file << parsed.do_script;;
-    file.close();
-
-    file.open(impl->_undo_script->path().asString().c_str());
-    if ( ! file )
-      ZYPP_THROW(Exception(N_("Cannot create a file needed to perform update installation.")));
-
-    file << parsed.undo_script;;
-    file.close();
+    impl->_doScript = parsed.doScript;
+    impl->_undoScript = parsed.undoScript;
 
     Arch arch;
     if (!parsed.arch.empty())
@@ -1030,9 +1017,9 @@ XMLFilesBackend::createProduct( const zypp::parser::xmlstore::XMLProductData & p
   try
   {
     detail::ResImplTraits<XMLProductImpl>::Ptr impl(new XMLProductImpl());
-    
+
     Edition parser_edition = ( parsed.parser_version.empty() ? Edition::noedition : Edition(parsed.parser_version) );
-    
+
     impl->_summary = parsed.summary;
     impl->_description = parsed.summary;
 
@@ -1067,7 +1054,7 @@ XMLFilesBackend::createProduct( const zypp::parser::xmlstore::XMLProductData & p
       catch ( const Exception &e )
       {
         ZYPP_THROW(Exception("Error parsing update url: " + e.msg()));
-      }      
+      }
     }
 
     // extra_urls
@@ -1082,9 +1069,9 @@ XMLFilesBackend::createProduct( const zypp::parser::xmlstore::XMLProductData & p
       catch ( const Exception &e )
       {
         ZYPP_THROW(Exception("Error parsing extra url: " + e.msg()));
-      }      
+      }
     }
-    
+
     // extra_urls
     list<string> optional_urls = parsed.optional_urls;
     for ( list<string>::const_iterator it = optional_urls.begin(); it != optional_urls.end(); ++it )
@@ -1097,9 +1084,9 @@ XMLFilesBackend::createProduct( const zypp::parser::xmlstore::XMLProductData & p
       catch ( const Exception &e )
       {
         ZYPP_THROW(Exception("Error parsing optional url: " + e.msg()));
-      }      
+      }
     }
-    
+
     impl->_flags = parsed.flags;
 
     Arch arch;
@@ -1121,19 +1108,19 @@ XMLFilesBackend::createProduct( const zypp::parser::xmlstore::XMLProductData & p
         if ( ( parsed.name == all_products->dist_name ) && ( prod_edition.asString() == all_products->dist_version ) )
         {
           MIL << "[ATTENTION] Detected bug #205392. Product " << parsed.name << " " << prod_edition << " will be changed to " << all_products->product_name << " " << all_products->product_version << std::endl;
-          
+
           // save pathname of the old wrong product
           Pathname wrong_product = Pathname(dirForResolvableKind(ResTraits<zypp::Product>::kind)) + fileNameForNVR( NVR( parsed.name, prod_edition) );
-          
+
           // ok, potentially this is a wrong product, well, IT IS!
           // overwrte those here as they are used in dataCollect
           prod_name = string(all_products->product_name);
           prod_edition = Edition(all_products->product_version);
-          
+
           // those were already set, so reset them.
           impl->_dist_name = all_products->dist_name;
           impl->_dist_version = Edition(all_products->dist_version);
-          
+
           // ok, now mark for save this product and delete the old one
           deleteFileObject( wrong_product );
           MIL << "Fix for bug #205392 Old product deleted." << std::endl;
@@ -1142,22 +1129,22 @@ XMLFilesBackend::createProduct( const zypp::parser::xmlstore::XMLProductData & p
         }
         ++all_products;
       }
-      
+
     }
-    
+
     // replace spaces to underscores
     std::replace(prod_name.begin(), prod_name.end(), ' ', '_');
-    
+
     // Collect basic Resolvable data
     NVRAD dataCollect( prod_name, prod_edition, arch, createDependencies(parsed, ResTraits<Product>::kind) );
     Product::Ptr product = detail::makeResolvableFromImpl( dataCollect, impl );
-    
+
     if ( save_new_product_again_workaround )
     {
       const_cast<XMLFilesBackend *>(this)->storeObject(product);
       MIL << "Fixed Product saved. Fix for bug #205392. complete" << std::endl;
     }
-    
+
     return product;
   }
   catch (const Exception & excpt_r)
index 089a223..5d86f77 100644 (file)
 #include "zypp/detail/ImplConnect.h"
 #include "zypp/detail/ResObjectImplIf.h"
 #include "zypp/detail/SelectionImplIf.h"
+#include "zypp/repo/ScriptProvider.h"
 
 #include "serialize.h"
+
 #include "xml_escape_parser.hpp"
 
 using namespace std;
@@ -34,6 +36,18 @@ namespace zypp
 namespace storage
 { /////////////////////////////////////////////////////////////////
 
+static void copyFileToStream( const Pathname & file_r, std::ostream & out_r )
+{
+  std::ifstream infile( file_r.c_str() );
+  while (infile.good())
+  {
+    char c = (char)infile.get();
+    if (! infile.eof())
+      out_r << c;
+  }
+  infile.close();
+}
+
 static string xml_escape( const string &text )
 {
   iobind::parser::xml_escape_parser parser;
@@ -89,7 +103,7 @@ static string translatedTextToXML(const TranslatedText &text, const string &tagn
 template<class T>
 string toXML( const T &obj ); //undefined
 
-template<> 
+template<>
 string toXML( const Edition &edition )
 {
   stringstream out;
@@ -98,7 +112,7 @@ string toXML( const Edition &edition )
   return out.str();
 }
 
-template<> 
+template<>
 string toXML( const Arch &arch )
 {
   stringstream out;
@@ -106,7 +120,7 @@ string toXML( const Arch &arch )
   return out.str();
 }
 
-template<> 
+template<>
 string toXML( const Capability &cap )
 {
   stringstream out;
@@ -116,7 +130,7 @@ string toXML( const Capability &cap )
   return out.str();
 }
 
-template<> 
+template<>
 string toXML( const CapSet &caps )
 {
   stringstream out;
@@ -128,7 +142,7 @@ string toXML( const CapSet &caps )
   return out.str();
 }
 
-template<> 
+template<>
 string toXML( const Dependencies &dep )
 {
   stringstream out;
@@ -144,7 +158,7 @@ string toXML( const Dependencies &dep )
   if ( dep[Dep::FRESHENS].size() > 0 )
     out << "    " << xml_tag_enclose(toXML(dep[Dep::FRESHENS]), "freshens") << endl;
   if ( dep[Dep::REQUIRES].size() > 0 )
-    out << "    " << xml_tag_enclose(toXML(dep[Dep::REQUIRES]), "requires") << endl;  
+    out << "    " << xml_tag_enclose(toXML(dep[Dep::REQUIRES]), "requires") << endl;
   if ( dep[Dep::RECOMMENDS].size() > 0 )
     out << "    " << xml_tag_enclose(toXML(dep[Dep::RECOMMENDS]), "recommends") << endl;
   if ( dep[Dep::ENHANCES].size() > 0 )
@@ -157,7 +171,7 @@ string toXML( const Dependencies &dep )
 
 }
 
-template<> 
+template<>
 string toXML( const Resolvable::constPtr &obj )
 {
   stringstream out;
@@ -170,7 +184,7 @@ string toXML( const Resolvable::constPtr &obj )
   return out.str();
 }
 
-template<> 
+template<>
 string toXML( const ResObject::constPtr &obj )
 {
   stringstream out;
@@ -179,7 +193,7 @@ string toXML( const ResObject::constPtr &obj )
   detail::ResImplTraits<ResObject::Impl>::constPtr pipp( detail::ImplConnect::resimpl( obj ) );
   out << translatedTextToXML(pipp->summary(), "summary");
   out << translatedTextToXML(pipp->description(), "description");
-  
+
   out << translatedTextToXML(pipp->insnotify(), "install-notify");
   out << translatedTextToXML(pipp->delnotify(), "delete-notify");
   //out << "  <license-to-confirm>" << xml_escape(obj->licenseToConfirm()) << "</license-to-confirm>" << endl;
@@ -191,11 +205,11 @@ string toXML( const ResObject::constPtr &obj )
   out << "  <build-time>" << obj->buildtime().asSeconds()  << "</build-time>" << endl;
   // we assume we serialize on storeObject, set install time to NOW
   out << "  <install-time>" << Date::now().asSeconds() << "</install-time>" << endl;
-  
+
   return out.str();
 }
 
-template<> 
+template<>
 string toXML( const Package::constPtr &obj )
 {
   stringstream out;
@@ -203,14 +217,11 @@ string toXML( const Package::constPtr &obj )
   // reuse Resolvable information serialize function
   out << toXML(static_cast<Resolvable::constPtr>(obj));
   out << toXML(static_cast<ResObject::constPtr>(obj));
-  //out << "  <do>" << endl;
-  //out << "      " << obj->do_script() << endl;
-  //out << "  </do>" << endl;
   out << "</package>" << endl;
   return out.str();
 }
 
-template<> 
+template<>
 string toXML( const Script::constPtr &obj )
 {
   stringstream out;
@@ -218,38 +229,21 @@ string toXML( const Script::constPtr &obj )
   // reuse Resolvable information serialize function
   out << toXML(static_cast<Resolvable::constPtr>(obj));
   out << toXML(static_cast<ResObject::constPtr>(obj));
+
+  repo::RepoMediaAccess access;
+  repo::ScriptProvider prov( access, obj );
+
   out << "  <do>" << endl;
   out << "  <![CDATA[" << endl;
-  
-  // read script
-  ifstream infile;
-  infile.open(obj->do_script().asString().c_str());
-  while (infile.good())
-  {
-    char c = (char)infile.get();
-    if (! infile.eof())
-      out << c;
-  }
-  infile.close();
-  
+  copyFileToStream( prov.provideDoScript(), out );
   out << "  ]]>" << endl;
   out << "  </do>" << endl;
 
-  if ( obj->undo_available() )
+  if ( obj->undoAvailable() )
   {
     out << "  <undo>" << endl;
     out << "  <![CDATA[" << endl;
-  
-  // read script
-    infile.open(obj->undo_script().asString().c_str());
-    while (infile.good())
-    {
-      char c = (char)infile.get();
-      if (! infile.eof())
-       out << c;
-    }
-    infile.close();
-  
+    copyFileToStream( prov.provideUndoScript(), out );
     out << "  ]]>" << endl;
     out << "  </undo>" << endl;
 
@@ -258,7 +252,7 @@ string toXML( const Script::constPtr &obj )
   return out.str();
 }
 
-template<> 
+template<>
 string toXML( const Message::constPtr &obj )
 {
   stringstream out;
@@ -271,7 +265,7 @@ string toXML( const Message::constPtr &obj )
   return out.str();
 }
 
-template<> 
+template<>
 string toXML( const Language::constPtr &obj )
 {
   stringstream out;
@@ -284,16 +278,16 @@ string toXML( const Language::constPtr &obj )
 }
 
 
-template<> 
+template<>
 string toXML( const Selection::constPtr &obj )
 {
   stringstream out;
   out << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" << endl;
   out << "<pattern version=\"" << SERIALIZER_VERSION << "\" xmlns=\"http://www.novell.com/metadata/zypp/xml-store\">" << endl;
-  
+
   out << toXML(static_cast<Resolvable::constPtr>(obj)) << endl;
   out << toXML(static_cast<ResObject::constPtr>(obj));
-  
+
   //out << "  <default>" << (obj->isDefault() ? "true" : "false" ) << "</default>" << endl;
   out << "  <uservisible>" << (obj->visible() ? "true" : "false" ) << "</uservisible>" << endl;
   out << "  <category>" << xml_escape(obj->category()) << "</category>" << endl;
@@ -302,7 +296,7 @@ string toXML( const Selection::constPtr &obj )
   return out.str();
 }
 
-template<> 
+template<>
 string toXML( const Atom::constPtr &obj )
 {
   stringstream out;
@@ -313,7 +307,7 @@ string toXML( const Atom::constPtr &obj )
   return out.str();
 }
 
-template<> 
+template<>
 string toXML( const Pattern::constPtr &obj )
 {
   stringstream out;
@@ -322,7 +316,7 @@ string toXML( const Pattern::constPtr &obj )
 
   out << toXML(static_cast<Resolvable::constPtr>(obj)) << endl;
   out << toXML(static_cast<ResObject::constPtr>(obj));
-  
+
   out << "  <default>" << (obj->isDefault() ? "true" : "false" ) << "</default>" << endl;
   out << "  <uservisible>" << (obj->userVisible() ? "true" : "false" ) << "</uservisible>" << endl;
   out << "  <category>" << xml_escape(obj->category()) << "</category>" << endl;
@@ -332,7 +326,7 @@ string toXML( const Pattern::constPtr &obj )
   return out.str();
 }
 
-template<> 
+template<>
 string toXML( const Product::constPtr &obj )
 {
   stringstream out;
@@ -340,50 +334,50 @@ string toXML( const Product::constPtr &obj )
   out << "<product version=\"" << SERIALIZER_VERSION << "\" xmlns=\"http://www.novell.com/metadata/zypp/xml-store\" type=\"" << xml_escape(obj->category()) << "\">" << endl;
   out << toXML(static_cast<Resolvable::constPtr>(obj)) << endl;
   #warning "FIXME description and displayname of products"
-  
+
   out << toXML(static_cast<ResObject::constPtr>(obj));
-  
+
   // access implementation
   detail::ResImplTraits<Product::Impl>::constPtr pipp( detail::ImplConnect::resimpl( obj ) );
   out << translatedTextToXML(pipp->shortName(), "shortname");
-  
+
   out << "  <distribution-name>" << xml_escape(obj->distributionName()) << "</distribution-name>" << endl;
   out << "  <distribution-edition>" << xml_escape(obj->distributionEdition().asString()) << "</distribution-edition>" << endl;
-  out << "  <source>" << xml_escape(obj->repository().info().alias()) << "</source>" << endl;  
+  out << "  <source>" << xml_escape(obj->repository().info().alias()) << "</source>" << endl;
   out << "  <release-notes-url>" << xml_escape(obj->releaseNotesUrl().asString()) << "</release-notes-url>" << endl;
-  
+
   out << "  <update-urls>" << endl;
   list<Url> updateUrls = obj->updateUrls();
   for ( list<Url>::const_iterator it = updateUrls.begin(); it != updateUrls.end(); ++it)
   {
-    out << "    <update-url>" << xml_escape(it->asString()) << "</update-url>" << endl; 
+    out << "    <update-url>" << xml_escape(it->asString()) << "</update-url>" << endl;
   }
   out << "  </update-urls>" << endl;
-  
+
   out << "  <extra-urls>" << endl;
   list<Url> extraUrls = obj->extraUrls();
   for ( list<Url>::const_iterator it = extraUrls.begin(); it != extraUrls.end(); ++it)
   {
-    out << "    <extra-url>" << xml_escape(it->asString()) << "</extra-url>" << endl; 
+    out << "    <extra-url>" << xml_escape(it->asString()) << "</extra-url>" << endl;
   }
   out << "  </extra-urls>" << endl;
-  
+
   out << "  <optional-urls>" << endl;
   list<Url> optionalUrls = obj->optionalUrls();
   for ( list<Url>::const_iterator it = optionalUrls.begin(); it != optionalUrls.end(); ++it)
   {
-    out << "    <optional-url>" << xml_escape(it->asString()) << "</optional-url>" << endl; 
+    out << "    <optional-url>" << xml_escape(it->asString()) << "</optional-url>" << endl;
   }
   out << "  </optional-urls>" << endl;
-  
+
   out << "  <product-flags>" << endl;
   list<string> flags = obj->flags();
   for ( list<string>::const_iterator it = flags.begin(); it != flags.end(); ++it)
   {
-    out << "    <product-flag>" << xml_escape(*it) << "</product-flag>" << endl; 
+    out << "    <product-flag>" << xml_escape(*it) << "</product-flag>" << endl;
   }
   out << "  </product-flags>" << endl;
-  
+
   out << "</product>" << endl;
 
   return out.str();
@@ -428,24 +422,24 @@ string resolvableKindToString( const Resolvable::Kind &kind, bool plural)
     return k + (plural?"s":"");
 }
 
-template<> 
+template<>
 string toXML( const Patch::constPtr &obj )
 {
   stringstream out;
   out << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" << endl;
-  out << "<patch version=\"" << SERIALIZER_VERSION << "\" xmlns=\"http://www.novell.com/metadata/zypp/xml-store\">" << endl; 
-  
+  out << "<patch version=\"" << SERIALIZER_VERSION << "\" xmlns=\"http://www.novell.com/metadata/zypp/xml-store\">" << endl;
+
   // reuse Resolvable information serialize function
   out << toXML(static_cast<Resolvable::constPtr>(obj));
   out << toXML(static_cast<ResObject::constPtr>(obj));
-  
+
   out << "<id>" << xml_escape(obj->id()) << "</id>" << endl;
   out << "<timestamp>" << obj->timestamp().asSeconds() << "</timestamp>" << endl;
-  
+
   out << "<category>" << obj->category() << "</category>" << endl;
   out << "<affects-package-manager>" << ( obj->affects_pkg_manager() ? "true" : "false" ) << "</affects-package-manager>" << endl;
   out << "<reboot-needed>" << ( obj->reboot_needed() ? "true" : "false" ) << "</reboot-needed>" << endl;
-  
+
   Patch::AtomList at = obj->atoms();
   out << "  <atoms>" << endl;
   for (Patch::AtomList::iterator it = at.begin(); it != at.end(); it++)
index 1010a17..1f9493f 100644 (file)
@@ -29,26 +29,17 @@ namespace zypp
 
     /** Default ctor */
     XMLScriptImpl::XMLScriptImpl()
-    {
-      _do_script.reset( new TmpFile( TmpPath::defaultLocation(), "zypp-xmlstore-do-script-") );
-      _undo_script.reset( new TmpFile( TmpPath::defaultLocation(), "zypp-xmlstore-undo-script-"));
-    }
-    
+    {}
+
     /** Dtor */
     XMLScriptImpl::~XMLScriptImpl()
     {}
 
-    Pathname XMLScriptImpl::do_script() const {
-      return _do_script->path();
-    }
-
-    Pathname XMLScriptImpl::undo_script() const {
-        return _undo_script->path();
-    }
+    std::string XMLScriptImpl::doScriptInlined() const
+    { return _doScript; }
 
-    bool XMLScriptImpl::undo_available() const {
-      return *_undo_script != "";
-    }
+    std::string XMLScriptImpl::undoScriptInlined() const
+    { return _undoScript; }
 
     /////////////////////////////////////////////////////////////////
   } // namespace detail
index ef22772..29ffc65 100644 (file)
@@ -41,39 +41,30 @@ namespace zypp
       virtual TranslatedText description() const
       { return _description; }
       virtual TranslatedText insnotify() const
-      { return _install_notify; }    
+      { return _install_notify; }
       virtual TranslatedText delnotify() const
-      { return _delete_notify; }    
+      { return _delete_notify; }
       virtual TranslatedText licenseToConfirm() const
-      { return _license_to_confirm; }    
+      { return _license_to_confirm; }
       virtual Vendor vendor() const
-      { return _vendor; }    
+      { return _vendor; }
       virtual ByteCount size() const
-      { return _size; }    
+      { return _size; }
       virtual ByteCount downloadSize() const
-      { return _downloadSize; }    
-      virtual unsigned sourceMediaNr() const
-      { return 0; }    
+      { return _downloadSize; }
       virtual bool installOnly() const
-      { return _install_only; }    
+      { return _install_only; }
       virtual Date buildtime() const
-      { return _build_time; }    
+      { return _build_time; }
       virtual Date installtime() const
-      { return _install_time; }    
-      
-      /** 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;
-      
-      mutable shared_ptr<filesystem::TmpFile> _do_script;
-      mutable shared_ptr<filesystem::TmpFile> _undo_script;      
+      { return _install_time; }
+
+      virtual std::string doScriptInlined() const;
+      virtual std::string undoScriptInlined() const;
 
       TranslatedText _summary;
       TranslatedText _description;
-      
+
       TranslatedText _install_notify;
       TranslatedText _delete_notify;
       TranslatedText _license_to_confirm;
@@ -83,8 +74,10 @@ namespace zypp
       bool _install_only;
       Date _build_time;
       Date _install_time;
-      
-    };
+
+      std::string _doScript;
+      std::string _undoScript;
+   };
     ///////////////////////////////////////////////////////////////////
 
     /////////////////////////////////////////////////////////////////