Add user-with-full-skel.bbclass to fix uncomplete /etc/skel population

Signed-off-by: Andreas Müller <schnitzeltony@gmail.com>
This commit is contained in:
Andreas Müller
2018-11-04 21:12:26 +01:00
parent 30e321b7d8
commit 7a2647519e
5 changed files with 49 additions and 2 deletions

2
README
View File

@@ -43,7 +43,7 @@ appends:
for the layer is ignored (see conf/layer.conf).
classes:
Currently instant-remote.bbclass only.
Currently instant-remote.bbclass and user-with-full-skel.bbclass.
conf:
layer.conf / and distro configurations

View File

@@ -0,0 +1,43 @@
# Problem with copying /etc/skel to home forder by useradd only is that
# user-recipe must RDEPEND on all recipes installing files to /etc/skel.
# Otherwise content found in home folder is unpredictable.
#
# To get around, this class was created. It is dual role and can be inherited
# by:
#
# * recipes creating a user whose home folder shall be populated by /etc/skel.
# The only action performed is dropping a file
# /home/${USERNAME}/${SKEL_INIT_MARKER} to mark the folder for later
# population.
# * images which get a postprocess command copying /etc/skel for those home
# folders marked.
SKEL_INIT_MARKER = "force-skel-full-init"
# user recipe part
pkg_postinst_${PN}() {
if [ -n "$D" ]; then
touch $D/home/${USERNAME}/${SKEL_INIT_MARKER}
fi
}
# image recipe part
ROOTFS_POSTPROCESS_COMMAND += "postinst_copy_skel; "
postinst_copy_skel () {
if [ -d "${IMAGE_ROOTFS}/home" -a -d "${IMAGE_ROOTFS}/${sysconfdir}/skel" ]; then
for home_target in `find "${IMAGE_ROOTFS}/home" -name ${SKEL_INIT_MARKER}`; do
# remove marker
rm "$home_target"
homedir=`dirname "$home_target"`
user=`basename "$homedir"`
# 1. copy -> /home/user/skel
cp -rf --preserve=mode,ownership,timestamps,links ${IMAGE_ROOTFS}${sysconfdir}/skel "$homedir"
chown -R "$user:$user" "$homedir/skel"
# 2. copy -> /home/user - TBD mv?
cp -rfT --preserve=mode,ownership,timestamps,links "$homedir/skel" "$homedir"
# 3. remove /home/user/skel
rm -rf "$homedir/skel"
done
fi
}

View File

@@ -2,7 +2,7 @@ DESCRIPTION = "This recipe adds a user 'morona' without password"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
inherit useradd
inherit useradd user-with-full-skel
USERNAME = "morona"
# groups user shall be member of (NO WHITESPACES ALLOWED)

View File

@@ -1,3 +1,5 @@
inherit user-with-full-skel
X11_BASE_INSTALL += " \
${DISTRO_GUI_USER} \
packagegroup-core-x11-xserver \

View File

@@ -2,6 +2,8 @@ require recipes-image/console/console-net-image.bb
export IMAGE_BASENAME = "weston-base-image"
inherit user-with-full-skel
IMAGE_INSTALL += " \
${DISTRO_GUI_USER} \
\