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.

160 lines
4.5 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 - 2006 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. umount=0
  29. nocheck=0
  30. while [ "$1" ] ; do
  31. case "$1" in
  32. -full)
  33. fullclean=1 ; shift ;;
  34. -nocheck)
  35. nocheck=1 ; shift ;;
  36. -umount)
  37. fullclean=1 ; nocheck=1
  38. umount=1 ; shift ;;
  39. -*)
  40. echo "Usage: $0 [ -full ] [ -nocheck ] [ -umount ] [ <dir(s)> ]"
  41. echo
  42. echo " Cleanup the build environment, deleting the directories src, src.*,"
  43. echo " build/*/ROCK/src.* and various temporary/backup files."
  44. echo " Also check for old lingering files."
  45. echo " Without options, remove src and all src.* and build/*/ROCK/src.*"
  46. echo " directories, and all temporary/backup files, and perform checks for old"
  47. echo " lingering files."
  48. echo " If directories are given, delete only them. Directories used by ROCK scripts"
  49. echo " at the moment are recognized and not deleted."
  50. echo
  51. echo " -full delete full build directories, "
  52. echo " e.g. build/desktop-*"
  53. echo
  54. echo " -nocheck don't delete temporary/backup files and don't"
  55. echo " check for old lingering files"
  56. echo
  57. echo " -umount don't remove anything, just umount all the"
  58. echo " lingering mounts, implies '-full' and '-nocheck'"
  59. echo
  60. exit 1 ;;
  61. *)
  62. break ;;
  63. esac
  64. done
  65. # Remove src*
  66. #
  67. if [ $umount = 0 ]; then
  68. for x in src src.* build/*/ROCK/src.*; do
  69. if [ -d "$x" -o -L "$x" ] ; then
  70. if [ "$#" != 0 ] ; then
  71. delme=0
  72. for y ; do [ "${y%/}" = "$x" ] && delme=1 ; done
  73. [ "$delme" = 0 ] && continue
  74. fi
  75. delme=1
  76. for y in build.pid; do
  77. if [ $delme = 1 -a -f "$x/$y" ] ; then
  78. if [ "`fuser "$x/$y"`" ] ; then
  79. echo "Found active $y in $x: Not removing!"
  80. delme=0
  81. fi
  82. fi
  83. done
  84. if [ $delme = 1 ]; then
  85. echo "removing $x .."
  86. rm -rf "$x"
  87. fi
  88. fi
  89. done
  90. fi
  91. # Remove build/*
  92. #
  93. fullhelp=0
  94. for x in build/* ; do
  95. if [ -d "$x" ] ; then
  96. if [ "$#" != 0 ] ; then
  97. delme=0
  98. for y ; do [ "${y%/}" = "$x" ] && delme=1 ; done
  99. [ "$delme" = 0 ] && continue
  100. fi
  101. if [ $fullclean = 1 ] ; then
  102. for y in proc ROCK/loop ROCK/config ROCK/download; do
  103. umount -d -f "$x/$y" > /dev/null 2>&1
  104. umount -d -f -l "$x/$y" > /dev/null 2>&1
  105. if [ $umount = 0 ]; then
  106. rmdir "$x/$y" > /dev/null 2>&1
  107. if [ -d "$x/$y" ] ; then
  108. echo "Found $y in $x: Not removing!"
  109. delme=0
  110. fi
  111. fi
  112. done
  113. if [ "$delme" != 0 -a $umount = 0 ] ; then
  114. echo "removing $x .."
  115. rm -rf "$x"
  116. fi
  117. else
  118. echo "Not removing $x."
  119. fullhelp=1
  120. fi
  121. fi
  122. done
  123. [ $fullhelp -eq 1 ] && echo "Use '$0 -full' to also remove build/*."
  124. [ "$nocheck" = 1 ] && exit 0
  125. # Remove temp/backup files
  126. #
  127. bash scripts/xfind.sh Documentation/. architecture/. misc/. \
  128. package/. scripts/. target/. -type f \( -name '*~' -o \
  129. -name 'a.out' -o -name 'core.*' -o -name 'core' \) | xargs rm -vf
  130. # Print warnings for 'lingering' files
  131. #
  132. bash scripts/xfind.sh Documentation/. architecture/. misc/. \
  133. package/. scripts/. target/. \
  134. \( \
  135. \( -name 'DEADJOE' -o -name '*-[xX]' -o -name '.[^.]*' \
  136. -o -name '*.orig' -o -name '*.rej' -o -name '*#*' \
  137. -o -name '*.mine' -o -name '*.r[1-9][0-9]*' \
  138. -o -name TRANS.TBL -o -name '*.cksum-err' -o -name x \
  139. -o -name '*[.-]old' -o -name a.out -o -name '*~' \
  140. -o -name '*.incomplete' -o -name '*.ckext-err' \) \
  141. -printf 'WARNING: Found %p\n' \
  142. \) -o \( \
  143. \( \( ! -type l ! -perm 755 ! -perm 644 \) -o \
  144. \( -type l ! -perm 777 \) \) \
  145. -printf 'WARNING: Non-Standard Perm at %p\n' \
  146. \) -o \( \
  147. \( ! -type d ! -type f \) \
  148. -printf 'WARNING: Neither a dir nor a regular file: %p\n' \
  149. \)
  150. exit 0