scripts/COPY: create parent directories if they don't exist

This commit is contained in:
Albert Hopkins 2018-12-01 16:00:33 -08:00
parent e9fcd8939f
commit 37bbba582e
1 changed files with 5 additions and 0 deletions

View File

@ -9,6 +9,11 @@ def main():
chroot = os.environ["CHROOT"]
target = sys.argv[-1]
chroot_target = os.path.join(chroot, target.lstrip("/"))
chroot_target_dir = os.path.dirname(chroot_target)
if not os.path.exists(chroot_target_dir):
os.makedirs(chroot_target_dir)
command = ["cp"] + sys.argv[1:-1] + [chroot_target]
subprocess.check_call(command)