mirror of the now-defunct rocklinux.org
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.

148 lines
4.2 KiB

  1. #!/bin/bash
  2. #
  3. # --- ROCK-COPYRIGHT-NOTE-BEGIN ---
  4. #
  5. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  6. # Please add additional copyright information _after_ the line containing
  7. # the ROCK-COPYRIGHT-NOTE-END tag. Otherwise it might get removed by
  8. # the ./scripts/Create-CopyPatch script. Do not edit this copyright text!
  9. #
  10. # ROCK Linux: rock-src/scripts/Cleanup
  11. # ROCK Linux is Copyright (C) 1998 - 2004 Clifford Wolf
  12. #
  13. # This program is free software; you can redistribute it and/or modify
  14. # it under the terms of the GNU General Public License as published by
  15. # the Free Software Foundation; either version 2 of the License, or
  16. # (at your option) any later version. A copy of the GNU General Public
  17. # License can be found at Documentation/COPYING.
  18. #
  19. # Many people helped and are helping developing ROCK Linux. Please
  20. # have a look at http://www.rocklinux.org/ and the Documentation/TEAM
  21. # file for details.
  22. #
  23. # --- ROCK-COPYRIGHT-NOTE-END ---
  24. #
  25. # Cleanup the build environment
  26. #
  27. fullclean=0
  28. nocheck=0
  29. while [ "$1" ] ; do
  30. case "$1" in
  31. -full)
  32. fullclean=1 ; shift ;;
  33. -nocheck)
  34. nocheck=1 ; shift ;;
  35. -*)
  36. echo "Usage: $0 [ -full ] [ -nocheck ] [ <dir(s)> ]"
  37. echo
  38. echo " Cleanup the build environment, deleting the directories src, src.*,"
  39. echo " build/*/ROCK/src.* and various temporary/backup files."
  40. echo " Also check for old liggering files."
  41. echo " Without options, remove src and all src.* and build/*/ROCK/src.*"
  42. echo " directories, and all temporary/backup files, and perform checks for old"
  43. echo " liggering files."
  44. echo " If directories are given, delete only them. Directories used by ROCK scripts"
  45. echo " at the moment are recognized and not deleted."
  46. echo
  47. echo " -full delete full build directories, "
  48. echo " e.g. build/desktop-*"
  49. echo " -nocheck don't delete temporary/backup files and don't"
  50. echo " check for old liggering files"
  51. echo
  52. exit 1 ;;
  53. *)
  54. break ;;
  55. esac
  56. done
  57. # Remove src*
  58. #
  59. for x in src src.* build/*/ROCK/src.*; do
  60. if [ -d "$x" -o -L "$x" ] ; then
  61. if [ "$#" != 0 ] ; then
  62. delme=0
  63. for y ; do [ "${y%/}" = "$x" ] && delme=1 ; done
  64. [ "$delme" = 0 ] && continue
  65. fi
  66. delme=1
  67. for y in build.pid; do
  68. if [ $delme = 1 -a -f "$x/$y" ] ; then
  69. if [ "`fuser "$x/$y"`" ] ; then
  70. echo "Found active $y in $x: Not removing!"
  71. delme=0
  72. fi
  73. fi
  74. done
  75. if [ $delme = 1 ] ; then
  76. echo "removing $x .."
  77. rm -rf "$x"
  78. fi
  79. fi
  80. done
  81. # Remove build/*
  82. #
  83. fullhelp=0
  84. for x in build/* ; do
  85. if [ -d "$x" ] ; then
  86. if [ "$#" != 0 ] ; then
  87. delme=0
  88. for y ; do [ "${y%/}" = "$x" ] && delme=1 ; done
  89. [ "$delme" = 0 ] && continue
  90. fi
  91. if [ $fullclean = 1 ] ; then
  92. for y in proc ROCK/loop ROCK/config ROCK/download; do
  93. umount -d -f "$x/$y" > /dev/null 2>&1
  94. umount -d -f -l "$x/$y" > /dev/null 2>&1
  95. rmdir "$x/$y" > /dev/null 2>&1
  96. if [ -d "$x/$y" ] ; then
  97. echo "Found $y in $x: Not removing!"
  98. delme=0
  99. fi
  100. done
  101. if [ "$delme" != 0 ] ; then
  102. echo "removing $x .."
  103. rm -rf "$x"
  104. fi
  105. else
  106. echo "Not removing $x."
  107. fullhelp=1
  108. fi
  109. fi
  110. done
  111. [ $fullhelp -eq 1 ] && echo "Use '$0 -full' to also remove build/*."
  112. [ "$nocheck" = 1 ] && exit 0
  113. # Remove temp/backup files
  114. #
  115. bash scripts/xfind.sh Documentation/. architecture/. misc/. \
  116. package/. scripts/. target/. -type f \( -name '*~' -o \
  117. -name 'a.out' -o -name 'core.*' -o -name 'core' \) | xargs rm -vf
  118. # Print warnings for 'liggering' files
  119. #
  120. bash scripts/xfind.sh Documentation/. architecture/. misc/. \
  121. package/. scripts/. target/. \
  122. \( \
  123. \( -name 'DEADJOE' -o -name '*-[xX]' -o -name '.[^.]*' \
  124. -o -name '*.orig' -o -name '*.rej' -o -name '*#*' \
  125. -o -name '*.mine' -o -name '*.r[1-9][0-9]*' \
  126. -o -name TRANS.TBL -o -name '*.cksum-err' -o -name x \
  127. -o -name '*[.-]old' -o -name a.out -o -name '*~' \
  128. -o -name '*.incomplete' -o -name '*.ckext-err' \) \
  129. -printf 'WARNING: Found %p\n' \
  130. \) -o \( \
  131. \( \( ! -type l ! -perm 755 ! -perm 644 \) -o \
  132. \( -type l ! -perm 777 \) \) \
  133. -printf 'WARNING: Non-Standard Perm at %p\n' \
  134. \) -o \( \
  135. \( ! -type d ! -type f \) \
  136. -printf 'WARNING: Neither a dir nor a regular file: %p\n' \
  137. \)
  138. exit 0