meta data for this page
  •  

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
sw:yocto:bitbake:split_packages [2026/02/23 15:53] – created niziaksw:yocto:bitbake:split_packages [2026/03/10 19:27] (current) niziak
Line 4: Line 4:
 ''/etc/fstab'' is provided by ''base-files'' ''/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'':     +  * create ''base-files-X'' and ''base-files-Y'' packages with the same content as ''base-files'' with only changed ''/etc/fstab'': [[https:// 
-[[https://yocto.yoctoproject.narkive.com/XcannnRd/per-image-customizations]]+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''
 + 
 +<code bash> 
 + 
 +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" 
 +</code> 
 + 
 +===== works: create separate package ===== 
 + 
 +Create second ''.bb'' file and include content of original file. 
 + 
 +  * Want to change ''/etc/fstab'' in ''base-files'': 
 +<file bash base-files_%.bbappend> 
 +FILESEXTRAPATHS:prepend := "${THISDIR}/files:" 
 + 
 +SRC_URI:append = " \ 
 +    file://fstab \ 
 +
 +</file> 
 +  * Want to provide another ''/etc/fstab'' in new package ''base-files-devel'': 
 +<file bash base-files-devel_3.0.14.bb> 
 +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 
 +
 +</file> 
 + 
 +