1
0
mirror of git://projects.qi-hardware.com/xburst-tools.git synced 2024-11-01 18:22:28 +02:00
xburst-tools/usbboot/debian/clean.sh
Jonathan Nieder 3d82483481 debian/rules: rewrite as a minimal debian/rules file (using dh)
This makes the packaging easier to read and modify.

Features added:

 * runs ‘make’ with the -j option for a tiny speedup
 * uses appropriate compiler flags even when run directly instead of
   through dpkg-buildpackage
 * after interrupting a partial build, there is no need any more
   for (fake) root privileges to clean up
 * after interrupting a partial build, ‘debian/rules clean’ will
   work without running autoreconf again.

Features retained:

 * ‘debian/rules -n <target>’ provides the list of commands used
   to make that target.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
2010-04-05 14:56:44 +08:00

110 lines
1.8 KiB
Bash

#!/bin/sh
# Clean up after a failed build.
#
# Requires access to .gitignore files excluding _all_ modified files.
#
# Requires a working /dev/fd (with more than just /dev/fd/0 and 1)
# or gawk.
set -e
splitgitignore='#!/usr/bin/awk
!/^#/ && !/^$/ {
glob = /[[*?]/;
directory = /\/$/;
sub(/\/$/, "");
anchored = /\//;
sub(/^\//, "");
output = "nonexistent/nonsense";
if (anchored) {
if (!directory && !glob)
output = "/dev/fd/1";
else if (directory && !glob)
output = "/dev/fd/3";
else if (!directory && glob)
output = "/dev/fd/4";
else if (directory && glob)
output = "/dev/fd/5";
} else {
if (!directory)
output = "/dev/fd/6";
else
output = "/dev/fd/7";
}
print >> output;
}
'
gitdir="-type d -name '.*' -prune"
debiandir="-type d -name debian -prune"
remove_file_globs() {
while read glob
do
eval "rm -f $glob"
done
}
remove_directory_globs() {
while read glob
do
eval "rm -fr $glob"
done
}
remove_file_findpatterns() {
while read pat
do
find . $gitdir -o \
'(' -name "$pat" -execdir rm -f '{}' + ')'
done
}
remove_directory_findpatterns() {
while read pat
do
find . $gitdir -o \
'(' -type d -name "$pat" -execdir rm -fr '{}' + ')'
done
}
find . $gitdir -o $debiandir -o '(' -name .gitignore -print ')' |
while read file
do
(
cd "$(dirname "$file")"
# Dispatch using pipes. Yuck.
{ { { { {
awk "$splitgitignore" |
{
# anchored files (globless)
xargs -d '\n' rm -f
}
} 3>&1 >&2 |
{
# anchored directories (globless)
xargs -d '\n' rm -fr
}
} 4>&1 >&2 |
{
# anchored files
remove_file_globs
}
} 5>&1 >&2 |
{
# anchored directories
remove_directory_globs
}
} 6>&1 >&2 |
{
# unanchored files
remove_file_findpatterns
}
} 7>&1 >&2 |
{
remove_directory_findpatterns
} >&2
) < "$file"
done