Skip to content
Open
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
3 changes: 1 addition & 2 deletions cerbero/bootstrap/android.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ def __init__(self, config, offline, assume_yes):
self.extract_steps.append((url, True, self.prefix))

def start(self):
if not os.path.exists(self.prefix):
os.makedirs(self.prefix)
os.makedirs(self.prefix, exist_ok = True)
ndkdir = os.path.join(self.prefix, 'android-ndk-' + NDK_VERSION)
if not os.path.isdir(ndkdir):
return
Expand Down
10 changes: 4 additions & 6 deletions cerbero/bootstrap/build_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,10 @@ def _setup_env(self):
config.binaries_local = self.config.binaries_local
config.binaries_remote = self.config.binaries_remote

if config.toolchain_prefix and not os.path.exists(config.toolchain_prefix):
os.makedirs(config.toolchain_prefix)
if not os.path.exists(config.prefix):
os.makedirs(config.prefix)
if not os.path.exists(config.sources):
os.makedirs(config.sources)
if config.toolchain_prefix:
os.makedirs(config.toolchain_prefix, exist_ok = True)
os.makedirs(config.prefix, exist_ok = True)
os.makedirs(config.sources, exist_ok = True)

config.do_setup_env()
self.cookbook = CookBook(config, offline=self.offline)
Expand Down
9 changes: 3 additions & 6 deletions cerbero/bootstrap/windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,10 @@ def start(self):
self.fix_mingw_unused()

def check_dirs(self):
if not os.path.exists(self.perl_prefix):
os.makedirs(self.perl_prefix)
if not os.path.exists(self.prefix):
os.makedirs(self.prefix)
os.makedirs(self.perl_prefix, exist_ok = True)
os.makedirs(self.prefix, exist_ok = True)
etc_path = os.path.join(self.config.prefix, 'etc')
if not os.path.exists(etc_path):
os.makedirs(etc_path)
os.makedirs(etc_path, exist_ok = True)

