Bug 4396 - Some bb.error should be bb.warn
Summary: Some bb.error should be bb.warn
Status: VERIFIED FIXED
Alias: None
Product: OE-Core
Classification: Build System, Metadata & Runtime
Component: core (show other bugs)
Version: 1.5
Hardware: x86 Multiple
: Medium normal
Target Milestone: 1.5 M2
Assignee: Robert Yang
QA Contact:
URL:
Whiteboard:
: 4397 (view as bug list)
Depends on:
Blocks:
 
Reported: 2013-04-23 09:23 UTC by Robert Yang
Modified: 2013-09-05 07:27 UTC (History)
6 users (show)

See Also:
OS type for building Yocto: ---
Type of Regression: ---
Verified:
Documentation change: Don't know


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Robert Yang 2013-04-23 09:23:27 UTC
From the bitbake-devel mailing list:

Marcin Juszkiewicz wrote:
> There is one thing which kind of bothers me. "ERROR" message which is
> just a warning. Like:
>
> ERROR: libelf is listed in PACKAGES multiple times, this leads to packaging errors.
> ERROR: libasm is listed in PACKAGES multiple times, this leads to packaging errors.
> ERROR: libdw is listed in PACKAGES multiple times, this leads to packaging errors.
> ERROR: libdw-dev is listed in PACKAGES multiple times, this leads to packaging errors.
> ERROR: libasm-dev is listed in PACKAGES multiple times, this leads to packaging errors.
> ERROR: libelf-dev is listed in PACKAGES multiple times, this leads to packaging errors.
>
> If it is error then let BitBake exit instead of doing task. If it is
> not error but just a warning then let it be renamed?

RP's reply:

What we're trying to do is move everything to use a standard mechanism
for reporting issues of this type. With insane.bbclass, you can elect
whether a given type of error is a warning or errors and fails the task.

There are however several places where bb.error is used without that
mechanism. I'd love to see them fixed, please file a bug for it...
Comment 1 Saul Wold 2013-04-25 14:43:37 UTC
These use the QA_WARNING mechanism, which allows it to be selected if it's a warning or error which will correctly allow the build to continue or stop.
Comment 2 Saul Wold 2013-04-25 14:49:58 UTC
*** Bug 4397 has been marked as a duplicate of this bug. ***
Comment 3 Robert Yang 2013-05-08 06:08:34 UTC
Hi Saul / RP:

Here is the design, please help me to take a look at it since I'm not sure whether I have got the point:

Summary:
Use package_qa_handle_error() to replace bb.error() and bb.warn() in insane.bbclass in package.bbclass and insane.bbclass (will we do this for other bbclass?), the package_qa_handle_error() respects the WARN_QA and ERROR_QA well.

Steps:
Define a name for the bb.error() or bb.warn() message, add it to ERROR_QA or WARN_QA,e.g., we have the following code in insane.bbclass:


def package_qa_check_license(workdir, d): 
    [snip]
    if not lic_files:
        bb.error(pn + ": Recipe file does not have license file information (LIC_FILES_CHKSUM)")
        return False
    [snip]

We can change it to:

# Define this message to "license" and add it to ERROR_QA (since it's bb.error())
ERROR_QA += "license"

def package_qa_check_license(workdir, d): 
    [snip]
    if not lic_files:
        package_qa_handle_error ("license", pn + ": Recipe file does not have license file information (LIC_FILES_CHKSUM)", d)
    [snip]


This is similar to another case 3190
Comment 4 Richard Purdie 2013-05-08 09:14:37 UTC
The idea looks right and this should let us solve the simpler cases. 

In package.bbclass we might have an issue calling functions from insane.bbclass and we may need to move exceplictly agree that insane.bbclass is no longer optional and is becomes a requirement (always included). That shouldn't be a big issue, we just need to consciously decide it.
Comment 6 Yi Zhao 2013-09-05 07:27:30 UTC
Verified.

Test case:

Steps:
1. Add the following lines to a .bb file. For expample, gzip_1.6.bb:
PACKAGES += "${PN}-dbg"

2. Run "bitbake gzip"

3. Modify the meta-yocto/conf/distro/poky.conf. Move the "packages-list" from ERROR_QA to WARN_QA. Run "bitbake gzip" again.

Expected results:
In step 2, the build should failed and show the following error:
########################
ERROR: QA Issue: gzip-dbg is listed in PACKAGES multiple times, this leads to packaging errors.
ERROR: QA run found fatal errors. Please consider fixing them.
ERROR: Function failed: do_package_qa
ERROR: Logfile of failure stored in: /buildarea1/yzhao1/poky/build-test/tmp/work/i586-poky-linux/gzip/1.6-r0/temp/log.do_package.28207
ERROR: Task 10 (/buildarea1/yzhao1/poky/meta/recipes-extended/gzip/gzip_1.6.bb, do_package) failed with exit code '1'
NOTE: Tasks Summary: Attempted 734 tasks of which 733 didn't need to be rerun and 1 failed.
No currently running tasks (498 of 738)

Summary: 1 task failed:
  /buildarea1/yzhao1/poky/meta/recipes-extended/gzip/gzip_1.6.bb, do_package
Summary: There were 3 ERROR messages shown, returning a non-zero exit code.
##########################
Check the return value of the command,should be 1.
echo $?
1

In step 3, the build can finish but will show a warning message:
####################
WARNING: QA Issue: gzip-dbg is listed in PACKAGES multiple times, this leads to packaging errors.
NOTE: Tasks Summary: Attempted 738 tasks of which 577 didn't need to be rerun and all succeeded.

Summary: There was 1 WARNING message shown.
####################

Check the return value of the command,should be 0.
echo $?
0