From 796be0a520efa832a44fab084041098c014bc027 Mon Sep 17 00:00:00 2001 From: Michael Marineau Date: Tue, 27 May 2014 16:53:06 -0700 Subject: [PATCH] fix(sdk_lib): Test for host file existence before copying. The main case here is /etc/hosts does not exist on CoreOS. In the process combine related and duplicate code. Setting the timezone now happens in entire_chroot like hosts and resolv.conf. Don't bother with setting a default UTC time zone, that is already the default. --- sdk_lib/enter_chroot.sh | 10 +++++++--- sdk_lib/make_chroot.sh | 13 ------------- 2 files changed, 7 insertions(+), 16 deletions(-) diff --git a/sdk_lib/enter_chroot.sh b/sdk_lib/enter_chroot.sh index 3f5409f64d..d39b5f4f94 100755 --- a/sdk_lib/enter_chroot.sh +++ b/sdk_lib/enter_chroot.sh @@ -236,9 +236,13 @@ setup_env() { # Make the lockfile writable for backwards compatibility. chown ${SUDO_UID}:${SUDO_GID} "${LOCKFILE}" - # Refresh /etc/resolv.conf and /etc/hosts in the chroot. - install -C -m644 /etc/resolv.conf ${FLAGS_chroot}/etc/resolv.conf - install -C -m644 /etc/hosts ${FLAGS_chroot}/etc/hosts + # Refresh system config files in the chroot. + for copy_file in /etc/{hosts,localtime,resolv.conf}; do + if [ -f "${copy_file}" ] ; then + rm -f "${FLAGS_chroot}${copy_file}" + install -C -m644 "${copy_file}" "${FLAGS_chroot}${copy_file}" + fi + done debug "Mounting chroot environment." MOUNT_CACHE=$(echo $(awk '{print $2}' /proc/mounts)) diff --git a/sdk_lib/make_chroot.sh b/sdk_lib/make_chroot.sh index 5c930d87b0..bc9fade881 100755 --- a/sdk_lib/make_chroot.sh +++ b/sdk_lib/make_chroot.sh @@ -182,19 +182,6 @@ EOF # Fix bad group for some. chown -R root:root "${FLAGS_chroot}/etc/"sudoers* - info "Setting timezone..." - rm -f "${FLAGS_chroot}/etc/localtime" - if [ -f /etc/localtime ] ; then - cp /etc/localtime "${FLAGS_chroot}/etc" - else - ln -sf /usr/share/zoneinfo/UTC "${FLAGS_chroot}/etc/localtime" - fi - - info "Setting up hosts/resolv..." - # Copy config from outside chroot into chroot. - cp /etc/{hosts,resolv.conf} "$FLAGS_chroot/etc/" - chmod 0644 "$FLAGS_chroot"/etc/{hosts,resolv.conf} - # Create directories referred to by our conf files. mkdir -p -m 775 "${FLAGS_chroot}/var/lib/portage/pkgs" \ "${FLAGS_chroot}/var/cache/"chromeos-{cache,chrome} \