summaryrefslogtreecommitdiff
path: root/mesonbuild
diff options
context:
space:
mode:
authorTristan Partin <tristan@partin.io>2024-01-24 11:36:33 -0600
committerEli Schwartz <eschwartz93@gmail.com>2024-04-15 16:17:44 -0400
commit2d3954efac61d37bdcf5c27204163e60d2932290 (patch)
treea64de292bbcc4a282486ce79398c626dc1bf6571 /mesonbuild
parent886836a69bab1e0af8942d3f86171c462a802ff4 (diff)
downloadmeson-2d3954efac61d37bdcf5c27204163e60d2932290.tar.gz
Add bztar support to meson dist
Some projects, like Postgres, distribute code in this format.
Diffstat (limited to 'mesonbuild')
-rw-r--r--mesonbuild/mdist.py13
1 files changed, 10 insertions, 3 deletions
diff --git a/mesonbuild/mdist.py b/mesonbuild/mdist.py
index faaf1bfdd..1ae0f5916 100644
--- a/mesonbuild/mdist.py
+++ b/mesonbuild/mdist.py
@@ -33,9 +33,10 @@ if T.TYPE_CHECKING:
from ._typing import ImmutableListProtocol
from .mesonlib import ExecutableSerialisation
-archive_choices = ['gztar', 'xztar', 'zip']
+archive_choices = ['bztar', 'gztar', 'xztar', 'zip']
-archive_extension = {'gztar': '.tar.gz',
+archive_extension = {'bztar': '.tar.bz2',
+ 'gztar': '.tar.gz',
'xztar': '.tar.xz',
'zip': '.zip'}
@@ -47,7 +48,7 @@ def add_arguments(parser: argparse.ArgumentParser) -> None:
parser.add_argument('--allow-dirty', action='store_true',
help='Allow even when repository contains uncommitted changes.')
parser.add_argument('--formats', default='xztar',
- help='Comma separated list of archive types to create. Supports xztar (default), gztar, and zip.')
+ help='Comma separated list of archive types to create. Supports xztar (default), bztar, gztar, and zip.')
parser.add_argument('--include-subprojects', action='store_true',
help='Include source code of subprojects that have been used for the build.')
parser.add_argument('--no-tests', action='store_true',
@@ -230,6 +231,7 @@ class HgDist(Dist):
os.makedirs(self.dist_sub, exist_ok=True)
tarname = os.path.join(self.dist_sub, self.dist_name + '.tar')
xzname = tarname + '.xz'
+ bz2name = tarname + '.bz2'
gzname = tarname + '.gz'
zipname = os.path.join(self.dist_sub, self.dist_name + '.zip')
# Note that -X interprets relative paths using the current working
@@ -248,6 +250,11 @@ class HgDist(Dist):
with lzma.open(xzname, 'wb') as xf, open(tarname, 'rb') as tf:
shutil.copyfileobj(tf, xf)
output_names.append(xzname)
+ if 'bztar' in archives:
+ import bz2
+ with bz2.open(bz2name, 'wb') as bf, open(tarname, 'rb') as tf:
+ shutil.copyfileobj(tf, bf)
+ output_names.append(bz2name)
if 'gztar' in archives:
with gzip.open(gzname, 'wb') as zf, open(tarname, 'rb') as tf:
shutil.copyfileobj(tf, zf)