Yes, there are syntax errors that yield logic errors..  These are fixed a 
few patches later.

This change adds the following behaviour:
* When running hooks forward, keep track of the last hook that ran sucessfully.
* If a hook fails with an unrecognized error code when running hooks forwards,
  do not run the rest of the hooks.
* When running hooks backwards, skip over hooks we did not run when we ran
  the hooks in normal order.

All these changes are implemented at the run_hooks level.  No other code is
involved.
---
 pm/pm-functions.in |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/pm/pm-functions.in b/pm/pm-functions.in
index 2966baf..4fa1ad1 100644
--- a/pm/pm-functions.in
+++ b/pm/pm-functions.in
@@ -140,6 +140,8 @@ run_hooks() {
        for base in $(IFS="${oifs}"; for f in "$syshooks/"*[!~] "$phooks/"*[!~];
                do [ -O "$f" ] && echo ${f##*/} ; done | $sort | uniq) ;
        do
+               # Skip any hooks we did not run when running going forward. 
+               [ "$3" -a "$LAST_HOOK" -a "$base" > "$LAST_HOOK" ] && continue
                if [ -f "$syshooks/$base" ]; then
                        hook="$syshooks/$base"
                elif [ -f "$phooks/$base" ]; then
@@ -150,7 +152,14 @@ run_hooks() {
                        IFS="${oifs}"
                        "${hook}" $2
                )
-               hook_exit_status $? || ret=$?
+               if hook_exit_status $?; then
+                       # save the name of this hook if we are not
+                       # running in reverse.
+                       [ -z "$3" ] && LAST_HOOK="$base"
+               else 
+                       ret=$?
+                       [ -z "$3" ] && break
+               fi
        done
        IFS="${oifs}"
        return $ret
-- 
1.5.4.3

_______________________________________________
Pm-utils mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/pm-utils

Reply via email to