Clean.sh 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #!/bin/bash
  2. set -e
  3. # enable /** globbing
  4. shopt -s globstar
  5. ARG=${1:-no-arg}
  6. echo "Deleting ugly files..."
  7. ROOTDIR="$(dirname "$0")/.."
  8. PAT_UNITS="*.dcu *.ppu *.rsj *.or"
  9. # Careful with these! We have some precompiled C code we want to keep
  10. PAT_OBJ="*.obj *.o"
  11. PAT_DELPHI="*.identcache *.local *.ddp *.tvsconfig *.otares *.deployproj *.stat"
  12. PAT_BACKUPS="*.bak *.bk? *.~* *.*~"
  13. PAT_DEBUG="*.dbg *.rsm *.jdbg"
  14. PAT_MISC="*.compiled link????.res Thumbs.db"
  15. ALL_BUT_OBJ_PATS="$PAT_UNITS $PAT_DELPHI $PAT_BACKUPS $PAT_DEBUG $PAT_MISC"
  16. ALL_PATS="$ALL_BUT_OBJ_PATS $PAT_OBJ"
  17. delInTree() {
  18. for PAT in $2; do
  19. find $1 -mindepth 1 -iname "$PAT" -type f | xargs rm -f
  20. done
  21. }
  22. delWholeDir() {
  23. rm -rf $1
  24. }
  25. delWholeDir "$ROOTDIR/Bin/Dcu"
  26. delWholeDir "$ROOTDIR/Demos/Bin/Dcu"
  27. delInTree "$ROOTDIR/Source" "$ALL_PATS"
  28. delInTree "$ROOTDIR/Demos" "$ALL_PATS"
  29. delInTree "$ROOTDIR/Packages" "$ALL_PATS"
  30. delInTree "$ROOTDIR/Extensions" "$ALL_BUT_OBJ_PATS"
  31. delInTree "$ROOTDIR/Extras" "$ALL_BUT_OBJ_PATS"
  32. delWholeDir "$ROOTDIR/**/__history"
  33. delWholeDir "$ROOTDIR/**/backup"
  34. delWholeDir "$ROOTDIR/**/__recovery"
  35. # Careful with the following options
  36. if [ $ARG = "--clean-also-bin-dirs" ]; then
  37. delWholeDir "$ROOTDIR/Bin/*"
  38. delWholeDir "$ROOTDIR/Demos/Bin/*"
  39. fi
  40. if [ $ARG = "--clean-delphi-projects" ]; then
  41. delInTree "$ROOTDIR/Demos" "*.cfg *.dsk"
  42. delInTree "$ROOTDIR/Packages" "*.cfg *.dsk"
  43. fi
  44. echo "Clean finished"