| 1 |
#! /bin/bash -e |
| 2 |
|
| 3 |
# Warning: This script deletes potentially important files. By design, |
| 4 |
# it fails and does nothing unless invoked with the '-f' force option. |
| 5 |
# Invoke the script with discretion. |
| 6 |
# |
| 7 |
# This shell script cleans the debian package files from the parent of |
| 8 |
# the source's top directory, including |
| 9 |
# |
| 10 |
# source-version.orig/ |
| 11 |
# source_version[.-]* |
| 12 |
|
| 13 |
SELF=cleandeb |
| 14 |
|
| 15 |
function usage { |
| 16 |
cat <<END |
| 17 |
Warning: This script deletes potentially important files. By design, |
| 18 |
it fails and does nothing unless invoked with the '-f' force option. |
| 19 |
Invoke the script with discretion. |
| 20 |
|
| 21 |
usage: debian/$SELF [-fh] |
| 22 |
-f force (this option is required against accidental invocation) |
| 23 |
-h print this help message and exit |
| 24 |
|
| 25 |
END |
| 26 |
} |
| 27 |
|
| 28 |
# Require that the script be invoked from the top source directory. |
| 29 |
if [[ ! ( $PWD/debian/$SELF -ef $0 ) ]] ; then |
| 30 |
echo 1>&2 "$0: must be invoked from the top source directory" |
| 31 |
exit 1 |
| 32 |
fi |
| 33 |
|
| 34 |
# Read options from the command line. |
| 35 |
FORCE=0 |
| 36 |
HELP=0 |
| 37 |
while getopts 'fh' OPT ; do |
| 38 |
[[ $OPT == 'f' ]] && FORCE=1 |
| 39 |
[[ $OPT == 'h' ]] && HELP=1 |
| 40 |
if [[ $OPT == '?' ]] ; then |
| 41 |
usage 1>&2 |
| 42 |
exit 1 |
| 43 |
fi |
| 44 |
done |
| 45 |
|
| 46 |
if [[ $HELP == 1 ]] ; then |
| 47 |
usage |
| 48 |
elif [[ $FORCE == 0 ]] ; then |
| 49 |
usage 1>&2 |
| 50 |
exit 1 |
| 51 |
else |
| 52 |
|
| 53 |
DIRNAME=$( dirname $PWD ) |
| 54 |
BASENAME=$( basename $PWD ) |
| 55 |
DEBBASENAME=$( echo $BASENAME | sed -e 's/-/_/' ) |
| 56 |
|
| 57 |
# Delete files! |
| 58 |
rm -Rf $DIRNAME/$BASENAME.orig $DIRNAME/$DEBBASENAME[.-]* |
| 59 |
|
| 60 |
fi |
| 61 |
|