mirror of
https://github.com/home-assistant/operating-system.git
synced 2025-11-09 10:58:36 +00:00
To make system timezone configurable, we need to have /etc/localtime writable, and it must be possible to atomically create a symlink from this place, which means the whole parent folder must be writable. We don't have /etc writable and can't use the usual bind mount for this. Latest Systemd v258 has patch that allows setting an environment variable that sets where the localtime should be written. This can be persisted in the overlay partition, with a symlink from /etc/localtime leading there, finally pointing to the actual zoneinfo file. If the symlink doesn't exist, create it by hassos-overlay script (it's not really needed as UTC is the default, but Systemd does the same if you change from non-UTC timezone back to UTC). Also disable BR2_TARGET_LOCALTIME, so /etc/localtime and /etc/timezone (the latter is only informative and non-standard) are not written by the tzdata package build.
53 lines
1.8 KiB
Bash
Executable File
53 lines
1.8 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
function fix_rootfs() {
|
|
# Cleanup etc
|
|
rm -rf "${TARGET_DIR:?}/etc/init.d"
|
|
rm -rf "${TARGET_DIR:?}/etc/network"
|
|
rm -rf "${TARGET_DIR:?}/etc/X11"
|
|
rm -rf "${TARGET_DIR:?}/etc/xdg"
|
|
|
|
# Cleanup root
|
|
rm -rf "${TARGET_DIR:?}/media"
|
|
rm -rf "${TARGET_DIR:?}/srv"
|
|
rm -rf "${TARGET_DIR:?}/opt"
|
|
|
|
# Remove info pages
|
|
rm -rf "${TARGET_DIR:?}/share/info"
|
|
rm -rf "${TARGET_DIR:?}/usr/share/info"
|
|
|
|
# Cleanup miscs
|
|
rm -rf "${TARGET_DIR}/usr/lib/modules-load.d"
|
|
|
|
# systemd-update-done.service relies on writeable /var and /etc
|
|
rm -f "${TARGET_DIR}/usr/lib/systemd/system/sysinit.target.wants/systemd-update-done.service"
|
|
|
|
# Fix: tempfs with /srv
|
|
sed -i "/srv/d" "${TARGET_DIR}/usr/lib/tmpfiles.d/home.conf"
|
|
|
|
# Fix: Could not generate persistent MAC address
|
|
sed -i "s/MACAddressPolicy=persistent/MACAddressPolicy=none/g" "${TARGET_DIR}/usr/lib/systemd/network/99-default.link"
|
|
|
|
# Use systemd-resolved for Host OS resolve
|
|
sed -i '/^hosts:/ {/resolve/! s/files/resolve [!UNAVAIL=return] files/}' "${TARGET_DIR}/etc/nsswitch.conf"
|
|
|
|
# Remove unnecessary grub userspace tools, config, modules and translations
|
|
find "${TARGET_DIR}"/usr/{,s}bin -name "grub-*" -not -name "grub-editenv" -delete
|
|
rm -rf "${TARGET_DIR}/etc/grub.d"
|
|
rm -rf "${TARGET_DIR}/usr/lib/grub"
|
|
if [ -d "${TARGET_DIR}/share/locale" ]; then
|
|
find "${TARGET_DIR}/share/locale" -name "grub.mo" -delete
|
|
find "${TARGET_DIR}/share/locale" -type d -empty -delete
|
|
fi
|
|
}
|
|
|
|
|
|
function install_tini_docker() {
|
|
ln -fs /usr/bin/tini "${TARGET_DIR}/usr/bin/docker-init"
|
|
}
|
|
|
|
function setup_localtime() {
|
|
# localtime is writable through SYSTEMD_ETC_LOCALTIME
|
|
ln -fs /mnt/overlay/etc/localtime "${TARGET_DIR}/etc/localtime"
|
|
}
|