Author: Alex Badea <vampire@p16.pub.ro>
[ircu2.10.12-pk.git] / ircd-patch
index f42f388e8b7e07370897dca469a37851dca23aef..f91c1bafb83b9df3c1e4310dc0843866bd5d8288 100755 (executable)
@@ -3,7 +3,7 @@
 # ircd-patch
 # Copyright (C) 2002 Alex Badea <vampire@p16.pub.ro>
 #
-# $Id: ircd-patch,v 1.2 2002-04-02 09:42:32 isomer Exp $
+# $Id: ircd-patch,v 1.3 2002-04-02 11:24:29 isomer Exp $
 #
 # Experimental centralized patch system for ircu
 #
 
 DIFFS=patches/diffs
 MARKS=patches/marks
+PLIST_FILE=include/patchlist.h
+
 retcode=0
 force=0
 
-[ ! -d $DIFFS ] && echo "*** Missing $DIFFS, creating it" ; mkdir -p $DIFFS
-[ ! -d $MARKS ] && echo "*** Missing $MARKS, creating it" ; mkdir -p $MARKS
 
 PLIST=""
 for fname in $DIFFS/*.diff ; do
@@ -29,6 +29,19 @@ for fname in $DIFFS/*.diff ; do
        PLIST="$PLIST $name"
 done
 
+update_patchlist() {
+       list=""
+       for name in $PLIST ; do
+               [ -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)
+
 dry_run() {
        patch -p0 -N -t --dry-run $2 >/dev/null < $1
 }
@@ -148,6 +161,7 @@ do_help() {
        echo "  test [patch list]   Tests whether patches can be (un)applied correctly"
        echo "  add  <patch list>   Applies a patch"
        echo "  del  <patch list>   Reverses a patch"
+       echo "  update              Updates $PLIST_FILE with the currently applied patches"
        echo "The -f option forces patching even if a dry run fails (effective on 'add'"
        echo "and 'del' commands only). Using it twice will also skip checking whether"
        echo "a patch is already applied."
@@ -164,12 +178,14 @@ case "$1" in
                for name in $* ; do
                        patch_add $name
                done
+               update_patchlist
                ;;
        del)
                shift
                for name in $* ; do
                        patch_del $name
                done
+               update_patchlist
                ;;
        test)
                shift
@@ -178,6 +194,9 @@ case "$1" in
        list)
                patch_list
                ;;
+       update)
+               update_patchlist
+               ;;
        *)
                do_help
                ;;