[rtems commit] build: Use Python tarfile instead of pax

Sebastian Huber sebh at rtems.org
Mon Sep 14 06:59:57 UTC 2020


Module:    rtems
Branch:    master
Commit:    aa27a85a83a4f05e77ed06825e24755f23f90eff
Changeset: http://git.rtems.org/rtems/commit/?id=aa27a85a83a4f05e77ed06825e24755f23f90eff

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Tue Aug 18 13:14:48 2020 +0200

build: Use Python tarfile instead of pax

This patch is for the new build system.

---

 spec/build/testsuites/libtests/dl01.yml   |  2 +-
 spec/build/testsuites/libtests/dl02.yml   |  2 +-
 spec/build/testsuites/libtests/dl04.yml   |  2 +-
 spec/build/testsuites/libtests/dl05.yml   |  2 +-
 spec/build/testsuites/libtests/dl06.yml   |  4 ++--
 spec/build/testsuites/libtests/dl07.yml   |  2 +-
 spec/build/testsuites/libtests/dl08.yml   |  2 +-
 spec/build/testsuites/libtests/dl09.yml   |  2 +-
 spec/build/testsuites/libtests/dl10.yml   |  2 +-
 spec/build/testsuites/libtests/grp.yml    |  2 --
 spec/build/testsuites/libtests/optpax.yml | 14 --------------
 wscript                                   | 27 ++++++++++++++-------------
 12 files changed, 24 insertions(+), 39 deletions(-)

diff --git a/spec/build/testsuites/libtests/dl01.yml b/spec/build/testsuites/libtests/dl01.yml
index 42e482b..49ff5a0 100644
--- a/spec/build/testsuites/libtests/dl01.yml
+++ b/spec/build/testsuites/libtests/dl01.yml
@@ -9,7 +9,7 @@ do-build: |
   objs = []
   objs.append(self.cc(bld, bic, path + "dl01-o1.c"))
   tar = path + "dl01.tar"
-  self.pax(bld, objs, [path], tar)
+  self.tar(bld, objs, [path], tar)
   tar_c, tar_h = self.bin2c(bld, tar)
   objs = []
   objs.append(self.cc(bld, bic, tar_c))
diff --git a/spec/build/testsuites/libtests/dl02.yml b/spec/build/testsuites/libtests/dl02.yml
index 83bc4d1..e6b1d0f 100644
--- a/spec/build/testsuites/libtests/dl02.yml
+++ b/spec/build/testsuites/libtests/dl02.yml
@@ -10,7 +10,7 @@ do-build: |
   objs.append(self.cc(bld, bic, path + "dl02-o1.c"))
   objs.append(self.cc(bld, bic, path + "dl02-o2.c"))
   tar = path + "dl02.tar"
-  self.pax(bld, objs, [path], tar)
+  self.tar(bld, objs, [path], tar)
   tar_c, tar_h = self.bin2c(bld, tar)
   objs = []
   objs.append(self.cc(bld, bic, tar_c))
diff --git a/spec/build/testsuites/libtests/dl04.yml b/spec/build/testsuites/libtests/dl04.yml
index 8957f9e..061c655 100644
--- a/spec/build/testsuites/libtests/dl04.yml
+++ b/spec/build/testsuites/libtests/dl04.yml
@@ -10,7 +10,7 @@ do-build: |
   objs = []
   objs.append(self.cxx(bld, bic, path + "dl04-o4.cc"))
   tar = path + "dl04.tar"
-  self.pax(bld, objs, [path], tar)
+  self.tar(bld, objs, [path], tar)
   tar_c, tar_h = self.bin2c(bld, tar)
   objs = []
   objs.append(self.cc(bld, bic, tar_c))
