forked from vixie/cron
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcatChangeLog
executable file
·225 lines (223 loc) · 4.03 KB
/
catChangeLog
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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
#!/bin/sh
#
# $Id: catChangeLog,v 1.10 2021-03-25 08:33:21+05:30 Cprogrammer Exp mbhangui $
#
option=1
while test $# -gt 0; do
case "$1" in
-*=*)
optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'`
;;
*)
optarg=""
;;
esac
valid=0
case "$1" in
--spec)
option=1
valid=1
;;
--debian)
option=2
valid=1
;;
--changes)
option=3
valid=1
;;
--email=*)
email=$optarg
valid=1
;;
--version=*)
version=$optarg
valid=1
;;
--release=*)
release=$optarg
valid=1
;;
--name=*)
name=$optarg
valid=1;
;;
--state=*)
state=$optarg
valid=1;
;;
--urgency=*)
urgency=$optarg
valid=1;
;;
*)
if [ -n "$optarg" ] ; then
echo "invalid option [$1]" 1>&2
exit 1
fi
;;
esac
if [ $valid -eq 0 ] ; then
break
fi
shift
done
if [ $# -eq 0 ] ; then
file=doc/ChangeLog
else
file=$1
fi
if [ $option -eq 2 ] ; then
if [ -z "$name" -o -z "$state" -o -z "$urgency" ] ; then
echo "you have to give --name --state --urgency options" 1>&1
fi
fi
if [ -z "$version" ] ; then
if [ -f conf-version ] ; then
version=$(cat conf-version)
elif [ -f ../conf-version ] ; then
version=$(cat ../conf-version)
fi
fi
if [ -z "$release" ] ; then
if [ -f conf-release ] ; then
release=$(cat conf-release)
elif [ -f ../conf-release ] ; then
release=$(cat ../conf-release)
fi
fi
if [ -z "$email" ] ; then
if [ -f conf-email ] ; then
email=$(cat conf-email)
elif [ -f ../conf-email ] ; then
email=$(cat ../conf-email)
fi
fi
flag=0
nonewline=0
bullet=0
highlights=0
exec 0<$file
while read line
do
echo "$line"|grep "^*" > /dev/null
status=$?
if [ $status -eq 0 -a $flag -ne 0 ] ; then
break
fi
if [ $status -ne 0 -a $flag -eq 0 ] ; then
continue
fi
echo "$line" | grep "^- [0-9]*/.*/.*" > /dev/null # skip dates
if [ $? -eq 0 ] ; then
continue
fi
if [ $flag -eq 0 ] ; then # first line
flag=1
if [ $option -eq 1 ] ; then
echo "* `date -u +"%a %b %d %Y %H:%M:%S %z"` $email" "$version"-"$release"%{?dist}
elif [ $option -eq 2 ] ; then
echo "$name ($version-$release) $state; urgency=$urgency"
echo
elif [ $option -eq 3 ] ; then
printf "%0*d\n" 67 |sed 's}0}-}g'
date "+%a, %b %d %H:%M:%S %Z %Y - $email"
echo
fi
continue
elif [ $flag -eq 1 ] ; then # second line
if [ $option -eq 1 ] ; then
echo "$line" | sed -e "s|@version\@|$version|g" -e "s|@release\@|$release|g"
fi
flag=2
continue
fi
echo $line | grep -E "^o " > /dev/null
if [ $? -eq 0 ] ; then
bullet=1
else
bullet=0
fi
echo "$line" |grep -E "^[0-9]|^[0-9][0-9]|^[0-9][0-9][0-9]" > /dev/null
if [ $? -eq 0 ] ; then
if [ $option -eq 2 -a $nonewline -eq 1 ] ; then
echo
fi
nonewline=0
if [ $option -eq 1 -o $option -eq 3 ] ; then
set $line
shift
echo "- $*"
elif [ $option -eq 2 ] ; then
set $line
shift
nonewline=1
echo -n " * $*"
fi
elif [ -n "$line" ] ; then
if [ $highlights -eq 0 ] ; then
nonewline=0
echo "$line" | grep "Release Highlights" >/dev/null
if [ $? -eq 0 ] ; then
highlights=1
if [ $option -eq 3 ] ; then
echo $line
fi
continue
fi
fi
if [ $highlights -eq 1 ] ; then
echo "$line" | grep "^====" >/dev/null
if [ $? -eq 0 ] ; then
highlights=2
if [ $option -ne 3 ] ; then
continue
fi
if [ $nonewline -eq 1 ] ; then
echo
nonewline=0
fi
echo $line
continue
fi
fi
if [ $highlights -eq 1 ] ; then
if [ $option -ne 3 ] ; then
continue
fi
if [ $bullet -eq 1 ] ; then
if [ $nonewline -eq 1 ] ; then
echo ""
nonewline=0
fi
echo "$line"
bullet=0
else
if [ $nonewline -eq 1 ] ; then
echo ""
nonewline=0
fi
echo -n " $line"
nonewline=1
fi
continue
fi
if [ $option -eq 1 -o $option -eq 3 ] ; then
echo " $line"
elif [ $option -eq 2 ] ; then
echo -n " $line"
nonewline=1
fi
fi
done
if [ $option -eq 2 ] ; then
if [ $nonewline -eq 1 ] ; then
echo
fi
echo
echo " -- $email `date -u +'%a, %d %b %Y %H:%M:%S %z'`"
elif [ $option -eq 3 ] ; then
if [ $nonewline -eq 1 ] ; then
echo
fi
fi