what-patch: extend verbosity to cover all patch systems

This commit is contained in:
Kees Cook 2008-06-13 11:20:44 -07:00
parent 11a10bd86c
commit ea9597604b

View File

@ -1,5 +1,5 @@
#!/bin/bash #!/bin/bash
# Copyright 2006-2007 (C) Kees Cook <kees@ubuntu.com> # Copyright 2006-2008 (C) Kees Cook <kees@ubuntu.com>
# Modified by Siegfried-A. Gevatter <rainct@ubuntu.com> # Modified by Siegfried-A. Gevatter <rainct@ubuntu.com>
# Modified by Daniel Hahler <ubuntu@thequod.de> # Modified by Daniel Hahler <ubuntu@thequod.de>
# License: GPLv2 # License: GPLv2
@ -14,8 +14,10 @@ Usage: $0 [-v]
Run this inside the source directory of a Debian package and it will detect Run this inside the source directory of a Debian package and it will detect
the patch system that it uses. the patch system that it uses.
-v: Print a list of all those files outside the debian/ directory that have -v: Enable verbose mode:
been modified (if any). - Print a list of all those files outside the debian/ directory that have
been modified (if any).
- Report additional details about patch systems, if available.
EOM EOM
exit 0 exit 0
fi fi
@ -29,8 +31,13 @@ do
cd .. cd ..
done done
VERBOSE=0
if [ "$1" = "-v" ] if [ "$1" = "-v" ]
then then
VERBOSE=1
fi
if [ "$VERBOSE" -gt 0 ]; then
files=`lsdiff -z ../$(dpkg-parsechangelog | grep ^Source: | sed -e "s/^Source: //")_$(dpkg-parsechangelog | grep ^Version: | sed -e "s/^Version: //").diff.gz 2>/dev/null | grep -v 'debian/'` files=`lsdiff -z ../$(dpkg-parsechangelog | grep ^Source: | sed -e "s/^Source: //")_$(dpkg-parsechangelog | grep ^Version: | sed -e "s/^Version: //").diff.gz 2>/dev/null | grep -v 'debian/'`
if [ -n "$files" ] if [ -n "$files" ]
then then
@ -42,13 +49,51 @@ then
fi fi
fi fi
# Do not change the output of existing checks by default, as there are build
# tools that rely on the exisitng output. If changes in reporting is needed,
# please check the "VERBOSE" flag (see below for examples). Feel free
# to add new patchsystem detection and reporting.
for filename in $(echo "debian/rules"; grep ^include debian/rules | fgrep -v '$(' | awk '{print $2}') for filename in $(echo "debian/rules"; grep ^include debian/rules | fgrep -v '$(' | awk '{print $2}')
do do
fgrep patchsys.mk "$filename" | grep -q -v "^#" && { echo "cdbs (patchsys.mk)"; exit 0; } fgrep patchsys.mk "$filename" | grep -q -v "^#" && {
if [ "$VERBOSE" -eq 0 ]; then
echo "cdbs"; exit 0;
else
echo "cdbs (patchsys.mk: see 'cdbs-edit-patch')"; exit 0;
fi
}
fgrep quilt "$filename" | grep -q -v "^#" && { echo "quilt"; exit 0; } fgrep quilt "$filename" | grep -q -v "^#" && { echo "quilt"; exit 0; }
fgrep dbs-build.mk "$filename" | grep -q -v "^#" && { echo "dbs"; exit 0; } fgrep dbs-build.mk "$filename" | grep -q -v "^#" && {
fgrep dpatch "$filename" | grep -q -v "^#" && { echo "dpatch"; exit 0; } if [ "$VERBOSE" -eq 0 ]; then
fgrep '*.diff' "$filename" | grep -q -v "^#" && { echo "diff splash"; exit 0; } echo "dbs"; exit 0;
else
echo "dbs (see 'dbs-edit-patch')"; exit 0;
fi
}
fgrep dpatch "$filename" | grep -q -v "^#" && {
if [ "$VERBOSE" -eq 0 ]; then
echo "dpatch"; exit 0;
else
echo "dpatch (see 'patch-edit-patch')"; exit 0;
fi
}
fgrep '*.diff' "$filename" | grep -q -v "^#" && {
if [ "$VERBOSE" -eq 0 ]; then
echo "diff splash"; exit 0;
else
echo "diff splash (check debian/rules)"; exit 0;
fi
}
done done
[ -d debian/patches ] || { echo "patchless?"; exit 0; } [ -d debian/patches ] || {
echo "unknown patch system" if [ "$VERBOSE" -eq 0 ]; then
echo "patchless?"; exit 0;
else
echo "patchless? (did not find debian/patches/)"; exit 0;
fi
}
if [ "$VERBOSE" -eq 0 ]; then
echo "unknown patch system"
else
echo "unknown patch system (see debian/patches/ and debian/rules)"
fi