]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
testexport.bbclass: Create tarballs for easy release
authorMariano Lopez <mariano.lopez@linux.intel.com>
Mon, 6 Jun 2016 09:15:54 +0000 (09:15 +0000)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Mon, 6 Jun 2016 21:48:17 +0000 (22:48 +0100)
This create tarballs in the testexport directory in order
to make easier to distribute the test in another systems.

There are three tarballs, one for the metadata that is not
arch dependant, another for packages needed by the DUT
(this depends of target MACHINE), and the last one for the
SDK needed by the systems that perform the tests.

This also create only the tarballs that are needed.

[YOCTO #8481]

(From OE-Core rev: f8a0456e100b07a966cc24a78f197400c5a2ccab)

Signed-off-by: Mariano Lopez <mariano.lopez@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/classes/testexport.bbclass

index 6009349341ad03c584ddf71914829324784243e6..15fa470785c97c1e44c7299583eceef0cbf30812 100644 (file)
@@ -128,9 +128,13 @@ def exportTests(d,tc):
         for f in files:
             shutil.copy2(os.path.join(root, f), os.path.join(exportpath, "oeqa/runtime/files"))
 
+    # Create tar file for common parts of testexport
+    create_tarball(d, "testexport.tar.gz", d.getVar("TEST_EXPORT_DIR", True))
+
     # Copy packages needed for runtime testing
     export_pkg_dir = os.path.join(d.getVar("TEST_EXPORT_DIR", True), "packages")
     test_pkg_dir = d.getVar("TEST_NEEDED_PACKAGES_DIR", True)
+    need_pkg_dir = False
     for root, subdirs, files in os.walk(test_pkg_dir):
         for subdir in subdirs:
             tmp_dir = os.path.join(root.replace(test_pkg_dir, "").lstrip("/"), subdir)
@@ -138,10 +142,18 @@ def exportTests(d,tc):
             bb.utils.mkdirhier(new_dir)
 
         for f in files:
+            need_pkg_dir = True
             src_f = os.path.join(root, f)
             dst_f = os.path.join(export_pkg_dir, root.replace(test_pkg_dir, "").lstrip("/"), f)
             shutil.copy2(src_f, dst_f)
 
+    if need_pkg_dir:
+        # Create tar file for packages needed by the DUT
+        create_tarball(d, "testexport_packages_%s.tar.gz" % d.getVar("MACHINE", True), export_pkg_dir)
+    else:
+        # Remov packages dir from exported test
+        bb.utils.remove(export_pkg_dir, True)
+
     # Copy SDK
     if d.getVar("TEST_EXPORT_SDK_ENABLED", True) == "1":
         sdk_deploy = d.getVar("SDK_DEPLOY", True)
@@ -152,6 +164,9 @@ def exportTests(d,tc):
         bb.utils.mkdirhier(export_sdk_dir)
         shutil.copy2(tarball_path, export_sdk_dir)
 
+        # Create tar file for the sdk
+        create_tarball(d, "testexport_sdk_%s.tar.gz" % d.getVar("SDK_ARCH", True), export_sdk_dir)
+
     bb.plain("Exported tests to: %s" % exportpath)
 
 def testexport_main(d):
@@ -183,6 +198,23 @@ def testexport_main(d):
     tc.extract_packages()
     exportTests(d,tc)
 
+def create_tarball(d, tar_name, src_dir):
+
+    import tarfile
+
+    tar_path = os.path.join(d.getVar("TEST_EXPORT_DIR", True), tar_name)
+    current_dir = os.getcwd()
+    src_dir = src_dir.rstrip('/')
+    dir_name = os.path.dirname(src_dir)
+    base_name = os.path.basename(src_dir)
+
+    os.chdir(dir_name)
+    tar = tarfile.open(tar_path, "w:gz")
+    tar.add(base_name)
+    tar.close()
+    os.chdir(current_dir)
+
+
 testexport_main[vardepsexclude] =+ "BB_ORIGENV"
 
 inherit testimage