Update lfs-bootscripts to only output escape sequences to a terminal.

Add -n to the ln command, for recreating /dev/fd correctly if the initramfs has already created one
This commit is contained in:
Poltern 2024-08-06 21:05:46 +05:00
parent d635a9860c
commit e88e84f858
3 changed files with 84 additions and 21 deletions

View File

@ -1,3 +1,11 @@
2024-07-12 Xi Ruoyao <xry111@xry111.site>
* In mountvirtfs, recreate /dev/fd correctly if it's already created
by the initramfs.
2024-07-06 Bruce Dubbs <bdubbs@linuxfromscratch.org>
* Add logic to init-functions to only print escape sequences
if stdin and stdout are connected to a terminal.
2024-04-16 Bruce Dubbs <bdubbs@linuxfromscratch.org> 2024-04-16 Bruce Dubbs <bdubbs@linuxfromscratch.org>
* Remove blank output line generated in ifup script when bringing * Remove blank output line generated in ifup script when bringing
up wireless interface. up wireless interface.

View File

@ -83,7 +83,7 @@ case "${1}" in
ln -sf /proc/self/fd/2 /dev/stderr || failed=1 ln -sf /proc/self/fd/2 /dev/stderr || failed=1
log_info_msg2 " ${INFO}/dev/fd" log_info_msg2 " ${INFO}/dev/fd"
ln -sf /proc/self/fd /dev/fd || failed=1 ln -sfn /proc/self/fd /dev/fd || failed=1
if [ -e /proc/kcore ]; then if [ -e /proc/kcore ]; then
log_info_msg2 " ${INFO}/dev/core" log_info_msg2 " ${INFO}/dev/core"

View File

