[initramfs] Enhanced output format to run `ldconfig` if etc/ld.so.conf is present
[opensde-nopast.git] / bin / sde-cleanup
blob06715c054583397873489c158a9ccd0aea1794b4
1 #!/bin/bash
2 # --- SDE-COPYRIGHT-NOTE-BEGIN ---
3 # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
5 # Filename: bin/sde-cleanup
6 # Copyright (C) 2006 - 2008 The OpenSDE Project
7 # Copyright (C) 2004 - 2006 The T2 SDE Project
8 # Copyright (C) 1998 - 2003 Clifford Wolf
10 # More information can be found in the files COPYING and README.
12 # This program is free software; you can redistribute it and/or modify
13 # it under the terms of the GNU General Public License as published by
14 # the Free Software Foundation; version 2 of the License. A copy of the
15 # GNU General Public License can be found in the file COPYING.
16 # --- SDE-COPYRIGHT-NOTE-END ---
18 #Description: Cleanup the build environment
19 #Alias: clean
21 [ -n "$SDEROOT" ] ||
22 export SDEROOT=$( cd "${0%/*}/.."; pwd -P )
24 . $SDEROOT/lib/libsde.in
26 nocheck=0
27 downclean=0
28 buildclean=0
29 cacheclean=0
31 cleanup_usage() {
32 cat <<EOT
33 Usage: sde cleanup [ -build ] [ -cache ] [ -full ] [ -nocheck ] [ -download ]
34 sde cleanup [ dir(s) ]
35 EOT
38 while [ "$1" ] ; do
39 case "$1" in
40 -build)
41 buildclean=1 ;;
42 -cache)
43 cacheclean=1 ;;
44 -full)
45 buildclean=1 ; cacheclean=1 ;;
46 -nocheck)
47 nocheck=1 ;;
48 -download)
49 downclean=1 ;;
50 -*) cleanup_usage
51 exit 1 ;;
53 break ;;
54 esac
55 shift
56 done
58 # Cleanup download/* and quit
60 if [ $downclean -eq 1 ]; then
61 echo "Searching for obsolete downloads (this may take some time) ..."
62 $SDEROOT/bin/sde-cleanup-download
65 # Remove src.*
67 for x in tmp src.* build/*/TOOLCHAIN/src.*; do
68 if [ -d "$x" -o -L "$x" ] ; then
69 if [ "$#" != 0 ] ; then
70 delme=0
71 for y ; do [ "${y%/}" = "$x" ] && delme=1 ; done
72 [ "$delme" = 0 ] && continue
74 delme=1
76 for y in build.pid; do
77 if [ $delme = 1 -a -f "$x/$y" ] ; then
78 if [ "`fuser "$x/$y"`" ] ; then
79 echo "Found active $y in $x: Not removing!"
80 delme=0
83 done
85 if [ $delme = 1 ] ; then
86 echo "removing $x .."
87 rm -rf "$x"
90 done
92 # Remove build/*
94 fullhelp=0
95 for x in build/* ; do
96 if [ -d "$x" ] ; then
97 if [ "$#" != 0 ] ; then
98 delme=0
99 for y ; do [ "${y%/}" = "$x" ] && delme=1 ; done
100 [ "$delme" = 0 ] && continue
103 # handle (c)cache pools first
104 if [ ${x/build\/ccache/} != $x ]; then
105 if [ $cacheclean = 1 ]; then
106 echo "removing $x ..."
107 rm -rf "$x"
108 else
109 echo "Not removing $x (cache)."
110 fullhelp=1
112 continue
115 if [ $buildclean = 1 ] ; then
116 for y in proc TOOLCHAIN/loop TOOLCHAIN/config TOOLCHAIN/download; do
117 umount -d -f "$x/$y" > /dev/null 2>&1
118 umount -d -f -l "$x/$y" > /dev/null 2>&1
119 rmdir "$x/$y" > /dev/null 2>&1
120 if [ -d "$x/$y" ] ; then
121 echo "Found $y in $x: Not removing!"
122 delme=0
124 done
125 if [ "$delme" != 0 ] ; then
126 echo "removing $x ..."
127 rm -rf "$x"
129 else
130 echo "Not removing $x (build)."
131 fullhelp=1
134 done
135 [ $fullhelp -eq 1 ] &&
136 echo -e "\nUse '$0 -build' to remove builds and '$0 -cache'
137 to also flush the cache."
139 [ "$nocheck" = 1 ] || exec $SDEROOT/bin/sde-cleanup-linger