Patchwork [v3] sstate.bbclass: add option to use alternate compression in lieu of gzip

login
register
mail settings
Submitter Matthew McClintock
Date Dec. 7, 2011, 12:52 a.m.
Message ID <1323219149-17056-1-git-send-email-msm@freescale.com>
Download mbox | patch
Permalink /patch/16349/
State New
Headers show

Comments

Matthew McClintock - Dec. 7, 2011, 12:52 a.m.
The savings can be substantial. The resutls below are for a
core-image-minimal type image:

gzip:    1.1G	sstate-cache
xz       714M	sstate-cache

Signed-off-by: Matthew McClintock <msm@freescale.com>
---
v2: This one actually works!
v3:
 - Use --use-compress-program= option to tar so we can use any compression
   not just ones built into tar
 - Add ASSUME_PROVIDED for the compression program we are using, this way
   it won't effect the build and if you are using it - it's already
   going to be available on the host


 meta/classes/sstate.bbclass |   22 ++++++++++++++--------
 1 files changed, 14 insertions(+), 8 deletions(-)
McClintock Matthew-B29882 - Dec. 14, 2011, 12:52 a.m.
Ping!

On Tue, Dec 6, 2011 at 6:52 PM, Matthew McClintock <msm@freescale.com> wrote:
> The savings can be substantial. The resutls below are for a
> core-image-minimal type image:
>
> gzip:    1.1G   sstate-cache
> xz       714M   sstate-cache
>
> Signed-off-by: Matthew McClintock <msm@freescale.com>
> ---
> v2: This one actually works!
> v3:
>  - Use --use-compress-program= option to tar so we can use any compression
>   not just ones built into tar
>  - Add ASSUME_PROVIDED for the compression program we are using, this way
>   it won't effect the build and if you are using it - it's already
>   going to be available on the host
>
>
>  meta/classes/sstate.bbclass |   22 ++++++++++++++--------
>  1 files changed, 14 insertions(+), 8 deletions(-)
>
> diff --git a/meta/classes/sstate.bbclass b/meta/classes/sstate.bbclass
> index 3d259f0..a2d7b65 100644
> --- a/meta/classes/sstate.bbclass
> +++ b/meta/classes/sstate.bbclass
> @@ -18,6 +18,12 @@ SSTATE_MANMACH ?= "${SSTATE_PKGARCH}"
>
>  SSTATEPOSTINSTFUNCS ?= ""
>
> +SSTATE_PKG_SUFFIX ?= "tgz"
> +SSTATE_PKG_TARZIPPROG ?= "gzip"
> +# the tool used above for sstate-cache will always need to be used from the host
> +# so we can ASSUME_PROVIDED it
> +ASSUME_PROVIDED += "${SSTATE_PKG_TARZIPPROG}-native"
> +
>  python () {
>     if bb.data.inherits_class('native', d):
>         bb.data.setVar('SSTATE_PKGARCH', bb.data.getVar('BUILD_ARCH', d), d)
> @@ -155,7 +161,7 @@ def sstate_installpkg(ss, d):
>         oe.path.remove(dir)
>
>     sstateinst = bb.data.expand("${WORKDIR}/sstate-install-%s/" % ss['name'], d)
> -    sstatepkg = bb.data.getVar('SSTATE_PKG', d, True) + '_' + ss['name'] + ".tgz"
> +    sstatepkg = bb.data.expand("${SSTATE_PKG}" + '_' + ss['name'] + ".${SSTATE_PKG_SUFFIX}", d)
>
>     if not os.path.exists(sstatepkg):
>        pstaging_fetch(sstatepkg, d)
> @@ -206,7 +212,7 @@ def sstate_clean_cachefile(ss, d):
>     import oe.path
>
>     sstatepkgdir = bb.data.getVar('SSTATE_DIR', d, True)
> -    sstatepkgfile = sstatepkgdir + '/' + bb.data.getVar('SSTATE_PKGSPEC', d, True) + "*_" + ss['name'] + ".tgz*"
> +    sstatepkgfile = bb.data.expand(sstatepkgdir + '/' + "${SSTATE_PKGSPEC}" + "*_" + ss['name'] + ".${SSTATE_PKG_SUFFIX}*", d)
>     bb.note("Removing %s" % sstatepkgfile)
>     oe.path.remove(sstatepkgfile)
>
> @@ -351,7 +357,7 @@ def sstate_package(ss, d):
>     tmpdir = bb.data.getVar('TMPDIR', d, True)
>
>     sstatebuild = bb.data.expand("${WORKDIR}/sstate-build-%s/" % ss['name'], d)
> -    sstatepkg = bb.data.getVar('SSTATE_PKG', d, True) + '_'+ ss['name'] + ".tgz"
> +    sstatepkg = bb.data.expand("${SSTATE_PKG}" + '_' + ss['name'] + ".${SSTATE_PKG_SUFFIX}", d)
>     bb.mkdirhier(sstatebuild)
>     bb.mkdirhier(os.path.dirname(sstatepkg))
>     for state in ss['dirs']:
> @@ -448,9 +454,9 @@ sstate_create_package () {
>        cd ${SSTATE_BUILDDIR}
>        # Need to handle empty directories
>        if [ "$(ls -A)" ]; then
> -               tar -czf ${SSTATE_PKG} *
> +               tar --use-compress-program=${SSTATE_PKG_TARZIPPROG} -cf ${SSTATE_PKG} *
>        else
> -               tar -cz --file=${SSTATE_PKG} --files-from=/dev/null
> +               tar --use-compress-program=${SSTATE_PKG_TARZIPPROG} -c --file=${SSTATE_PKG} --files-from=/dev/null
>        fi
>
>        cd ${WORKDIR}
> @@ -463,7 +469,7 @@ sstate_create_package () {
>  sstate_unpack_package () {
>        mkdir -p ${SSTATE_INSTDIR}
>        cd ${SSTATE_INSTDIR}
> -       tar -xvzf ${SSTATE_PKG}
> +       tar --use-compress-program=${SSTATE_PKG_TARZIPPROG} -xvf ${SSTATE_PKG}
>  }
>
>  BB_HASHCHECK_FUNCTION = "sstate_checkhashes"
> @@ -483,7 +489,7 @@ def sstate_checkhashes(sq_fn, sq_task, sq_hash, sq_hashfn, d):
>     }
>
>     for task in range(len(sq_fn)):
> -        sstatefile = bb.data.expand("${SSTATE_DIR}/" + sq_hashfn[task] + "_" + mapping[sq_task[task]] + ".tgz", d)
> +        sstatefile = bb.data.expand("${SSTATE_DIR}/" + sq_hashfn[task] + "_" + mapping[sq_task[task]] + ".${SSTATE_PKG_SUFFIX}", d)
>         sstatefile = sstatefile.replace("${BB_TASKHASH}", sq_hash[task])
>         if os.path.exists(sstatefile):
>             bb.debug(2, "SState: Found valid sstate file %s" % sstatefile)
> @@ -508,7 +514,7 @@ def sstate_checkhashes(sq_fn, sq_task, sq_hash, sq_hashfn, d):
>             if task in ret:
>                 continue
>
> -            sstatefile = bb.data.expand("${SSTATE_DIR}/" + sq_hashfn[task] + "_" + mapping[sq_task[task]] + ".tgz", d)
> +            sstatefile = bb.data.expand("${SSTATE_DIR}/" + sq_hashfn[task] + "_" + mapping[sq_task[task]] + ".${SSTATE_PKG_SUFFIX}", d)
>             sstatefile = sstatefile.replace("${BB_TASKHASH}", sq_hash[task])
>
>             srcuri = "file://" + os.path.basename(sstatefile)
> --
> 1.7.6.1
>
>
>
> _______________________________________________
> Openembedded-core mailing list
> Openembedded-core@lists.openembedded.org
> http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-core

Patch

diff --git a/meta/classes/sstate.bbclass b/meta/classes/sstate.bbclass
index 3d259f0..a2d7b65 100644
--- a/meta/classes/sstate.bbclass
+++ b/meta/classes/sstate.bbclass
@@ -18,6 +18,12 @@  SSTATE_MANMACH ?= "${SSTATE_PKGARCH}"
 
 SSTATEPOSTINSTFUNCS ?= ""
 
+SSTATE_PKG_SUFFIX ?= "tgz"
+SSTATE_PKG_TARZIPPROG ?= "gzip"
+# the tool used above for sstate-cache will always need to be used from the host
+# so we can ASSUME_PROVIDED it
+ASSUME_PROVIDED += "${SSTATE_PKG_TARZIPPROG}-native"
+
 python () {
     if bb.data.inherits_class('native', d):
         bb.data.setVar('SSTATE_PKGARCH', bb.data.getVar('BUILD_ARCH', d), d)
@@ -155,7 +161,7 @@  def sstate_installpkg(ss, d):
         oe.path.remove(dir)
 
     sstateinst = bb.data.expand("${WORKDIR}/sstate-install-%s/" % ss['name'], d)
-    sstatepkg = bb.data.getVar('SSTATE_PKG', d, True) + '_' + ss['name'] + ".tgz"
+    sstatepkg = bb.data.expand("${SSTATE_PKG}" + '_' + ss['name'] + ".${SSTATE_PKG_SUFFIX}", d)
 
     if not os.path.exists(sstatepkg):
        pstaging_fetch(sstatepkg, d)
@@ -206,7 +212,7 @@  def sstate_clean_cachefile(ss, d):
     import oe.path
 
     sstatepkgdir = bb.data.getVar('SSTATE_DIR', d, True)
-    sstatepkgfile = sstatepkgdir + '/' + bb.data.getVar('SSTATE_PKGSPEC', d, True) + "*_" + ss['name'] + ".tgz*"
+    sstatepkgfile = bb.data.expand(sstatepkgdir + '/' + "${SSTATE_PKGSPEC}" + "*_" + ss['name'] + ".${SSTATE_PKG_SUFFIX}*", d)
     bb.note("Removing %s" % sstatepkgfile)
     oe.path.remove(sstatepkgfile)
 
@@ -351,7 +357,7 @@  def sstate_package(ss, d):
     tmpdir = bb.data.getVar('TMPDIR', d, True)
 
     sstatebuild = bb.data.expand("${WORKDIR}/sstate-build-%s/" % ss['name'], d)
-    sstatepkg = bb.data.getVar('SSTATE_PKG', d, True) + '_'+ ss['name'] + ".tgz"
+    sstatepkg = bb.data.expand("${SSTATE_PKG}" + '_' + ss['name'] + ".${SSTATE_PKG_SUFFIX}", d)
     bb.mkdirhier(sstatebuild)
     bb.mkdirhier(os.path.dirname(sstatepkg))
     for state in ss['dirs']:
@@ -448,9 +454,9 @@  sstate_create_package () {
 	cd ${SSTATE_BUILDDIR}
 	# Need to handle empty directories
 	if [ "$(ls -A)" ]; then
-		tar -czf ${SSTATE_PKG} *
+		tar --use-compress-program=${SSTATE_PKG_TARZIPPROG} -cf ${SSTATE_PKG} *
 	else
-		tar -cz --file=${SSTATE_PKG} --files-from=/dev/null
+		tar --use-compress-program=${SSTATE_PKG_TARZIPPROG} -c --file=${SSTATE_PKG} --files-from=/dev/null
 	fi
 
 	cd ${WORKDIR}
@@ -463,7 +469,7 @@  sstate_create_package () {
 sstate_unpack_package () {
 	mkdir -p ${SSTATE_INSTDIR}
 	cd ${SSTATE_INSTDIR}
-	tar -xvzf ${SSTATE_PKG}
+	tar --use-compress-program=${SSTATE_PKG_TARZIPPROG} -xvf ${SSTATE_PKG}
 }
 
 BB_HASHCHECK_FUNCTION = "sstate_checkhashes"
@@ -483,7 +489,7 @@  def sstate_checkhashes(sq_fn, sq_task, sq_hash, sq_hashfn, d):
     }
 
     for task in range(len(sq_fn)):
-        sstatefile = bb.data.expand("${SSTATE_DIR}/" + sq_hashfn[task] + "_" + mapping[sq_task[task]] + ".tgz", d)
+        sstatefile = bb.data.expand("${SSTATE_DIR}/" + sq_hashfn[task] + "_" + mapping[sq_task[task]] + ".${SSTATE_PKG_SUFFIX}", d)
         sstatefile = sstatefile.replace("${BB_TASKHASH}", sq_hash[task])
         if os.path.exists(sstatefile):
             bb.debug(2, "SState: Found valid sstate file %s" % sstatefile)
@@ -508,7 +514,7 @@  def sstate_checkhashes(sq_fn, sq_task, sq_hash, sq_hashfn, d):
             if task in ret:
                 continue
 
-            sstatefile = bb.data.expand("${SSTATE_DIR}/" + sq_hashfn[task] + "_" + mapping[sq_task[task]] + ".tgz", d)
+            sstatefile = bb.data.expand("${SSTATE_DIR}/" + sq_hashfn[task] + "_" + mapping[sq_task[task]] + ".${SSTATE_PKG_SUFFIX}", d)
             sstatefile = sstatefile.replace("${BB_TASKHASH}", sq_hash[task])
 
             srcuri = "file://" + os.path.basename(sstatefile)