blob: 4ceff7d3d4fccdb21aa6d16dce360ee6983b29ea (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
|
#! /bin/bash
# This script is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
#
# See the COPYING and AUTHORS files for more details.
# 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
|