4 # Copyright (C) 2002 Alex Badea <vampire@p16.pub.ro>
6 # $Id: ircd-patch,v 1.2 2002-04-02 09:42:32 isomer Exp $
8 # Experimental centralized patch system for ircu
12 # 1 - at least one live patch failed
13 # 2 - at least one simulation (dry run) failed
14 # 3 - invalid arguments (i.e. no such patch)
15 # 4 - invalid operation (i.e. tried to apply when already applied)
23 [ ! -d $DIFFS ] && echo "*** Missing $DIFFS, creating it" ; mkdir -p $DIFFS
24 [ ! -d $MARKS ] && echo "*** Missing $MARKS, creating it" ; mkdir -p $MARKS
27 for fname in $DIFFS/*.diff ; do
28 name=`basename $fname | sed -e 's/\.diff//'`
33 patch -p0 -N -t --dry-run $2 >/dev/null < $1
37 echo "Available patches (* marks applied patches):"
38 for name in $PLIST ; do
39 [ -f $MARKS/$name ] && echo -n " * " || echo -n " "
46 echo "Testing patches:"
48 [ -z "$list" ] && list=$PLIST
49 for name in $list ; do
50 fname=$DIFFS/$name.diff
52 if [ ! -f $MARKS/$name ] ; then
53 if dry_run "$fname" ; then
56 echo -n " PATCH FAILED"
61 if dry_run "$fname" -R ; then
64 echo -n " REVERSE FAILED"
75 fname="$DIFFS/$name.diff"
76 if [ ! -f $fname ]; then
77 echo "Patch $name ($fname) does not exist"
82 if [ $force -lt 2 -a -f $MARKS/$name ] ; then
83 echo "Patch $name seems already applied"
88 if [ $force -lt 1 ]; then
89 echo -n "Testing $fname... "
90 if ! dry_run $fname ; then
91 echo "Failed (use -f to force)."
98 echo "Applying $fname..."
99 if patch -p0 -N -t < $fname ; then
110 fname="$DIFFS/$name.diff"
111 if [ ! -f $fname ]; then
112 echo "Patch $name ($fname) does not exist"
117 if [ $force -lt 2 -a ! -f $MARKS/$name ] ; then
118 echo "Patch $name doesn't seem to be applied"
123 if [ $force -lt 1 ]; then
124 echo -n "Testing $fname... "
125 if ! dry_run $fname -R ; then
126 echo "Failed (use -f to force)."
133 echo "Reversing $fname..."
134 if patch -p0 -R -t < $fname ; then
144 echo "Usage: $0 [-f [-f]] [args]"
145 echo "Arguments may be:"
146 echo " help Prints this help"
147 echo " list List available patches"
148 echo " test [patch list] Tests whether patches can be (un)applied correctly"
149 echo " add <patch list> Applies a patch"
150 echo " del <patch list> Reverses a patch"
151 echo "The -f option forces patching even if a dry run fails (effective on 'add'"
152 echo "and 'del' commands only). Using it twice will also skip checking whether"
153 echo "a patch is already applied."
156 while [ "$1" == "-f" ]; do