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.

143 lines
3.7 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 - 2003 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. exit 1 ;;
  38. *)
  39. break ;;
  40. esac
  41. done
  42. # Remove src*
  43. #
  44. for x in src* ; do
  45. if [ -d "$x" ] ; then
  46. if [ "$#" != 0 ] ; then
  47. delme=0
  48. for y ; do [ "${y%/}" = "$x" ] && delme=1 ; done
  49. [ "$delme" = 0 ] && continue
  50. fi
  51. delme=1
  52. for y in build.pid R.src/build.pid ; do
  53. if [ $delme = 1 -a -f "$x/$y" ] ; then
  54. if [ "`fuser "$x/$y"`" ] ; then
  55. echo "Found active $y in $x: Not removing!"
  56. delme=0
  57. fi
  58. fi
  59. done
  60. for y in dev proc R.orig/download R.orig R.build R.src/mnt* mnt* ; do
  61. if [ $delme = 1 -a -d "$x/$y" ] ; then
  62. umount -d -f "$x/$y" > /dev/null 2>&1
  63. umount -d -f -l "$x/$y" > /dev/null 2>&1
  64. rmdir "$x/$y" > /dev/null 2>&1
  65. if [ -d "$x/$y" ] ; then
  66. echo "Found $y in $x: Not removing!"
  67. delme=0
  68. fi
  69. fi
  70. done
  71. if [ $delme = 1 ] ; then
  72. echo "removing $x .."
  73. rm -rf "$x"
  74. fi
  75. fi
  76. done
  77. # Remove build/*
  78. #
  79. fullhelp=0
  80. for x in build/* ; do
  81. if [ -d "$x" ] ; then
  82. if [ "$#" != 0 ] ; then
  83. delme=0
  84. for y ; do [ "${y%/}" = "$x" ] && delme=1 ; done
  85. [ "$delme" = 0 ] && continue
  86. fi
  87. if [ $fullclean = 1 ] ; then
  88. for y in dev proc ; do
  89. umount -d -f "$x/root/$y" > /dev/null 2>&1
  90. umount -d -f -l "$x/root/$y" > /dev/null 2>&1
  91. rmdir "$x/root/$y" > /dev/null 2>&1
  92. if [ -d "$x/root/$y" ] ; then
  93. echo "Found $y in $x: Not removing!"
  94. delme=0
  95. fi
  96. done
  97. if [ "$delme" != 0 ] ; then
  98. echo "removing $x .."
  99. rm -rf "$x"
  100. fi
  101. else
  102. echo "Not removing $x."
  103. fullhelp=1
  104. fi
  105. fi
  106. done
  107. [ $fullhelp -eq 1 ] && echo "Use '$0 -full' to also remove build/*."
  108. [ "$nocheck" = 1 ] && exit 0
  109. # Remove temp/backup files
  110. #
  111. bash scripts/xfind.sh Documentation/. architecture/. misc/. \
  112. package/. scripts/. target/. -type f \( -name '*~' -o \
  113. -name 'a.out' -o -name 'core.*' -o -name 'core' \) | xargs rm -vf
  114. # Print warnings for 'liggering' files
  115. #
  116. bash scripts/xfind.sh Documentation/. architecture/. misc/. \
  117. package/. scripts/. target/. \
  118. \( \
  119. \( -name 'DEADJOE' -o -name '*-[xX]' -o -name '.[^.]*' \
  120. -o -name '*.orig' -o -name '*.rej' -o -name '*#*' \
  121. -o -name '*.mine' -o -name '*.r[1-9][0-9]*' \
  122. -o -name TRANS.TBL -o -name '*.cksum-err' -o -name x \
  123. -o -name '*[.-]old' -o -name a.out -o -name '*~' \
  124. -o -name '*.incomplete' -o -name '*.ckext-err' \) \
  125. -printf 'WARNING: Found %p\n' \
  126. \) -o \( \
  127. \( \( ! -type l ! -perm 755 ! -perm 644 \) -o \
  128. \( -type l ! -perm 777 \) \) \
  129. -printf 'WARNING: Non-Standard Perm at %p\n' \
  130. \) -o \( \
  131. \( ! -type d ! -type f \) \
  132. -printf 'WARNING: Dangerous file: %p\n' \
  133. \)
  134. exit 0