OpenSDE Framework (without history before r20070)
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.

116 lines
3.3 KiB

  1. # --- SDE-COPYRIGHT-NOTE-BEGIN ---
  2. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  3. #
  4. # Filename: lib/output/terminal
  5. # Copyright (C) 2006 - 2012 The OpenSDE Project
  6. # Copyright (C) 1998 - 2003 Clifford Wolf
  7. #
  8. # More information can be found in the files COPYING and README.
  9. #
  10. # This program is free software; you can redistribute it and/or modify
  11. # it under the terms of the GNU General Public License as published by
  12. # the Free Software Foundation; version 2 of the License. A copy of the
  13. # GNU General Public License can be found in the file COPYING.
  14. # --- SDE-COPYRIGHT-NOTE-END ---
  15. if [ "$SDECFG_OUTPUT_TERM_COLOR" = 1 ] ; then
  16. term_color_normal=$'\e[0m'
  17. term_color_error=$'\e[31;1m'
  18. term_color_warning=$'\e[33;1m'
  19. term_color_status=$'\e[32;1m'
  20. term_color_header=$'\e[35;1m'
  21. else
  22. term_color_normal=
  23. term_color_error=
  24. term_color_warning=
  25. term_color_status=
  26. term_color_header=
  27. fi
  28. # A free-form header at start of a section usually followed by calls to
  29. # echo_status_terminal().
  30. #
  31. # E.g. echo_header "Building cross binutils and cc for ${arch_target} ..."
  32. #
  33. echo_header_terminal() {
  34. echo ; echo "${term_color_header}$*${term_color_normal}"
  35. }
  36. # A free-form status message informaing the user of what is happening just
  37. # now.
  38. #
  39. # E.g. echo_status "writing build log to src.cross.$id/binutils.log."
  40. #
  41. echo_status_terminal() {
  42. echo "${term_color_status}->${term_color_normal} $*"
  43. }
  44. # A free-form warning message
  45. #
  46. # E.g. echo_warn "Something went wrong, but we corrected it"
  47. echo_warning_terminal() {
  48. echo "${term_color_warning}*>${term_color_normal} $*"
  49. }
  50. # A free-form error or warning message if something fails.
  51. #
  52. # E.g. echo_error "Detected a problem with the flist wrapper" \
  53. # "lib on your system."
  54. #
  55. echo_error_terminal() {
  56. echo "${term_color_error}!> $*${term_color_normal}"
  57. }
  58. # We deny to build a package for some reason.
  59. #
  60. # Usage: echo_pkg_deny <stagelevel> <package-name> <reason>
  61. #
  62. # E.g. echo_pkg_deny $stagelevel $pkg "already failed"
  63. #
  64. echo_pkg_deny_terminal() {
  65. date "+%n${term_color_error}== %F %T =[$1]=> Package $2 $3.${term_color_normal}"
  66. }
  67. # We start building a package.
  68. #
  69. # Usage: echo_pkg_start <stagelevel> <repository> <package-name> \
  70. # <ver> <extraver>
  71. #
  72. # E.g. echo_pkg_start $stagelevel $repository $pkg $ver $extraver
  73. #
  74. echo_pkg_start_terminal() {
  75. date "+%n${term_color_header}== %F %T =[$1]=> Building $2/$3 [$4 $5].${term_color_normal}"
  76. }
  77. # We finished building a package.
  78. #
  79. # Usage: echo_pkg_finish <stagelevel> <repository> <package-name>
  80. #
  81. # E.g. echo_pkg_finish $stagelevel $repository $pkg
  82. #
  83. echo_pkg_finish_terminal() {
  84. date "+${term_color_header}== %F %T =[$1]=> Finished building package $3.${term_color_normal}"
  85. }
  86. # We aborted building a package.
  87. #
  88. # Usage: echo_pkg_abort <stagelevel> <repository> <package-name>
  89. #
  90. # E.g. echo_pkg_abort $stagelevel $repository $pkg
  91. #
  92. echo_pkg_abort_terminal() {
  93. date "+${term_color_error}== %F %T =[$1]=> Aborted building package $3.${term_color_normal}"
  94. }
  95. # Whenever the tail of error logs are printed, this function is used for
  96. # that. The parameter may contain newlines.
  97. #
  98. # E.g. echo_errorquote "`tail $root/var/adm/logs/$stagelevel-$pkg.out`"
  99. #
  100. echo_errorquote_terminal() {
  101. local cols=$( expr ${columns:-80} - 6 )
  102. echo "$@" | grep -vx -- -- | grep . |
  103. sed -e "s/^\(.\{$cols\}\).\{3,\}/\1 ../" \
  104. -e "s,^,${term_color_error}!>${term_color_normal} ,"
  105. }