# --- SDE-COPYRIGHT-NOTE-BEGIN ---
|
|
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
|
|
#
|
|
# Filename: lib/sde-cleanup/cleanup.sh
|
|
# Copyright (C) 2006 The OpenSDE 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.
|
|
# --- SDE-COPYRIGHT-NOTE-END ---
|
|
|
|
. lib/term-functions.in
|
|
|
|
cleanup_basic() {
|
|
local node="$1" type='unknown'
|
|
local lock= pid= delete=1
|
|
|
|
if [ -d "$node/" ]; then
|
|
type='folder'
|
|
|
|
# check if the folder is locked
|
|
for lock in build; do
|
|
pid="$node/$lock.pid"
|
|
if [ ! -e "$pid" ]; then
|
|
continue
|
|
elif [ -n "$( fuser "$pid" 2> /dev/null )" ]; then
|
|
echo_warning "Not removing '$node' ($lock), locked."
|
|
delete=0; break
|
|
fi
|
|
done
|
|
elif [ -L "$node" ]; then
|
|
type='symlink'
|
|
else
|
|
type='file'
|
|
fi
|
|
|
|
if [ $delete -eq 1 ]; then
|
|
echo_info "Removing '$node' ($type)".
|
|
case "$type" in
|
|
folder) # FIXME: check for mount points!
|
|
rm -rf "$node/"
|
|
[ ! -e "$node" ] || rm -f "$node"
|
|
;;
|
|
*) rm -f "$node"
|
|
;;
|
|
esac
|
|
fi
|
|
}
|
|
|
|
ls -1d tmp/* src.* build/*/TOOLCHAIN/src.* 2> /dev/null |
|
|
while read f; do
|
|
cleanup_basic "$f"
|
|
done
|