Commit 8e3b5543 authored by Tom Anderson's avatar Tom Anderson Committed by Commit Bot

Don't spam console when building Linux packages

Now that the Linux packages are going to be built on all of the linux
CQ bots, we shouldn't spam the console with miscellaneous info.  This
CL guards all of the logging behing the VERBOSE flag, but still prints
command stdout and stderr when the return code is nonzero.

BUG=758654
R=thestig@chromium.org

Change-Id: Ia037371b836cbf059d37131a602037c5b972c182
Reviewed-on: https://chromium-review.googlesource.com/656566Reviewed-by: default avatarLei Zhang <thestig@chromium.org>
Commit-Queue: Thomas Anderson <thomasanderson@chromium.org>
Cr-Commit-Position: refs/heads/master@{#501520}
parent e48bbdc2
# Shows the output of a given command only on failure, or when VERBOSE is set.
log_cmd() {
if [ "${VERBOSE:-}" ]; then
"$@"
else
# Record $- into a separate variable because it gets reset in the subshell.
FORWARD_SHELL_OPTS=$-
ERREXIT=$(echo ${FORWARD_SHELL_OPTS} | grep -o e || true)
set +${ERREXIT}
CMD_OUTPUT=$("$@" 2>&1)
ERRCODE=$?
set -${ERREXIT}
if [ ${ERRCODE} -ne 0 ]; then
echo "$@"
echo "${CMD_OUTPUT}"
if [ ${ERREXIT} ]; then
exit ${ERRCODE}
fi
fi
fi
}
# Recursively replace @@include@@ template variables with the referenced file,
# and write the resulting text to stdout.
process_template_includes() {
......@@ -104,7 +126,7 @@ get_version_info() {
}
stage_install_common() {
echo "Staging common install files in '${STAGEDIR}'..."
log_cmd echo "Staging common install files in '${STAGEDIR}'..."
# TODO(mmoss) This assumes we built the static binaries. To support shared
# builds, we probably want an install target in scons so it can give us all
......
......@@ -4,9 +4,6 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# TODO(mmoss) This currently only works with official builds, since non-official
# builds don't add the "${BUILDDIR}/installer/" files needed for packaging.
set -e
set -o pipefail
if [ "$VERBOSE" ]; then
......@@ -66,14 +63,14 @@ stage_install_debian() {
fi
prep_staging_debian
stage_install_common
echo "Staging Debian install files in '${STAGEDIR}'..."
log_cmd echo "Staging Debian install files in '${STAGEDIR}'..."
install -m 755 -d "${STAGEDIR}/${INSTALLDIR}/cron"
process_template "${BUILDDIR}/installer/common/repo.cron" \
"${STAGEDIR}/${INSTALLDIR}/cron/${PACKAGE}"
chmod 755 "${STAGEDIR}/${INSTALLDIR}/cron/${PACKAGE}"
pushd "${STAGEDIR}/etc/cron.daily/"
pushd "${STAGEDIR}/etc/cron.daily/" > /dev/null
ln -snf "${INSTALLDIR}/cron/${PACKAGE}" "${PACKAGE}"
popd
popd > /dev/null
process_template "${BUILDDIR}/installer/debian/debian.menu" \
"${STAGEDIR}/usr/share/menu/${PACKAGE}.menu"
chmod 644 "${STAGEDIR}/usr/share/menu/${PACKAGE}.menu"
......@@ -106,7 +103,7 @@ verify_package() {
# Actually generate the package file.
do_package() {
echo "Packaging ${ARCHITECTURE}..."
log_cmd echo "Packaging ${ARCHITECTURE}..."
PREDEPENDS="$COMMON_PREDEPS"
DEPENDS="${COMMON_DEPS}"
REPLACES=""
......@@ -123,13 +120,13 @@ do_package() {
else
local COMPRESSION_OPTS="-Znone"
fi
fakeroot dpkg-deb ${COMPRESSION_OPTS} -b "${STAGEDIR}" .
log_cmd fakeroot dpkg-deb ${COMPRESSION_OPTS} -b "${STAGEDIR}" .
verify_package "$DEPENDS"
}
# Remove temporary files and unwanted packaging output.
cleanup() {
echo "Cleaning..."
log_cmd echo "Cleaning..."
rm -rf "${STAGEDIR}"
rm -rf "${TMPFILEDIR}"
}
......
......@@ -4,9 +4,6 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# TODO(mmoss) This currently only works with official builds, since non-official
# builds don't add the "${BUILDDIR}/installer/" files needed for packaging.
set -e
if [ "$VERBOSE" ]; then
set -x
......@@ -48,7 +45,7 @@ stage_install_rpm() {
fi
prep_staging_rpm
stage_install_common
echo "Staging RPM install files in '${STAGEDIR}'..."
log_cmd echo "Staging RPM install files in '${STAGEDIR}'..."
process_template "${BUILDDIR}/installer/common/rpmrepo.cron" \
"${STAGEDIR}/etc/cron.daily/${PACKAGE}"
chmod 755 "${STAGEDIR}/etc/cron.daily/${PACKAGE}"
......@@ -80,7 +77,7 @@ verify_package() {
# Actually generate the package file.
do_package() {
echo "Packaging ${ARCHITECTURE}..."
log_cmd echo "Packaging ${ARCHITECTURE}..."
PROVIDES="${PACKAGE}"
local REPS="$REPLACES"
REPLACES=""
......@@ -120,7 +117,7 @@ do_package() {
# (brp-compress, etc.), which by default appears to only be enabled on 32-bit,
# and which doesn't gain us anything since we already explicitly do all the
# compression, symbol stripping, etc. that we want.
fakeroot rpmbuild -bb --target="$ARCHITECTURE" --rmspec \
log_cmd fakeroot rpmbuild -bb --target="$ARCHITECTURE" --rmspec \
--define "_topdir $RPMBUILD_DIR" \
--define "${COMPRESSION_OPT}" \
--define "__os_install_post %{nil}" \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment