From 6364206eb7be5693a48b0b7a7b07aa02f7fc1c8f Mon Sep 17 00:00:00 2001 From: Stefan Agner Date: Fri, 19 Jul 2019 22:11:50 +0200 Subject: image_types_ostree: add /usr/local support Add /usr/local support as outlined in OSTree documentation. This makes sure that a writeable and persistent /usr/local directory is available. See also: https://ostree.readthedocs.io/en/latest/manual/adapting-existing/ Signed-off-by: Stefan Agner --- classes/image_types_ostree.bbclass | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/classes/image_types_ostree.bbclass b/classes/image_types_ostree.bbclass index 9ae5a3a..a9a8174 100644 --- a/classes/image_types_ostree.bbclass +++ b/classes/image_types_ostree.bbclass @@ -106,6 +106,31 @@ IMAGE_CMD_ostree () { ln -sf var/roothome root fi + if [ -d usr/local ] && [ ! -L usr/local ]; then + if [ "$(ls -A usr/local)" ]; then + bbfatal "Data in /usr/local directory is not preserved by OSTree." + fi + rm -rf usr/local + fi + + if [ -n "${SYSTEMD_USED}" ]; then + echo "d /var/usrlocal 0755 root root -" >>${tmpfiles_conf} + else + echo "mkdir -p /var/usrlocal; chown 755 /var/usrlocal" >>${tmpfiles_conf} + fi + + dirs="bin etc games include lib man sbin share src" + + for dir in ${dirs}; do + if [ -n "${SYSTEMD_USED}" ]; then + echo "d /var/usrlocal/${dir} 0755 root root -" >>${tmpfiles_conf} + else + echo "mkdir -p /var/usrlocal/${dir}; chown 755 /var/usrlocal/${dir}" >>${tmpfiles_conf} + fi + done + + ln -sf ../var/usrlocal usr/local + if [ "${KERNEL_IMAGETYPE}" = "fitImage" ]; then # this is a hack for ostree not to override init= in kernel cmdline - # make it think that the initramfs is present (while it is in FIT image) -- cgit v1.2.3-54-g00ecf