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.

56 lines
1.4 KiB

  1. # --- SDE-COPYRIGHT-NOTE-BEGIN ---
  2. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  3. #
  4. # Filename: lib/sde-cleanup/cleanup.sh
  5. # Copyright (C) 2006 The OpenSDE Project
  6. #
  7. # More information can be found in the files COPYING and README.
  8. #
  9. # This program is free software; you can redistribute it and/or modify
  10. # it under the terms of the GNU General Public License as published by
  11. # the Free Software Foundation; version 2 of the License. A copy of the
  12. # GNU General Public License can be found in the file COPYING.
  13. # --- SDE-COPYRIGHT-NOTE-END ---
  14. . lib/term-functions.in
  15. cleanup_basic() {
  16. local node="$1" type='unknown'
  17. local lock= pid= delete=1
  18. if [ -d "$node/" ]; then
  19. type='folder'
  20. # check if the folder is locked
  21. for lock in build; do
  22. pid="$node/$lock.pid"
  23. if [ ! -e "$pid" ]; then
  24. continue
  25. elif [ -n "$( fuser "$pid" 2> /dev/null )" ]; then
  26. echo_warning "Not removing '$node' ($lock), locked."
  27. delete=0; break
  28. fi
  29. done
  30. elif [ -L "$node" ]; then
  31. type='symlink'
  32. else
  33. type='file'
  34. fi
  35. if [ $delete -eq 1 ]; then
  36. echo_info "Removing '$node' ($type)".
  37. case "$type" in
  38. folder) # FIXME: check for mount points!
  39. rm -rf "$node/"
  40. [ ! -e "$node" ] || rm -f "$node"
  41. ;;
  42. *) rm -f "$node"
  43. ;;
  44. esac
  45. fi
  46. }
  47. ls -1d tmp/* src.* build/*/TOOLCHAIN/src.* 2> /dev/null |
  48. while read f; do
  49. cleanup_basic "$f"
  50. done