Make enter_chroot spew logs to stderr.

It's sometimes useful to run a command in chroot and redirect/pipe stdout. Any objections to having enter_chroot send its chatter to stderr?

Review URL: http://codereview.chromium.org/3160024
This commit is contained in:
Sean O'Connor 2010-08-18 21:18:23 +02:00
parent eca76464c7
commit d52c5ea1bc
2 changed files with 22 additions and 22 deletions

View File

@ -320,15 +320,15 @@ V_BOLD_RED="\e[1;31m"
V_BOLD_YELLOW="\e[1;33m" V_BOLD_YELLOW="\e[1;33m"
function info { function info {
echo -e "${V_BOLD_GREEN}INFO : $1${V_VIDOFF}" echo -e >&2 "${V_BOLD_GREEN}INFO : $1${V_VIDOFF}"
} }
function warn { function warn {
echo -e "${V_BOLD_YELLOW}WARNING: $1${V_VIDOFF}" echo -e >&2 "${V_BOLD_YELLOW}WARNING: $1${V_VIDOFF}"
} }
function error { function error {
echo -e "${V_BOLD_RED}ERROR : $1${V_VIDOFF}" echo -e >&2 "${V_BOLD_RED}ERROR : $1${V_VIDOFF}"
} }
function die { function die {

View File

@ -80,7 +80,7 @@ function setup_env {
flock 200 flock 200
echo $$ >> "$LOCKFILE" echo $$ >> "$LOCKFILE"
echo "Mounting chroot environment." echo >&2 "Mounting chroot environment."
# Mount only if not already mounted # Mount only if not already mounted
MOUNTED_PATH="$(readlink -f "$FLAGS_chroot/proc")" MOUNTED_PATH="$(readlink -f "$FLAGS_chroot/proc")"
@ -127,10 +127,10 @@ function setup_env {
2>/dev/null)" 2>/dev/null)"
fi fi
if [[ ( -z "$CHROME_ROOT" ) || ( ! -d "${CHROME_ROOT}/src" ) ]]; then if [[ ( -z "$CHROME_ROOT" ) || ( ! -d "${CHROME_ROOT}/src" ) ]]; then
echo "Not mounting chrome source" echo >&2 "Not mounting chrome source"
sudo rm -f "${FLAGS_chroot}${CHROME_ROOT_CONFIG}" sudo rm -f "${FLAGS_chroot}${CHROME_ROOT_CONFIG}"
else else
echo "Mounting chrome source at: $INNER_CHROME_ROOT" echo >&2 "Mounting chrome source at: $INNER_CHROME_ROOT"
echo "$CHROME_ROOT" | \ echo "$CHROME_ROOT" | \
sudo dd of="${FLAGS_chroot}${CHROME_ROOT_CONFIG}" sudo dd of="${FLAGS_chroot}${CHROME_ROOT_CONFIG}"
mkdir -p "$MOUNTED_PATH" mkdir -p "$MOUNTED_PATH"
@ -143,12 +143,12 @@ function setup_env {
if [ -z "$(mount | grep -F "on $MOUNTED_PATH ")" ] if [ -z "$(mount | grep -F "on $MOUNTED_PATH ")" ]
then then
if [ $(which gclient 2>/dev/null) ]; then if [ $(which gclient 2>/dev/null) ]; then
echo "Mounting depot_tools" echo >&2 "Mounting depot_tools"
DEPOT_TOOLS=$(dirname $(which gclient) ) DEPOT_TOOLS=$(dirname $(which gclient) )
mkdir -p "$MOUNTED_PATH" mkdir -p "$MOUNTED_PATH"
if ! sudo mount --bind "$DEPOT_TOOLS" "$MOUNTED_PATH"; then if ! sudo mount --bind "$DEPOT_TOOLS" "$MOUNTED_PATH"; then
echo "depot_tools failed to mount; perhaps it's on NFS?" echo >&2 "depot_tools failed to mount; perhaps it's on NFS?"
echo "This may impact chromium build." echo >&2 "This may impact chromium build."
fi fi
fi fi
fi fi
@ -156,7 +156,7 @@ function setup_env {
# Install fuse module. # Install fuse module.
if [ -c "${FUSE_DEVICE}" ] ; then if [ -c "${FUSE_DEVICE}" ] ; then
sudo modprobe fuse 2> /dev/null ||\ sudo modprobe fuse 2> /dev/null ||\
echo "-- Note: modprobe fuse failed. gmergefs will not work" echo >&2 "-- Note: modprobe fuse failed. gmergefs will not work"
fi fi
# Turn off automounting of external media when we enter the # Turn off automounting of external media when we enter the
@ -166,10 +166,10 @@ function setup_env {
gconftool-2 -g ${AUTOMOUNT_PREF} > \ gconftool-2 -g ${AUTOMOUNT_PREF} > \
"${FLAGS_chroot}${SAVED_AUTOMOUNT_PREF_FILE}" "${FLAGS_chroot}${SAVED_AUTOMOUNT_PREF_FILE}"
if [ $(gconftool-2 -s --type=boolean ${AUTOMOUNT_PREF} false) ]; then if [ $(gconftool-2 -s --type=boolean ${AUTOMOUNT_PREF} false) ]; then
echo "-- Note: USB sticks may be automounted by your host OS." echo >&2 "-- Note: USB sticks may be automounted by your host OS."
echo "-- Note: If you plan to burn bootable media, you may need to" echo >&2 "-- Note: If you plan to burn bootable media, you may need to"
echo "-- Note: unmount these devices manually, or run image_to_usb.sh" echo >&2 "-- Note: unmount these devices manually, or run image_to_usb.sh"
echo "-- Note: outside the chroot." echo >&2 "-- Note: outside the chroot."
fi fi
fi fi
@ -204,15 +204,15 @@ function teardown_env {
if [ $(which gconftool-2 2>/dev/null) ]; then if [ $(which gconftool-2 2>/dev/null) ]; then
SAVED_PREF=$(cat "${FLAGS_chroot}${SAVED_AUTOMOUNT_PREF_FILE}") SAVED_PREF=$(cat "${FLAGS_chroot}${SAVED_AUTOMOUNT_PREF_FILE}")
gconftool-2 -s --type=boolean ${AUTOMOUNT_PREF} ${SAVED_PREF} || \ gconftool-2 -s --type=boolean ${AUTOMOUNT_PREF} ${SAVED_PREF} || \
echo "could not re-set your automount preference." echo >&2 "could not re-set your automount preference."
fi fi
if [ -s "$LOCKFILE" ]; then if [ -s "$LOCKFILE" ]; then
echo "At least one other pid is running in the chroot, so not" echo >&2 "At least one other pid is running in the chroot, so not"
echo "tearing down env." echo >&2 "tearing down env."
else else
MOUNTED_PATH=$(readlink -f "$FLAGS_chroot") MOUNTED_PATH=$(readlink -f "$FLAGS_chroot")
echo "Unmounting chroot environment." echo >&2 "Unmounting chroot environment."
# sort the list of mounts in reverse order, to ensure umount of # sort the list of mounts in reverse order, to ensure umount of
# cascading mounts in proper order # cascading mounts in proper order
for i in \ for i in \
@ -226,10 +226,10 @@ function teardown_env {
if [ $FLAGS_mount -eq $FLAGS_TRUE ] if [ $FLAGS_mount -eq $FLAGS_TRUE ]
then then
setup_env setup_env
echo "Make sure you run" echo >&2 "Make sure you run"
echo " $0 --unmount" echo >&2 " $0 --unmount"
echo "before deleting $FLAGS_chroot" echo >&2 "before deleting $FLAGS_chroot"
echo "or you'll end up deleting $FLAGS_trunk too!" echo >&2 "or you'll end up deleting $FLAGS_trunk too!"
exit 0 exit 0
fi fi