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.

buildrun.sh 4.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. #!/bin/sh
  2. inc_buildrun=true
  3. [ -z "$inc_makerules" ] && . "$basedir/build/makerules.sh"
  4. [ -z "$inc_stirrups" ] && . "$basedir/build/stirrups.sh"
  5. [ -z "$inc_logging" ] && . "$basedir/build/logging.sh"
  6. [ -z "$inc_misc" ] && . "$basedir/build/misc.sh"
  7. build_into(){
  8. ncpu="$(grep -c ^processor /proc/cpuinfo)"
  9. [ -n "$statusdir" ] && cp "$basedir/build/status.html.sh" "$statusdir/index.cgi"
  10. printf %s "$start_time" |logstatus start_time
  11. [ -s "$(logname debug)" ] && truncate -s 0 "$(logname debug)"
  12. forcelog Makefile
  13. validate_caches
  14. make -C "$basedir" \
  15. | t_logstatus premake
  16. dir_maker "$basedir" "$stagedir"
  17. tree_maker "$basedir" "$stagedir" "$@" \
  18. | logstatus Makefile \
  19. | build_manifest \
  20. | logstatus manifest \
  21. | remove_orphans "$stagedir" \
  22. | logstatus removed
  23. if ! make -j $ncpu -f "$(logname Makefile)" all 2>&1; then
  24. die "See buildlog for errors reported by Make"
  25. fi | t_logstatus buildlog
  26. if [ "$stagedir" != "$target" ]; then
  27. rsync -av --del "$stagedir/" "$target/" \
  28. | t_logstatus stagesync
  29. fi
  30. date +%s |logstatus end_time
  31. if [ -n "$statusdir" ]; then
  32. cd "$statusdir"
  33. ./index.cgi |tail -n+3 >status_$(date +%s).html
  34. cd -
  35. fi
  36. }
  37. git_build_into(){
  38. forcelog GITchanges; GITchanges="$(logname GITchanges)"
  39. forcelog GITerrors; GITerrors="$(logname GITerrors)"
  40. git -C "$basedir" pull >"$GITchanges" 2>"$GITerrors"
  41. gitterm="$?"
  42. if [ "$gitterm" -ne 0 ]; then
  43. die "GIT reported the following problem:\n" \
  44. "$(cat "$GITerrors")"
  45. #elif egrep '^(C...|.C..|...C) .+' "$SVNchanges"; then
  46. # die "GIT encountered a conflict:\n" \
  47. # "$(cat "$SVNchanges")"
  48. elif egrep '^Already up-to-date\.' "$GITchanges"; then
  49. debug "No changes to GIT:\n" \
  50. "$(cat "$GITchanges")"
  51. exit 0
  52. else
  53. logstatus GITlatest <"$GITchanges"
  54. regen_xhtml=false
  55. regen_xsldeps=false
  56. regen_copy=false
  57. # What to do, if a certain file type gets added, deleted, modified
  58. egrep -q '^ (delete|rename) .*\.xhtml' "$GITchanges" && regen_xhtml=true
  59. egrep -q '^ (create|rename) .*\.sources' "$GITchanges" && regen_xhtml=true
  60. egrep -q '^ (delete|rename) .*\.sources' "$GITchanges" && regen_xhtml=true
  61. egrep -q '^ (create|rename) .*\.xsl' "$GITchanges" && regen_xhtml=true
  62. egrep -q '^ (delete|rename) .*\.xsl' "$GITchanges" && regen_xhtml=true && regen_xsldeps=true
  63. egrep -q '^ .*\.xsl *\|' "$GITchanges" && regen_xsldeps=true
  64. egrep -v '.*(\.xml|\.xsl|\.xhtml|\.sources|Makefile)' "$GITchanges" \
  65. | egrep -q '^ (delete|rename)' && regen_copy=true
  66. build_into $(sed -rn '
  67. /^ create mode [0-7]{6} .*(Makefile|\.xml)/d
  68. /^ rename .* => .*(Makefile|\.xml)\}? \([0-9]+%\)/d
  69. s;^ create mode [0-7]{6} (.+);\1;p;
  70. s;^ rename ([^{]+ => )(.*) \([0-9]+%\);\2;p;
  71. s;^ rename ([^{]*)(\{.* => )(.+)\}(.*) \([0-9]+%\);\1\3\4;p
  72. ' "$GITchanges" \
  73. | xargs -d\\n printf "${basedir}"/%s\\n
  74. )
  75. fi
  76. }
  77. svn_build_into(){
  78. forcelog SVNchanges; SVNchanges="$(logname SVNchanges)"
  79. forcelog SVNerrors; SVNerrors="$(logname SVNerrors)"
  80. svn --non-interactive update "$basedir" >"$SVNchanges" 2>"$SVNerrors"
  81. svnterm="$?"
  82. if [ "$svnterm" -ne 0 ]; then
  83. die "SVN reported the following problem:\n" \
  84. "$(cat "$SVNerrors")"
  85. elif egrep '^(C...|.C..|...C) .+' "$SVNchanges"; then
  86. die "SVN encountered a conflict:\n" \
  87. "$(cat "$SVNchanges")"
  88. elif egrep '^At revision [0-9]+\.' "$SVNchanges"; then
  89. debug "No changes to SVN:\n" \
  90. "$(cat "$SVNchanges")"
  91. exit 0
  92. else
  93. logstatus SVNlatest <"$SVNchanges"
  94. regen_xhtml=false
  95. regen_xsldeps=false
  96. regen_copy=false
  97. # What to do, if a certain file type gets added, deleted, modified
  98. egrep -q '^[A]... .*\.xml' "$SVNchanges" && true
  99. egrep -q '^[D]... .*\.xml' "$SVNchanges" && true
  100. egrep -q '^[UGR]... .*\.xml' "$SVNchanges" && true
  101. egrep -q '^[A]... .*\.xhtml' "$SVNchanges" && true
  102. egrep -q '^[D]... .*\.xhtml' "$SVNchanges" && regen_xhtml=true
  103. egrep -q '^[UGR]... .*\.xhtml' "$SVNchanges" && true
  104. egrep -q '^[A]... .*\.sources' "$SVNchanges" && regen_xhtml=true
  105. egrep -q '^[D]... .*\.sources' "$SVNchanges" && regen_xhtml=true
  106. egrep -q '^[UGR]... .*\.sources' "$SVNchanges" && true
  107. egrep -q '^[A]... .*\.xsl' "$SVNchanges" && regen_xhtml=true
  108. egrep -q '^[D]... .*\.xsl' "$SVNchanges" && regen_xhtml=true && regen_xsldeps=true
  109. egrep -q '^[UGR]... .*\.xsl' "$SVNchanges" && regen_xsldeps=true
  110. egrep -v '.*(\.xml|\.xsl|\.xhtml|\.sources|Makefile)$' "$SVNchanges" \
  111. | egrep -q '^[D]... .*' && regen_copy=true
  112. build_into $(sed -rn '/.*(Makefile|\.xml)$/d;s;^A... (.+)$;\1;p' "$SVNchanges")
  113. fi
  114. }