diff --git a/spec/build/testsuites/libtests/dl05.yml b/spec/build/testsuites/libtests/dl05.yml
index 3e049dc..67370cc 100644
--- a/spec/build/testsuites/libtests/dl05.yml
+++ b/spec/build/testsuites/libtests/dl05.yml
@@ -10,7 +10,7 @@ do-build: |
   objs = []
   objs.append(self.cxx(bld, bic, path + "dl05-o5.cc"))
   tar = path + "dl05.tar"
-  self.pax(bld, objs, [path], tar)
+  self.tar(bld, objs, [path], tar)
   tar_c, tar_h = self.bin2c(bld, tar)
   objs = []
   objs.append(self.cc(bld, bic, tar_c))
diff --git a/spec/build/testsuites/libtests/dl06.yml b/spec/build/testsuites/libtests/dl06.yml
index cd19712..2f5d4ab 100644
--- a/spec/build/testsuites/libtests/dl06.yml
+++ b/spec/build/testsuites/libtests/dl06.yml
@@ -7,7 +7,7 @@ cppflags: []
 do-build: |
   path = "testsuites/libtests/dl06/"
   pre_tar = path + "dl06-pre.tar"
-  self.pax(bld, path + "dl06_pre_file", [path], pre_tar)
+  self.tar(bld, path + "dl06_pre_file", [path], pre_tar)
   pre_tar_c, pre_tar_h = self.bin2c(bld, pre_tar, name="dl06_tar")
   objs = []
   objs.append(self.cc(bld, bic, pre_tar_c))
@@ -22,7 +22,7 @@ do-build: |
   dl06_rap = path + "dl06.rap"
   self.rtems_rap(bld, dl06_pre, objs, ["m"], dl06_rap)
   tar = path + "dl06.tar"
-  self.pax(bld, dl06_rap, [path], tar)
+  self.tar(bld, dl06_rap, [path], tar)
   tar_c, tar_h = self.bin2c(bld, tar)
   objs.append(self.cc(bld, bic, tar_c))
   objs.append(self.cc(bld, bic, path + "init.c", deps=[tar_h], cppflags=bld.env.TEST_DL06_CPPFLAGS))
diff --git a/spec/build/testsuites/libtests/dl07.yml b/spec/build/testsuites/libtests/dl07.yml
index 3641086..2fedef4 100644
--- a/spec/build/testsuites/libtests/dl07.yml
+++ b/spec/build/testsuites/libtests/dl07.yml
@@ -13,7 +13,7 @@ do-build: |
   objs.append(self.cc(bld, bic, path + "dl07-o4.c"))
   objs.append(self.cc(bld, bic, path + "dl07-o5.c"))
   tar = path + "dl07.tar"
-  self.pax(bld, objs, [path], tar)
+  self.tar(bld, objs, [path], tar)
   tar_c, tar_h = self.bin2c(bld, tar)
   objs = []
   objs.append(self.cc(bld, bic, tar_c))
diff --git a/spec/build/testsuites/libtests/dl08.yml b/spec/build/testsuites/libtests/dl08.yml
index 43a74e3..94f16fe 100644
--- a/spec/build/testsuites/libtests/dl08.yml
+++ b/spec/build/testsuites/libtests/dl08.yml
@@ -18,7 +18,7 @@ do-build: |
   objs.append(self.ar(bld, lib_objs, path + "libdl08_2.a"))
   objs.append(self.cc(bld, bic, path + "dl08-o1.c"))
   tar = path + "dl08.tar"
-  self.pax(bld, [path + "etc/libdl.conf"] + objs, [path], tar)
+  self.tar(bld, [path + "etc/libdl.conf"] + objs, [path], tar)
   tar_c, tar_h = self.bin2c(bld, tar)
   objs = []
   objs.append(self.cc(bld, bic, tar_c))
