Best Known Methods (BKMs) for Package Updating

From Yocto Project
Jump to navigationJump to search

This page is used for capturing the Best Known Methods (BKMs) of package upgrading as we get reviewed and process more of the packages.

Don't Retain older Versions

Unless there is a specific need (which will probably occur for GPLv2, this has also happened in the past when platforms have known bugs in the latest version) don't retain older versions of the recipe files and patches.

Use git mv to rename recipe and patches

From Josh: Generally the way I perform recipe upgrades is to use git mv to rename the old file to the new version, this means that you don't have to consciously delete the old version later (win 1) and that git tracks the rename and the differences with the old file, which doesn't happen with a delete and add (win 2).

The advantage of this is that you and any reviewers can more easily see what has changed with the updated version of the recipe.


Nitin: Actually {git mv a b} is nothing but {mv a b; git rm a; git add b} And the file renames are detected by git automatically by looking at the file contents. Because of this git behavior, git shows some renames as renames and sometimes not. And I did not find a way to force git to understand renames. So if after "git mv" git is showing "file add & file remove", then don't get surprised, it's normal git operation.

Reset PR to 0 (or add PR) when upgrading recipes

This is a good visual reminder to bump in the future if needed.

For upgrades it's ok to use OE for inspiration

When upgrading packages, do the git mv as above, and build if it breaks, it's OK to check the OE equivalent and grab new patch or configuration change, just don't grab the whole recipe.

Be sure to add a credit to OE in your commit message when you do take a change like this.

Review: Merging packages from OpenEmbedded

For new package grab OE version, but sanitize them

Follow the recipe rules for Yocto when you take an OE recipe, be sure to clean all the OE'isms out

Again, give credit to OE in commit messages

Review: Merging packages from OpenEmbedded

Do NOT Merge .inc / .bb files

This was a decision that slipped by me, and was not communicated well, we do not want to merge the common ".inc" files and recipe (.bb) files. This is the case even if the .bb only contains a require and a PR="r0" line. This does not mean split everything at this point, but don't merge going forward.

White Space Management

  • Most variables such as SRC_URI should use spaces.
  • Shell functions should use tabs
  • Python functions should use spaces (4 spaces per indent).

Patches

Patches should contain information about where they came from and why they are required, as the project moves forward, we want to increase the quality of the data that is made available to the community. This can be done in the recipes and also in the patch files in order to understand why the patch exists and to help future maintainer to understand why it is required.

Patch Comments

Patch comments should contains information about why the patch is required, who created the patch and when, if that information is not currently know the the last information about where the patch came from (such as from OpenEmbedded) is very important to maintain in the patch header. Having a Signed-off-by: tag is good to acknowledge that someone looked at the patch and added the comments to ensure it is still valid and current.

To recap, patches should contain:

  • Why
  • Date Created
  • Who Created it
  • Any Upstream information
    • link to upstream mailing list
    • link to upstream bug tracking
    • IRC info
  • Signed-off-by:
    • This is most important when importing the patch and not the original author

Patch Upstreaming

In order to keep track of patches and ultimate reduce the number of patches that the Yotco Project maintains, we need to track the status of the patches that are created. As mentioned above, we the patches to contain comments about why they are created, by whom and when, we also want to track if it's appropriate to get this particular patch into the upstream project. Since we want to track this information, we need a consistent tag and set of status that can be searched. These are defined here.

New style patch application

The patch and pnum parameters have been renamed to the more logical apply and striplevel. The apply parameter takes either "yes" or "no" and the striplevel parameter takes an integer (0, 1, etc).

Both parameters are now optional with "sane" defaults.

The apply parameter is optional for SRC_URI lines with patch or diff extensions, which will default to being applied.

The striplevel parameter is also optional with a default striplevel of 1.

Old style parameters (patch and pnum) will continue to work for some time but it would be useful to move to the new style syntax as people are updating other parts of their recipes.

Therefore a patch line would be changed from:

file://some.patch;patch=1;pnum=2

to:

file://some.patch;striplevel=2 

and a patch line:

file://another.diff;patch=1;pnum=1

could be changed to:

file://another.diff 

Recipe Metadata Updates

DESCRIPTION and SUMMARY

LICENSE Metadata

  • The LICENSE information in the .bb file needs to be practical.
  • if there's "or any later version" in GPL related copyright, append "+" then which effectively means below:
GPLv2, GPLv2+, GPLv3, GPLv3+, LGPLv2, LGPLv2+, LGPLv2.1, LGPLv2.1+, LGPLv3, LGPLv3+
  • Scripts generated by autotools are not counted for licensing (they are always under GPL)
  • Dual license: GPLv2 | BSD
  • Multiple licenses: GPLv3+ & LGPLv2.1+
  • GPLv3 (correction may be required!)
