Dont mark failed patch scripts as installed.
authorMichael Andres <ma@suse.de>
Mon, 5 Nov 2007 15:47:18 +0000 (15:47 +0000)
committerMichael Andres <ma@suse.de>
Mon, 5 Nov 2007 15:47:18 +0000 (15:47 +0000)
VERSION.cmake
package/libzypp.changes
zypp/target/TargetImpl.cc
zypp/target/store/XMLFilesBackend.cc

index 931e812..7daae73 100644 (file)
@@ -47,4 +47,4 @@
 SET(LIBZYPP_MAJOR "4")
 SET(LIBZYPP_MINOR "1")
 SET(LIBZYPP_COMPATMINOR "1")
-SET(LIBZYPP_PATCH "1")
+SET(LIBZYPP_PATCH "2")
index 3dec853..d873605 100644 (file)
@@ -1,4 +1,11 @@
 -------------------------------------------------------------------
+Mon Nov  5 15:22:33 CET 2007 - ma@suse.de
+
+- Don't mark failed patch scripts as installed. (#327523)
+- version 4.1.2
+- revision 7744
+
+-------------------------------------------------------------------
 Fri Oct 26 15:12:24 CEST 2007 - aschnell@suse.de
 
 - fixed retrieval of epoch from rpmdb (bug #246680)
index 85e2d46..9776e4a 100644 (file)
@@ -65,7 +65,8 @@ namespace zypp
     { /////////////////////////////////////////////////////////////////
       void ExecuteScriptHelper( repo::RepoMediaAccess & access_r,
                                 Script::constPtr script_r,
-                                bool do_r )
+                                bool do_r,
+                                storage::PersistentStorage & storage_r )
       {
         MIL << "Execute script " << script_r << endl;
         if ( ! script_r )
@@ -98,7 +99,7 @@ namespace zypp
           ZYPP_THROW(Exception(err.str()));
         }
 
-        filesystem::chmod( localfile, S_IRUSR|S_IXUSR );       // "r-x------"
+        filesystem::chmod( localfile, S_IRUSR|S_IWUSR|S_IXUSR );       // "rwx------"
         ExternalProgram prog( localfile->asString(), ExternalProgram::Stderr_To_Stdout, false, -1, true );
         for ( std::string output = prog.receiveLine(); output.length(); output = prog.receiveLine() )
         {
@@ -112,24 +113,31 @@ namespace zypp
         int exitCode = prog.close();
         if ( exitCode != 0 )
         {
+          storage_r.setObjectFlag( script_r, "SCRIPT_EXEC_FAILED" );
           std::ostringstream err;
           err << "Script failed with exit code " << exitCode;
           report->problem( err.str() );
           ZYPP_THROW(Exception(err.str()));
         }
+        else if ( storage_r.doesObjectHasFlag( script_r, "SCRIPT_EXEC_FAILED" ) )
+        {
+          storage_r.removeObjectFlag( script_r, "SCRIPT_EXEC_FAILED" );
+        }
 
         report->finish();
         return;
       }
 
-      inline void ExecuteDoScript( repo::RepoMediaAccess & access_r, const Script::constPtr & script_r )
+      inline void ExecuteDoScript( repo::RepoMediaAccess & access_r, const Script::constPtr & script_r,
+                                   storage::PersistentStorage & storage_r )
       {
-        ExecuteScriptHelper( access_r, script_r, true );
+        ExecuteScriptHelper( access_r, script_r, true, storage_r );
       }
 
-      inline void ExecuteUndoScript( repo::RepoMediaAccess & access_r, const Script::constPtr & script_r )
+      inline void ExecuteUndoScript( repo::RepoMediaAccess & access_r, const Script::constPtr & script_r,
+                                     storage::PersistentStorage & storage_r )
       {
-        ExecuteScriptHelper( access_r, script_r, false );
+        ExecuteScriptHelper( access_r, script_r, false, storage_r );
       }
       /////////////////////////////////////////////////////////////////
     } // namespace
@@ -619,7 +627,7 @@ namespace zypp
                 }
                 else if (isKind<Script>(it->resolvable()))
                 {
-                  ExecuteDoScript( access, asKind<Script>(it->resolvable()) );
+                  ExecuteDoScript( access, asKind<Script>(it->resolvable()), _storage );
                 }
                 else if (!isKind<Atom>(it->resolvable()))      // atoms are re-created from the patch data, no need to save them
                 {
@@ -662,7 +670,7 @@ namespace zypp
                 }
                 else if (isKind<Script>(it->resolvable()))
                 {
-                  ExecuteUndoScript( access, asKind<Script>(it->resolvable()) );
+                  ExecuteUndoScript( access, asKind<Script>(it->resolvable()), _storage );
                 }
                 else
                 {
index 2615ae7..75e5ba0 100644 (file)
@@ -174,7 +174,7 @@ XMLFilesBackend::XMLFilesBackend(const Pathname &root) : Backend(root)
   d->kinds_flags.insert(ResTraits<zypp::Package>::kind);
   d->kinds_flags.insert(ResTraits<zypp::Patch>::kind);
   //d->kinds.insert(ResTraits<zypp::Message>::kind);
-  //d->kinds.insert(ResTraits<zypp::Script>::kind);
+  d->kinds_flags.insert(ResTraits<zypp::Script>::kind);
   d->kinds_flags.insert(ResTraits<zypp::Selection>::kind);
   d->kinds_flags.insert(ResTraits<zypp::Product>::kind);
   d->kinds_flags.insert(ResTraits<zypp::Pattern>::kind);
@@ -832,7 +832,12 @@ XMLFilesBackend::createPatch( const zypp::parser::xmlstore::XMLPatchData & parse
         {
           XMLPatchScriptData_Ptr script_data = dynamic_pointer_cast<XMLPatchScriptData>(*it);
           atom = createScript(*script_data);
-          impl->_atoms.push_back(atom);
+          if ( doesObjectHasFlag( atom, "SCRIPT_EXEC_FAILED" ) )
+          {
+            WAR << "Patch script not yet successfully executed: " << atom << endl;
+          } else {
+            impl->_atoms.push_back(atom);
+          }
           break;
         }
         default: