1 # --- T2-COPYRIGHT-BEGIN ---
2 # t2/misc/output/terminal
3 # Copyright (C) 2004 - 2025 The T2 SDE Project
4 # Copyright (C) 1998 - 2003 ROCK Linux Project
5 # SPDX-License-Identifier: GPL-2.0
6 # --- T2-COPYRIGHT-END ---
8 . scripts/core-functions.in
10 if [ "$SDECFG_OUTPUT_TERM_COLOR" = 1 ]; then
11 term_color_normal=$'\e[0m'
12 term_color_error=$'\e[31;1m'
13 term_color_warning=$'\e[33;1m'
15 term_color_header=$'\e[35;1m'
24 # A free-form header at start of a section usually followed by calls to
25 # echo_status_terminal().
27 # E.g. echo_header "Building cross binutils and cc for ${arch_target}"
29 echo_header_terminal() {
30 echo; echo "${term_color_header}$*${term_color_normal}"
33 # A free-form status message informaing the user of what is happening just
36 # E.g. echo_status "writing build log to src.cross.$id/binutils.log"
38 echo_status_terminal() {
39 echo " ${term_color_status}$*${term_color_normal}"
42 # A free-form warning message
44 # E.g. echo_warn "Something went wrong, but we corrected it"
45 echo_warning_terminal() {
46 echo " ${term_color_warning}$*${term_color_normal}"
49 # A free-form error or warning message if something fails.
51 # E.g. echo_error "Detected a problem with the flist wrapper" \
52 # "lib on your system."
54 echo_error_terminal() {
55 echo " ${term_color_error}$*${term_color_normal}"
58 # We deny to build a package for some reason.
60 # Usage: echo_pkg_deny <stagelevel> <package-name> <reason>
62 # E.g. echo_pkg_deny $stagelevel $pkg "already failed"
64 echo_pkg_deny_terminal() {
65 local buildend="`date '+%s'`"
66 date --date=@$((buildend - buildstart)) --utc "+${term_color_error}+%H:%M:%S Package $1-$2 $3${term_color_normal}"
69 # We start building a package.
71 # Usage: echo_pkg_start <stagelevel> <repository> <package-name> <ver> <esttime> <progress>
73 # E.g. echo_pkg_start $stagelevel $repository $pkg $ver $extraver $esttime $progress
75 echo_pkg_start_terminal() {
76 buildstart="`date '+%s'`"
77 date "+%n${term_color_header}%T ${7:+$7 }Building $1-$2/$3 ($4)$(fmt_time $6)${term_color_normal}"
80 # We finished building a package.
82 # Usage: echo_pkg_finish <stagelevel> <repository> <package-name>
84 # E.g. echo_pkg_finish $stagelevel $repository $pkg
86 echo_pkg_finish_terminal() {
87 local buildend="`date '+%s'`"
88 date --date=@$((buildend - buildstart)) --utc "+ ${term_color_header}+%H:%M:%S Finished building $2/$3${term_color_normal}"
91 # We aborted building a package.
93 # Usage: echo_pkg_abort <stagelevel> <repository> <package-name>
95 # E.g. echo_pkg_abort $stagelevel $repository $pkg
97 echo_pkg_abort_terminal() {
98 local buildend="`date '+%s'`"
99 date --date=@$((buildend - buildstart)) --utc "+ ${term_color_error}+%H:%M:%S Aborted building $2/$3${term_color_normal}"
102 # Whenever the tail of error logs are printed, this function is used for
103 # that. The parameter may contain newlines.
105 # E.g. echo_errorquote "`tail $root/var/adm/logs/$stagelevel-$pkg.out`"
107 echo_errorquote_terminal() {
108 echo "$@" | grep -vx -- -- | grep . |
109 sed -e 's/^\(.\{'$(( columns - 6 ))'\}\).\{3,\}/\1 ../' \
110 -e 's,^,'"${term_color_error}!${term_color_normal} "','