OpenSDE Framework (without history before r20070)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

58 lines
1.3 KiB

  1. #!/bin/sh
  2. # --- SDE-COPYRIGHT-NOTE-BEGIN ---
  3. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  4. #
  5. # Filename: lib/misc/apply-patch.sh
  6. # Copyright (C) 2008 The OpenSDE Project
  7. # Copyright (C) 2004 - 2006 The T2 SDE Project
  8. #
  9. # More information can be found in the files COPYING and README.
  10. #
  11. # This program is free software; you can redistribute it and/or modify
  12. # it under the terms of the GNU General Public License as published by
  13. # the Free Software Foundation; version 2 of the License. A copy of the
  14. # GNU General Public License can be found in the file COPYING.
  15. # --- SDE-COPYRIGHT-NOTE-END ---
  16. basedirs="Documentation|architecture|misc|package|scripts|target";
  17. error=0
  18. for patch in "$@"
  19. do
  20. plevel=1
  21. for plevelc in 2 0 1
  22. do
  23. if egrep -q "^--- ([^/]*/){$plevelc}($basedirs)" $patch; then
  24. plevel=$plevelc
  25. fi
  26. done
  27. echo
  28. echo "*** patch -fp$plevel --dry-run < $patch"
  29. patch -fp$plevel --dry-run < $patch || error=1
  30. done
  31. if [ $error = 1 ]; then
  32. echo
  33. echo "*** Dry run returned errors."
  34. echo
  35. exit 1
  36. fi
  37. echo
  38. read -p 'Press ENTER to apply the patches or Ctrl-C to abort: '
  39. echo
  40. for patch in "$@"
  41. do
  42. plevel=1
  43. for plevelc in 2 0 1
  44. do
  45. if egrep -q "^--- ([^/]*/){$plevelc}($basedirs)" $patch; then
  46. plevel=$plevelc
  47. fi
  48. done
  49. echo "*** patch -fp$plevel < $patch"
  50. patch -fp$plevel <$patch
  51. echo
  52. done