From e1320a7a81ee4c3e54fd3d71c63a31d02c4b04b6 Mon Sep 17 00:00:00 2001 From: Andrew Hlynskyi Date: Wed, 26 Aug 2020 14:55:21 +0300 Subject: [PATCH 1/3] fix: take build_plan into account when computing hash --- package.py | 1 + 1 file changed, 1 insertion(+) diff --git a/package.py b/package.py index 2e19db7e..2cae89cd 100644 --- a/package.py +++ b/package.py @@ -1047,6 +1047,7 @@ def prepare_command(args): hash_extra_paths = [p.format(path=tf_paths) for p in hash_extra_paths] content_hash = bpm.hash(hash_extra_paths) + content_hash.update(json.dumps(build_plan, sort_keys=True).encode()) content_hash.update(runtime.encode()) content_hash.update(hash_extra.encode()) content_hash = content_hash.hexdigest() From 80d0926de2f11b15d6eb96fd5f34c95579eb9d1b Mon Sep 17 00:00:00 2001 From: Andrew Hlynskyi Date: Fri, 23 Oct 2020 11:18:37 +0300 Subject: [PATCH 2/3] Don't silently ignore content by symlinks TODO: Check symlink relativity to a content root and if it refers to outside and doesn't filtered then raise an error and abort packaging. --- package.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package.py b/package.py index 2cae89cd..6b5c4064 100644 --- a/package.py +++ b/package.py @@ -139,7 +139,7 @@ def list_files(top_path, log=None): results = [] - for root, dirs, files in os.walk(top_path): + for root, dirs, files in os.walk(top_path, followlinks=True): for file_name in files: file_path = os.path.join(root, file_name) relative_path = os.path.relpath(file_path, top_path) @@ -210,7 +210,7 @@ def yesno_bool(val): # Packaging functions def emit_dir_content(base_dir): - for root, dirs, files in os.walk(base_dir): + for root, dirs, files in os.walk(base_dir, followlinks=True): if root != base_dir: yield os.path.normpath(root) for name in files: @@ -595,7 +595,7 @@ def emit_file(fpath, opath): if apply(name): yield path else: - for root, dirs, files in os.walk(path): + for root, dirs, files in os.walk(path, followlinks=True): o, d = norm_path(path, root) # log.info('od: %s %s', o, d) if root != path: From 95b41be094eec1cb2e0e936f22ba4d9680752b91 Mon Sep 17 00:00:00 2001 From: Andrew Hlynskyi Date: Fri, 23 Oct 2020 11:35:26 +0300 Subject: [PATCH 3/3] fix: paths creation in case of concurrent builds, closes #64 --- package.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.py b/package.py index 6b5c4064..b99ca2cb 100644 --- a/package.py +++ b/package.py @@ -323,7 +323,7 @@ def _ensure_base_path(self, zip_filename): if archive_dir and not os.path.exists(archive_dir): self._log.info("creating %s", archive_dir) - os.makedirs(archive_dir) + os.makedirs(archive_dir, exist_ok=True) def write_dirs(self, *base_dirs, prefix=None, timestamp=None): """ @@ -1083,7 +1083,7 @@ def prepare_command(args): build_plan_filename = os.path.join(artifacts_dir, '{}.plan.json'.format(content_hash)) if not os.path.exists(artifacts_dir): - os.makedirs(artifacts_dir) + os.makedirs(artifacts_dir, exist_ok=True) with open(build_plan_filename, 'w') as f: f.write(build_plan)