Skip to content

Commit

Permalink
Merge pull request #70 from quaresmajose/image_types_ostree
Browse files Browse the repository at this point in the history
Backport [kirkstone]: image_types_ostree: ostree_rmdir_helper: fix regression in removing /var symbolic links
  • Loading branch information
pattivacek authored Apr 25, 2023
2 parents dc93745 + 60c3f72 commit ce939ff
Showing 1 changed file with 22 additions and 24 deletions.
46 changes: 22 additions & 24 deletions classes/image_types_ostree.bbclass
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@ TAR_IMAGE_ROOTFS:task-image-ostree = "${OSTREE_ROOTFS}"

OSTREE_RMDIR_HELPER_MSGTYPE ?= "bbwarn"
ostree_rmdir_helper(){
if ! rmdir ${1}; then
${OSTREE_RMDIR_HELPER_MSGTYPE} "Data in ${1} directory is not preserved by OSTree. Consider moving it under /usr\n$(find ${1})"
rm -vrf ${1}
if [ -d ${1} ] && [ ! -L ${1} ]; then
if ! rmdir ${1}; then
${OSTREE_RMDIR_HELPER_MSGTYPE} "Data in '${1}' directory is not preserved by OSTree. Consider moving it under '/usr'\n$(find ${1} | tail -n +2)"
rm -vrf ${1}
fi
fi
}

Expand All @@ -37,13 +39,15 @@ IMAGE_CMD:ostree () {
# Copy required as we change permissions on some files.
tar --xattrs --xattrs-include='*' -cf - -S -C ${IMAGE_ROOTFS} -p . | tar --xattrs --xattrs-include='*' -xf - -C ${OSTREE_ROOTFS}

for d in var/*; do
if [ "${d}" != "var/local" ]; then
if [ -d ${d} ] && [ ! -L ${d} ]; then
ostree_rmdir_helper ${d}
fi
fi
done
# Just preserve var/local
if [ -d var/local ]; then
mv var/local var-local
fi
ostree_rmdir_helper var
mkdir var
if [ -d var/local ]; then
mv var-local var/local
fi

# Create sysroot directory to which physical sysroot will be mounted
mkdir sysroot
Expand Down Expand Up @@ -80,9 +84,7 @@ IMAGE_CMD:ostree () {
dirs="opt mnt media srv"

for dir in ${dirs}; do
if [ -d ${dir} ] && [ ! -L ${dir} ]; then
ostree_rmdir_helper ${dir}
fi
ostree_rmdir_helper ${dir}

if [ -n "${SYSTEMD_USED}" ]; then
echo "d /var/rootdirs/${dir} 0755 root root -" >>${tmpfiles_conf}
Expand All @@ -92,20 +94,16 @@ IMAGE_CMD:ostree () {
ln -sf var/rootdirs/${dir} ${dir}
done

if [ -d root ] && [ ! -L root ]; then
ostree_rmdir_helper root
ln -sf var/roothome root
ostree_rmdir_helper root
ln -sf var/roothome root

if [ -n "${SYSTEMD_USED}" ]; then
echo "d /var/roothome 0700 root root -" >>${tmpfiles_conf}
else
echo "mkdir -p /var/roothome; chmod 700 /var/roothome" >>${tmpfiles_conf}
fi
if [ -n "${SYSTEMD_USED}" ]; then
echo "d /var/roothome 0700 root root -" >>${tmpfiles_conf}
else
echo "mkdir -p /var/roothome; chmod 700 /var/roothome" >>${tmpfiles_conf}
fi

if [ -d usr/local ] && [ ! -L usr/local ]; then
ostree_rmdir_helper usr/local
fi
ostree_rmdir_helper usr/local

if [ -n "${SYSTEMD_USED}" ]; then
echo "d /var/usrlocal 0755 root root -" >>${tmpfiles_conf}
Expand Down

0 comments on commit ce939ff

Please sign in to comment.