virtual-appliance/scripts/COPY

24 lines
528 B
Plaintext
Raw Permalink Normal View History

#!/usr/bin/env python3
"""Copy files from source to target in the chroot"""
import os
import subprocess
import sys
def main():
chroot = os.environ["CHROOT"]
target = sys.argv[-1]
2018-10-27 20:15:59 +02:00
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]
sys.exit(subprocess.call(command))
if __name__ == "__main__":
main()