edit-patch: Correct indentation to spaces only.

This commit is contained in:
Benjamin Drung 2010-12-02 23:36:32 +01:00
parent 84e2835686
commit daf1535d05

View File

@ -44,13 +44,13 @@ fatal_error() {
# arg2: error message # arg2: error message
require_installed() { require_installed() {
if ! which "$1" >/dev/null; then if ! which "$1" >/dev/null; then
fatal_error "$2" fatal_error "$2"
fi fi
} }
ensure_debian_dir() { ensure_debian_dir() {
if [ ! -e debian/control ] || [ ! -e debian/rules ]; then if [ ! -e debian/control ] || [ ! -e debian/rules ]; then
fatal_error "Can not find debian/rules or debian/control. Not in a debian dir?" fatal_error "Can not find debian/rules or debian/control. Not in a debian dir?"
fi fi
} }
@ -59,18 +59,18 @@ detect_patchsystem() {
CDBS_PATCHSYS="^[^#]*simple-patchsys.mk" CDBS_PATCHSYS="^[^#]*simple-patchsys.mk"
if grep -q "$CDBS_PATCHSYS" debian/rules; then if grep -q "$CDBS_PATCHSYS" debian/rules; then
PATCHSYSTEM="cdbs" PATCHSYSTEM="cdbs"
require_installed cdbs-edit-patch "no cdbs-edit-patch found, is 'cdbs' installed?" require_installed cdbs-edit-patch "no cdbs-edit-patch found, is 'cdbs' installed?"
elif [ -e debian/patches/00list ]; then elif [ -e debian/patches/00list ]; then
PATCHSYSTEM="dpatch" PATCHSYSTEM="dpatch"
require_installed dpatch-edit-patch "no dpatch-edit-patch found, is 'dpatch' installed?" require_installed dpatch-edit-patch "no dpatch-edit-patch found, is 'dpatch' installed?"
elif [ -e debian/patches/series -o \( \ elif [ -e debian/patches/series -o \( \
-e debian/source/format -a "$(cat debian/source/format)" = "3.0 (quilt)" \) ]; then -e debian/source/format -a "$(cat debian/source/format)" = "3.0 (quilt)" \) ]; then
PATCHSYSTEM="quilt" PATCHSYSTEM="quilt"
require_installed quilt "no quilt found, is 'quilt' installed?" require_installed quilt "no quilt found, is 'quilt' installed?"
else else
PATCHSYSTEM="none" PATCHSYSTEM="none"
PREFIX="debian/applied-patches" PREFIX="debian/applied-patches"
fi fi
} }
@ -86,20 +86,20 @@ normalize_patch_path() {
normalize_patch_extension() { normalize_patch_extension() {
# check if we have a patch already # check if we have a patch already
if [ -e $PREFIX/$PATCHNAME ]; then if [ -e $PREFIX/$PATCHNAME ]; then
echo "Patch $PATCHNAME exists, not normalizing" echo "Patch $PATCHNAME exists, not normalizing"
return return
fi fi
# normalize name for new patches # normalize name for new patches
PATCHNAME=${PATCHNAME%.*} PATCHNAME=${PATCHNAME%.*}
if [ "$PATCHSYSTEM" = "quilt" ]; then if [ "$PATCHSYSTEM" = "quilt" ]; then
PATCHNAME="${PATCHNAME}.patch" PATCHNAME="${PATCHNAME}.patch"
elif [ "$PATCHSYSTEM" = "cdbs" ]; then elif [ "$PATCHSYSTEM" = "cdbs" ]; then
PATCHNAME="${PATCHNAME}.patch" PATCHNAME="${PATCHNAME}.patch"
elif [ "$PATCHSYSTEM" = "dpatch" ]; then elif [ "$PATCHSYSTEM" = "dpatch" ]; then
PATCHNAME="${PATCHNAME}.dpatch" PATCHNAME="${PATCHNAME}.dpatch"
elif [ "$PATCHSYSTEM" = "none" ]; then elif [ "$PATCHSYSTEM" = "none" ]; then
PATCHNAME="${PATCHNAME}.patch" PATCHNAME="${PATCHNAME}.patch"
fi fi
echo "Normalizing patch name to $PATCHNAME" echo "Normalizing patch name to $PATCHNAME"
@ -114,7 +114,7 @@ edit_patch_dpatch() {
dpatch-edit-patch $PATCHNAME dpatch-edit-patch $PATCHNAME
# add if needed # add if needed
if ! grep -q $1 $PREFIX/00list; then if ! grep -q $1 $PREFIX/00list; then
echo "$1" >> $PREFIX/00list echo "$1" >> $PREFIX/00list
fi fi
vcs_add $PREFIX/00list $PREFIX/$1 vcs_add $PREFIX/00list $PREFIX/$1
} }
@ -122,18 +122,18 @@ edit_patch_dpatch() {
edit_patch_quilt() { edit_patch_quilt() {
export QUILT_PATCHES=debian/patches export QUILT_PATCHES=debian/patches
if [ -e $PREFIX/$1 ]; then if [ -e $PREFIX/$1 ]; then
# if its a existing patch and we are at the end of the stack, # if its a existing patch and we are at the end of the stack,
# go back at the beginning # go back at the beginning
if ! quilt unapplied; then if ! quilt unapplied; then
quilt pop -a quilt pop -a
fi fi
quilt push $1 quilt push $1
else else
# if its a new patch make sure we are at the end of the stack # if its a new patch make sure we are at the end of the stack
if quilt unapplied >/dev/null; then if quilt unapplied >/dev/null; then
quilt push -a quilt push -a
fi fi
quilt new $1 quilt new $1
fi fi
# use a sub-shell # use a sub-shell
quilt shell quilt shell
@ -144,18 +144,18 @@ edit_patch_quilt() {
vcs_add() { vcs_add() {
if [ -d .bzr ]; then if [ -d .bzr ]; then
bzr add $@ bzr add $@
elif [ -d .git ];then elif [ -d .git ];then
git add $@ git add $@
else else
echo "Remember to add $@ to a VCS if you use one" echo "Remember to add $@ to a VCS if you use one"
fi fi
} }
vcs_commit() { vcs_commit() {
# check if debcommit is happy # check if debcommit is happy
if ! debcommit --noact 2>/dev/null; then if ! debcommit --noact 2>/dev/null; then
return return
fi fi
# commit (if the user confirms) # commit (if the user confirms)
debcommit --confirm debcommit --confirm
@ -164,9 +164,9 @@ vcs_commit() {
add_changelog() { add_changelog() {
S="$PREFIX/$1: [DESCRIBE CHANGES HERE]" S="$PREFIX/$1: [DESCRIBE CHANGES HERE]"
if head -n1 debian/changelog|grep UNRELEASED; then if head -n1 debian/changelog|grep UNRELEASED; then
dch --append "$S" dch --append "$S"
else else
dch --increment "$S" dch --increment "$S"
fi fi
# let the user edit it # let the user edit it
dch --edit dch --edit
@ -175,13 +175,13 @@ add_changelog() {
add_patch_tagging() { add_patch_tagging() {
# check if we have a descripton already # check if we have a descripton already
if grep "## Description:" $PREFIX/$1; then if grep "## Description:" $PREFIX/$1; then
return return
fi fi
# if not, add one # if not, add one
RANGE=1,1 RANGE=1,1
# make sure we keep the first line (for dpatch) # make sure we keep the first line (for dpatch)
if head -n1 $PREFIX/$1|grep -q '^#'; then if head -n1 $PREFIX/$1|grep -q '^#'; then
RANGE=2,2 RANGE=2,2
fi fi
sed -i ${RANGE}i"$PATCH_DESC" $PREFIX/$1 sed -i ${RANGE}i"$PATCH_DESC" $PREFIX/$1
} }
@ -189,7 +189,7 @@ add_patch_tagging() {
detect_patch_location() { detect_patch_location() {
# Checks whether the specified patch exists in debian/patches or on the filesystem # Checks whether the specified patch exists in debian/patches or on the filesystem
FILENAME=${PATCHNAME##*/} FILENAME=${PATCHNAME##*/}
if [ -f "$PREFIX/$FILENAME" ]; then if [ -f "$PREFIX/$FILENAME" ]; then
PATCHTYPE="debian" PATCHTYPE="debian"
elif [ -f "$PATCHNAME" ]; then elif [ -f "$PATCHNAME" ]; then
@ -213,31 +213,31 @@ stored in debian/patches-applied. Please remember to mention this in your change
handle_file_patch() { handle_file_patch() {
if [ "$PATCHTYPE" = "file" ]; then if [ "$PATCHTYPE" = "file" ]; then
[ -f "$PATCHORIG" ] || fatal_error "No patch detected" [ -f "$PATCHORIG" ] || fatal_error "No patch detected"
if [ "$PATCHSYSTEM" = "none" ]; then if [ "$PATCHSYSTEM" = "none" ]; then
# If we're supplied a file and there is no patchsys we apply it directly # If we're supplied a file and there is no patchsys we apply it directly
# and store it in debian/applied patches # and store it in debian/applied patches
[ -d $PREFIX ] || mkdir $PREFIX [ -d $PREFIX ] || mkdir $PREFIX
patch -p0 < "$PATCHORIG" patch -p0 < "$PATCHORIG"
cp "$PATCHORIG" "$PREFIX/$PATCHNAME" cp "$PATCHORIG" "$PREFIX/$PATCHNAME"
else else
# Patch type is file but there is a patchsys present, so we add it # Patch type is file but there is a patchsys present, so we add it
# correctly # correctly
cp "$PATCHORIG" "$PREFIX/$PATCHNAME" cp "$PATCHORIG" "$PREFIX/$PATCHNAME"
if [ "$PATCHSYSTEM" = "quilt" ]; then if [ "$PATCHSYSTEM" = "quilt" ]; then
echo "$PATCHNAME" >> $PREFIX/series echo "$PATCHNAME" >> $PREFIX/series
elif [ "$PATCHSYSTEM" = "dpatch" ]; then elif [ "$PATCHSYSTEM" = "dpatch" ]; then
echo "$PATCHNAME" >> $PREFIX/00list echo "$PATCHNAME" >> $PREFIX/00list
# Add the dpatch header to files that don't already have it # Add the dpatch header to files that don't already have it
if ! grep -q "@DPATCH@" "$PREFIX/$PATCHNAME"; then if ! grep -q "@DPATCH@" "$PREFIX/$PATCHNAME"; then
sed -i '1i#! /bin/sh /usr/share/dpatch/dpatch-run\n@DPATCH@' $PREFIX/$PATCHNAME sed -i '1i#! /bin/sh /usr/share/dpatch/dpatch-run\n@DPATCH@' $PREFIX/$PATCHNAME
fi fi
fi fi
echo "Copying and applying new patch. You can now edit the patch or exit the subshell to save." echo "Copying and applying new patch. You can now edit the patch or exit the subshell to save."
fi fi
fi fi
} }
@ -249,8 +249,8 @@ handle_file_patch() {
main() { main() {
# parse args # parse args
if [ $# -ne 1 ]; then if [ $# -ne 1 ]; then
fatal_error "Need exactly one patch name" fatal_error "Need exactly one patch name"
fi fi
PATCHNAME="$1" PATCHNAME="$1"
# do the work # do the work
ensure_debian_dir ensure_debian_dir