@@ -43,7 +43,8 @@ class DebError(Exception):
4343 pass
4444
4545 def __init__ (self , output , directory , compression , compressor , create_parents ,
46- allow_dups_from_deps , default_mtime , compression_level ):
46+ allow_dups_from_deps , default_mtime , compression_level ,
47+ tar_format = None ):
4748 # Directory prefix on all output paths
4849 d = directory .strip ('/' )
4950 self .directory = (d + '/' ) if d else None
@@ -54,6 +55,7 @@ def __init__(self, output, directory, compression, compressor, create_parents,
5455 self .create_parents = create_parents
5556 self .allow_dups_from_deps = allow_dups_from_deps
5657 self .compression_level = compression_level
58+ self .tar_format = tar_format
5759
5860 def __enter__ (self ):
5961 self .tarfile = tar_writer .TarFileWriter (
@@ -63,7 +65,8 @@ def __enter__(self):
6365 self .create_parents ,
6466 self .allow_dups_from_deps ,
6567 default_mtime = self .default_mtime ,
66- compression_level = self .compression_level )
68+ compression_level = self .compression_level ,
69+ format = self .tar_format )
6770 return self
6871
6972 def __exit__ (self , t , v , traceback ):
@@ -375,7 +378,9 @@ def main():
375378 compression .add_argument ('--compressor' ,
376379 help = 'Compressor program and arguments, '
377380 'e.g. `pigz -p 4`' )
378-
381+ parser .add_argument (
382+ '--format' , default = 'DEFAULT' , choices = ('DEFAULT' , 'USTAR' , 'GNU' , 'PAX' ),
383+ help = 'Specify the tar format to use: USTAR, GNU, PAX (default)' )
379384 parser .add_argument (
380385 '--modes' , action = 'append' ,
381386 help = 'Specific mode to apply to specific file (from the file argument),'
@@ -449,6 +454,15 @@ def main():
449454 f = f [1 :]
450455 ids_map [f ] = (int (user ), int (group ))
451456
457+ if options .format == 'DEFAULT' :
458+ tar_format = tarfile .DEFAULT_FORMAT
459+ elif options .format == 'USTAR' :
460+ tar_format = tarfile .USTAR_FORMAT
461+ elif options .format == 'GNU' :
462+ tar_format = tarfile .GNU_FORMAT
463+ elif options .format == 'PAX' :
464+ tar_format = tarfile .PAX_FORMAT
465+
452466 default_mtime = options .mtime
453467 if options .stamp_from :
454468 default_mtime = build_info .get_timestamp (options .stamp_from )
@@ -466,7 +480,8 @@ def main():
466480 default_mtime = default_mtime ,
467481 create_parents = options .create_parents ,
468482 allow_dups_from_deps = options .allow_dups_from_deps ,
469- compression_level = compression_level ) as output :
483+ compression_level = compression_level ,
484+ tar_format = tar_format ) as output :
470485
471486 def file_attributes (filename ):
472487 if filename .startswith ('/' ):
0 commit comments