Current-Users archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
RE: Output alignment in build.sh
I wrote on 2010-08-22:
It seems that build.sh tries to manually align its output, but when
displaying the values of various paths, it gets RELEASEDIR wrong (it's
offset by 3 character positions):
...
===> HOST_SH: /bin/sh
===> TOOLDIR path: /build/netbsd-local/tools/x86_64/amd64
===> DESTDIR path: /build/netbsd-local/dest/amd64
===> RELEASEDIR path: /build/netbsd-local/release
===> makewrapper: /build/netbsd-local/tools/x86_64/amd64/bin/nbmake-amd64
===> Updated /build/netbsd-local/tools/x86_64/amd64/bin/nbmake-amd64
--- release ---
...
And Christos responded with:
Use ${#var} please; what happens if we grow more long variable names?
The attached diffs create a new statusmsg2() shell function that takes
two arguments, and pads its first argument to a minimum size. And yes,
it uses ${#var} to do this.
(These changes also condense the two makewrapper lines into a single
line - no real need to mention the makewrapper filename twice!)
Comments?
-------------------------------------------------------------------------
| Paul Goyette | PGP Key fingerprint: | E-mail addresses: |
| Customer Service | FA29 0E3B 35AF E8AE 6651 | paul at whooppee.com |
| Network Engineer | 0786 F758 55DE 53BA 7731 | pgoyette at juniper.net |
| Kernel Developer | | pgoyette at netbsd.org |
-------------------------------------------------------------------------
Index: build.sh
===================================================================
RCS file: /cvsroot/src/build.sh,v
retrieving revision 1.237
diff -u -p -r1.237 build.sh
--- build.sh 17 Jun 2010 08:19:02 -0000 1.237
+++ build.sh 23 Aug 2010 17:00:51 -0000
@@ -63,6 +63,15 @@ statusmsg()
${runcmd} echo "===> $@" | tee -a "${results}"
}
+statusmsg2()
+{
+ msg="${1}"
+ while [ ${#msg} -lt 21 ] ; do
+ msg="${msg} "
+ done
+ statusmsg "${msg}${2}"
+}
+
warning()
{
statusmsg "Warning: $@"
@@ -1219,7 +1228,12 @@ validatemakeparams()
fi
eval ${var}=\"\${newval}\"
eval export ${var}
- statusmsg "${var} path: ${newval}"
+ if [ "${var}" = "RELEASEDIR" ]; then
+ pad=""
+ else
+ pad=" "
+ fi
+ statusmsg2 "${var} path:" "${newval}"
done
# RELEASEMACHINEDIR is just a subdir name, e.g. "i386".
@@ -1386,8 +1400,7 @@ exec "\${TOOLDIR}/bin/${toolprefix}make"
EOF
[ "${runcmd}" = "echo" ] && echo EOF
${runcmd} chmod +x "${makewrapper}"
- statusmsg "makewrapper: ${makewrapper}"
- statusmsg "Updated ${makewrapper}"
+ statusmsg2 "Updated makewrapper:" "${makewrapper}"
}
make_in_dir()
@@ -1456,8 +1469,8 @@ buildkernel()
buildkernelwarned=true
fi
getkernelconf $1
- statusmsg "Building kernel: ${kernelconf}"
- statusmsg "Build directory: ${kernelbuildpath}"
+ statusmsg2 "Building kernel:" "${kernelconf}"
+ statusmsg2 "Build directory:" "${kernelbuildpath}"
${runcmd} mkdir -p "${kernelbuildpath}" ||
bomb "Cannot mkdir: ${kernelbuildpath}"
if [ "${MKUPDATE}" = "no" ]; then
@@ -1491,7 +1504,7 @@ releasekernel()
builtkern="${kernelbuildpath}/${kern}"
[ -f "${builtkern}" ] || continue
releasekern="${kernelreldir}/${kern}-${kernelconfname}.gz"
- statusmsg "Kernel copy: ${releasekern}"
+ statusmsg2 "Kernel copy:" "${releasekern}"
if [ "${runcmd}" = "echo" ]; then
echo "gzip -c -9 < ${builtkern} > ${releasekern}"
else
@@ -1635,13 +1648,13 @@ main()
sanitycheck
build_start=$(date)
- statusmsg "${progname} command: $0 $@"
- statusmsg "${progname} started: ${build_start}"
- statusmsg "NetBSD version: ${DISTRIBVER}"
- statusmsg "MACHINE: ${MACHINE}"
- statusmsg "MACHINE_ARCH: ${MACHINE_ARCH}"
- statusmsg "Build platform: ${uname_s} ${uname_r} ${uname_m}"
- statusmsg "HOST_SH: ${HOST_SH}"
+ statusmsg2 "${progname} command:" "$0 $@"
+ statusmsg2 "${progname} started:" "${build_start}"
+ statusmsg2 "NetBSD version:" "${DISTRIBVER}"
+ statusmsg2 "MACHINE:" "${MACHINE}"
+ statusmsg2 "MACHINE_ARCH:" "${MACHINE_ARCH}"
+ statusmsg2 "Build platform:" "${uname_s} ${uname_r} ${uname_m}"
+ statusmsg2 "HOST_SH:" "${HOST_SH}"
rebuildmake
validatemakeparams
@@ -1716,7 +1729,7 @@ main()
esac
done
- statusmsg "${progname} ended: $(date)"
+ statusmsg2 "${progname} ended:" "$(date)"
if [ -s "${results}" ]; then
echo "===> Summary of results:"
sed -e 's/^===>//;s/^/ /' "${results}"
Home |
Main Index |
Thread Index |
Old Index