Bug 7128

Summary: net-tools do_patch failure after enabling multilib in an old build directory
Product: [Build System, Metadata & Runtime] OE-Core Reporter: Chen Qi <Qi.Chen>
Component: coreAssignee: Saul Wold <sgw>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: Medium CC: bluelightning, meta.mr.watcher, meta.watcher, richard.purdie
Version: 1.8   
Target Milestone: 1.8   
Hardware: x86   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: Don't know

Description Chen Qi 2015-01-09 08:35:05 UTC
Steps to reproduce the bug:
===========================
1. bitbake net-tools
2. add in local.conf:
   require conf/multilib.conf
   MULTILIBS = "multilib:lib32"
   DEFAULTTUNE_virtclass-multilib-lib32 = "x86"
3. bitbake net-tools

Error message:
===============
| Patch /buildarea2/chenqi/poky/build-systemd/tmp/work/core2-64-poky-linux/net-tools/1.60-25-r0/net-tools-1.60/debian/patches/fix-fprintf.patch is already applied; check your series file
| WARNING: exit code 1 from a shell command.
| DEBUG: Python function do_patch finished
| ERROR: Function failed: nettools_do_patch (log file is located at /buildarea2/chenqi/poky/build-systemd/tmp/work/core2-64-poky-linux/net-tools/1.60-25-r0/temp/log.do_patch.4014)
ERROR: Task 1 (/buildarea2/chenqi/poky/meta/recipes-extended/net-tools/net-tools_1.60-25.bb, do_patch) failed with exit code '1'

Simple analysis
===============
The error is caused by re-execution of do_patch task.
The re-execution of do_patch task due to the fact the the do_patch task of net-tools is customized as follows.

nettools_do_patch() {
        cd ${S}
        quilt pop -a || true
        if [ -d ${S}/.pc-nettools ]; then
                mv ${S}/.pc-nettools ${S}/.pc
                QUILT_PATCHES=${S}/debian/patches quilt pop -a
                rm -rf ${S}/.pc ${S}/debian
        fi
        patch -p1 < ${WORKDIR}/${BPN}_${PV}.diff
        QUILT_PATCHES=${S}/debian/patches quilt push -a
        mv ${S}/.pc ${S}/.pc-nettools
}

do_unpack[cleandirs] += "${S}"

# We invoke base do_patch at end, to incorporate any local patch                                                                                                                                                 
python do_patch() {
    bb.build.exec_func('nettools_do_patch', d)
    bb.build.exec_func('patch_do_patch', d)
}

As the nettools_do_patch is a shell function, it by defaults depends on all environment variable in bitbake build environment, including variables that do not affect the do_patch task like TUNE_ARCH.

Workaround
===========
bitbake nettools -c clean

Other information
=================
Normally, do_patch task should not re-executed in the above use case.
Only recipes that defines its own do_patch task which includes a customized shell function would re-execute the do_patch task.

//Chen Qi
Comment 1 Paul Eggleton 2015-01-30 18:24:56 UTC
Is this fixed by Richard's recent patch?

http://git.yoctoproject.org/cgit/cgit.cgi/poky/commit/?id=2b899a472a850c52f3f5228868d58cf2e6fac621
Comment 2 Saul Wold 2015-02-02 15:50:47 UTC
Paul is correct this above patch fixes this issue