diff --git a/src/rtems_proxy/copy.py b/src/rtems_proxy/copy.py index 19eb3ec..16be849 100644 --- a/src/rtems_proxy/copy.py +++ b/src/rtems_proxy/copy.py @@ -17,20 +17,23 @@ def copy_rtems(): root = GLOBALS.RTEMS_ROOT # root of the path that the RTEMS IOC expects to find the IOC files rtems_root = Path("/iocs") / GLOBALS.IOC_GROUP / GLOBALS.IOC_NAME - # the binary blob to load into the RTEMS IOC via TFTP - ioc_bin = (GLOBALS.IOC / "bin") / GLOBALS.EPICS_TARGET_ARCH / "ioc.boot" # where to copy the Generic IOC folder to (at present only holds the dbd folder) dest_ioc = root / "ioc" + # where to copy the generated runtime assets to (st.cmd and ioc.db) + dest_runtime = root / "runtime" - # because we are moving the ioc files we need to fix up startup script paths - startup = GLOBALS.RUNTIME / "st.cmd" - cmd_txt = startup.read_text() - cmd_txt = re.sub("/epics/", f"{str(rtems_root)}/", cmd_txt) - startup.write_text(cmd_txt) + # clean up previous IOC binaries + shutil.rmtree(dest_ioc, ignore_errors=True) + shutil.rmtree(dest_runtime, ignore_errors=True) # move all the files needed for runtime into the PVC that is being shared # over nfs/tftp by the nfsv2-tftp service Path.mkdir(dest_ioc, exist_ok=True) shutil.copytree(GLOBALS.IOC / "dbd", dest_ioc, symlinks=True, dirs_exist_ok=True) - shutil.copytree(GLOBALS.RUNTIME, root / "runtime", dirs_exist_ok=True) - shutil.copy(ioc_bin, root) + shutil.copytree(GLOBALS.RUNTIME, dest_runtime, dirs_exist_ok=True) + + # because we moved the ioc files we need to fix up startup script paths + startup = dest_runtime / "st.cmd" + cmd_txt = startup.read_text() + cmd_txt = re.sub("/epics/", f"{str(rtems_root)}/", cmd_txt) + startup.write_text(cmd_txt)