aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElliott Sales de Andrade <quantum.analyst@gmail.com>2017-06-09 05:22:40 -0400
committerElliott Sales de Andrade <quantum.analyst@gmail.com>2017-06-13 00:32:43 -0400
commit79d005364f8e6ee05cba4bb3c971caa36dd8b482 (patch)
tree64dfcc8cbc6c75d8d95c27733aa2f5fd2c380f9c
parent1aa1d0d9ad378aa89f5d593e9d9b5c0d4ce30610 (diff)
downloadmeson-79d005364f8e6ee05cba4bb3c971caa36dd8b482.zip
meson-79d005364f8e6ee05cba4bb3c971caa36dd8b482.tar.gz
meson-79d005364f8e6ee05cba4bb3c971caa36dd8b482.tar.bz2
Add Mercurial dist support.
-rw-r--r--docs/markdown/Release-notes-for-0.42.0.md5
-rw-r--r--mesonbuild/scripts/dist.py29
2 files changed, 29 insertions, 5 deletions
diff --git a/docs/markdown/Release-notes-for-0.42.0.md b/docs/markdown/Release-notes-for-0.42.0.md
index 5ea0d18..dcb86c3 100644
--- a/docs/markdown/Release-notes-for-0.42.0.md
+++ b/docs/markdown/Release-notes-for-0.42.0.md
@@ -7,4 +7,7 @@ short-description: Release notes for 0.42 (preliminary)
# New features
-Add features here as code is merged to master.
+## Distribution tarballs from Mercurial repositories
+
+Creating distribution tarballs can now be made out of projects based on
+Mercurial. As before, this remains possible only with the Ninja backend.
diff --git a/mesonbuild/scripts/dist.py b/mesonbuild/scripts/dist.py
index a8e163c..cb3bbe2 100644
--- a/mesonbuild/scripts/dist.py
+++ b/mesonbuild/scripts/dist.py
@@ -13,6 +13,7 @@
# limitations under the License.
+import lzma
import os
import shutil
import subprocess
@@ -71,7 +72,8 @@ def process_submodules(dirname):
continue
del_gitfiles(os.path.join(dirname, v))
-def create_dist(dist_name, src_root, bld_root, dist_sub):
+
+def create_dist_git(dist_name, src_root, bld_root, dist_sub):
distdir = os.path.join(dist_sub, dist_name)
if os.path.exists(distdir):
shutil.rmtree(distdir)
@@ -89,6 +91,22 @@ def create_dist(dist_name, src_root, bld_root, dist_sub):
shutil.rmtree(distdir)
return (xzname, )
+
+def create_dist_hg(dist_name, src_root, bld_root, dist_sub):
+ os.makedirs(dist_sub, exist_ok=True)
+
+ tarname = os.path.join(dist_sub, dist_name + '.tar')
+ xzname = tarname + '.xz'
+ subprocess.check_call(['hg', 'archive', '-R', src_root, '-S', '-t', 'tar', tarname])
+ with lzma.open(xzname, 'wb') as xf, open(tarname, 'rb') as tf:
+ shutil.copyfileobj(tf, xf)
+ os.unlink(tarname)
+ # Create only .tar.xz for now.
+ # zipname = os.path.join(dist_sub, dist_name + '.zip')
+ # subprocess.check_call(['hg', 'archive', '-R', src_root, '-S', '-t', 'zip', zipname])
+ return (xzname, )
+
+
def check_dist(packagename, meson_command):
print('Testing distribution package %s.' % packagename)
unpackdir = tempfile.mkdtemp()
@@ -133,10 +151,13 @@ def run(args):
dist_name = build.project_name + '-' + build.project_version
- if not os.path.isdir(os.path.join(src_root, '.git')):
- print('Dist currently only works with Git repos.')
+ if os.path.isdir(os.path.join(src_root, '.git')):
+ names = create_dist_git(dist_name, src_root, bld_root, dist_sub)
+ elif os.path.isdir(os.path.join(src_root, '.hg')):
+ names = create_dist_hg(dist_name, src_root, bld_root, dist_sub)
+ else:
+ print('Dist currently only works with Git or Mercurial repos.')
return 1
- names = create_dist(dist_name, src_root, bld_root, dist_sub)
if names is None:
return 1
error_count = 0