-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathotdm2Wiki.sh
executable file
·337 lines (253 loc) · 8.05 KB
/
otdm2Wiki.sh
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
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
echo "It will build auto pages from otdm- packages."
rootDir="/OT"
wikiDir="/home/yoyo/Apps/oiyshTerminal.wiki"
. ${rootDir}/otdmBuildList.sh
if [ "$1" = "" ]; then
echo "no arg run"
else
echo "with arg: ["$1"]"
if [ -d $1 ];then
echo "dir is ok ... "$1
echo "swaping bList to one from arg ..."
bList=$1
else
exit 1
fi
fi
echo "list to build:
"${bList}
echo "otdm dir: "${rootDir}
echo "wiki dir: "${wikiDir}
#exit 1
bIndex="# otdm index\n\n
This is a automatic list of family packages with subjects in them.\n\n
\n\n"
for o in ${bList}
do
wF=${wikiDir}"/"${o}".md"
cowsay " wiki for: "${o}"
"
echo "" > ${wF}
index=""
bIndex=${bIndex}"\n\n---\n\n## "${o}"\n\n"
echo "- "${o}" checking Description... "${wF}
if [ -f ${rootDir}"/"${o}"/DEBIAN/control" ]
then
echo "
## Automatic information from "${o}" .deb/control
" >> ${wF}
echo " is .deb with control direct to .md"
sed ':a;N;$!ba;s/\n/\n\n/g' ${rootDir}"/"${o}"/DEBIAN/control" >> ${wF}
#sed -i "s/\n/\n\n/g" ${wF}
echo "checking if can build dependency list ...."
depS=`cat ${rootDir}"/"${o}"/DEBIAN/control" | grep -v "# Depends:"| grep Depends`
if [ $? = "0" ]
then
echo "
## Dependencies:
" >> ${wF}
for d in ${depS}; do
d=`echo ${d} | sed 's|,||g' | sed 's| ||g'`
if [ ${d} = "Depends:" ]; then
echo "start...["${d}"]"
elif [ ${d} = "|" ]; then
echo "or"
else
known=`echo ${bList} | grep ${d}`
if [ $? = "0" ]
then
echo "["${d}"](./"${d}")" >> ${wF}
else
echo ${d} >> ${wF}
fi
fi
done
echo -e "\n\n---\n\n">> ${wF}
fi
homPageDone="0"
homPage=`cat ${rootDir}"/"${o}"/DEBIAN/control" | grep Homepage`
if [ $? = "0" ]
then
echo " have homepage "${homPage}
urlIs=`echo ${homPage}|awk '{print $2}'`
echo " urlIs:"${urlIs}"------------------"
if [ ${urlIs} = "https://github.com/yOyOeK1/oiyshTerminal" ]
then
echo "skip... it's going to main manual."
else
echo "ok try to extract some info...."
pathToMd=`echo ${urlIs} | \
sed -r 's|https://github.com/yOyOeK1/oiyshTerminal||g' | \
sed -r 's|tree/main/||g' `
echo " loking in ... "${rootDir}${pathToMd}"/README.md"
if [ -f ${rootDir}${pathToMd}"/README.md" ]
then
echo "have readmy!"
#https://github.com/yOyOeK1/oiyshTerminal/raw/main/ySS_calibration/screenShots/ilooNav3D_ver0.1.png
cat ${rootDir}${pathToMd}"/README.md" | \
sed -r 's|]\(./|]\(https://github.com/yOyOeK1/oiyshTerminal/raw/main/'${pathToMd}'/|g' >> ${wF}
homPageDone=1
fi
fi
fi
echo "checking if have README in home directory..."
if [ ${homPageDone} = "1" ]; then
echo " skip... main is home page"
else
echo "----------------------"
echo ${rootDir}
yssSiteName=`echo ${o}| sed 's|otdm-yss-||g'`
echo "yssSiteName: ["${yssSiteName}"]"
if [ -d ${otDir}"/ySS_calibration/sites/"${yssSiteName} ];then
echo "is yss-site name !! "${yssSiteName}
else
echo "rogular directory"
fi
rListInHome=`find ${rootDir}"/"${o}"/" | grep README`
for rH in ${rListInHome}; do
echo "found readme by find... "${rootDir}"/"${o}"/"
echo "f: "${rH}
#echo "wF now-------------"
#cat ${wF}
#echo "-------------- end wF"
if [ -f ${rootDir}"/"${o}"/DEBIAN/isYssSite" ];
then
echo "have .isYssSite .... "${rootDir}"/"${o}"/DEBIAN/isYssSite"
echo "using url from ./DEBIAN/isYssSite"
urlToSwap=`cat ${rootDir}"/"${o}"/DEBIAN/isYssSite"`
echo " got url to swap from file: "${urlToSwap}
pathToFile2="https://github.com/yOyOeK1/oiyshTerminal/raw/main/ySS_calibration/"${urlToSwap}
else
urlToSwap="https://github.com/yOyOeK1/oiyshTerminal/raw/main"
pathToFile2=$pathToFile
fi
pathToFile=`echo ${rH} | \
sed -r 's|'${rootDir}'|'${urlToSwap}'|g' | \
sed -r 's|/README.md||g' | sed -r 's|/README||g'`
echo "-------- rH ..... "${rH}
echo "------------pathToFile ... "${pathToFile}
echo "------------pathToFile2 ... "${pathToFile2}
echo "------------rootDir .... "${rootDir}
echo "------------urlToSwap .... "${urlToSwap}
cat ${rH} | \
sed -r 's|]\(./|]\('${pathToFile}'/|g' | \
sed -r 's|]\(../|]\('${pathToFile2}'/../|g' >> ${wF}
echo "
---
" >> ${wF}
done
fi
echo "checking if have changelog..."
if [ -f ${rootDir}"/"${o}"/DEBIAN/changelog" ]; then
echo " have... ading"
echo "
## CHANGELOG
" >> ${wF}
cat ${rootDir}"/"${o}"/DEBIAN/changelog" >> ${wF}
fi
echo "
---
## otdm family:
" >> ${wF}
echo -n '[index](./otdm-index) ' >> ${wF}
for d in ${bList}; do
echo -n "["`echo ${d}|sed 's|otdm-||g'`"](./"${d}") " >> ${wF}
done
echo "building index ...."
indexIn=`cat ${wF} | grep '# ' | sed 's|###|##|g' | sed 's|###|##|g' | sed 's|##|-|g'`
#echo " have keys:"${indexIn}
indexStr=""
while read p; do
li=`echo ${p} | grep '# ' | sed 's|-# ||g' | sed 's|####|#|g' | sed 's|###|##|g' | sed 's|###|##|g' |sed 's|##|#|g' | sed 's|#|-|g'| sed 's|:||g' | grep "-"`
if [ $? = "0" ]
then
#echo "p["${p}"] to li["${li}"]"
echo "["${li}"]"
case ${li} in
"- otdm family" )
echo "- otdm family ... skip"
;;
"- Dependencies" )
echo "- Dependencies ... skip"
indexStr=${indexStr}"- [x] [Dependencies](#Dependencies)"'\n\n'
bIndex=${bIndex}"- [x] [Dependencies]("${o}"#Dependencies)"'\n\n'
;;
* )
##Automatic-information-from-otdm-nrf-yss-debcontrol
##automatic-information-from--otdm-nrf-yss-debcontrol
s=`echo ${li}| sed 's|- ||g'`
l=`echo ${s}|sed 's| |-|g'|sed 's|/||g'| sed 's|\.||g' | sed 's|(||g'| \
sed 's|)||g' | sed "s|'||g" | sed 's|?||g' | sed 's|!||g' `
## making profix for count of shashes
pref=""
shC=0
for ss in `echo ${p}|sed 's|#|# |g'`; do
if [ ${ss} = "#" ];then
shC=$[$shC+1]
pref=" . "${pref}
if [ ${shC} = "1" ]; then
pref=""
fi
fi
done
#echo "shCount:"${shC}
echo ${li} | grep "Automatic information"
if [ $? = "0" ]; then
echo "- automatic info .... mod"
indexStr=${indexStr}"- [x] [Info from deb package](#"${l}")"'\n\n'
bIndex=${bIndex}"- [x] [Info from deb package]("${o}"#"${l}")"'\n\n'
else
indexStr=${indexStr}${pref}"- ["${s}"](#"${l}")"'\n\n'
bIndex=${bIndex}${pref}"- ["${s}"]("${o}"#"${l}")"'\n\n'
fi
;;
esac
fi
done < ${wF}
#echo "index: "
#echo -e ${indexStr}
echo -e "## Legend:
"${indexStr}"
" > ${wF}"_legend"
cat ${wF} >> ${wF}"_legend"
mv ${wF}"_legend" ${wF}
fi
if [ ${o} = "otdm-nrf-yss" ]; then
#exit 1
echo "exit no"
fi
done
#echo "--------- exit"
#exit 1
echo -e ${bIndex} > ${wikiDir}"/otdm-index.md"
echo -e "
---
**generated**: "`date` >> ${wikiDir}"/otdm-index.md"
echo "-- build done now publishing to git hub..."
cd ${wikiDir}
echo "it "${wikiDir}
fl=`git diff --raw | awk '{print $6}'`
pushIt=0
cmd="changes in wiki files: "
for f in ${fl}; do
echo "adding ... ["${f}"]"
git add ${f}
cmd=${cmd}${f}", "
pushIt=1
done
if [ ${pushIt} = 1 ]
then
echo "there is what to commit /push ..."
echo 'then git commit -m "command"'
git commit -m "${cmd}"
read -p "push it? [Y/n]" pushIt
case ${pushIt} in
"" | "y" | "Y" )
echo "then git push"
git push
;;
esac
else
echo "nothing to push"
fi
cd ${rootDir}