[elbe-devel] [PATCH 1/2] Use tar GNU-style options and auto compression mode

Daniel Braunwarth daniel at braunwarth.dev
Fri Jan 7 10:05:31 CET 2022


This patch migrates the tar options from UNIX-style to GNU-style.
This way we are more flexible passing options to the TarAchiver class.

This patch also enables the auto compression mode of tar.

Signed-off-by: Daniel Braunwarth <daniel at braunwarth.dev>
---
 elbepack/packers.py | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/elbepack/packers.py b/elbepack/packers.py
index bcf4ccde6..7cb876bbf 100644
--- a/elbepack/packers.py
+++ b/elbepack/packers.py
@@ -50,7 +50,7 @@ class TarArchiver(Packer):
             dirname = os.path.dirname(fpath)
             basename = os.path.basename(fpath)
             archname = fpath + self.suffix
-            do('tar cv%sf "%s" --sparse -C "%s" "%s"' %
+            do('tar --create --verbose --sparse %s --file "%s" --directory "%s" "%s"' %
                (self.flag, archname, dirname, basename))
             do('rm -f "%s"' % fpath)
         except CommandError:
@@ -68,8 +68,9 @@ class TarArchiver(Packer):
 
 packers = {'none': NoPacker(),
            'gzip': InPlacePacker('gzip -f', '.gz'),
-           'tar':  TarArchiver('', '.tar'),
-           'tarxz': TarArchiver('J', '.tar.xz'),
-           'targz': TarArchiver('z', '.tar.gz')}
+           'tar':  TarArchiver('--auto-compress', '.tar'),
+           'tarxz': TarArchiver('--auto-compress', '.tar.xz'),
+           'targz': TarArchiver('--auto-compress', '.tar.gz'),
+           }
 
 default_packer = packers['targz']
-- 
2.34.1



More information about the elbe-devel mailing list