<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugzilla.yoctoproject.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.6"
          urlbase="https://bugzilla.yoctoproject.org/"
          
          maintainer="it-coreprojects-helpdesk@linuxfoundation.org"
>

    <bug>
          <bug_id>4391</bug_id>
          
          <creation_ts>2013-04-23 03:33:59 +0000</creation_ts>
          <short_desc>Remove the obsolote images</short_desc>
          <delta_ts>2013-06-05 05:31:48 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>7</classification_id>
          <classification>Build System, Metadata &amp; Runtime</classification>
          <product>OE-Core</product>
          <component>core</component>
          <version>1.5</version>
          <rep_platform>x86</rep_platform>
          <op_sys>Multiple</op_sys>
          <bug_status>VERIFIED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>Medium</priority>
          <bug_severity>enhancement</bug_severity>
          <target_milestone>1.5 M1</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Robert Yang">liezhi.yang</reporter>
          <assigned_to name="Robert Yang">liezhi.yang</assigned_to>
          <cc>ke.zou</cc>
    
    <cc>mark.hatle</cc>
    
    <cc>meta.mr.watcher</cc>
    
    <cc>meta.watcher</cc>
    
    <cc>richard.purdie</cc>
    
    <cc>sgw</cc>
          
          
          <cf_os>---</cf_os>
          <cf_regression_type>---</cf_regression_type>
          
          <cf_docchange>---</cf_docchange>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>32499</commentid>
    <comment_count>0</comment_count>
    <who name="Robert Yang">liezhi.yang</who>
    <bug_when>2013-04-23 03:33:59 +0000</bug_when>
    <thetext>There would be many obsolote images under the deploy/images if we build the project many times, e.g.:

1.5G core-image-sato-sdk-qemumips-20130308094505.rootfs.ext3
248M core-image-sato-sdk-qemumips-20130308094505.rootfs.tar.bz2
1.5G core-image-sato-sdk-qemumips-20130320102143.rootfs.ext3
248M core-image-sato-sdk-qemumips-20130320102143.rootfs.tar.bz2
1.5G core-image-sato-sdk-qemumips-20130321070044.rootfs.ext3
248M core-image-sato-sdk-qemumips-20130321070044.rootfs.tar.bz2
1.5G core-image-sato-sdk-qemumips-20130322111701.rootfs.ext3
248M core-image-sato-sdk-qemumips-20130322111701.rootfs.tar.bz2
1.5G core-image-sato-sdk-qemumips-20130402095142.rootfs.ext3
248M core-image-sato-sdk-qemumips-20130402095142.rootfs.tar.bz2
1.5G core-image-sato-sdk-qemumips-20130402123337.rootfs.ext3
248M core-image-sato-sdk-qemumips-20130402123337.rootfs.tar.bz2

They would use much disk space when time goes on.

I think that we can add a configure variable to remove them, e.g.:
RM_OLD_IMAGE = &quot;1&quot; (defult &quot;0&quot;)

We have a symlink links to the previous current image, we can use &quot;read link -f symlink&quot; to remove the *old* image before we symlink the new image.

