3 # print out patch status. Usage: pstatus [ patchfile ... ]
5 # Stephen Cameron <steve.cameron@hp.com>
8 . patchfns >/dev/null || . /usr/lib/patch-scripts/patchfns >/dev/null || { \
9 echo "Impossible to find my library 'patchfns'."
10 echo "Check your install, or go to the right directory"
16 echo "./series does not exist." 1>&2
22 echo "Directory ./patches does not exist." 1>&2
28 if [ "$PATCHLIST" = "" ]
31 PATCHLIST=`cat series | sed -e 's/[.]patch[ ]*$//'`
32 SORTSERIES=`mktemp /tmp/ser.XXXXXX` || exit 1
33 SORTPATCHES=`mktemp /tmp/pat.XXXXXX` || exit 1
34 sed -e 's/^[ ]//' -e 's/[.]patch[ ]*$//' < series | \
36 exists="`echo $P/patches/*.patch 2>/dev/null`"
37 if [ "$exists" != "$P/patches/*.patch" ]
39 ls -1 $P/patches/*.patch | sed -e 's/^.*\/patches\///' \
40 -e 's/[.]patch[ ]*$//' | sort > $SORTPATCHES
41 PATCHLIST="$PATCHLIST"" `comm -1 -3 $SORTSERIES $SORTPATCHES`"
43 rm -f $SORTPATCHES $SORTSERIES
48 NSERIES=`wc -l series | awk '{ print $1; }'`
50 for PATCH_NAME in $PATCHLIST
52 PATCH_NAME=$(stripit $PATCH_NAME)
53 # see if this patch even exists
54 if [ ! -f $P/patches/"$PATCH_NAME".patch ]
56 echo "$PATCH_NAME does not exist."
59 # see if this patch is applied
61 if [ -f applied-patches ]
63 grep '^'"$PATCH_NAME"'$' applied-patches > /dev/null
70 # figure the status of this patch, that is,
71 # if it needs changelog, pcpatch, refpatch
74 if [ ! -f $P/txt/"$PATCH_NAME".txt ]
78 if [ ! -f $P/pc/"$PATCH_NAME".pc ]
80 stat="$stat""pcpatch "
81 elif [ "$applied" != '-' ]
85 # for each file this patch touches
86 for y in `cat $P/pc/"$PATCH_NAME".pc`
88 # is the patch adding the file?
89 if [ ! -e "$y"'~'"$PATCH_NAME" -a -f "$y" ]
91 # file is newer than the patch?
92 if [ "$y" -nt $P/patches/"$PATCH_NAME".patch ]
95 stat="$stat""refpatch "
99 # modified file is newer than the patch?
100 if [ "$y"'~'"$PATCH_NAME" -nt \
101 $P/patches/"$PATCH_NAME".patch ]
104 stat="$stat""refpatch "
107 if [ "`toppatch`" = "$PATCH_NAME" -a \
108 "$y" -nt $P/patches/"$PATCH_NAME".patch ]
110 # toppatch, so check if the file
111 # is newer than the patch?
113 stat="$stat""refpatch "
119 # check if they changed the changelog recently
120 if [ "$rpatch" = "n" -a -f $P/txt/"$PATCH_NAME".txt \
121 -a $P/txt/"$PATCH_NAME".txt -nt \
122 $P/patches/"$PATCH_NAME".patch ]
125 stat="$stat""refpatch "
132 if [ "$series_optimize" != "yes" ]
134 # have to find the series number the hard way.
135 series=`grep -n '^'"$PATCH_NAME"'\.patch$' series |\
136 awk -F: '{ printf "%d", $1}' `
137 if [ "$series" = "" ]
143 echo "$series":"$applied":"$PATCH_NAME $stat"
145 if [ "$series_optimize" = "yes" ]
147 if [ "$series" != "?" ]
149 series=`expr $series + 1`
150 if [ $series -gt $NSERIES ]