scripts/patch-rework.sh
changeset 2147 0ec4491d6496
parent 1624 782dea79ae56
child 2224 fc58927f24b8
     1.1 --- a/scripts/patch-rework.sh	Fri Nov 13 19:34:18 2009 +0100
     1.2 +++ b/scripts/patch-rework.sh	Thu Oct 07 23:45:25 2010 +0200
     1.3 @@ -31,6 +31,8 @@
     1.4  }
     1.5  
     1.6  mkdir -p "${dst}"
     1.7 +base="${base%%/}"
     1.8 +src="$( cd "${src}"; pwd )"
     1.9  dst="$( cd "${dst}"; pwd )"
    1.10  
    1.11  # Iterate through patches
    1.12 @@ -87,21 +89,14 @@
    1.13    # contain multiple accumulated patches onto a single file.
    1.14    printf "  applying patch..."
    1.15    if ! patch -g0 -F1 -f -p${d} <"${p}" >"../patch.out" 2>&1; then
    1.16 -    printf " ERROR\n"
    1.17 -    # Revert the patch
    1.18 +    printf " ERROR\n\n"
    1.19      popd >/dev/null 2>&1
    1.20 -    printf "  restoring '${base}'..."
    1.21 -    rm -f "diffstat.tmp"
    1.22 -    rm -rf "${base}"
    1.23 -    mv "${base}.orig" "${base}"
    1.24 -    printf " done\n\n"
    1.25      printf "There was an error while applying:\n  -->  ${p}  <--\n"
    1.26      printf "'${base}' was restored to the state it was prior to applying this faulty patch.\n"
    1.27      printf "Here's the 'patch' command, and its output:\n"
    1.28      printf "  ----8<----\n"
    1.29      printf "  patch -g0 -F1 -f -p${d} <'${p}'\n"
    1.30 -    cat "patch.out" |(IFS=$(printf "\n"); while read line; do printf "  ${line}\n"; done)
    1.31 -    rm -f "patch.out"
    1.32 +    sed -r -e 's/^/  /;' "patch.out"
    1.33      printf "  ----8<----\n"
    1.34      exit 1
    1.35    fi
    1.36 @@ -136,6 +131,7 @@
    1.37    printf "  removing temporary files/dirs..."
    1.38    rm -f "patch.out"
    1.39    rm -f "diffstat.tmp"
    1.40 +  rm -f "diffstat.orig"
    1.41    rm -rf "${base}.orig"
    1.42    printf " done\n"
    1.43  done
    1.44 @@ -148,6 +144,8 @@
    1.45  
    1.46    if ! cmp "${p}.diffstat.orig" "${p}.diffstat.new" >/dev/null; then
    1.47      printf "  --> '${pname}' differ in touched files <--\n"
    1.48 +  else
    1.49 +    rm -f "${p}.diffstat.orig" "${p}.diffstat.new"
    1.50    fi
    1.51  done
    1.52  printf "  done.\n"