#!/bin/sh
|
|
# --- SDE-COPYRIGHT-NOTE-BEGIN ---
|
|
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
|
|
#
|
|
# Filename: bin/sde-cleanup-linger
|
|
# Copyright (C) 2006 - 2013 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: Removes temp files and search for lingering files
|
|
#Alias: lingering
|
|
|
|
[ -n "$SDEROOT" ] ||
|
|
export SDEROOT=$( cd "${0%/*}/.."; pwd -P )
|
|
|
|
. $SDEROOT/lib/libsde.in
|
|
|
|
cleanup_usage() {
|
|
local progname="${0##*/}"
|
|
cat <<EOT
|
|
Usage: $progname [--dry-run]
|
|
EOT
|
|
}
|
|
|
|
shortopts='d'
|
|
longopts='dry-run'
|
|
options=$( getopt -o "$shortopts" -l "$longopts" -- "$@" )
|
|
|
|
if [ $? -ne 0 ]; then
|
|
cleanup_usage
|
|
exit -1
|
|
fi
|
|
|
|
# load new arguments list
|
|
eval set -- "$options"
|
|
|
|
dryrun=
|
|
|
|
while [ $# -gt 0 ]; do
|
|
case "$1" in
|
|
--) shift; break ;;
|
|
-d|--dry-run)
|
|
dryrun=yes ;;
|
|
esac
|
|
shift
|
|
done
|
|
|
|
cd "$SDEROOT"
|
|
|
|
echo_info "Searching for lingering temp/backup files (this may take some time) ..."
|
|
|
|
sderootdirs="scripts/. bin/. etc/. lib/. doc/. src/. package/. architecture/." # target/.
|
|
|
|
files_remove="-name *~ -o -name a.out -o -name core.[0-9]* -o -name core"
|
|
files_warn="-name DEADJOE -o -name *-[xX] \
|
|
-o -name *.orig -o -name *.rej -o -name *#* \
|
|
-o -name *.mine -o -name *.r[1-9][0-9]* \
|
|
-o -name TRANS.TBL -o -name *.cksum-err -o -name x \
|
|
-o -name *[.-]old -o -name a.out -o -name *~ \
|
|
-o -name *.incomplete -o -name *.ckext-err"
|
|
|
|
# Remove temp/backup files
|
|
#
|
|
remove() {
|
|
if [ "x-d" = "x${1:-}" ]; then
|
|
shift
|
|
bin/find $sderootdirs target/. -type f \( "$@" \)
|
|
else
|
|
bin/find $sderootdirs target/. -type f \( "$@" \) -print0 | xargs -r0 rm -vf
|
|
fi
|
|
}
|
|
|
|
remove ${dry_run:+-d} $files_remove
|
|
|
|
# Print warnings for 'lingering' files
|
|
#
|
|
( bin/find ${sderootdirs} \( \
|
|
\( \( $files_warn -o -name '.[^.]*' \) \
|
|
-a ! -name '.gitignore' -a ! -name '.gitattributes' \) \
|
|
-printf 'WARNING: Found %p\n' \
|
|
\) -o \( \
|
|
\( ! -type d ! -type f \) \
|
|
-printf 'WARNING: Neither a dir nor a regular file: %p\n' \
|
|
\) ) &
|
|
|
|
# for targets we tolerate .files
|
|
( bin/find target/. \( \
|
|
\( $files_warn \) \
|
|
-printf 'WARNING: Found %p\n' \
|
|
\) -o \( \
|
|
\( ! -type d ! -type f \) \
|
|
-printf 'WARNING: Neither a dir nor a regular file: %p\n' \
|
|
\) ) &
|
|
|
|
wait
|
|
exit 0
|