====== split packages ======
How to customise ''/etc/fstab'' per image ?
''/etc/fstab'' is provided by ''base-files''.
* create ''base-files-X'' and ''base-files-Y'' packages with the same content as ''base-files'' with only changed ''/etc/fstab'': [[https://
yocto.yoctoproject.narkive.com/XcannnRd/per-image-customizations]]
* Search in Yocto for ''python populate_packages'' and see what others do
===== almost works =====
Adapted solution from 1st link almost works. Until SPDX fails because ''base-files-devel'' provides ''base-files''.
PACKAGES += "${PN}-devel"
PROVIDES += "${PN}-devel"
CONFFILES:${PN}-devel = "${CONFFILES:${PN}}"
RREPLACES:${PN}-devel = "${PN}"
RCONFLICTS:${PN}-devel = "${PN}"
# ${PN}-devel also provides ${PN} - for compatibility with other packages
# But it breaks SPDX generation in do_rootfs so disable it
RPROVIDES:${PN}-devel = "${PN}"
CVE_PRODUCT:${PN}-devel = "base-files"
python populate_packages:prepend() {
import shutil
packages = ("${PN}-devel",)
# PKGD (Package Destination Directory): This is the directory where files are
# staged before they are split into individual packages. It represents the intermediate,
# unsplit state of the files that do_install has already installed.
#
# PKGDEST (Package Destination): This is the parent directory where packages reside after they have
# been split. It is often referred to as the packages-split directory, containing subdirectories for
# each package (e.g., pkg-name, pkg-name-dbg, pkg-name-dev).
preinst = d.getVar('pkg_preinst:${PN}')
for package in packages:
d.setVar(d.expand(f"pkg_preinst:{package}"), preinst)
# copy ${PN} content to other packages
shutil.copytree(d.expand("${PKGD}"), d.expand("${PKGDEST}"+ f"/{package}"), symlinks=True)
# replace fstab
if package == "${PN}-devel":
shutil.copy(d.expand("${WORKDIR}/fstab-devel"), d.expand("${PKGDEST}/${PN}-devel/etc/fstab"))
}
INSANE_SKIP:${PN}-devel += "empty-dirs"
===== works: create separate package =====
Create second ''.bb'' file and include content of original file.
* Want to change ''/etc/fstab'' in ''base-files'':
FILESEXTRAPATHS:prepend := "${THISDIR}/files:"
SRC_URI:append = " \
file://fstab \
"
* Want to provide another ''/etc/fstab'' in new package ''base-files-devel'':
require recipes-core/base-files/base-files_${PV}.bb
FILESEXTRAPATHS:append := ":${COREBASE}/meta/recipes-core/base-files/base-files"
SUMMARY = "Devel version of base-files package."
RPROVIDES:${PN} = "base-files"
SRC_URI += " \
file://fstab-devel \
"
do_install:append() {
install -m 0644 ${WORKDIR}/fstab-devel ${D}${sysconfdir}/fstab
}