diff --git a/spec/build/testsuites/libtests/dl09.yml b/spec/build/testsuites/libtests/dl09.yml
index 8f9557e..7f9da4c 100644
--- a/spec/build/testsuites/libtests/dl09.yml
+++ b/spec/build/testsuites/libtests/dl09.yml
@@ -13,7 +13,7 @@ do-build: |
   objs.append(self.cc(bld, bic, path + "dl09-o4.c"))
   objs.append(self.cc(bld, bic, path + "dl09-o5.c"))
   tar = path + "dl09.tar"
-  self.pax(bld, objs, [path], tar)
+  self.tar(bld, objs, [path], tar)
   tar_c, tar_h = self.bin2c(bld, tar)
   objs = []
   objs.append(self.cc(bld, bic, tar_c))
diff --git a/spec/build/testsuites/libtests/dl10.yml b/spec/build/testsuites/libtests/dl10.yml
index ba09a6f..b3e4bc0 100644
--- a/spec/build/testsuites/libtests/dl10.yml
+++ b/spec/build/testsuites/libtests/dl10.yml
@@ -18,7 +18,7 @@ do-build: |
   objs.append(self.ar(bld, lib_objs, path + "libdl10_2.a"))
   objs.append(self.cc(bld, bic, path + "dl10-o1.c"))
   tar = path + "dl10.tar"
-  self.pax(bld, [path + "etc/libdl.conf"] + objs, [path], tar)
+  self.tar(bld, [path + "etc/libdl.conf"] + objs, [path], tar)
   tar_c, tar_h = self.bin2c(bld, tar)
   objs = []
   objs.append(self.cc(bld, bic, tar_c))
diff --git a/spec/build/testsuites/libtests/grp.yml b/spec/build/testsuites/libtests/grp.yml
index e6e0ce7..4889379 100644
--- a/spec/build/testsuites/libtests/grp.yml
+++ b/spec/build/testsuites/libtests/grp.yml
@@ -17,8 +17,6 @@ links:
 - role: build-dependency
   uid: optgzip
 - role: build-dependency
-  uid: optpax
-- role: build-dependency
   uid: optrtemsld
 - role: build-dependency
   uid: optrtemssyms
diff --git a/spec/build/testsuites/libtests/optpax.yml b/spec/build/testsuites/libtests/optpax.yml
deleted file mode 100644
index 097b602..0000000
--- a/spec/build/testsuites/libtests/optpax.yml
+++ /dev/null
@@ -1,14 +0,0 @@
-SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
-actions:
-- set-value: pax
-- find-program: null
-- env-assign: PAX
-build-type: option
-copyrights:
-- Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de)
-default: null
-default-by-variant: []
-description: ''
-enabled-by: true
-links: []
-type: build
diff --git a/wscript b/wscript
index 5463b1c..2e42918 100755
--- a/wscript
+++ b/wscript
@@ -405,22 +405,23 @@ class Item(object):
         bld(rule="${XZ} < ${SRC} > ${TGT}", source=source, target=target)
         return target
 
-    def pax(self, bld, source, remove, target):
+    def tar(self, bld, source, remove, target):
         def run(task):
+            import tarfile
+
+            tar = tarfile.TarFile(
+                task.outputs[0].abspath(), "w", format=tarfile.USTAR_FORMAT
+            )
             srcpath = bld.path.abspath() + "/"
             bldpath = bld.bldnode.abspath() + "/"
-            cmd = [bld.env.PAX[0], "-w", "-f", task.outputs[0].abspath()]
-            for r in remove:
-                cmd.extend(
-                    [
-                        "-s",
-                        "," + srcpath + r + ",,",
-                        "-s",
-                        "," + bldpath + r + ",,",
-                    ]
-                )
-            cmd.extend([i.abspath() for i in task.inputs])
-            return task.exec_command(cmd)
+            for src in task.inputs:
+                src = src.abspath()
+                dst = src
+                for r in remove:
+                    dst = src.replace(srcpath + r, "").replace(bldpath + r, "")
+                tar.add(src, dst)
+            tar.close()
+            return 0
 
         bld(rule=run, source=source, target=target)
         return target



More information about the vc mailing list