[PATCH] make dist: Create tar.xz with python3 and sign compressed tarballs
Andreas Schneider
asn at samba.org
Fri Dec 7 14:07:53 UTC 2018
Hi,
the attached patch will create tar.xz tarballs when waf is called with python3
and tar.gz with python2. python2 doesn't support xz tarballs.
Also the signature is created on the tar.xz file and not on the tar file.
-rw-r--r-- 1 asn users 18M Dec 7 15:02 samba-4.10.0pre1-
GIT-5b697db7560.tar.gz
-rw-r--r-- 1 asn users 833 Dec 7 15:02 samba-4.10.0pre1-
GIT-5b697db7560.tar.gz.asc
-rw-r--r-- 1 asn users 12M Dec 7 15:04 samba-4.10.0pre1-
GIT-5b697db7560.tar.xz
-rw-r--r-- 1 asn users 833 Dec 7 15:04 samba-4.10.0pre1-
GIT-5b697db7560.tar.xz.asc
As you can see, the tar.xz is 6MB smaller. I've used:
python3 buildtools/bin/waf dist --sign-release
Please review and push if OK.
Thanks,
Andreas
--
Andreas Schneider asn at samba.org
Samba Team www.samba.org
GPG-ID: 8DFF53E18F2ABC8D8F3C92237EE0FC4DCC014E3D
-------------- next part --------------
>From 5b697db75605957d36f528cdade1fb18bd53eaca Mon Sep 17 00:00:00 2001
From: Andreas Schneider <asn at samba.org>
Date: Tue, 27 Nov 2018 09:16:11 +0100
Subject: [PATCH] wafsamba: Create xz compressed tarballs with py3 and sign
them
This will create tar.gz with python2 and tar.xz files with python3. It
will also sign the compressed tarballs.
Signed-off-by: Andreas Schneider <asn at samba.org>
---
buildtools/wafsamba/samba_dist.py | 28 +++++++++-------------------
1 file changed, 9 insertions(+), 19 deletions(-)
diff --git a/buildtools/wafsamba/samba_dist.py b/buildtools/wafsamba/samba_dist.py
index 0568403aa44..040caa47d33 100644
--- a/buildtools/wafsamba/samba_dist.py
+++ b/buildtools/wafsamba/samba_dist.py
@@ -7,6 +7,8 @@ from waflib.Configure import conf
from samba_utils import os_path_relpath
from waflib import Context
+PY3 = sys.version_info[0] == 3
+
dist_dirs = None
dist_files = None
dist_blacklist = ""
@@ -97,7 +99,7 @@ def add_tarfile(tar, fname, abspath, basedir):
tinfo.gid = 0
tinfo.uname = 'root'
tinfo.gname = 'root'
- fh = open(abspath)
+ fh = open(abspath, 'rb')
tar.addfile(tinfo, fileobj=fh)
fh.close()
@@ -119,7 +121,7 @@ def vcs_dir_contents(path):
repo = os.path.dirname(repo)
if repo == "/":
raise Exception("unsupported or no vcs for %s" % path)
- return Utils.cmd_output(ls_files_cmd, cwd=cwd, env=env).split('\n')
+ return Utils.cmd_output(ls_files_cmd, cwd=cwd, env=env).decode('utf8').split('\n')
def dist(appname='', version=''):
@@ -179,9 +181,9 @@ def dist(appname='', version=''):
dist_base = '%s-%s' % (appname, version)
- if Options.options.SIGN_RELEASE:
- dist_name = '%s.tar' % (dist_base)
- tar = tarfile.open(dist_name, 'w')
+ if PY3:
+ dist_name = '%s.tar.xz' % (dist_base)
+ tar = tarfile.open(dist_name, 'w:xz')
else:
dist_name = '%s.tar.gz' % (dist_base)
tar = tarfile.open(dist_name, 'w:gz')
@@ -195,6 +197,7 @@ def dist(appname='', version=''):
else:
destdir = '.'
absdir = os.path.join(srcdir, dir)
+
try:
files = vcs_dir_contents(absdir)
except Exception as e:
@@ -224,7 +227,6 @@ def dist(appname='', version=''):
tar.close()
if Options.options.SIGN_RELEASE:
- import gzip
try:
os.unlink(dist_name + '.asc')
except OSError:
@@ -232,19 +234,7 @@ def dist(appname='', version=''):
cmd = "gpg --detach-sign --armor " + dist_name
os.system(cmd)
- uncompressed_tar = open(dist_name, 'rb')
- compressed_tar = gzip.open(dist_name + '.gz', 'wb')
- while 1:
- buffer = uncompressed_tar.read(1048576)
- if buffer:
- compressed_tar.write(buffer)
- else:
- break
- uncompressed_tar.close()
- compressed_tar.close()
- os.unlink(dist_name)
- Logs.info('Created %s.gz %s.asc' % (dist_name, dist_name))
- dist_name = dist_name + '.gz'
+ Logs.info('Created %s %s.asc' % (dist_name, dist_name))
else:
Logs.info('Created %s' % dist_name)
--
2.19.2
More information about the samba-technical
mailing list