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.

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