X-Git-Url: http://git.pk910.de/?p=ircu2.10.12-pk.git;a=blobdiff_plain;f=ircd-patch;h=9637b89aa72ad77ccfd98932f1f660673cdcee49;hp=f91c1bafb83b9df3c1e4310dc0843866bd5d8288;hb=refs%2Fheads%2Fupstream;hpb=6dca66de9006eb9bb918e69a001774f85add0b9b diff --git a/ircd-patch b/ircd-patch index f91c1ba..9637b89 100755 --- a/ircd-patch +++ b/ircd-patch @@ -1,11 +1,27 @@ #!/bin/sh # -# ircd-patch +# IRC - Internet Relay Chat, ircd-patch # Copyright (C) 2002 Alex Badea # -# $Id: ircd-patch,v 1.3 2002-04-02 11:24:29 isomer Exp $ +# 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; either version 1, or (at your option) +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# +# $Id: ircd-patch,v 1.5.2.1 2005-12-29 03:41:56 entrope Exp $ +# # # Experimental centralized patch system for ircu +# Run with no arguments to get help. # # Return codes: # 0 - success @@ -32,24 +48,25 @@ done update_patchlist() { list="" for name in $PLIST ; do - [ -f $MARKS/$name ] && list="$list.$name" + test -f $MARKS/$name && list="$list.$name" done echo "/* This file was automatically generated by ircd-patch */" > $PLIST_FILE echo "#define PATCHLIST \"$list\"" >> $PLIST_FILE echo "Updated $PLIST_FILE" } -[ ! -d $DIFFS ] && (echo "*** Missing $DIFFS, creating it" ; mkdir -p $DIFFS) -[ ! -d $MARKS ] && (echo "*** Missing $MARKS, creating it" ; mkdir -p $MARKS) +test -d $DIFFS || (echo "*** Missing $DIFFS, creating it" ; mkdir -p $DIFFS) +test -d $MARKS || (echo "*** Missing $MARKS, creating it" ; mkdir -p $MARKS) dry_run() { - patch -p0 -N -t --dry-run $2 >/dev/null < $1 + rejects=`patch -p0 -N -t --dry-run $2 < $1 | grep "hunk FAILED" | sed -e 's/.*to file / /;s/\.rej$//'` + test -z "$rejects" } patch_list() { echo "Available patches (* marks applied patches):" for name in $PLIST ; do - [ -f $MARKS/$name ] && echo -n " * " || echo -n " " + test -f $MARKS/$name && echo -n " * " || echo -n " " echo $name done echo "Done." @@ -58,11 +75,11 @@ patch_list() { patch_test() { echo "Testing patches:" list="$*" - [ -z "$list" ] && list=$PLIST + test "z$list" = "z" && list=$PLIST for name in $list ; do fname=$DIFFS/$name.diff echo -ne " $name\t" - if [ ! -f $MARKS/$name ] ; then + if test ! -f $MARKS/$name ; then if dry_run "$fname" ; then echo -n " OK" else @@ -86,22 +103,24 @@ patch_test() { patch_add() { name=$1 fname="$DIFFS/$name.diff" - if [ ! -f $fname ]; then + if test ! -f $fname ; then echo "Patch $name ($fname) does not exist" retcode=3 return fi - if [ $force -lt 2 -a -f $MARKS/$name ] ; then + if test $force -lt 2 -a -f $MARKS/$name ; then echo "Patch $name seems already applied" retcode=4 return fi - if [ $force -lt 1 ]; then + if test $force -lt 1 ; then echo -n "Testing $fname... " if ! dry_run $fname ; then echo "Failed (use -f to force)." + echo "The following files failed patching:" + echo "$rejects" retcode=2 return fi @@ -121,22 +140,24 @@ patch_add() { patch_del() { name=$1 fname="$DIFFS/$name.diff" - if [ ! -f $fname ]; then + if test ! -f $fname ; then echo "Patch $name ($fname) does not exist" retcode=3 return fi - if [ $force -lt 2 -a ! -f $MARKS/$name ] ; then + if test $force -lt 2 -a ! -f $MARKS/$name ; then echo "Patch $name doesn't seem to be applied" retcode=4 return fi - if [ $force -lt 1 ]; then + if test $force -lt 1 ; then echo -n "Testing $fname... " if ! dry_run $fname -R ; then echo "Failed (use -f to force)." + echo "The following files failed patching:" + echo "$rejects" retcode=2 return fi @@ -167,8 +188,8 @@ do_help() { echo "a patch is already applied." } -while [ "$1" == "-f" ]; do - force=$[$force + 1] +while test "$1" = "-f" ; do + force=`expr $force + 1` shift done