3 # --- T2-COPYRIGHT-NOTE-BEGIN ---
4 # T2 SDE: scripts/Cleanup
5 # Copyright (C) 2004 - 2024 The T2 SDE Project
6 # Copyright (C) 1998 - 2003 ROCK Linux Project
8 # This Copyright note is generated by scripts/Create-CopyPatch,
9 # more information can be found in the files COPYING and README.
11 # This program is free software; you can redistribute it and/or modify
12 # it under the terms of the GNU General Public License version 2.
13 # --- T2-COPYRIGHT-NOTE-END ---
15 # Cleanup the build environment
30 buildclean
=1 cacheclean
=1 ;;
36 echo "Usage: $0 [ -build ] [ -cache ] [ -full ] [ -nocheck ] [ -download ]"
37 echo " ${0//[a-zA-Z\/.]/ } [ dir(s) ]"
45 # Cleanup download/* and quit
47 if [ $downclean -eq 1 ]; then
48 echo "Searching for obsolete downloads (this may take some time) ..."
49 scripts
/Download
-list-unknown | cut
-d ' ' -f 3- |
51 [ "$fn" ] && rm -v "$fn"
58 for x
in src src.
* build
/*/TOOLCHAIN
/src.
*; do
59 if [ -d "$x" -o -L "$x" ]; then
60 if [ "$#" != 0 ]; then
62 for y
; do [ "${y%/}" = "$x" ] && delme
=1; done
63 [ "$delme" = 0 ] && continue
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!"
76 if [ $delme = 1 ]; then
77 echo "Removing $x ..."
78 umount
-n -r -d -f "$x" 2> /dev
/null
79 umount
-n -r -d -f -l "$x" 2> /dev
/null
82 if [[ "$x" = *src.
* ]]; then
94 if [ "$#" != 0 ]; then
96 for y
; do [ "${y%/}" = "$x" ] && delme
=1; done
97 [ "$delme" = 0 ] && continue
100 # handle (c)cache pools first
101 if [ ${x/build\/ccache/} != $x ]; then
102 if [ $cacheclean = 1 ]; then
103 echo "Removing $x ..."
106 echo "Not removing $x (cache)"
112 if [ $buildclean = 1 ]; then
113 for y
in proc tmp TOOLCHAIN
/loop TOOLCHAIN
/config TOOLCHAIN
/download
; do
114 umount
-d -f "$x/$y" > /dev
/null
2>&1
115 umount
-d -f -l "$x/$y" > /dev
/null
2>&1
116 rmdir "$x/$y" > /dev
/null
2>&1
117 if [ -d "$x/$y" ]; then
118 echo "Found $y in $x: Not removing!"
122 if [ "$delme" != 0 ]; then
123 echo "Removing $x ..."
127 echo "Not removing $x (build)"
132 [ $fullhelp -eq 1 ] &&
133 echo -e "\nUse '$0 -build' to remove builds and '$0 -cache'
134 to also flush the cache."
136 [ "$nocheck" = 1 ] && exit 0
138 echo -e "\nSearching for lingering temp/backup files (this may take some time) ..."
140 # Remove temp/backup files
142 bash
scripts
/xfind.sh
doc
/. architecture
/. misc
/. \
143 package
/.
scripts
/. target
/.
-type f \
( -name '*~' -o \
144 -name 'a.out' -o -name 'core.[0-9]*' -o -name 'core' \
) |
xargs rm -vf
146 # Print warnings for 'lingering' files
148 bash
scripts
/xfind.sh
doc
/. architecture
/. misc
/. \
149 package
/.
scripts
/. \
151 \
( -name 'DEADJOE' -o -name '.[^.]*' \
152 -o -name '*.orig' -o -name '*.rej' -o -name '*#*' \
153 -o -name '*.mine' -o -name '*.r[1-9][0-9]*' \
154 -o -name TRANS.TBL
-o -name '*.cksum-err' -o -name x \
155 -o -name '*[.-]old' -o -name a.out
-o -name '*~' \
156 -o -name '*.incomplete' -o -name '*.ckext-err' \
) \
157 -printf 'WARNING: Found %p\n' \
159 \
( ! -type d
! -type f \
) \
160 -printf 'WARNING: Neither a dir nor a regular file: %p\n' \
163 bash
scripts
/xfind.sh target
/. \
165 \
( -name 'DEADJOE' -o -name '*-[xX]' \
166 -o -name '*.orig' -o -name '*.rej' -o -name '*#*' \
167 -o -name '*.mine' -o -name '*.r[1-9][0-9]*' \
168 -o -name TRANS.TBL
-o -name '*.cksum-err' -o -name x \
169 -o -name '*[.-]old' -o -name a.out
-o -name '*~' \
170 -o -name '*.incomplete' -o -name '*.ckext-err' \
) \
171 -printf 'WARNING: Found %p\n' \
173 \
( ! -type d
! -type f \
) \
174 -printf 'WARNING: Neither a dir nor a regular file: %p\n' \