Current-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

RE: Output alignment in build.sh



On Tue, 24 Aug 2010, Christos Zoulas wrote:

On Aug 23, 10:07am, paul%whooppee.com@localhost (Paul Goyette) wrote:
-- Subject: RE: Output alignment in build.sh

| > 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?
|

Comments prefixed with XXX:

christos


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}"
+}
+

XXX: Maybe call it settingmsg? or variablesettingmsg?

Maybe. I called it statusmsg2() since it was a 2-arg columnized version of statusmsg().


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

XXX: Surely the above is not needed?

Ooopppsss - forgot to remove that part of the original patch. It is definitely not needed.


+               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}"

XXX: The above changes the message; is this intentional?

Yes.  This is what I meant in my introductiory comments when I said

| (These changes also condense the two makewrapper lines into a single
| line - no real need to mention the makewrapper filename twice!)



}

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}"


-------------------------------------------------------------------------
| 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  |
-------------------------------------------------------------------------


Home | Main Index | Thread Index | Old Index