From 165b86e4aac70f279368b9fe1ef70075168a737e Mon Sep 17 00:00:00 2001 From: Bruce Leidl Date: Sat, 17 Feb 2018 17:44:33 -0500 Subject: [PATCH] big refactor of how state is handled on /storage --- .../base-files/base-files_%.bbappend | 21 ++++++++++++-- .../base-files/files/00-storage-tmpfiles.conf | 16 +++++++++++ .../base-files/files/NetworkManager.conf | 4 +++ .../recipes-core/base-files/files/fstab | 4 +-- .../recipes-core/images/citadel-image.bb | 28 ++++++++++++++++++- 5 files changed, 67 insertions(+), 6 deletions(-) create mode 100644 meta-citadel-distro/recipes-core/base-files/files/00-storage-tmpfiles.conf create mode 100644 meta-citadel-distro/recipes-core/base-files/files/NetworkManager.conf diff --git a/meta-citadel-distro/recipes-core/base-files/base-files_%.bbappend b/meta-citadel-distro/recipes-core/base-files/base-files_%.bbappend index 6cadf5e..4299479 100644 --- a/meta-citadel-distro/recipes-core/base-files/base-files_%.bbappend +++ b/meta-citadel-distro/recipes-core/base-files/base-files_%.bbappend @@ -6,18 +6,35 @@ SRC_URI += "\ file://environment.sh \ file://fstab \ file://99-grsec-debootstrap.conf \ + file://00-storage-tmpfiles.conf \ + file://NetworkManager.conf \ " +dirs1777_remove = "${localstatedir}/volatile/tmp" +dirs755="/boot /dev /usr/bin /usr/sbin /usr/lib /etc /etc/default /etc/skel /usr/lib /mnt /proc /home/root /run /usr /usr/bin /usr/share/doc/base-files-3.0.14 /usr/include /usr/lib /usr/sbin /usr/share /usr/share/common-licenses /usr/share/info /usr/share/man /usr/share/misc /var /sys /home /media" + +volatiles = "" + do_install_append () { install -m 0755 -d ${D}/storage - install -m 0755 -d ${D}/var/lib/machines + install -d ${D}${libdir}/sysctl.d install -m 0755 -d ${D}${sysconfdir}/profile.d + install -m 0755 -d ${D}${sysconfdir}/tmpfiles.d + install -m 0755 -d ${D}${sysconfdir}/NetworkManager + install -m 0700 -d ${D}${localstatedir}/lib/NetworkManager + install -m 0700 -d ${D}${localstatedir}/lib/NetworkManager/system-connections + install -m 0644 ${WORKDIR}/locale.conf ${D}${sysconfdir}/locale.conf install -m 0644 ${WORKDIR}/environment.sh ${D}${sysconfdir}/profile.d/environment.sh install -m 0644 ${WORKDIR}/fstab ${D}${sysconfdir}/fstab + install -m 0644 ${WORKDIR}/00-storage-tmpfiles.conf ${D}${sysconfdir}/tmpfiles.d + install -m 0644 ${WORKDIR}/NetworkManager.conf ${D}${sysconfdir}/NetworkManager # disable some pax and grsecurity features so that debootstrap will work # this should be removed later - install -d ${D}${libdir}/sysctl.d install -m 0644 ${WORKDIR}/99-grsec-debootstrap.conf ${D}${libdir}/sysctl.d/ + + ln -s /storage/citadel-state/resolv.conf ${D}${sysconfdir}/resolv.conf + ln -s /dev/null ${D}${sysconfdir}/tmpfiles.d/etc.conf + ln -s /dev/null ${D}${sysconfdir}/tmpfiles.d/home.conf } diff --git a/meta-citadel-distro/recipes-core/base-files/files/00-storage-tmpfiles.conf b/meta-citadel-distro/recipes-core/base-files/files/00-storage-tmpfiles.conf new file mode 100644 index 0000000..1aae6ea --- /dev/null +++ b/meta-citadel-distro/recipes-core/base-files/files/00-storage-tmpfiles.conf @@ -0,0 +1,16 @@ +C /var/cache - - - - +C /var/lib/AccountsService - - - - +C /var/lib/NetworkManager - - - - +C /var/lib/colord - - - - +C /var/lib/dbus - - - - +C /var/lib/dhcp - - - - +C /var/lib/gdm - - - - +C /var/lib/plymouth - - - - +C /var/lib/upower - - - - +C /var/log - - - - +C /var/spool - - - - +C /home - - - - +C /home/citadel - - - - +C /home/root - - - - +f /storage/citadel-state/resolv.conf 0644 root root + diff --git a/meta-citadel-distro/recipes-core/base-files/files/NetworkManager.conf b/meta-citadel-distro/recipes-core/base-files/files/NetworkManager.conf new file mode 100644 index 0000000..22c4111 --- /dev/null +++ b/meta-citadel-distro/recipes-core/base-files/files/NetworkManager.conf @@ -0,0 +1,4 @@ +[main] + +[keyfile] +path=/var/lib/NetworkManager/system-connections diff --git a/meta-citadel-distro/recipes-core/base-files/files/fstab b/meta-citadel-distro/recipes-core/base-files/files/fstab index 1fe3904..e944de3 100644 --- a/meta-citadel-distro/recipes-core/base-files/files/fstab +++ b/meta-citadel-distro/recipes-core/base-files/files/fstab @@ -1,7 +1,5 @@ /dev/root / auto defaults 1 1 -tmpfs /var tmpfs defaults 0 0 /dev/mapper/citadel-storage /storage auto defaults 0 0 /storage/citadel-state/home /home none bind 0 0 -/storage/citadel-state/var/log /var/log none bind 0 0 -/storage/citadel-state/etc/NetworkManager/system-connections /etc/NetworkManager/system-connections none bind 0 0 +/storage/citadel-state/var /var none bind 0 0 diff --git a/meta-citadel-distro/recipes-core/images/citadel-image.bb b/meta-citadel-distro/recipes-core/images/citadel-image.bb index 74064f4..030e995 100644 --- a/meta-citadel-distro/recipes-core/images/citadel-image.bb +++ b/meta-citadel-distro/recipes-core/images/citadel-image.bb @@ -6,7 +6,7 @@ SYSTEMD_DEFAULT_TARGET = "graphical.target" require citadel-image-base.bb -ROOTFS_POSTPROCESS_COMMAND += "set_citadel_user_password; symlink_lib64; " +ROOTFS_POSTPROCESS_COMMAND += "set_citadel_user_password; symlink_lib64; setup_var; " #IMAGE_FSTYPES += "ext2" IMAGE_FSTYPES = "ext2" @@ -24,6 +24,32 @@ set_citadel_user_password() { sed -i 's%^citadel:!:%citadel:aadg8rGtZzOY6:%' ${IMAGE_ROOTFS}/etc/shadow } +setup_var() { + install -m 0755 -d ${IMAGE_ROOTFS}/usr/share/factory/var + install -m 0755 -d ${IMAGE_ROOTFS}/usr/share/factory/home + + install -m 0755 -o 1000 -g 1000 -d ${IMAGE_ROOTFS}/home/citadel/.local/share/applications + + mv ${IMAGE_ROOTFS}/var/lib ${IMAGE_ROOTFS}/usr/share/factory/var + mv ${IMAGE_ROOTFS}/var/log ${IMAGE_ROOTFS}/usr/share/factory/var + mv ${IMAGE_ROOTFS}/var/cache ${IMAGE_ROOTFS}/usr/share/factory/var + mv ${IMAGE_ROOTFS}/var/spool ${IMAGE_ROOTFS}/usr/share/factory/var + mv ${IMAGE_ROOTFS}/var/run ${IMAGE_ROOTFS}/usr/share/factory/var + mv ${IMAGE_ROOTFS}/var/lock ${IMAGE_ROOTFS}/usr/share/factory/var + + mv ${IMAGE_ROOTFS}/home/citadel ${IMAGE_ROOTFS}/usr/share/factory/home + mv ${IMAGE_ROOTFS}/home/root ${IMAGE_ROOTFS}/usr/share/factory/home + + # do_rootfs() will fail otherwise + ln -sf ../usr/share/factory/var/lib ${IMAGE_ROOTFS}/var/lib +} + +do_rm_var_link() { + rm ${IMAGE_ROOTFS}/var/lib +} + +addtask rm_var_link after do_rootfs before do_image_qa + symlink_lib64() { ln -s /usr/lib ${IMAGE_ROOTFS}/lib64 }