mirror of
https://github.com/flatcar/scripts.git
synced 2025-09-21 21:51:57 +02:00
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.
This commit is contained in:
parent
57f65add2b
commit
796be0a520
@ -236,9 +236,13 @@ setup_env() {
|
|||||||
# Make the lockfile writable for backwards compatibility.
|
# Make the lockfile writable for backwards compatibility.
|
||||||
chown ${SUDO_UID}:${SUDO_GID} "${LOCKFILE}"
|
chown ${SUDO_UID}:${SUDO_GID} "${LOCKFILE}"
|
||||||
|
|
||||||
# Refresh /etc/resolv.conf and /etc/hosts in the chroot.
|
# Refresh system config files in the chroot.
|
||||||
install -C -m644 /etc/resolv.conf ${FLAGS_chroot}/etc/resolv.conf
|
for copy_file in /etc/{hosts,localtime,resolv.conf}; do
|
||||||
install -C -m644 /etc/hosts ${FLAGS_chroot}/etc/hosts
|
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."
|
debug "Mounting chroot environment."
|
||||||
MOUNT_CACHE=$(echo $(awk '{print $2}' /proc/mounts))
|
MOUNT_CACHE=$(echo $(awk '{print $2}' /proc/mounts))
|
||||||
|
@ -182,19 +182,6 @@ EOF
|
|||||||
# Fix bad group for some.
|
# Fix bad group for some.
|
||||||
chown -R root:root "${FLAGS_chroot}/etc/"sudoers*
|
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.
|
# Create directories referred to by our conf files.
|
||||||
mkdir -p -m 775 "${FLAGS_chroot}/var/lib/portage/pkgs" \
|
mkdir -p -m 775 "${FLAGS_chroot}/var/lib/portage/pkgs" \
|
||||||
"${FLAGS_chroot}/var/cache/"chromeos-{cache,chrome} \
|
"${FLAGS_chroot}/var/cache/"chromeos-{cache,chrome} \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user