-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcleanup.sh
executable file
·55 lines (51 loc) · 1.64 KB
/
cleanup.sh
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
#!/bin/bash
FAST=0
if [ $1 ] && [ "$1" = "noprompt" ]; then
REPLY="yes"
elif [ $1 ] && [ "$1" = "fast" ]; then
FAST=1
REPLY="yes"
else
echo "This script will remove all files with extensions other than"
echo ".pas or .inc or .sh or .mcp or with names other than ''Makefile'' or"
echo "''Makefile.fpc'' or ''INSTALL'' or ''LICENSE'', etc."
echo "It will leave the docs, docsrc, versions and delphi directories intact."
echo "Do you want to proceed? (yes/no) "
read
fi
FILES_TO_RETAIN='(\.pas$)|(\.inc$)|(\.i$)|(\.sh$)|(\.mcp$)|(\.mac$)|(^\.backup\.bpl$)'
if [ "$REPLY" = "yes" ]; then
rm -f `ls -1 | grep '~'`;
if [ $FAST = 0 ]; then
rm -f uninstall*.sh
fi
rm -f -r `ls -1 | egrep -v "${FILES_TO_RETAIN}"'|(Makefile)|(Makefile\.fpc)|(INSTALL)|(README)|(LICENSE)|(NEWS)|(tests$)|(^docs$)|(docsrc)|(versions)|(delphi)|(^demo$)|(^tools$)'`;
for FILENAME in *.mcp
do
if [ ! `ls -1 *.pas.mcp | grep $FILENAME` ]; then
rm $FILENAME
fi
done
for FILENAME in adt*.pas
do
if [ -f ${FILENAME}.mcp ]; then
rm ${FILENAME}
fi
done
cd tests
rm -f `ls -1 | grep '~'`
rm -f `ls -1 | egrep -v "${FILES_TO_RETAIN}"'|(units)'`;
cd units
rm -f `ls -1 | grep '~'`
rm -f `ls -1 | egrep -v "${FILES_TO_RETAIN}"'|(cpu)'`;
cd ../../demo
rm -f `ls -1 | grep '~'`
rm -f `ls -1 | egrep -v "${FILES_TO_RETAIN}"'|(customer)|(Makefile)'`;
cd customer
rm -f `ls -1 | grep '~'`
rm -f `ls -1 | egrep -v "${FILES_TO_RETAIN}"'|(Makefile)'`;
cd ../../docs
rm -f `ls -1 | grep '~'`
cd ../docsrc
rm -f `ls -1 | grep '~'`
fi