virtual-appliance/scripts/COPY
Albert Hopkins 3eece1b6ed scripts/COPY: don't use check_call
subprocess.check_call() raises an execption and produces an ugly Python
traceback on the console.  It's not really needed.  The cp command and
Makefile already give error output.  Instead we call sys.exit() with the
exit status of the cp command.
2018-12-02 11:53:35 -08:00

24 lines
528 B
Python
Executable File

#!/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]
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()