Skip to content

Commit

Permalink
Merge pull request #163 from smcv/autocreate-dir-more
Browse files Browse the repository at this point in the history
build-runtime: Automatically create directory for --archive
  • Loading branch information
TTimo committed Mar 29, 2019
2 parents 077aeb6 + 20a9f77 commit 36e4ab1
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions build-runtime.py
Expand Up @@ -1212,13 +1212,6 @@ def normalize_tar_entry(entry):
])

if args.archive is not None:
if args.archive.endswith('/'):
try:
os.makedirs(args.archive, 0o755)
except OSError as e:
if e.errno != errno.EEXIST:
raise

ext = '.tar.' + args.compression

if args.compression == 'none':
Expand All @@ -1231,7 +1224,7 @@ def normalize_tar_entry(entry):
elif args.compression == 'bz2':
compressor_args = ['bzip2', '-c']

if os.path.isdir(args.archive):
if os.path.isdir(args.archive) or args.archive.endswith('/'):
archive_basename = name_version
archive_dir = args.archive
archive = os.path.join(archive_dir, archive_basename + ext)
Expand All @@ -1247,6 +1240,12 @@ def normalize_tar_entry(entry):
archive_dir = None
make_latest_symlink = False

try:
os.makedirs(os.path.dirname(archive) or '.', 0o755)
except OSError as e:
if e.errno != errno.EEXIST:
raise

print("Creating archive %s..." % archive)

with open(archive, 'wb') as archive_writer, waiting(subprocess.Popen(
Expand Down

0 comments on commit 36e4ab1

Please sign in to comment.