blob: a057534b1a6798c845d9efa301720bf1820f292a [file] [log] [blame]
inherit image
PREFERRED_PROVIDER_virtual/kernel = "linux-dummy"
DM_VERITY_IMAGE_TYPE = "squashfs-xz"
IMAGE_CLASSES = "dm-verity-img"
IMAGE_LINGUAS = ""
# use container for skipping kernel
IMAGE_FSTYPES = "${DM_VERITY_IMAGE_TYPE}.verity container"
NO_RECOMMENDATIONS = "1"
do_image[depends] += " obmc-phosphor-image:do_rootfs"
IMAGE_INSTALL:append = " \
gbmc-systemd-config \
"
trim_dir() {
for file in $(ls -A ${1}/); do
local ext_item="${1}/${file}"
local obmc_item="${2}/${file}"
if [ -d "${ext_item}" -a -d "${obmc_item}" ]; then
# If both are directories, recurse
trim_dir "${ext_item}" "${obmc_item}"
# remove same empty dir as well
if [ -z "$( ls -A ${ext_item} )" ]; then
rm -r "${ext_item}"
fi
elif [ -e "${ext_item}" -a -e "${obmc_item}" ] || [ -L "${ext_item}" -a -L "${obmc_item}" ]; then
# If both are files, remove from root
rm "${ext_item}"
fi
done
}
# remove unecessary files from extendable image
trim_rootfs () {
obmc_rootfs="$(readlink -f ${TMPDIR}/work-shared/${MACHINE}/rootfs-dir)"
for item in $(ls -A ${IMAGE_ROOTFS}/); do
if [ "${item}" != 'etc' ] && [ "${item}" != 'opt' ] && [ "${item}" != 'usr' ]; then
rm -r "${IMAGE_ROOTFS}/${item}"
fi
done
trim_dir ${IMAGE_ROOTFS} ${obmc_rootfs}
}
# redirect all services to a new target for clean start
redirect_target () {
for file in $(find ${IMAGE_ROOTFS} -type f -name *.service); do
sed -i "s#WantedBy=multi-user.target#WantedBy=emmc-image.target#" $file
# Also ensure that it stops with emmc-image.target
printf "\n[Unit]\nPartOf=emmc-image.target\n" >> $file
done
if [ -d ${IMAGE_ROOTFS}/etc/systemd/system/multi-user.target.wants ]; then
mv ${IMAGE_ROOTFS}/etc/systemd/system/multi-user.target.wants ${IMAGE_ROOTFS}/etc/systemd/system/emmc-image.target.wants
fi
if [ -d ${IMAGE_ROOTFS}/lib/systemd/system/multi-user.target.wants ]; then
mv ${IMAGE_ROOTFS}/lib/systemd/system/multi-user.target.wants ${IMAGE_ROOTFS}/lib/systemd/system/emmc-image.target.wants
fi
# We may have services in time-sync.target as well, special handling for these services.
if [ -d ${IMAGE_ROOTFS}/etc/systemd/system/time-sync.target.wants ]; then
mv ${IMAGE_ROOTFS}/etc/systemd/system/time-sync.target.wants ${IMAGE_ROOTFS}/etc/systemd/system/emmc-image.target.wants
fi
if [ -d ${IMAGE_ROOTFS}/lib/systemd/system/time-sync.target.wants ]; then
mv ${IMAGE_ROOTFS}/lib/systemd/system/time-sync.target.wants ${IMAGE_ROOTFS}/lib/systemd/system/emmc-image.target.wants
fi
}
# we want the trim and tweak happen before systemd enable
IMAGE_PREPROCESS_COMMAND:prepend = "trim_rootfs redirect_target"