-
Notifications
You must be signed in to change notification settings - Fork 1
/
Cleanup
executable file
·174 lines (159 loc) · 4.54 KB
/
Cleanup
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
#!/bin/bash
#
# --- T2-COPYRIGHT-NOTE-BEGIN ---
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
#
# T2 SDE: scripts/Cleanup
# Copyright (C) 2004 - 2008 The T2 SDE Project
# Copyright (C) 1998 - 2003 ROCK Linux Project
#
# More information can be found in the files COPYING and README.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License. A copy of the
# GNU General Public License can be found in the file COPYING.
# --- T2-COPYRIGHT-NOTE-END ---
#
# Cleanup the build environment
#
nocheck=0
downclean=0
buildclean=0
cacheclean=0
while [ "$1" ] ; do
case "$1" in
-build)
buildclean=1 ;;
-cache)
cacheclean=1 ;;
-full)
buildclean=1 ; cacheclean=1 ;;
-nocheck)
nocheck=1 ;;
-download)
downclean=1 ;;
-*)
echo "Usage: $0 [ -build ] [ -cache ] [ -full ] [ -nocheck ] [ -download ]"
echo " ${0//[a-zA-Z\/.]/ } [ dir(s) ]"
exit 1 ;;
*)
break ;;
esac
shift
done
# Cleanup download/* and quit
#
if [ $downclean -eq 1 ]; then
echo "Searching for obsolete downloads (this may take some time) ..."
./scripts/Download -list-unknown | cut -d ' ' -f 3- |
while read fn; do
[ "$fn" ] && rm -v "$fn"
done
exit
fi
# Remove src*
#
for x in src src.* build/*/TOOLCHAIN/src.*; do
if [ -d "$x" -o -L "$x" ] ; then
if [ "$#" != 0 ] ; then
delme=0
for y ; do [ "${y%/}" = "$x" ] && delme=1 ; done
[ "$delme" = 0 ] && continue
fi
delme=1
for y in build.pid; do
if [ $delme = 1 -a -f "$x/$y" ] ; then
if [ "`fuser "$x/$y"`" ] ; then
echo "Found active $y in $x: Not removing!"
delme=0
fi
fi
done
if [ $delme = 1 ] ; then
echo "removing $x ..."
rm -rf "$x"
fi
fi
done
# Remove build/*
#
fullhelp=0
for x in build/* ; do
if [ -d "$x" ] ; then
if [ "$#" != 0 ] ; then
delme=0
for y ; do [ "${y%/}" = "$x" ] && delme=1 ; done
[ "$delme" = 0 ] && continue
fi
# handle (c)cache pools first
if [ ${x/build\/ccache/} != $x ]; then
if [ $cacheclean = 1 ]; then
echo "removing $x ..."
rm -rf "$x"
else
echo "Not removing $x (cache)."
fullhelp=1
fi
continue
fi
if [ $buildclean = 1 ] ; then
for y in proc TOOLCHAIN/loop TOOLCHAIN/config TOOLCHAIN/download; do
umount -d -f "$x/$y" > /dev/null 2>&1
umount -d -f -l "$x/$y" > /dev/null 2>&1
rmdir "$x/$y" > /dev/null 2>&1
if [ -d "$x/$y" ] ; then
echo "Found $y in $x: Not removing!"
delme=0
fi
done
if [ "$delme" != 0 ] ; then
echo "removing $x ..."
rm -rf "$x"
fi
else
echo "Not removing $x (build)."
fullhelp=1
fi
fi
done
[ $fullhelp -eq 1 ] &&
echo -e "\nUse '$0 -build' to remove builds and '$0 -cache'
to also flush the cache."
[ "$nocheck" = 1 ] && exit 0
echo -e "\nSearching for lingering temp/backup files (this may take some time) ..."
# Remove temp/backup files
#
bash scripts/xfind.sh doc/. architecture/. misc/. \
package/. scripts/. target/. -type f \( -name '*~' -o \
-name 'a.out' -o -name 'core.*' -o -name 'core' \) | xargs rm -vf
# Print warnings for 'lingering' files
#
bash scripts/xfind.sh doc/. architecture/. misc/. \
package/. scripts/. \
\( \
\( -name 'DEADJOE' -o -name '*-[xX]' -o -name '.[^.]*' \
-o -name '*.orig' -o -name '*.rej' -o -name '*#*' \
-o -name '*.mine' -o -name '*.r[1-9][0-9]*' \
-o -name TRANS.TBL -o -name '*.cksum-err' -o -name x \
-o -name '*[.-]old' -o -name a.out -o -name '*~' \
-o -name '*.incomplete' -o -name '*.ckext-err' \) \
-printf 'WARNING: Found %p\n' \
\) -o \( \
\( ! -type d ! -type f \) \
-printf 'WARNING: Neither a dir nor a regular file: %p\n' \
\)
bash scripts/xfind.sh target/. \
\( \
\( -name 'DEADJOE' -o -name '*-[xX]' \
-o -name '*.orig' -o -name '*.rej' -o -name '*#*' \
-o -name '*.mine' -o -name '*.r[1-9][0-9]*' \
-o -name TRANS.TBL -o -name '*.cksum-err' -o -name x \
-o -name '*[.-]old' -o -name a.out -o -name '*~' \
-o -name '*.incomplete' -o -name '*.ckext-err' \) \
-printf 'WARNING: Found %p\n' \
\) -o \( \
\( ! -type d ! -type f \) \
-printf 'WARNING: Neither a dir nor a regular file: %p\n' \
\)
exit 0