Source files of fsfe.org, pdfreaders.org, freeyourandroid.org, ilovefs.org, drm.info, and test.fsfe.org. Contribute: https://fsfe.org/contribute/web/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

status.html.sh 8.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. #!/bin/sh
  2. exec 2>/dev/null
  3. if [ "$QUERY_STRING" = "full_build" ]; then
  4. if printf %s "$HTTP_REFERER" |grep -qE '^https?://([^/]+\.)?fsfe\.org/'; then
  5. touch ./full_build
  6. fi
  7. printf 'Location: ./\n\n'
  8. exit 0
  9. fi
  10. timestamp(){
  11. date -d "@$1" +"%F %T (%Z)"
  12. }
  13. duration(){
  14. printf %s "$(($1 / 60))min $(($1 % 60))s"
  15. }
  16. web_tab(){
  17. tabname="$1"
  18. tablabel="$2"
  19. tabcontent="$3"
  20. [ -n "$4" ] && checked='checked="checked"' || checked=''
  21. cat <<EOF
  22. <input type="checkbox" class="tabhandle" id="$tabname" ${checked}
  23. ><label class="$([ -n "$tabcontent" ] && echo filled)" for="$tabname">${tablabel}</label>
  24. <div class="tabcontent">${tabcontent}</div>
  25. EOF
  26. }
  27. htmlcat(){
  28. sed 's;&;\&amp\;;g;
  29. s;<;\&lt\;;g;
  30. s;>;\&gt\;;g;
  31. s;";\&quot\;;g;
  32. s;'\'';\&apos\;;g;' $@
  33. }
  34. start_time=$(cat "start_time" || stat -c %Y "$0" || echo 0)
  35. t_svnupdate=$(stat -c %Y "SVNlatest" ||echo 0)
  36. t_gitupdate=$(stat -c %Y "GITlatest" ||echo 0)
  37. t_premake=$(stat -c %Y "premake" ||echo 0)
  38. t_makefile=$(stat -c %Y "Makefile" ||echo 0)
  39. t_makecopy=$(stat -c %Y "Make_copy" ||echo 0)
  40. t_makesourcecopy=$(stat -c %Y "Make_sourcecopy" ||echo 0)
  41. t_makexslt=$(stat -c %Y "Make_xslt" ||echo 0)
  42. t_makexhtml=$(stat -c %Y "Make_xhtml" ||echo 0)
  43. t_manifest=$(stat -c %Y "manifest" ||echo 0)
  44. t_makerun=$(stat -c %Y "buildlog" ||echo 0)
  45. t_errors=$(stat -c %Y "lasterror" ||echo 0)
  46. t_removed=$(stat -c %Y "removed" ||echo 0)
  47. t_stagesync=$(stat -c %Y "stagesync" ||echo 0)
  48. end_time=$(cat "end_time" || echo 0)
  49. duration=$(($end_time - $start_time))
  50. term_status=$(if [ "$duration" -gt 0 -a lasterror -nt start_time ]; then
  51. echo Error
  52. elif [ "$duration" -gt 0 ]; then
  53. echo Success
  54. fi)
  55. printf %s\\n\\n "Content-Type: text/html;charset=utf-8"
  56. cat <<HTML_END
  57. <!DOCTYPE HTML>
  58. <html>
  59. <head>
  60. <title>Build status</title>
  61. <style type="text/css">
  62. <!--
  63. body { width: 100%; margin: 0; padding: 1ex; }
  64. * {
  65. margin: auto auto;
  66. box-sizing: border-box;
  67. transition: all .2s linear;
  68. }
  69. dl, .fullbuild {
  70. display: block;
  71. width: 60%;
  72. min-width: 320px;
  73. }
  74. dt, dd {
  75. display: inline-block;
  76. padding: 0 1ex .5ex 0;
  77. margin: 0;
  78. border-width: 1px;
  79. border-style: solid none none none;
  80. vertical-align: top;
  81. }
  82. dt {
  83. width: 40%;
  84. font-weight: bold;
  85. }
  86. dd { width: 60%; }
  87. input.tabhandle { display: none;}
  88. input.tabhandle + label + .tabcontent {
  89. width: 75%; min-width: 300px;
  90. min-height: 1px; max-height: 1px;
  91. overflow: hidden;
  92. padding-top: 0; padding-bottom: 0;
  93. margin-top: 0; margin-bottom: 0;
  94. border-style: none none solid none;
  95. }
  96. input.tabhandle:checked + label.filled + .tabcontent {
  97. width: 100%;
  98. min-height: 1px; max-height: 110em;
  99. border-style: dashed solid solid solid;
  100. overflow: auto;
  101. }
  102. input.tabhandle + label.filled { color: #008;}
  103. input.tabhandle + label::before { content: '\25b9 \00a0';}
  104. input.tabhandle + label.filled::before { content: '\25b8 \00a0'; color: initial;}
  105. input.tabhandle + label.filled::after { content: ', more...';}
  106. input.tabhandle:checked + label::before { content: '\25b9 \00a0';}
  107. input.tabhandle:checked + label.filled::before { content: '\25be \00a0'; color: initial;}
  108. input.tabhandle:checked + label.filled::after { content: ', less...';}
  109. .fullbuild {
  110. text-align: center;
  111. padding: 1ex;
  112. border: 1px solid black;
  113. border-radius: 1ex;
  114. }
  115. span.fullbuild { color: #000; background-color: #AAA;}
  116. a.fullbuild {
  117. font-weight: bold;
  118. color: #FFF;
  119. background-color: #66D;
  120. border-width: 2px;
  121. border-color: #008;
  122. }
  123. h1 {
  124. text-align: center;
  125. border-width: 1px;
  126. border-style: none none solid none;
  127. margin-bottom: 1ex;
  128. }
  129. h2, h3, label {
  130. display: inline-block;
  131. font-size: 1em;
  132. line-height: 1em;
  133. color: #000;
  134. background-color: #DDF;
  135. border-color: #000; border-width: 1px;
  136. padding: .5ex 1ex 1ex 1ex;
  137. margin: .5em 0 0 0;
  138. }
  139. h2, h3 {
  140. width: 15%; min-width: 150px;
  141. font-weight: bold;
  142. border-style: solid none none solid;
  143. border-radius: 1ex 0 0 0;
  144. }
  145. label {
  146. width: 50%; min-width: 100px;
  147. border-style: solid solid none none;
  148. background-color: #EEF;
  149. border-radius: 0 1ex 0 0;
  150. }
  151. .tabcontent {
  152. color: #000;
  153. background-color: #EEF;
  154. border-color: #000;
  155. border-width: 1px;
  156. border-radius: 0 1ex 1ex 1ex;
  157. margin: 0;
  158. padding: 1ex 1ex;
  159. }
  160. .tabcontent pre { margin: 1em 0;}
  161. -->
  162. </style>
  163. </head><body>
  164. <h1>Build report</h1>
  165. <dl class="buildinfo">
  166. <dt>Start time:</dt><dd>$(timestamp ${start_time})</dd>
  167. <dt>End time:</dt><dd>$([ "$duration" -gt 0 ] && timestamp ${end_time})</dd>
  168. <dt>Duration:</dt><dd>$([ "$duration" -gt 0 ] && duration ${duration})</dd>
  169. <dt>Termination Status:</dt><dd>${term_status:-running...}</dd>
  170. </dl>
  171. $(if [ ./full_build -nt ./index.cgi ]; then
  172. printf '<span class="fullbuild">Full rebuild will be started within next minute.</span>'
  173. else
  174. printf '<a class="fullbuild" href="./?full_build">Schedule full rebuild</a>'
  175. fi)
  176. <h2>Previous builds</h2>$(
  177. web_tab prev_tab '' "
  178. <a href=\"./\">latest</a><br>
  179. $(
  180. ls -t status_*.html |head -n10 |while read stat; do
  181. t="${stat#status_}"
  182. t="${t%.html}"
  183. printf '<a href="%s">%s</a> - %s<br>' \
  184. "$stat" "$(timestamp "$t")" "$(sed -rn 's;^.*<dt>Duration:</dt><dd>(.+)</dd>.*$;\1;p;T;q' "$stat")"
  185. done
  186. )"
  187. )
  188. <h2>VCS changes</h2>$(
  189. if [ ${start_time} -le ${t_gitupdate} ]; then
  190. web_tab VCS_tab "at $(timestamp ${t_gitupdate})" "<pre>$(htmlcat GITlatest)</pre>" checked
  191. elif [ ${start_time} -le ${t_svnupdate} ]; then
  192. web_tab VCS_tab "at $(timestamp ${t_svnupdate})" "<pre>$(htmlcat SVNlatest)</pre>" checked
  193. else
  194. web_tab VCS_tab "Unconditional build, changes ignored" ""
  195. fi)
  196. <h2>Premake</h2>$(
  197. if [ $start_time -lt $t_premake -a $start_time -lt $t_gitupdate ]; then
  198. web_tab Premaketab "Premake run time $(duration $(($t_premake - $t_gitupdate)))" "<pre>$(tail premake |htmlcat)</pre><a href="premake">full log</a>"
  199. elif [ $start_time -lt $t_premake -a $start_time -lt $t_svnupdate ]; then
  200. web_tab Premaketab "Premake run time $(duration $(($t_premake - $t_svnupdate)))" "<pre>$(tail premake |htmlcat)</pre><a href="premake">full log</a>"
  201. elif [ $start_time -lt $t_premake ]; then
  202. web_tab Premaketab "Premake run time $(duration $(($t_premake - $start_time)))" "<pre>$(tail premake |htmlcat)</pre><a href="premake">full log</a>"
  203. else
  204. web_tab Premaketab "waiting..." ""
  205. fi)
  206. <h2>Makefile</h2>$(
  207. if [ $start_time -lt $t_makefile ]; then
  208. web_tab Makefiletab "Generation time: $(duration $(($t_makefile - $t_premake)) )" "
  209. <h3>Header</h3>$(web_tab Makeheadertab "" "<pre>$(head Makefile |htmlcat)</pre>")
  210. <h3>Copy rules</h3>$(web_tab Makecopytab "Generation time: $(duration $(($t_makecopy - $t_premake)))" "<pre>$(tail Make_copy |htmlcat)</pre>")
  211. <h3>Source copy rules</h3>$(web_tab Makescopytab "Generation time: $(duration $(($t_makesourcecopy - $t_premake)))" "<pre>$(tail Make_sourcecopy |htmlcat)</pre>")
  212. <h3>XSLT rules</h3>$(web_tab Makexslttab "Generation time: $(duration $(($t_makexslt - $t_premake)))" "<pre>$(tail Make_xslt |htmlcat)</pre>")
  213. <h3>XHTML rules</h3>$(web_tab Makexhtmltab "Generation time: $(duration $(($t_makexhtml - $t_premake)))" "<pre>$(tail Make_xhtml |htmlcat)</pre>")
  214. <h3>Full Makefile</h3>$(web_tab Makefilefull "<a href="Makefile">view</a>" "")"
  215. else
  216. web_tab Makefiletab "waiting..." ""
  217. fi)
  218. <h2>Makerun</h2>$(
  219. if [ $start_time -lt $t_makerun ]; then
  220. web_tab Makeruntab "Build time: $(duration $(($t_makerun - $t_makefile)) )" "<pre>$(tail buildlog |htmlcat)</pre><a href=\"buildlog\">view full</a>"
  221. else
  222. web_tab Makeruntab "waiting..." ""
  223. fi)
  224. <h2>Errors</h2>$(
  225. if [ $start_time -lt $t_errors ]; then
  226. web_tab Errortab "There were errors" "<pre>$(htmlcat lasterror)</pre>"
  227. else
  228. web_tab Errortab "none" ""
  229. fi)
  230. <h2>File Manifest</h2>$(web_tab Manifesttab "Number of files: $(wc -l manifest |cut -d\ -f1)" "<pre>$(tail manifest |htmlcat)</pre><a href=\"manifest\">view full</a>")
  231. <h2>Files removed</h2>$(
  232. if [ $start_time -lt $t_removed -a -s "removed" ]; then
  233. web_tab Removedtab "$(wc -l removed |cut -f1 -d\ )" "<pre>$(htmlcat removed)</pre>"
  234. elif [ $start_time -lt $t_removed ]; then
  235. web_tab Removedtab "none" ""
  236. elif [ -z ${term_status} ]; then
  237. web_tab Removedtab "waiting..." ""
  238. else
  239. web_tab Removedtab "none" ""
  240. fi)
  241. <h2>Files updated</h2>$(
  242. if [ ${start_time} -lt ${t_stagesync} -a -s stagesync ]; then
  243. web_tab Updatedtab "Updated $(( $(wc -l stagesync |cut -f1 -d\ ) - 4 )) files" "<pre>$(htmlcat stagesync)</pre>"
  244. elif [ -z ${term_status} ]; then
  245. web_tab Updatedtab "waiting..." ""
  246. else
  247. web_tab Updatedtab "-" ""
  248. fi)
  249. </body>
  250. </html>
  251. HTML_END
  252. # vi:set filetype=html: