Bug 1561

Summary: Enable cleanup of WORKDIR
Product: [Build System, Metadata & Runtime] Meta-yocto Reporter: Richard Purdie <richard.purdie>
Component: meta-yoctoAssignee: Kai Kang <kai.kang>
Status: VERIFIED FIXED QA Contact:
Severity: enhancement    
Priority: Low CC: jessica.zhang, liang.li2, poky.bs.watcher, poky.watcher, sgw, yi.zhao, zhenfeng.zhao
Version: unspecified   
Target Milestone: 1.2 M4   
Hardware: x86   
OS: Multiple   
Whiteboard: (P3)(QA testing completed) Done
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: ---

Description Richard Purdie 2011-10-03 07:13:38 UTC
Currently, old versions of recipes can be left lying around the in WORKDIR. We could have a script that could go through and prune out old versions.
Comment 1 Kai Kang 2012-02-13 17:57:53 UTC
      Rough design document for cleanup of WORKDIR

* Purpose

This feature is from Yocto 1.2 Bug 1651.
Currently, old versions of recipes can be left lying around the in WORKDIR. We
could have a script that could go through and prune out old versions.

Name it with bitbake-cleanworkdir, implent with python and put it into directory bitbake/bin

* Usage:
bitbake-cleanworkdir [package-name]

* Design Flow
1 parse the argument. If the package name is provides, just clean the package's
  old build directory; otherwise clean all packages' the old build directory
2 Just like bitbake-runtask, construct a bitbake cooker then get current version(s)
  of giving package or every package, similar with 'bitbake -s'
3 walk the WORKDIR and clean the old version directory
Comment 2 Kai Kang 2012-03-02 09:01:41 UTC
Implement in another way by adding a option to bitbake, because the original design doesn't work
Comment 3 Richard Purdie 2012-03-02 12:23:17 UTC
Please try and do this by calling into bitbake and obtaining the appropriate information from an external script rather than patch bitbake itself.

If you have to patch bitbake itself, that means teaching bitbake "internal" knowledge about the metadata layout and breaks our APIs. Such a patch is likely not going to be acceptable (bitbake knows nothing directly about WORKDIR, nor should it).
Comment 4 Kai Kang 2012-03-05 02:32:20 UTC
(In reply to comment #3)
> Please try and do this by calling into bitbake and obtaining the appropriate
> information from an external script rather than patch bitbake itself.
> 
> If you have to patch bitbake itself, that means teaching bitbake "internal"
> knowledge about the metadata layout and breaks our APIs. Such a patch is likely
> not going to be acceptable (bitbake knows nothing directly about WORKDIR, nor
> should it).

OK. I'll try to send another patch.
Comment 5 Kai Kang 2012-03-06 07:30:23 UTC
Sent the patch as external script for review.
Comment 6 Kai Kang 2012-03-22 02:04:36 UTC
Patch is merged
Comment 7 liang li 2012-03-22 04:10:07 UTC
verified on :
git info:047ce547edd61b0d3b15c22b3492f7595ce2bc66
git branch:master

test env:
host os: ubuntu 11.10 x86_64
kernel : 
3.0.0-16-generic #29-Ubuntu SMP

test steps below:
1. set build env,run "soruce ./oe-init-build-env builddir".
2. In builddir,run "bitbake gzip" (MACHINE ?= "mpc8315e-rdb" in local.conf).
3. In builddir,run "bitbake -b path_to_git/meta/recipes-extended/gzip/gzip_1.3.12.bb".
4. run "path_to_git/scripts/cleanup-workdir".

results below:

output from screen :
Updating bitbake caches...
......
Deleleting path_to_git/tmp/work/powerpc-poky-linux/gzip-1.3.12-r0
......
Total 80 items.

only "gzip-1.4-r1" dir exists in tmp/work/powerpc-poky-linux after step 4,which is the version currently used by bitbake.