@ -58,11 +58,21 @@ SCRIPT_STAT="0"
# Set any user specified environment variables e.g. HEADLESS # Set any user specified environment variables e.g. HEADLESS
[ -r /etc/sysconfig/rc.site ] && . /etc/sysconfig/rc.site [ -r /etc/sysconfig/rc.site ] && . /etc/sysconfig/rc.site
## Screen Dimensions # If HEADLESS is set, use that.
# Find current screen size # If file descriptor 1 or 2 (stdout and stderr) is not open or
if [ -z "${COLUMNS}" ]; then # does not refer to a terminal, consider the script headless.
COLUMNS=$(stty size) [ ! -t 1 -o ! -t 2 ] && HEADLESS=${HEADLESS:-yes}
COLUMNS=${COLUMNS##* }
if [ "x$HEADLESS" != "xyes" ]
then
## Screen Dimensions
# Find current screen size
if [ -z "${COLUMNS}" ]; then
COLUMNS=$(stty size)
COLUMNS=${COLUMNS##* }
fi
else
COLUMNS=80
fi fi
# When using remote connections, such as a serial port, stty size returns 0 # When using remote connections, such as a serial port, stty size returns 0
@ -575,9 +585,14 @@ timespec()
################################################################################ ################################################################################
log_success_msg() log_success_msg()
{ {
/bin/echo -n -e "${BMPREFIX}${@}" if [ "x$HEADLESS" != "xyes" ]
/bin/echo -e "${CURS_ZERO}${SUCCESS_PREFIX}${SET_COL}${SUCCESS_SUFFIX}" then
/bin/echo -n -e "${BMPREFIX}${@}"
/bin/echo -e "${CURS_ZERO}${SUCCESS_PREFIX}${SET_COL}${SUCCESS_SUFFIX}"
else
logmessage=`echo "${@}" | sed 's/\\\033[^a-zA-Z]*.//g'`
/bin/echo -e "${logmessage} OK"
fi
# Strip non-printable characters from log file # Strip non-printable characters from log file
logmessage=`echo "${@}" | sed 's/\\\033[^a-zA-Z]*.//g'` logmessage=`echo "${@}" | sed 's/\\\033[^a-zA-Z]*.//g'`
@ -589,8 +604,13 @@ log_success_msg()
log_success_msg2() log_success_msg2()
{ {
/bin/echo -n -e "${BMPREFIX}${@}" if [ "x$HEADLESS" != "xyes" ]
/bin/echo -e "${CURS_ZERO}${SUCCESS_PREFIX}${SET_COL}${SUCCESS_SUFFIX}" then
/bin/echo -n -e "${BMPREFIX}${@}"
/bin/echo -e "${CURS_ZERO}${SUCCESS_PREFIX}${SET_COL}${SUCCESS_SUFFIX}"
else
echo " OK"
fi
echo " OK" >> ${BOOTLOG} echo " OK" >> ${BOOTLOG}
@ -610,8 +630,14 @@ log_success_msg2()
################################################################################ ################################################################################
log_failure_msg() log_failure_msg()
{ {
/bin/echo -n -e "${BMPREFIX}${@}" if [ "x$HEADLESS" != "xyes" ]
/bin/echo -e "${CURS_ZERO}${FAILURE_PREFIX}${SET_COL}${FAILURE_SUFFIX}" then
/bin/echo -n -e "${BMPREFIX}${@}"
/bin/echo -e "${CURS_ZERO}${FAILURE_PREFIX}${SET_COL}${FAILURE_SUFFIX}"
else
logmessage=`echo "${@}" | sed 's/\\\033[^a-zA-Z]*.//g'`
/bin/echo -e "${logmessage} FAIL"
fi
# Strip non-printable characters from log file # Strip non-printable characters from log file
@ -624,8 +650,13 @@ log_failure_msg()
log_failure_msg2() log_failure_msg2()
{ {
/bin/echo -n -e "${BMPREFIX}${@}" if [ "x$HEADLESS" != "xyes" ]
/bin/echo -e "${CURS_ZERO}${FAILURE_PREFIX}${SET_COL}${FAILURE_SUFFIX}" then
/bin/echo -n -e "${BMPREFIX}${@}"
/bin/echo -e "${CURS_ZERO}${FAILURE_PREFIX}${SET_COL}${FAILURE_SUFFIX}"
else
echo "FAIL"
fi
echo "FAIL" >> ${BOOTLOG} echo "FAIL" >> ${BOOTLOG}
@ -643,8 +674,14 @@ log_failure_msg2()
################################################################################ ################################################################################
log_warning_msg() log_warning_msg()
{ {
/bin/echo -n -e "${BMPREFIX}${@}" if [ "x$HEADLESS" != "xyes" ]
/bin/echo -e "${CURS_ZERO}${WARNING_PREFIX}${SET_COL}${WARNING_SUFFIX}" then
/bin/echo -n -e "${BMPREFIX}${@}"
/bin/echo -e "${CURS_ZERO}${WARNING_PREFIX}${SET_COL}${WARNING_SUFFIX}"
else
logmessage=`echo "${@}" | sed 's/\\\033[^a-zA-Z]*.//g'`
/bin/echo -e "${logmessage} WARN"
fi
# Strip non-printable characters from log file # Strip non-printable characters from log file
logmessage=`echo "${@}" | sed 's/\\\033[^a-zA-Z]*.//g'` logmessage=`echo "${@}" | sed 's/\\\033[^a-zA-Z]*.//g'`
@ -656,8 +693,14 @@ log_warning_msg()
log_skip_msg() log_skip_msg()
{ {
/bin/echo -n -e "${BMPREFIX}${@}" if [ "x$HEADLESS" != "xyes" ]
/bin/echo -e "${CURS_ZERO}${SKIP_PREFIX}${SET_COL}${SKIP_SUFFIX}" then
/bin/echo -n -e "${BMPREFIX}${@}"
/bin/echo -e "${CURS_ZERO}${SKIP_PREFIX}${SET_COL}${SKIP_SUFFIX}"
else
logmessage=`echo "${@}" | sed 's/\\\033[^a-zA-Z]*.//g'`
/bin/echo "SKIP"
fi
# Strip non-printable characters from log file # Strip non-printable characters from log file
logmessage=`echo "${@}" | sed 's/\\\033[^a-zA-Z]*.//g'` logmessage=`echo "${@}" | sed 's/\\\033[^a-zA-Z]*.//g'`
@ -677,7 +720,13 @@ log_skip_msg()
################################################################################ ################################################################################
log_info_msg() log_info_msg()
{ {
/bin/echo -n -e "${BMPREFIX}${@}" if [ "x$HEADLESS" != "xyes" ]
then
/bin/echo -n -e "${BMPREFIX}${@}"
else
logmessage=`echo "${@}" | sed 's/\\\033[^a-zA-Z]*.//g'`
/bin/echo -n -e "${logmessage}"
fi
# Strip non-printable characters from log file # Strip non-printable characters from log file
logmessage=`echo "${@}" | sed 's/\\\033[^a-zA-Z]*.//g'` logmessage=`echo "${@}" | sed 's/\\\033[^a-zA-Z]*.//g'`
@ -689,7 +738,13 @@ log_info_msg()
log_info_msg2() log_info_msg2()
{ {
/bin/echo -n -e "${@}" if [ "x$HEADLESS" != "xyes" ]
then
/bin/echo -n -e "${@}"
else
logmessage=`echo "${@}" | sed 's/\\\033[^a-zA-Z]*.//g'`
/bin/echo -n -e "${logmessage}"
fi
# Strip non-printable characters from log file # Strip non-printable characters from log file
logmessage=`echo "${@}" | sed 's/\\\033[^a-zA-Z]*.//g'` logmessage=`echo "${@}" | sed 's/\\\033[^a-zA-Z]*.//g'`