summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJavier Jardón <jjardon@gnome.org>2016-05-04 17:45:12 +0100
committerJavier Jardón <jjardon@gnome.org>2017-02-09 10:53:03 +0000
commitbd8c38c0f8c9d1c1492bd8ff82afe624b6953cc7 (patch)
treead91783c71959a706d436b0c8cdac86041340ae6
parent78d135a75ea163fac257c536a58c30b90872a7f0 (diff)
downloadybd-jjardon/xz.tar.gz
ybd/utils.py: Remove make_deterministic_gztar_archive()jjardon/xz
We are using lzma compression now
-rw-r--r--ybd/utils.py37
1 files changed, 0 insertions, 37 deletions
diff --git a/ybd/utils.py b/ybd/utils.py
index 9d0cf1b..5d35af6 100644
--- a/ybd/utils.py
+++ b/ybd/utils.py
@@ -14,7 +14,6 @@
#
# =*= License: GPL-2 =*=
-import gzip
try:
import lzma
except ImportError:
@@ -314,42 +313,6 @@ def make_xztar_archive(base_name, root_dir):
add_directory_to_tarfile(f_tar, root_dir, '.')
-def make_deterministic_gztar_archive(base_name, root_dir, time=1321009871.0):
- '''Make a gzipped tar archive of contents of 'root_dir'.
-
- This function takes extra steps to ensure the output is deterministic,
- compared to shutil.make_archive(). First, it sorts the results of
- os.listdir() to ensure the ordering of the files in the archive is the
- same. Second, it sets a fixed timestamp and filename in the gzip header.
-
- As well as fixing https://bugs.python.org/issue24465, to make this function
- redundant we would need to patch shutil.make_archive() so we could manually
- set the timestamp and filename set in the gzip file header.
-
- '''
- # It's hard to implement this function by monkeypatching
- # shutil.make_archive() because of the way the tarfile module includes the
- # filename of the tarfile in the gzip header. So we have to reimplement
- # shutil.make_archive().
-
- def add_directory_to_tarfile(f_tar, dir_name, dir_arcname):
- for filename in sorted(os.listdir(dir_name)):
- name = os.path.join(dir_name, filename)
- arcname = os.path.join(dir_arcname, filename)
-
- f_tar.add(name=name, arcname=arcname, recursive=False)
-
- if os.path.isdir(name) and not os.path.islink(name):
- add_directory_to_tarfile(f_tar, name, arcname)
-
- with open(base_name + '.tar.gz', 'wb') as f:
- gzip_context = gzip.GzipFile(
- filename='', mode='wb', fileobj=f, mtime=time)
- with gzip_context as f_gzip:
- with tarfile.TarFile(mode='w', fileobj=f_gzip) as f_tar:
- add_directory_to_tarfile(f_tar, root_dir, '.')
-
-
def make_deterministic_tar_archive(base_name, root):
'''Make a tar archive of contents of 'root_dir'.