From 4d8c2855098e3a09df00d59078d63b05d00e8a93 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Wed, 16 May 2012 15:22:49 -0400 Subject: [PATCH] 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 Tested-by: Mike Frysinger Commit-Ready: Mike Frysinger --- sdk_lib/enter_chroot.sh | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/sdk_lib/enter_chroot.sh b/sdk_lib/enter_chroot.sh index b7f8621a5f..904e8057d2 100755 --- a/sdk_lib/enter_chroot.sh +++ b/sdk_lib/enter_chroot.sh @@ -138,12 +138,16 @@ env_sync_proc() { local poll_interval=10 local sync_files=( etc/resolv.conf etc/hosts ) - # Make sure the synced files are writable by normal user, so that we - # don't have to sudo inside the loop. - local chmods=$(find ${sync_files[@]/#/${FLAGS_chroot}/} '!' -user ${USER}) - if [ -n "${chmods}" ]; then - sudo -- chown ${USER} ${chmods} 1>&2 - fi + # Make sure the files exist before the find -- they might not in a + # fresh chroot which results in warnings in the build output. + local chown_cmd=( + # Make sure the files exists first -- they might not in a fresh chroot. + "touch ${sync_files[*]/#/${FLAGS_chroot}/}" + # 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. # This is needed for properly daemonizing the process.