def fix_mingw(self):
if self.arch == Architecture.X86:
Expand Down
3 changes: 1 addition & 2 deletions cerbero/build/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,8 +394,7 @@ async def configure(self):
When called from a method in derived class, that method has to be
decorated with modify_environment decorator.
'''
if not os.path.exists(self.make_dir):
os.makedirs(self.make_dir)
os.makedirs(self.make_dir, exist_ok = True)
if self.requires_non_src_build:
self.config_sh = os.path.join('../', self.config_sh)

Expand Down
3 changes: 1 addition & 2 deletions cerbero/build/cookbook.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,8 +346,7 @@ def list_recipe_reverse_deps(self, recipe_name):
def save(self):
try:
cache_file = self._cache_file(self.get_config())
if not os.path.exists(os.path.dirname(cache_file)):
os.makedirs(os.path.dirname(cache_file))
os.makedirs(os.path.dirname(cache_file), exist_ok = True)
with open(cache_file, 'wb') as f:
pickle.dump(self.status, f)
except IOError as ex:
Expand Down
3 changes: 1 addition & 2 deletions cerbero/build/fridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,7 @@ def _ensure_ready(self, recipe):
self.binaries_local = os.path.join(self.config.binaries_local, self.env_checksum)
if not self.binaries_remote:
raise FatalError(_('Configuration without binaries remote'))
if not os.path.exists(self.binaries_local):
os.makedirs(self.binaries_local)
os.makedirs(self.binaries_local, exist_ok = True)
self.env_file = os.path.join(self.binaries_local, 'ENVIRONMENT')
if not os.path.exists(self.env_file):
with open(self.env_file, 'w') as f:
Expand Down
3 changes: 1 addition & 2 deletions cerbero/build/recipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -1005,6 +1005,5 @@ def not_in_prefix(src):

dest = os.path.join(self._config.prefix,
recipe.config.target_arch, f)
if not os.path.exists(os.path.dirname(dest)):
os.makedirs(os.path.dirname(dest))
os.makedirs(os.path.dirname(dest), exist_ok = True)
shutil.move(src, dest)
6 changes: 2 additions & 4 deletions cerbero/build/source.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,7 @@ async def fetch_impl(self, redownload=False):
self.verify()
m.action(_('Found %s at %s') % (self.url, self.download_path))
return
if not os.path.exists(self.download_dir):
os.makedirs(self.download_dir)
os.makedirs(self.download_dir, exist_ok = True)
# Enable certificate checking only on Linux for now
# FIXME: Add more platforms here after testing
cc = self.config.platform == Platform.LINUX and self.config.distro_version != DistroVersion.REDHAT_6
Expand Down Expand Up @@ -244,8 +243,7 @@ def __init__(self):
BaseTarball.__init__(self)

async def fetch_impl(self, redownload=False):
if not os.path.exists(self.download_dir):
os.makedirs(self.download_dir)
os.makedirs(self.download_dir, exist_ok = True)

cached_file = os.path.join(self.config.cached_sources,
self.package_name, self.tarball_name)
Expand Down
4 changes: 2 additions & 2 deletions cerbero/commands/genlibfiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ def run(self, config, args):
raise UsageError(_('%s command can only be used targetting '
'Windows platforms') % self.name)

if args.output_dir is not None and not os.path.exists(args.output_dir):
os.makedirs(args.output_dir)
if args.output_dir is not None:
os.makedirs(args.output_dir, exist_ok = True)

cookbook = CookBook(config)
recipes = cookbook.get_recipes_list()
Expand Down
3 changes: 1 addition & 2 deletions cerbero/commands/genvsprops.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ def run(self, config, args):
self.runargs(config, args.output_dir, args.prefix)

def runargs(self, config, output_dir, prefix=DEFAULT_PREFIX_MACRO):
if not os.path.exists(output_dir):
os.makedirs(output_dir)
os.makedirs(output_dir, exist_ok = True)

for pc in PkgConfig.list_all():
p2v = PkgConfig2VSProps(pc, prefix=config.prefix,
Expand Down
3 changes: 1 addition & 2 deletions cerbero/commands/genxcconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ def run(self, config, args):
self.runargs(config, args.output_dir, args.filename, args.libraries)

def runargs(self, config, output_dir, filename, libraries):
if not os.path.exists(output_dir):
os.makedirs(output_dir)
os.makedirs(output_dir, exist_ok = True)

if len(libraries) == 0:
raise UsageError("You need to specify at least one library name")
Expand Down
9 changes: 4 additions & 5 deletions cerbero/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -607,11 +607,10 @@ def _check_uninstalled(self):
self.uninstalled = int(os.environ.get(CERBERO_UNINSTALLED, 0)) == 1

def _create_path(self, path):
if not os.path.exists(path):
try:
os.makedirs(path)
except:
raise FatalError(_('directory (%s) can not be created') % path)
try:
os.makedirs(path, exist_ok = True)
except:
raise FatalError(_('directory (%s) can not be created') % path)

def _join_path(self, path1, path2):
if len(path1) == 0:
Expand Down
3 changes: 1 addition & 2 deletions cerbero/packages/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ def pack(self, output_dir, devel=True, force=False, keep_temp=False, split=True)
@rtype: list
'''
self.output_dir = os.path.realpath(output_dir)
if not os.path.exists(self.output_dir):
os.makedirs(self.output_dir)
os.makedirs(self.output_dir, exist_ok = True)
self.devel = devel
self.force = force
self.keep_temp = keep_temp
Expand Down
3 changes: 1 addition & 2 deletions cerbero/packages/disttarball.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,7 @@ def _create_tarball_stripped(self, output_dir, package_type, files, force,
orig_file = os.path.join(self.prefix, f)
tmp_file = os.path.join(tmpdir, f)
tmp_file_dir = os.path.dirname(tmp_file)
if not os.path.exists(tmp_file_dir):
os.makedirs(tmp_file_dir)
os.makedirs(tmp_file_dir, exist_ok = True)
shutil.copy(orig_file, tmp_file, follow_symlinks=False)
s.strip_file(tmp_file)

Expand Down
3 changes: 1 addition & 2 deletions cerbero/packages/osx/bundles.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,7 @@ def create_bundle(self, tmp=None):
macos = os.path.join(contents, 'MacOS')
resources = os.path.join(contents, 'Resources')
for p in [contents, macos, resources]:
if not os.path.exists(p):
os.makedirs(p)
os.makedirs(p, exist_ok = True)

# Create Contents/Info.plist
# Use the template if provided in the package
Expand Down
18 changes: 6 additions & 12 deletions cerbero/packages/osx/packager.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,7 @@ def _copy_versioned_headers(self, headers, include_dirs):
for p in os.listdir(inc_dir):
src = os.path.join(inc_dir, p)
dest = os.path.join(headers, p)
if not os.path.exists(os.path.dirname(dest)):
os.makedirs(os.path.dirname(dest))
os.makedirs(os.path.dirname(dest), exist_ok = True)
# include/cairo/cairo.h -> Headers/cairo.h
if os.path.isfile(src):
shutil.copy(src, dest)
Expand All @@ -94,8 +93,7 @@ def _copy_unversioned_headers(self, dirname, include, headers,
if os.path.isfile(path):
p = os.path.join(headers, rel_path)
d = os.path.dirname(p)
if not os.path.exists(d):
os.makedirs(d)
os.makedirs(d, exist_ok = True)
shutil.copy(path, p)
# scan sub-directories
elif os.path.isdir(path):
Expand Down Expand Up @@ -192,8 +190,7 @@ def _create_bundle(self, files, package_type):
continue
out_path = os.path.join(root, f)
out_dir = os.path.split(out_path)[0]
if not os.path.exists(out_dir):
os.makedirs(out_dir)
os.makedirs(out_dir, exist_ok = True)
shutil.copy(in_path, out_path, follow_symlinks=False)
if package_type == PackageType.DEVEL or not self.split:
self._create_framework_headers(self.config.prefix, self.include_dirs, root)
Expand Down Expand Up @@ -425,8 +422,7 @@ def _create_bundle(self):
continue
out_path = os.path.join(out_dir, f)
odir = os.path.split(out_path)[0]
if not os.path.exists(odir):
os.makedirs(odir)
os.makedirs(odir, exist_ok = True)
shutil.copy(in_path, out_path)

def _create_app_bundle(self):
Expand Down Expand Up @@ -558,8 +554,7 @@ def _copy_files(self, files, root):
for f in files:
out_path = f.replace(self.config.prefix, root)
out_dir = os.path.split(out_path)[0]
if not os.path.exists(out_dir):
os.makedirs(out_dir)
os.makedirs(out_dir, exist_ok = True)
shutil.copy(f, out_path)

def _copy_templates(self, files):
Expand All @@ -570,8 +565,7 @@ def _copy_templates(self, files):
os.path.join(self.tmp, 'Templates'))
out_path = out_path.replace(templates_prefix, '')
out_dir = os.path.split(out_path)[0]
if not os.path.exists(out_dir):
os.makedirs(out_dir)
os.makedirs(out_dir, exist_ok = True)
shutil.copy(f, out_path)

def _copy_headers(self, files, version_dir):
Expand Down
3 changes: 1 addition & 2 deletions cerbero/packages/wix_packager.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,7 @@ def _create_merge_module(self, package_type, keep_strip_temp_dir=False):
for f in files_list:
src = os.path.join(self.config.prefix, f)
dst = os.path.join(tmpdir, f)
if not os.path.exists(os.path.dirname(dst)):
os.makedirs(os.path.dirname(dst))
os.makedirs(os.path.dirname(dst), exist_ok = True)
shutil.copy(src, dst)

if self.package.strip:
Expand Down
9 changes: 3 additions & 6 deletions cerbero/tools/osxuniversalgenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,7 @@ def do_merge(self, filepath, dirs):
elif action == 'link':
self._link(current_file, output_file, filepath)
elif action == 'merge':
if not os.path.exists(output_dir):
os.makedirs(output_dir)
os.makedirs(output_dir, exist_ok = True)
self.create_universal_file(output_file, full_filepaths, dirs)
elif action == 'skip':
pass #just pass
Expand Down Expand Up @@ -200,8 +199,7 @@ def parse_dirs(self, dirs, filters=None):
self.do_merge(current_file, dirs)

def _copy(self, src, dest):
if not os.path.exists(os.path.dirname(dest)):
os.makedirs(os.path.dirname(dest))
os.makedirs(os.path.dirname(dest), exist_ok = True)
shutil.copy(src, dest)

def _copy_and_replace_paths(self, src, dest, dirs):
Expand All @@ -212,8 +210,7 @@ def _copy_and_replace_paths(self, src, dest, dirs):
shell.replace(dest, replacements)

def _link(self, src, dest, filepath):
if not os.path.exists(os.path.dirname(dest)):
os.makedirs(os.path.dirname(dest))
os.makedirs(os.path.dirname(dest), exist_ok = True)
if os.path.lexists(dest):
return #link exists, skip it

Expand Down
3 changes: 1 addition & 2 deletions cerbero/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,8 +382,7 @@ def copy_files(origdir, destdir, files, extensions, target_platform):
for f in files:
f = f % extensions
install_dir = os.path.dirname(os.path.join(destdir, f))
if not os.path.exists(install_dir):
os.makedirs(install_dir)
os.makedirs(install_dir, exist_ok = True)
if destdir[1] == ':':
# windows path
relprefix = to_unixpath(destdir)[2:]
Expand Down
9 changes: 3 additions & 6 deletions cerbero/utils/shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,8 +328,7 @@ async def unpack(filepath, output_dir, logfile=None):
# can't use tar on Windows because MSYS tar is ancient and buggy.
if filepath.endswith(TARBALL_SUFFIXES):
if PLATFORM != Platform.WINDOWS:
if not os.path.exists(output_dir):
os.makedirs(output_dir)
os.makedirs(output_dir, exist_ok = True)
await async_call(['tar', '-C', output_dir, '-xf', filepath])
else:
cmode = 'bz2' if filepath.endswith('bz2') else filepath[-2:]
Expand Down Expand Up @@ -461,8 +460,7 @@ async def download(url, destination=None, check_cert=True, overwrite=False, logf
logging.info("File %s already downloaded." % destination)
return
else:
if not os.path.exists(os.path.dirname(destination)):
os.makedirs(os.path.dirname(destination))
os.makedirs(os.path.dirname(destination), exist_ok = True)
log("Downloading {}".format(url), logfile)

urls = [url]
Expand Down Expand Up @@ -629,8 +627,7 @@ def copy_dir(src, dest, exclude_dirs=[]):
continue
s = os.path.join(src, path)
d = os.path.join(dest, path)
if not os.path.exists(os.path.dirname(d)):
os.makedirs(os.path.dirname(d))
os.makedirs(os.path.dirname(d), exist_ok = True)
if os.path.isfile(s):
shutil.copy(s, d)
elif os.path.isdir(s):
Expand Down
8 changes: 4 additions & 4 deletions config/android.config
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,10 @@ if 'universal' in variants:
else:
incl_dir = os.path.join(prefix, 'include')
lib_dir = os.path.join(prefix, 'lib')
if target_arch != Architecture.UNIVERSAL and not os.path.exists(incl_dir):
os.makedirs(incl_dir)
if target_arch != Architecture.UNIVERSAL and not os.path.exists(lib_dir):
os.makedirs(lib_dir)
if target_arch != Architecture.UNIVERSAL:
os.makedirs(incl_dir, exist_ok = True)
if target_arch != Architecture.UNIVERSAL:
os.makedirs(lib_dir, exist_ok = True)

# Most of the compiler/linker specific flags are taken from
# from android-ndk-r16/build/core/toolchains/$NAME-$VERSION/setup.mk
Expand Down
3 changes: 1 addition & 2 deletions config/darwin.config
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ arch_cflags += ' -Wno-error=format-nonliteral '


incl_dir = os.path.join(prefix, 'include')
if not os.path.exists(incl_dir):
os.makedirs(incl_dir)
os.makedirs(incl_dir, exist_ok = True)

# Append to these flags if not already present
for f in ['CFLAGS', 'CCASFLAGS', 'CXXFLAGS', 'OBJCFLAGS']:
Expand Down
3 changes: 1 addition & 2 deletions recipes/build-tools/gas-preprocessor.recipe
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ class Recipe(recipe.Recipe):
commit = 'f8a2d8c155bda8d925a7ee2ed8315c553a2b865f'

def install(self):
if not os.path.exists(os.path.join(self.config.prefix, 'bin')):
os.makedirs(os.path.join(self.config.prefix, 'bin'))
os.makedirs(os.path.join(self.config.prefix, 'bin'), exist_ok = True)
shutil.copy (os.path.join(self.build_dir, 'gas-preprocessor.pl'),
os.path.join(self.config.prefix, 'bin'))
shell.call ('chmod +x %s' %
Expand Down
9 changes: 3 additions & 6 deletions recipes/build-tools/gtk-doc-lite.recipe
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,11 @@ class Recipe(recipe.Recipe):
from cerbero.utils import shell
import shutil
aclocal_dir = os.path.join(self.config.prefix, 'share', 'aclocal')
if not os.path.exists(aclocal_dir):
os.makedirs(aclocal_dir)
os.makedirs(aclocal_dir, exist_ok = True)
data_dir = os.path.join(self.config.prefix, 'share', 'gtk-doc', 'data')
if not os.path.exists(data_dir):
os.makedirs(data_dir)
os.makedirs(data_dir, exist_ok = True)
bin_dir = os.path.join(self.config.prefix, 'bin')
if not os.path.exists(bin_dir):
os.makedirs(bin_dir)
os.makedirs(bin_dir, exist_ok = True)
autotools_dir = os.path.join(self.build_dir, 'buildsystems/autotools')
shutil.copy(os.path.join(autotools_dir, 'gtk-doc.m4'),
os.path.join(aclocal_dir, 'gtk-doc.m4'))
Expand Down
3 changes: 1 addition & 2 deletions recipes/build-tools/vala-m4.recipe
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ class Recipe(recipe.Recipe):
os.path.join(self.config.prefix, 'share',
'aclocal', 'vala.m4'))
destdir = os.path.join(self.config.prefix, 'share', 'vala')
if not os.path.exists(destdir):
os.makedirs(destdir)
os.makedirs(destdir, exist_ok = True)
shutil.copy(os.path.join(self.build_dir, 'vapigen', 'Makefile.vapigen'),
os.path.join(destdir, 'Makefile.vapigen'))
3 changes: 1 addition & 2 deletions recipes/ca-certificates.recipe
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ class Recipe(recipe.Recipe):

def install(self):
dst_dir = os.path.join(self.config.prefix, 'etc', 'ssl', 'certs')
if not os.path.exists(dst_dir):
os.makedirs(dst_dir)
os.makedirs(dst_dir, exist_ok = True)
src_dir = os.path.join(self.config.recipes_dir, 'ca-certificates')
for f in self.files_etc:
fname = os.path.basename(f)
Expand Down
Loading