The affected files might be: (from a rough investigation)
bootimg.bbclass
image.bbclass
image_types.bbclass
image-vmdk.bbclass
boot-directdisk.bbclass</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>32636</commentid>
    <comment_count>1</comment_count>
    <who name="Saul Wold">sgw</who>
    <bug_when>2013-04-25 14:39:42 +0000</bug_when>
    <thetext>This should be part of the cleanup-workdir instead and not part of the bbclass files.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>32893</commentid>
    <comment_count>2</comment_count>
    <who name="Robert Yang">liezhi.yang</who>
    <bug_when>2013-05-06 14:12:47 +0000</bug_when>
    <thetext>(In reply to comment #1)
&gt; This should be part of the cleanup-workdir instead and not part of the
&gt; bbclass files.

Hi Saul, thanks for your suggestion, but it seems that it is easy to use and implement if we do it in image_types.bbclass, here is the draft patch:

diff --git a/meta-yocto/conf/local.conf.sample.extended b/meta-yocto/conf/local.conf.sample.extended
index d0dff80..a7979e1 100644
--- a/meta-yocto/conf/local.conf.sample.extended
+++ b/meta-yocto/conf/local.conf.sample.extended
@@ -211,3 +211,6 @@
 # Put the following two lines in the conf file with intact.
 #ARCHIVER_CLASS = &quot;${@&apos;archive-${ARCHIVER_MODE}-source&apos; if ARCHIVER_MODE != &apos;none&apos; else &apos;&apos;}&quot;
 #INHERIT += &quot;${ARCHIVER_CLASS}&quot;
+
+# Remove the obsolete image before the new one generated to save disk sapce
+#RM_OBSOLETE_IMAGE = &quot;1&quot;
diff --git a/meta/classes/image_types.bbclass b/meta/classes/image_types.bbclass
index 94837ae..27f232e 100644
--- a/meta/classes/image_types.bbclass
+++ b/meta/classes/image_types.bbclass
@@ -51,7 +51,11 @@ def get_imagecmds(d):
         types.remove(&quot;live&quot;)
 
     if d.getVar(&apos;IMAGE_LINK_NAME&apos;, True):
-        cmds += &quot;\trm -f ${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.*&quot;
+        if d.getVar(&apos;RM_OBSOLETE_IMAGE&apos;, True) == &quot;1&quot;:
+            # Remove the obsolete image
+            cmds += &quot;\trm -f `find ${DEPLOY_DIR_IMAGE} -maxdepth 1 -type l -name ${IMAGE_LINK_NAME}&apos;.*&apos; -exec readlink -f {} \;`&quot;
+        # Remove the symlink
+        cmds += &quot;\n\trm -f ${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.*&quot;
 
     for type in types:
         ccmd = []

If we do it in the cleanup-workdir script, we need consider which files should be kept when different archs and image recipes have been built, and we need to add an option for it to cleanup the DEPLOY_DIR_IMAGE directory rather than the work dir.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>32932</commentid>
    <comment_count>3</comment_count>
    <who name="Robert Yang">liezhi.yang</who>
    <bug_when>2013-05-08 01:57:52 +0000</bug_when>
    <thetext>Merged into master:
http://git.yoctoproject.org/cgit/cgit.cgi/poky/commit/?id=c51e8b4532361b11fe73c28613653c0f5aaf566b</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>32933</commentid>
    <comment_count>4</comment_count>
    <who name="Robert Yang">liezhi.yang</who>
    <bug_when>2013-05-08 02:04:40 +0000</bug_when>
    <thetext>No, not merged, it is in review.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>33178</commentid>
    <comment_count>5</comment_count>
    <who name="Robert Yang">liezhi.yang</who>
    <bug_when>2013-05-21 11:55:01 +0000</bug_when>
    <thetext>Merged into master:

http://git.yoctoproject.org/cgit/cgit.cgi/poky/commit/?id=0948a237ddfcd92dcc4a21e238a963568161f12d

http://git.yoctoproject.org/cgit/cgit.cgi/poky/commit/?id=995c196f98bf3a85e73f4981cfeeacfb5b84330e</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>33603</commentid>
    <comment_count>6</comment_count>
    <who name="Ke Zou">ke.zou</who>
    <bug_when>2013-06-05 05:31:48 +0000</bug_when>
    <thetext>verified in yocto 1.5 
master git rev: 676fd3f394a0c0576b63c77ed2184bf5f42c29b6

Test step:
1.build any type of image in poky
2.change ${POKY}/build/conf/local.conf
  add line:  RM_OLD_IMAGE = 1
3.re-build image again
4.Last build in ${POKY}/build/tmp/deploy/images/  should be deleted</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>