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

login
register
mail settings
Submitter Matthew McClintock
Date Dec. 2, 2011, 5:24 p.m.
Message ID <1322846687-13057-1-git-send-email-msm@freescale.com>
Download mbox | patch
Permalink /patch/16115/
State New
Headers show

Comments

Matthew McClintock - Dec. 2, 2011, 5:24 p.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!

 meta/classes/sstate.bbclass |   19 +++++++++++--------
 1 files changed, 11 insertions(+), 8 deletions(-)
McClintock Matthew-B29882 - Dec. 6, 2011, 3:55 p.m.
On Fri, Dec 2, 2011 at 11:24 AM, Matthew McClintock <msm@freescale.com> wrote:
> -               tar -czf ${SSTATE_PKG} *
> +               tar -${SSTATE_PKG_TAROPT}cf ${SSTATE_PKG} *
>        else
> -               tar -cz --file=${SSTATE_PKG} --files-from=/dev/null
> +               tar -${SSTATE_PKG_TAROPT}c --file=${SSTATE_PKG} --files-from=/dev/null
>        fi
>
>        cd ${WORKDIR}
> @@ -463,7 +466,7 @@ sstate_create_package () {
>  sstate_unpack_package () {
>        mkdir -p ${SSTATE_INSTDIR}
>        cd ${SSTATE_INSTDIR}
> -       tar -xvzf ${SSTATE_PKG}
> +       tar -${SSTATE_PKG_TAROPT}xvf  ${SSTATE_PKG}

I'm going to respin this to look more like:

tar -cvf - | "$SSTATE_PKG_TARCOMPRESSION"

such that we don't depend on newer versions of tar for specific types
of compression.

-M

Patch

diff --git a/meta/classes/sstate.bbclass b/meta/classes/sstate.bbclass
index 3d259f0..e3a2a83 100644
--- a/meta/classes/sstate.bbclass
+++ b/meta/classes/sstate.bbclass
@@ -18,6 +18,9 @@  SSTATE_MANMACH ?= "${SSTATE_PKGARCH}"
 
 SSTATEPOSTINSTFUNCS ?= ""
 
+SSTATE_PKG_SUFFIX ?= "tgz"
+SSTATE_PKG_TAROPT ?= "z"
+
 python () {
     if bb.data.inherits_class('native', d):
         bb.data.setVar('SSTATE_PKGARCH', bb.data.getVar('BUILD_ARCH', d), d)
@@ -155,7 +158,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 +209,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 +354,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 +451,9 @@  sstate_create_package () {
 	cd ${SSTATE_BUILDDIR}
 	# Need to handle empty directories
 	if [ "$(ls -A)" ]; then
-		tar -czf ${SSTATE_PKG} *
+		tar -${SSTATE_PKG_TAROPT}cf ${SSTATE_PKG} *
 	else
-		tar -cz --file=${SSTATE_PKG} --files-from=/dev/null
+		tar -${SSTATE_PKG_TAROPT}c --file=${SSTATE_PKG} --files-from=/dev/null
 	fi
 
 	cd ${WORKDIR}
@@ -463,7 +466,7 @@  sstate_create_package () {
 sstate_unpack_package () {
 	mkdir -p ${SSTATE_INSTDIR}
 	cd ${SSTATE_INSTDIR}
-	tar -xvzf ${SSTATE_PKG}
+	tar -${SSTATE_PKG_TAROPT}xvf  ${SSTATE_PKG}
 }
 
 BB_HASHCHECK_FUNCTION = "sstate_checkhashes"
@@ -483,7 +486,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 +511,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)