enter_chroot: fix spurious resolv.conf warning

When bootstrapping for the first time, files in chroot/etc/ might not
exist, so we can't run `find` on them.  This manifests itself currently
by spitting out the warning on all initial sdk boots:
	find: `.../chroot/etc/resolv.conf': No such file or directory

People can find this confusing and cause sheriffs to waste time on the
wrong thing, so rework the code to avoid this.

BUG=None
TEST=`cros_sdk --delete ; cros_sdk` no longer warns about resolv.conf

Change-Id: I83f892e325e63e682aeb370a9dfc33e284e059d2
Reviewed-on: https://gerrit.chromium.org/gerrit/22845
Reviewed-by: Brian Harring <ferringb@chromium.org>
Tested-by: Mike Frysinger <vapier@chromium.org>
Commit-Ready: Mike Frysinger <vapier@chromium.org>
This commit is contained in:
Mike Frysinger 2012-05-16 15:22:49 -04:00 committed by Gerrit
parent 9e5b0a43ba
commit 4d8c285509

View File

@ -138,12 +138,16 @@ env_sync_proc() {
local poll_interval=10 local poll_interval=10
local sync_files=( etc/resolv.conf etc/hosts ) local sync_files=( etc/resolv.conf etc/hosts )
# Make sure the synced files are writable by normal user, so that we # Make sure the files exist before the find -- they might not in a
# don't have to sudo inside the loop. # fresh chroot which results in warnings in the build output.
local chmods=$(find ${sync_files[@]/#/${FLAGS_chroot}/} '!' -user ${USER}) local chown_cmd=(
if [ -n "${chmods}" ]; then # Make sure the files exists first -- they might not in a fresh chroot.
sudo -- chown ${USER} ${chmods} 1>&2 "touch ${sync_files[*]/#/${FLAGS_chroot}/}"
fi # Make sure the files are writable by normal user so that we don't have
# to execute sudo in the main loop below.
"chown ${USER} ${sync_files[*]/#/${FLAGS_chroot}/}"
)
sudo_multi "${chown_cmd[@]}"
# Drop stdin, stderr, stdout, and chroot lock. # Drop stdin, stderr, stdout, and chroot lock.
# This is needed for properly daemonizing the process. # This is needed for properly daemonizing the process.