From 4f6bd2518d030cf94f48885dbdeceb483b05384a 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 (cherry-picked from commit bc6c9f098442a2c0bf4a7a40ba50c9ee5fe40cc1) --- 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 d644f53..3300a3d 100644 --- a/classes/image_types_ostree.bbclass +++ b/classes/image_types_ostree.bbclass @@ -119,6 +119,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 + checksum=`sha256sum ${DEPLOY_DIR_IMAGE}/${OSTREE_KERNEL} | cut -f 1 -d " "` cp ${DEPLOY_DIR_IMAGE}/${OSTREE_KERNEL} boot/vmlinuz-${checksum} -- cgit v1.2.3-54-g00ecf