Skip to contentSkip to conversation

overview-manual: concepts: add details on package splitting

PATCH In review Antonin Godard 2 participants 3 messages Oct 22, 2024

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 overview-manual: concepts: add details on package splitting

The package splitting section of the overview manual currently lacks any explanation of how package splitting is implemented and redirects to the package class, which is not really understandable for newcomers to the project.

This patch adds a short explanation of what is done:

* How the PACKAGES variable is defined.
* How the FILES variable is defined.
* How the two work together.
* How to add a custom package.

This should give enough details to a new user on what package splitting achieves and how to add a custom package.

Adresses [YOCTO #13225]

---
Changes in v2:
- Rewrite multiple paragraphs after reviews from Quentin.
- Be explicit on _NOT_ using D in FILES!
- Mention the oe-pkgdata-util cli tool.
- Link to v1: https://lore.kernel.org/r/[email protected]

---
 documentation/overview-manual/concepts.rst | 61 +++++++++++++++++++++++++++---
 1 file changed, 56 insertions(+), 5 deletions(-)
documentation/overview-manual/concepts.rst +56 -5
index 62f2327a7e27a777f738523e7fafe62422186abb..e38ca196260c1f7ece2dcd0cfd3aafe41fd27147 100644
@@ -912,11 +912,62 @@ the analysis and package splitting process use several areas:
    execute on a system and it generates code for yet another machine
    (e.g. :ref:`ref-classes-cross-canadian` recipes).
 
-The :term:`FILES` variable defines the
-files that go into each package in
-:term:`PACKAGES`. If you want
-details on how this is accomplished, you can look at
-:yocto_git:`package.bbclass </poky/tree/meta/classes-global/package.bbclass>`.
+Packages for a recipe are listed in the :term:`PACKAGES` variable. The
+:oe_git:`bitbake.conf </openembedded-core/tree/meta/conf/bitbake.conf>`
+configuration file defines the following default list of packages::
+
+  PACKAGES = "${PN}-src ${PN}-dbg ${PN}-staticdev ${PN}-dev ${PN}-doc ${PN}-locale ${PACKAGE_BEFORE_PN} ${PN}"
+
+Each of these packages contain a default list of files defined with the
+:term:`FILES` variable. For example, the package ``${PN}-dev`` represents files
+useful to the development of applications depending on ``${PN}``. The default
+list of files for ``${PN}-dev``, also defined in :oe_git:`bitbake.conf
+</openembedded-core/tree/meta/conf/bitbake.conf>`, is defined as follows::
+
+  FILES:${PN}-dev = "${includedir} ${FILES_SOLIBSDEV} ${libdir}/*.la \
+                  ${libdir}/*.o ${libdir}/pkgconfig ${datadir}/pkgconfig \
+                  ${datadir}/aclocal ${base_libdir}/*.o \
+                  ${libdir}/${BPN}/*.la ${base_libdir}/*.la \
+                  ${libdir}/cmake ${datadir}/cmake"
+
+The paths in this list must be *absolute* paths from the point of view of the
+root filesystem on the target, and must *not* make references to the variable
+:term:`D` or any :term:`WORKDIR` related variable. A correct example would be::
+
+  ${sysconfdir}/foo.conf
+
+.. note::
+
+   The list of files for a package is defined using the override syntax by
+   separating :term:`FILES` and the package name by a semi-colon (``:``).
+
+.. note::
+
+  To find out which package installs a file, the ``oe-pkgdata-util``
+  command-line utility can be used::
+
+    $ oe-pkgdata-util find-path '/etc/fstab'
+    base-files: /etc/fstab
+
+  For more information on the ``oe-pkgdata-util`` utility, see the section
+  :ref:`dev-manual/debugging:Viewing Package Information with
+  \`\`oe-pkgdata-util\`\`` of the Yocto Project Development Tasks Manual.
+
+A given file can only ever be in one package. By iterating from the leftmost to
+rightmost package in :term:`PACKAGES`, each file matching one of the patterns
+defined in the corresponding :term:`FILES` definition is included in the
+package.
+
+To add a custom package variant of the ``${PN}`` recipe named
+``${PN}-extra`` (name is arbitrary), one can add it to the
+:term:`PACKAGE_BEFORE_PN` variable::
+
+  PACKAGE_BEFORE_PN += "${PN}-extra"
+
+Alternatively, a custom package can be added by adding it to the
+:term:`PACKAGES` variable using the prepend operator (``=+``)::
+
+  PACKAGES =+ "${PN}-extra"
 
 Depending on the type of packages being created (RPM, DEB, or IPK), the
 :ref:`do_package_write_* <ref-tasks-package_write_deb>`

---
base-commit: e4b64514673471850635a8dbbf62f34e710e276a
change-id: 20241015-bug-13225-package-split-57c8dc0f96b5

Best regards,

Signature · 1 line
Antonin Godard <[email protected]>
Reviewed-by on v2 1/1
#1 lore raw

Hi Antonin,

Quoted 38 lines · Antonin Godard

The package splitting section of the overview manual currently lacks any explanation of how package splitting is implemented and redirects to the package class, which is not really understandable for newcomers to the project.

This patch adds a short explanation of what is done:

* How the PACKAGES variable is defined.
* How the FILES variable is defined.
* How the two work together.
* How to add a custom package.

This should give enough details to a new user on what package splitting achieves and how to add a custom package.

Adresses [YOCTO #13225]

---
Changes in v2:
- Rewrite multiple paragraphs after reviews from Quentin.
- Be explicit on _NOT_ using D in FILES!
- Mention the oe-pkgdata-util cli tool.
- Link to v1: https://lore.kernel.org/r/[email protected]

---
  documentation/overview-manual/concepts.rst | 61 +++++++++++++++++++++++++++---
  1 file changed, 56 insertions(+), 5 deletions(-)
documentation/overview-manual/concepts.rst +0 -2
index 62f2327a7e27a777f738523e7fafe62422186abb..e38ca196260c1f7ece2dcd0cfd3aafe41fd27147 100644
@@ -912,11 +912,62 @@ the analysis and package splitting process use several areas:
     execute on a system and it generates code for yet another machine
     (e.g. :ref:`ref-classes-cross-canadian` recipes).
 
-The :term:`FILES` variable defines the
-files that go into each package in

documentation/overview-manual/concepts.rst the analysis and package splitting process use several areas: · line 921

Quoted 10 lines
documentation/overview-manual/concepts.rst +7 -3
-:term:`PACKAGES`. If you want
-details on how this is accomplished, you can look at
-:yocto_git:`package.bbclass </poky/tree/meta/classes-global/package.bbclass>`.
+Packages for a recipe are listed in the :term:`PACKAGES` variable. The
+:oe_git:`bitbake.conf </openembedded-core/tree/meta/conf/bitbake.conf>`
+configuration file defines the following default list of packages::
+
+  PACKAGES = "${PN}-src ${PN}-dbg ${PN}-staticdev ${PN}-dev ${PN}-doc ${PN}-locale ${PACKAGE_BEFORE_PN} ${PN}"
+
+Each of these packages contain a default list of files defined with the

s/contain/contains/ since it's "each" so singular.

documentation/overview-manual/concepts.rst the analysis and package splitting process use several areas: · line 934

Quoted 13 lines
documentation/overview-manual/concepts.rst +13 -0
+:term:`FILES` variable. For example, the package ``${PN}-dev`` represents files
+useful to the development of applications depending on ``${PN}``. The default
+list of files for ``${PN}-dev``, also defined in :oe_git:`bitbake.conf
+</openembedded-core/tree/meta/conf/bitbake.conf>`, is defined as follows::
+
+  FILES:${PN}-dev = "${includedir} ${FILES_SOLIBSDEV} ${libdir}/*.la \
+                  ${libdir}/*.o ${libdir}/pkgconfig ${datadir}/pkgconfig \
+                  ${datadir}/aclocal ${base_libdir}/*.o \
+                  ${libdir}/${BPN}/*.la ${base_libdir}/*.la \
+                  ${libdir}/cmake ${datadir}/cmake"
+
+The paths in this list must be *absolute* paths from the point of view of the
+root filesystem on the target, and must *not* make references to the variable

I would use the singular here for reference as a path can only make a reference to another path and not multiple ones.

Quoted 7 lines
documentation/overview-manual/concepts.rst +7 -0
+:term:`D` or any :term:`WORKDIR` related variable. A correct example would be::
+
+  ${sysconfdir}/foo.conf
+
+.. note::
+
+   The list of files for a package is defined using the override syntax by

documentation/overview-manual/concepts.rst the analysis and package splitting process use several areas:

Quoted 10 lines
documentation/overview-manual/concepts.rst +10 -0
+   separating :term:`FILES` and the package name by a semi-colon (``:``).
+
+.. note::
+
+  To find out which package installs a file, the ``oe-pkgdata-util``
+  command-line utility can be used::
+
+    $ oe-pkgdata-util find-path '/etc/fstab'
+    base-files: /etc/fstab
+> +  For more information on the ``oe-pkgdata-util`` utility, see the 

section

documentation/overview-manual/concepts.rst the analysis and package splitting process use several areas: · line 955

Quoted 3 lines
documentation/overview-manual/concepts.rst +3 -0
+  :ref:`dev-manual/debugging:Viewing Package Information with
+  \`\`oe-pkgdata-util\`\`` of the Yocto Project Development Tasks Manual.
+

I would move the second note to after the paragraph in which the "a file is only in one package" statement below, but that's personal taste at that point :)

Looks good to me.

With the contain/contains typo fixed:

Cheers,
Quentin

#2 lore raw
Quoted 6 lines · Quentin Schulz
Quoted 6 lines
documentation/overview-manual/concepts.rst +1 -5
-The :term:`FILES` variable defines the
-files that go into each package in
-:term:`PACKAGES`. If you want
-details on how this is accomplished, you can look at
-:yocto_git:`package.bbclass </poky/tree/meta/classes-global/package.bbclass>`.
+Packages for a recipe are listed in the :term:`PACKAGES` variable. The
Quoted 8 lines

documentation/overview-manual/concepts.rst the analysis and package splitting process use several areas: · line 921

Quoted 6 lines

+:oe_git:bitbake.conf </openembedded-core/tree/meta/conf/bitbake.conf>

documentation/overview-manual/concepts.rst +5 -0
+configuration file defines the following default list of packages::
+
+  PACKAGES = "${PN}-src ${PN}-dbg ${PN}-staticdev ${PN}-dev ${PN}-doc ${PN}-locale ${PACKAGE_BEFORE_PN} ${PN}"
+
+Each of these packages contain a default list of files defined with the

s/contain/contains/ since it's "each" so singular.

Thanks... I know it's the correct way to write it but my brain can't stop from finding it weird that way :)

Quoted 8 lines
Quoted 8 lines

+:term:FILES variable. For example, the package ``${PN}-dev`` represents files

documentation/overview-manual/concepts.rst +7 -0
+useful to the development of applications depending on ``${PN}``. The default
+list of files for ``${PN}-dev``, also defined in :oe_git:`bitbake.conf
+</openembedded-core/tree/meta/conf/bitbake.conf>`, is defined as follows::
+
+  FILES:${PN}-dev = "${includedir} ${FILES_SOLIBSDEV} ${libdir}/*.la \
+                  ${libdir}/*.o ${libdir}/pkgconfig ${datadir}/pkgconfig \
+                  ${datadir}/aclocal ${base_libdir}/*.o \
Quoted 8 lines

documentation/overview-manual/concepts.rst the analysis and package splitting process use several areas: · line 934

Quoted 5 lines
documentation/overview-manual/concepts.rst +5 -0
+                  ${libdir}/${BPN}/*.la ${base_libdir}/*.la \
+                  ${libdir}/cmake ${datadir}/cmake"
+
+The paths in this list must be *absolute* paths from the point of view of the
+root filesystem on the target, and must *not* make references to the variable

I would use the singular here for reference as a path can only make a reference to another path and not multiple ones.

+1

Quoted 18 lines
Quoted 7 lines

+:term:D or any :term:WORKDIR related variable. A correct example would be::

documentation/overview-manual/concepts.rst +6 -0
+
+  ${sysconfdir}/foo.conf
+
+.. note::
+
+   The list of files for a package is defined using the override syntax by

documentation/overview-manual/concepts.rst the analysis and package splitting process use several areas:

Quoted 10 lines
documentation/overview-manual/concepts.rst +10 -0
+   separating :term:`FILES` and the package name by a semi-colon (``:``).
+
+.. note::
+
+  To find out which package installs a file, the ``oe-pkgdata-util``
+  command-line utility can be used::
+
+    $ oe-pkgdata-util find-path '/etc/fstab'
+    base-files: /etc/fstab
+> +  For more information on the ``oe-pkgdata-util`` utility, see the

section

Quoted 7 lines

documentation/overview-manual/concepts.rst the analysis and package splitting process use several areas: · line 955

Quoted 3 lines
documentation/overview-manual/concepts.rst +3 -0
+  :ref:`dev-manual/debugging:Viewing Package Information with
+  \`\`oe-pkgdata-util\`\`` of the Yocto Project Development Tasks Manual.
+

I would move the second note to after the paragraph in which the "a file is only in one package" statement below, but that's personal taste at that point :)

Right, I agree.

Quoted 8 lines

Looks good to me.

With the contain/contains typo fixed:

Cheers,
Quentin

Thanks Quentin.

Cheers,
Antonin

--
Antonin Godard, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com