config: Create directories if we have write access
Also rename util.check_dir to util.ensure_dirs. BUG:FIXED:14000
This commit is contained in:
+1
-1
@@ -533,7 +533,7 @@ class ArchiveZip(ArchiveBase):
|
||||
continue
|
||||
|
||||
# check that output dir is present
|
||||
util.check_dir(os.path.dirname(ofile))
|
||||
util.ensure_dirs(os.path.dirname(ofile))
|
||||
|
||||
# remove output file we might be overwriting.
|
||||
# (also check for islink? for broken symlinks...)
|
||||
|
||||
+2
-1
@@ -90,7 +90,8 @@ class Config(object):
|
||||
|
||||
def subdir(self, path):
|
||||
subdir = pisi.util.join_path(self.dest_dir(), path)
|
||||
pisi.util.check_dir(subdir)
|
||||
if os.access(os.path.dirname(subdir), os.W_OK):
|
||||
pisi.util.ensure_dirs(subdir)
|
||||
return subdir
|
||||
|
||||
def log_dir(self):
|
||||
|
||||
+1
-2
@@ -118,8 +118,7 @@ class Fetcher:
|
||||
self.partial_file = self.archive_file + ctx.const.partial_suffix
|
||||
self.progress = None
|
||||
|
||||
util.check_dir(self.destdir)
|
||||
|
||||
util.ensure_dirs(self.destdir)
|
||||
|
||||
def fetch (self):
|
||||
"""Return value: Fetched file's full path.."""
|
||||
|
||||
@@ -105,6 +105,8 @@ class File:
|
||||
|
||||
assert isinstance(uri, pisi.uri.URI)
|
||||
|
||||
pisi.util.ensure_dirs(transfer_dir)
|
||||
|
||||
if sha1sum:
|
||||
sha1filename = File.download(pisi.uri.URI(uri.get_uri() + '.sha1sum'), transfer_dir)
|
||||
sha1f = file(sha1filename)
|
||||
|
||||
+2
-1
@@ -63,7 +63,8 @@ class Index(xmlfile.XmlFile):
|
||||
else:
|
||||
tmpdir = os.path.join(ctx.config.tmp_dir(), 'index')
|
||||
pisi.util.clean_dir(tmpdir)
|
||||
pisi.util.check_dir(tmpdir)
|
||||
|
||||
pisi.util.ensure_dirs(tmpdir)
|
||||
|
||||
# write uri
|
||||
urlfile = file(pisi.util.join_path(tmpdir, 'uri'), 'w')
|
||||
|
||||
+1
-1
@@ -189,7 +189,7 @@ class Package:
|
||||
"""Extract file with path to outdir"""
|
||||
data = self.impl.read_file(path)
|
||||
fpath = util.join_path(outdir, path)
|
||||
util.check_dir(os.path.dirname(fpath))
|
||||
util.ensure_dirs(os.path.dirname(fpath))
|
||||
|
||||
with open(fpath, "wb") as f:
|
||||
f.write(data)
|
||||
|
||||
+8
-11
@@ -343,13 +343,10 @@ def check_file(file, mode = os.F_OK):
|
||||
raise FileError("File " + file + " not found")
|
||||
return True
|
||||
|
||||
# FIXME: check_dir is not a good name considering it can also create the dir
|
||||
def check_dir(d):
|
||||
"""Make sure given directory path exists."""
|
||||
# FIXME: What is first strip doing there?
|
||||
d = d.strip().rstrip("/")
|
||||
if not os.access(d, os.F_OK):
|
||||
os.makedirs(d)
|
||||
def ensure_dirs(path):
|
||||
"""Make sure the given directory path exists."""
|
||||
if not os.path.exists(path):
|
||||
os.makedirs(path)
|
||||
|
||||
def clean_dir(path):
|
||||
"""Remove all content of a directory."""
|
||||
@@ -386,13 +383,13 @@ def dir_size(dir):
|
||||
def copy_file(src,dest):
|
||||
"""Copy source file to the destination file."""
|
||||
check_file(src)
|
||||
check_dir(os.path.dirname(dest))
|
||||
ensure_dirs(os.path.dirname(dest))
|
||||
shutil.copyfile(src, dest)
|
||||
|
||||
def copy_file_stat(src,dest):
|
||||
"""Copy source file to the destination file with all stat info."""
|
||||
check_file(src)
|
||||
check_dir(os.path.dirname(dest))
|
||||
ensure_dirs(os.path.dirname(dest))
|
||||
shutil.copy2(src, dest)
|
||||
|
||||
def read_link(link):
|
||||
@@ -615,7 +612,7 @@ def strip_file(filepath, fileinfo, outpath):
|
||||
|
||||
elif "SB executable" in fileinfo:
|
||||
if ctx.config.values.build.generatedebug:
|
||||
check_dir(os.path.dirname(outpath))
|
||||
ensure_dirs(os.path.dirname(outpath))
|
||||
save_elf_debug(filepath, outpath)
|
||||
run_strip(filepath)
|
||||
# FIXME: removing RPATH also causes problems, for details see gelistirici mailing list - caglar10ur
|
||||
@@ -624,7 +621,7 @@ def strip_file(filepath, fileinfo, outpath):
|
||||
|
||||
elif "SB shared object" in fileinfo:
|
||||
if ctx.config.values.build.generatedebug:
|
||||
check_dir(os.path.dirname(outpath))
|
||||
ensure_dirs(os.path.dirname(outpath))
|
||||
save_elf_debug(filepath, outpath)
|
||||
run_strip(filepath, "--strip-unneeded")
|
||||
# run_chrpath(filepath)
|
||||
|
||||
Reference in New Issue
Block a user