* added python-wheel (0.42.0) - The official binary distribution format for Python
[t2sde.git] / scripts / Cleanup
blob0c9ae52b97bc1fe236055cb9c6af2a5824e8930e
1 #!/usr/bin/env bash
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
7 #
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
18 nocheck=0
19 downclean=0
20 buildclean=0
21 cacheclean=0
23 while [ "$1" ]; do
24 case "$1" in
25 -build)
26 buildclean=1 ;;
27 -cache)
28 cacheclean=1 ;;
29 -full)
30 buildclean=1 cacheclean=1 ;;
31 -nocheck)
32 nocheck=1 ;;
33 -download)
34 downclean=1 ;;
35 -*)
36 echo "Usage: $0 [ -build ] [ -cache ] [ -full ] [ -nocheck ] [ -download ]"
37 echo " ${0//[a-zA-Z\/.]/ } [ dir(s) ]"
38 exit 1 ;;
40 break ;;
41 esac
42 shift
43 done
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- |
50 while read fn; do
51 [ "$fn" ] && rm -v "$fn"
52 done
53 exit
56 # Remove src*
58 for x in src src.* build/*/TOOLCHAIN/src.*; do
59 if [ -d "$x" -o -L "$x" ]; then
60 if [ "$#" != 0 ]; then
61 delme=0
62 for y; do [ "${y%/}" = "$x" ] && delme=1; done
63 [ "$delme" = 0 ] && continue
65 delme=1
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!"
71 delme=0
74 done
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
80 rm -rf "$x"
82 if [[ "$x" = *src.* ]]; then
83 rm -rf /tmp/${x##*/}
87 done
89 # Remove build/*
91 fullhelp=0
92 for x in build/*; do
93 if [ -d "$x" ]; then
94 if [ "$#" != 0 ]; then
95 delme=0
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 ..."
104 rm -rf "$x"
105 else
106 echo "Not removing $x (cache)"
107 fullhelp=1
109 continue
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!"
119 delme=0
121 done
122 if [ "$delme" != 0 ]; then
123 echo "Removing $x ..."
124 rm -rf "$x"
126 else
127 echo "Not removing $x (build)"
128 fullhelp=1
131 done
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/. \
150 \( \
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' \
158 \) -o \( \
159 \( ! -type d ! -type f \) \
160 -printf 'WARNING: Neither a dir nor a regular file: %p\n' \
163 bash scripts/xfind.sh target/. \
164 \( \
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' \
172 \) -o \( \
173 \( ! -type d ! -type f \) \
174 -printf 'WARNING: Neither a dir nor a regular file: %p\n' \
177 exit 0