Skip to content
This repository was archived by the owner on May 23, 2024. It is now read-only.

Fix tarball creation, for real :) #12

Merged
merged 4 commits into from
Apr 8, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 3 additions & 32 deletions bob/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,39 +45,10 @@ def pipe(a, b, indent=True):

def archive_tree(dir, archive):
"""Creates a tar.gz archive from a given directory."""

abspath = os.path.abspath(dir)
base_root = None
is_top_level = False

with tarfile.open(archive, 'w:gz') as tar:

for root, _, files in os.walk(abspath):

# Mark the first pass as the top-level directory.
if is_top_level is None:
is_top_level = True

if not base_root:
base_root = root

transposed_base = root[len(base_root)+1:]

for file in files:

standard_path = os.path.join(root, file)

if is_top_level:
transposed_path = file
else:
transposed_path = os.path.join(transposed_base, file)

# Add the file to the archive, with the proper transposed path.
tar.add(standard_path, arcname=transposed_path)

# Close out the top-level directory marker.
is_top_level = False

# do not tar.add(dir) with empty arcname, that will create a "/" entry and tar will complain when extracting
for item in os.listdir(dir):
tar.add(dir+"/"+item, arcname=item)

def extract_tree(archive, dir):
"""Extract tar.gz archive to a given directory."""
Expand Down
2 changes: 1 addition & 1 deletion setup.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

setup(
name='bob-builder',
version='0.0.5',
version='0.0.6',
install_requires=deps,
description='Binary Build Toolkit.',
# long_description='Meh.',/
Expand Down