All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Kjellerstedt <peter.kjellerstedt@axis.com>
To: Richard Purdie <richard.purdie@linuxfoundation.org>,
	"openembedded-core@lists.openembedded.org"
	<openembedded-core@lists.openembedded.org>
Subject: RE: [OE-core] [PATCH 3/4] license/insane: Show warning for obsolete license usage
Date: Wed, 2 Mar 2022 15:17:05 +0000	[thread overview]
Message-ID: <fd6a428f453c4675ae5fa17bb71615b7@axis.com> (raw)
In-Reply-To: <20220301234214.247172-3-richard.purdie@linuxfoundation.org>

> -----Original Message-----
> From: openembedded-core@lists.openembedded.org <openembedded-core@lists.openembedded.org> On Behalf Of Richard Purdie
> Sent: den 2 mars 2022 00:42
> To: openembedded-core@lists.openembedded.org
> Subject: [OE-core] [PATCH 3/4] license/insane: Show warning for obsolete license usage
> 
> We want to use SPDX identifiers in LICENSE variables. There is now a
> conversion script to make most of the translations. Add a list of
> strings which have been replaced so we can show warnings to users
> if they're still used anywhere.
> 
> Add checks to the package as insane check. This is currently a warning
> by default but can be turned off or made an error as per the other standard
> checks.
> 
> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
> ---
>  meta/classes/base.bbclass   |  6 ++++++
>  meta/classes/insane.bbclass | 31 ++++++++++++++++++++++---------
>  meta/lib/oe/license.py      | 10 ++++++++++
>  3 files changed, 38 insertions(+), 9 deletions(-)
> 
> diff --git a/meta/classes/base.bbclass b/meta/classes/base.bbclass
> index bfc7087a189..b7869da3b38 100644
> --- a/meta/classes/base.bbclass
> +++ b/meta/classes/base.bbclass
> @@ -597,6 +597,12 @@ python () {
> 
>              exceptions = (d.getVar("INCOMPATIBLE_LICENSE_EXCEPTIONS") or "").split()
> 
> +            for lic_exception in exceptions:
> +                if ":" in lic_exception:
> +                    lic_exception.split(":")[0]
> +                if lic_exception in oe.license.obsolete_license_list():
> +                    bb.fatal("Invalid license %s used in INCOMPATIBLE_LICENSE_EXCEPTIONS" % lic_exception)
> +
>              pkgs = d.getVar('PACKAGES').split()
>              skipped_pkgs = {}
>              unskipped_pkgs = []
> diff --git a/meta/classes/insane.bbclass b/meta/classes/insane.bbclass
> index 29b9b3d466a..3c8d49f13bd 100644
> --- a/meta/classes/insane.bbclass
> +++ b/meta/classes/insane.bbclass
> @@ -27,7 +27,7 @@ WARN_QA ?= " libdir xorg-driver-abi \
>              mime mime-xdg unlisted-pkg-lics unhandled-features-check \
>              missing-update-alternatives native-last missing-ptest \
>              license-exists license-no-generic license-syntax license-format \
> -            license-incompatible license-file-missing \
> +            license-incompatible license-file-missing obsolete-license \
>              "
>  ERROR_QA ?= "dev-so debug-deps dev-deps debug-files arch pkgconfig la \
>              perms dep-cmp pkgvarcheck perm-config perm-line perm-link \
> @@ -909,14 +909,19 @@ def package_qa_check_unlisted_pkg_lics(package, d, messages):
>          return True
> 
>      recipe_lics_set = oe.license.list_licenses(d.getVar('LICENSE'))
> -    unlisted = oe.license.list_licenses(pkg_lics) - recipe_lics_set
> -    if not unlisted:
> -        return True
> -
> -    oe.qa.add_message(messages, "unlisted-pkg-lics",
> -                           "LICENSE:%s includes licenses (%s) that are not "
> -                           "listed in LICENSE" % (package, ' '.join(unlisted)))
> -    return False
> +    package_lics = oe.license.list_licenses(pkg_lics)
> +    unlisted = package_lics - recipe_lics_set
> +    if unlisted:
> +        oe.qa.add_message(messages, "unlisted-pkg-lics",
> +                               "LICENSE:%s includes licenses (%s) that are not "
> +                               "listed in LICENSE" % (package, ' '.join(unlisted)))
> +        return False
> +    obsolete = set(oe.license.obsolete_license_list()) & package_lics - recipe_lics_set
> +    if obsolete:
> +        oe.qa.add_message(messages, "obsolete-license",
> +                               "LICENSE:%s includes obsolete licenses %s" % (package, ' '.join(obsolete)))
> +        return False
> +    return True
> 
>  QAPKGTEST[empty-dirs] = "package_qa_check_empty_dirs"
>  def package_qa_check_empty_dirs(pkg, d, messages):
> @@ -1012,6 +1017,14 @@ python do_package_qa () {
> 
>      bb.note("DO PACKAGE QA")
> 
> +    main_lic = d.getVar('LICENSE')
> +
> +    # Check for obsolete license references in main LICENSE (packages are checked below for any changes)
> +    main_licenses = oe.license.list_licenses(d.getVar('LICENSE'))

The documentation for oe.license.list_licenses() says that it returns 
a list, but I assume that is not true or the code below would not work...

> +    obsolete = set(oe.license.obsolete_license_list()) & main_licenses
> +    if obsolete:
> +        oe.qa.handle_error("obsolete-license", "Recipe LICENSE includes obsolete licenses %s" % ' '.join(obsolete), d)
> +
>      bb.build.exec_func("read_subpackage_metadata", d)
> 
>      # Check non UTF-8 characters on recipe's metadata

//Peter



  reply	other threads:[~2022-03-02 15:17 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-01 23:42 [PATCH 1/4] mutlilib: Handle WHITELIST_GPL-3.0 being unset Richard Purdie
2022-03-01 23:42 ` [PATCH 2/4] base/license: Rework INCOMPATIBLE_LICENSE variable handling Richard Purdie
2022-03-01 23:42 ` [PATCH 3/4] license/insane: Show warning for obsolete license usage Richard Purdie
2022-03-02 15:17   ` Peter Kjellerstedt [this message]
2022-03-02 15:19     ` [OE-core] " Richard Purdie
2022-03-01 23:42 ` [PATCH 4/4] license: Rework INCOMPATIBLE_LICENSE wildcard handling Richard Purdie
2022-03-02 15:09   ` [OE-core] " Peter Kjellerstedt
2022-03-02 15:34     ` Richard Purdie

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=fd6a428f453c4675ae5fa17bb71615b7@axis.com \
    --to=peter.kjellerstedt@axis.com \
    --cc=openembedded-core@lists.openembedded.org \
    --cc=richard.purdie@linuxfoundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.