pmb.helpers.mount: bind_file: Add create_folders option (!1861)
Create the necessary directory structure if create_folders=True.
This commit is contained in:
parent
f43d552039
commit
81d9bfe3ba
|
@ -66,7 +66,7 @@ def bind(args, source, destination, create_folders=True, umount=False):
|
||||||
raise RuntimeError("Mount failed: " + source + " -> " + destination)
|
raise RuntimeError("Mount failed: " + source + " -> " + destination)
|
||||||
|
|
||||||
|
|
||||||
def bind_file(args, source, destination):
|
def bind_file(args, source, destination, create_folders=False):
|
||||||
"""
|
"""
|
||||||
Mount a file with the --bind option, and create the destination file,
|
Mount a file with the --bind option, and create the destination file,
|
||||||
if necessary.
|
if necessary.
|
||||||
|
@ -77,6 +77,11 @@ def bind_file(args, source, destination):
|
||||||
|
|
||||||
# Create empty file
|
# Create empty file
|
||||||
if not os.path.exists(destination):
|
if not os.path.exists(destination):
|
||||||
|
if create_folders:
|
||||||
|
dir = os.path.dirname(destination)
|
||||||
|
if not os.path.isdir(dir):
|
||||||
|
pmb.helpers.run.root(args, ["mkdir", "-p", dir])
|
||||||
|
|
||||||
pmb.helpers.run.root(args, ["touch", destination])
|
pmb.helpers.run.root(args, ["touch", destination])
|
||||||
|
|
||||||
# Mount
|
# Mount
|
||||||
|
|
Loading…
Reference in New Issue