anti-tivoization in GPLv3 only applies to User Products, which per definition is “either 
(1) a “consumer product”, which means any tangible personal property which is normally 
used for personal, family, or household purposes, or (2) anything designed or sold for 
incorporation into a dwelling."
  • For package changing its license, better to keep new license in .inc file with old license in corresponding .bb file. Take readline for example:
readline.inc: LICENSE = "GPLv3+"
readline_5.2.bb: LICENSE = "GPLv2"
  • we can treat MIT-style license as "MIT", meaning that any lawyer can tell it derivatives from standard form, such as below one:
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that copyright
notice and this permission notice appear in supporting documentation, and
that the name of the copyright holders not be used in advertising or
publicity pertaining to distribution of the software without specific,
written prior permission.  The copyright holders make no representations
about the suitability of this software for any purpose.  It is provided "as
is" without express or implied warranty.
  • some package may have complex license, such as wireless-tool:
most of files are GPLv2; 
one part in file is GPLv2+; 
some of them are dual licensed, such as sample_enc.c under LGPL | MPL | BSD.

In such case, first ignore the GPLv2+ bit since there is no way you could ever ship the package under say GPLv3 due to many headers being v2 only. Since there are files that are GPLv2 only, the answer is no. The LICENSE field is therefore primarily GPLv2 and we can ignore the 2+ bits. If they're a key part, the recipe becomes "GPLv2 & (LGPL | MPL | BSD)"

  • automake may generate COPYING automatically if there's no such one existing (e.g. Xsettings-client-0.10). A short answer is to add a MIT-style COPYING in poky and then install it before autotools work. See last section for detail description
  • all .bb files require LICENSE fields, even for those Poky specific (which are MIT).
  • ask on the ML for license information for those local files we don't know their origins
  • Name Sub-Packages with different Licenses
    • LICENSE = "LGPLv2.1 & GPLv3+"
    • LICENSE_libidn = "LGPLv2.1"
    • LICENSE_libidn-tests = "GPLv3+"
  • when listing sub-package license, remember to use names included in PACKAGES instead of source directories, e.g:
LICENSE = "GPLv2 & LGPLv2 & BSD & MIT"
LICENSE_lib/ext2fs = "LGPLv2"

Better to use:
LICENSE_e2fsprogs-mke2fs = "LGPLv2"
because mke2fs is a package name

Autotools adds wrong COPYING

Autotools add the wrong COPYING license to source code with out COPYING, to ensure that we have the correct and consistent license, add the correct license file to the SRC_URI List and a do_config_prepend().

SRC_URI = "... \
        ...
        file://XXX-license"

do_configure_prepend() {
        # This package doesn't ship with its own COPYING file and 
        # autotools will install a GPLv2 one instead of MIT. Add the
        # correct license here to avoid confusion.
        cp ${WORKDIR}/MIT-style-license ${S}/COPYING
}

Distro Tracking Fields

The file meta/conf/distro/include/distro_tracking_fields.inc exists to allow us to track various pieces of information about recipes and upstream versions (e.g, recipe maintainer contact information, date of latest upstream release, alternate names used for this recipe in other Linux distros, etc). The following defines the meaning of each field:

RECIPE_STATUS
Indicates whether the recipe has been reviewed for basic quality control information (e.g, has had its software license verified). "red" indicates these checks have not been done, and "green" indicates that they have been done.
RECIPE_DEPENDENCY_CHECK
Indicates whether the recipe has been built from scratch to verify that all of its build and runtime dependencies have been specified. Value is either "not done" or "done"
RECIPE_LATEST_VERSION
The latest upstream stable version, "3.0"
RECIPE_NO_OF_PATCHES
The number of patches we ship with the recipe.
RECIPE_PATCH
Summarizes the purpose of each patch associated with a recipe.
RECIPE_LATEST_RELEASE_DATE
The date at which the latest upstream stable version (mentioned in RECIPE_LATEST_VERSION) was released, "03/2010"
RECIPE_TIME_BETWEEN_LAST_TWO_RELEASES
The amount of time which passed between the most recent two upstream stable releases, "2 months"
RECIPE_COMMENTS
A field to mention comments, such as why a recipe can't be brought up to the latest upstream release, or unusual build issues that need to be worked around.
RECIPE_LAST_UPDATE
Date of the last changes to the recipe, "Dec 10, 2010"
RECIPE_MAINTAINER
Name and email address of the person maintaining the recipe, "Firstname Lastname <email.address>"

Note that in the file, each field name is appended with -pn-<recipe name>.