summaryrefslogtreecommitdiffstats
path: root/needs-checking/pstatus
diff options
context:
space:
mode:
authorMartin Quinson <mquinson@debian.org>2003-01-21 09:49:29 +0000
committerMartin Quinson <mquinson@debian.org>2003-01-21 09:49:29 +0000
commit02dc4a5f8c1979e9a23f7b6851f693d29b640c4d (patch)
tree2f397f5df89f4529b89fd0e7a021238d0f290007 /needs-checking/pstatus
parent4d11e99bfc25e0261111d202a3a2afdf97daea5c (diff)
downloadquilt-02dc4a5f8c1979e9a23f7b6851f693d29b640c4d.tar.gz
Version 0.11, from Andreas Gruenbacher
Diffstat (limited to 'needs-checking/pstatus')
-rwxr-xr-xneeds-checking/pstatus158
1 files changed, 158 insertions, 0 deletions
diff --git a/needs-checking/pstatus b/needs-checking/pstatus
new file mode 100755
index 0000000..0c32102
--- /dev/null
+++ b/needs-checking/pstatus
@@ -0,0 +1,158 @@
+#!/bin/sh
+
+# print out patch status. Usage: pstatus [ patchfile ... ]
+#
+# Stephen Cameron <steve.cameron@hp.com>
+#
+
+. patchfns 2>/dev/null ||
+. /usr/lib/patch-scripts/patchfns 2>/dev/null ||
+. $PATCHSCRIPTS_LIBDIR/patchfns 2>/dev/null ||
+{
+ echo "Impossible to find my library 'patchfns'."
+ echo "Check your install, or go to the right directory"
+ exit 1
+}
+
+if [ ! -f $P/series ]
+then
+ echo "./series does not exist." 1>&2
+ exit 1
+fi
+
+if [ ! -d $P/patches ]
+then
+ echo "Directory ./patches does not exist." 1>&2
+ exit 1
+fi
+
+
+PATCHLIST="$*"
+if [ "$PATCHLIST" = "" ]
+then
+ series_optimize=yes
+ PATCHLIST=$(cat_series)
+ SORTSERIES=`mktemp /tmp/ser.XXXXXX` || exit 1
+ SORTPATCHES=`mktemp /tmp/pat.XXXXXX` || exit 1
+ cat_series | sort > $SORTSERIES
+ exists="`echo $P/patches/*.patch 2>/dev/null`"
+ if [ "$exists" != "$P/patches/*.patch" ]
+ then
+ ls -1 $P/patches/*.patch | sed -e 's/^.*\/patches\///' \
+ -e 's/[.]patch[ ]*$//' | sort > $SORTPATCHES
+ PATCHLIST="$PATCHLIST"" `comm -1 -3 $SORTSERIES $SORTPATCHES`"
+ fi
+ rm -f $SORTPATCHES $SORTSERIES
+else
+ series_optimize=no
+fi
+
+NSERIES=$(cat_series | wc -l | awk '{ print $1; }')
+series=1
+for PATCH_NAME in $PATCHLIST
+do
+ PATCH_NAME=$(stripit $PATCH_NAME)
+ # see if this patch even exists
+ if [ ! -f $P/patches/"$PATCH_NAME".patch ]
+ then
+ echo "$PATCH_NAME does not exist."
+ continue
+ fi
+ # see if this patch is applied
+ applied="-"
+ if [ -f $P/applied-patches ]
+ then
+ grep '^'"$PATCH_NAME"'$' $P/applied-patches > /dev/null
+ if [ "$?" = "0" ]
+ then
+ applied="a"
+ fi
+ fi
+
+ # figure the status of this patch, that is,
+ # if it needs changelog, pcpatch, refpatch
+
+ stat=""
+ if [ ! -f $P/txt/"$PATCH_NAME".txt ]
+ then
+ stat="changelog "
+ fi
+ if [ ! -f $P/pc/"$PATCH_NAME".pc ]
+ then
+ stat="$stat""pcpatch "
+ elif [ "$applied" != '-' ]
+ then
+ rpatch=n
+
+ # for each file this patch touches
+ for y in `cat $P/pc/"$PATCH_NAME".pc`
+ do
+ # is the patch adding the file?
+ if [ ! -e "$y"'~'"$PATCH_NAME" -a -f "$y" ]
+ then
+ # file is newer than the patch?
+ if [ "$y" -nt $P/patches/"$PATCH_NAME".patch ]
+ then
+ rpatch=y
+ stat="$stat""refpatch "
+ break
+ fi
+ else
+ # modified file is newer than the patch?
+ if [ "$y"'~'"$PATCH_NAME" -nt \
+ $P/patches/"$PATCH_NAME".patch ]
+ then
+ rpatch=y
+ stat="$stat""refpatch "
+ break
+ fi
+ if [ "`$PATCHSCRIPTS_LIBDIR/toppatch`" = "$PATCH_NAME" -a \
+ "$y" -nt $P/patches/"$PATCH_NAME".patch ]
+ then
+ # toppatch, so check if the file
+ # is newer than the patch?
+ rpatch=y
+ stat="$stat""refpatch "
+ break
+ fi
+ fi
+ done
+ fi
+ # check if they changed the changelog recently
+ if [ "$rpatch" = "n" -a -f $P/txt/"$PATCH_NAME".txt \
+ -a $P/txt/"$PATCH_NAME".txt -nt \
+ $P/patches/"$PATCH_NAME".patch ]
+ then
+ rpatch=y
+ stat="$stat""refpatch "
+ fi
+ if [ "$stat" != "" ]
+ then
+ stat="Needs ""$stat"
+ fi
+
+ if [ "$series_optimize" != "yes" ]
+ then
+ # have to find the series number the hard way.
+ series=$(cat_series | grep -n '^'"$PATCH_NAME"'$' |\
+ awk -F: '{ printf "%d", $1}' )
+ if [ "$series" = "" ]
+ then
+ series="?"
+ fi
+ fi
+
+ echo "$series":"$applied":"$PATCH_NAME $stat"
+
+ if [ "$series_optimize" = "yes" ]
+ then
+ if [ "$series" != "?" ]
+ then
+ series=`expr $series + 1`
+ if [ $series -gt $NSERIES ]
+ then
+ series="?"
+ fi
+ fi
+ fi
+done