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