|
|
#!/bin/bash # --- SDE-COPYRIGHT-NOTE-BEGIN --- # This copyright note is auto-generated by ./scripts/Create-CopyPatch. # # Filename: bin/sde-cleanup # Copyright (C) 2006 - 2008 The OpenSDE Project # Copyright (C) 2004 - 2006 The T2 SDE Project # Copyright (C) 1998 - 2003 Clifford Wolf # # 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. # --- SDE-COPYRIGHT-NOTE-END ---
#Description: Cleanup the build environment
[ -n "$SDEROOT" ] || export SDEROOT=$( cd "${0%/*}/.."; pwd -P )
. $SDEROOT/lib/libsde.in
nocheck=0 downclean=0 buildclean=0 cacheclean=0
cleanup_usage() { cat <<EOT Usage: sde cleanup [ -build ] [ -cache ] [ -full ] [ -nocheck ] [ -download ] sde cleanup [ dir(s) ] EOT }
while [ "$1" ] ; do case "$1" in -build) buildclean=1 ;; -cache) cacheclean=1 ;; -full) buildclean=1 ; cacheclean=1 ;; -nocheck) nocheck=1 ;; -download) downclean=1 ;; -*) cleanup_usage 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) ..." $SDEROOT/bin/sde-cleanup-download fi
# Remove src.* # for x in tmp 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 ] || exec $SDEROOT/bin/sde-clean-linger
|