Files
ec-gn-ja-pcf/generate.sh
2026-02-09 10:59:18 +00:00

163 lines
4.9 KiB
Bash
Executable File

#!/bin/sh
if [[ $# > 0 ]]; then
mask=$1
fi
cid=1
project_name=EC-GN-JA-PCF
mkdir ${project_name}
current_dir=$(pwd)
################################################################################################################
#Section 1
#Update SVN
ok=$(echo ${mask} | cut -c ${cid})
if [[ ${ok} != "0" ]]; then
if [[ ! -d ${project_name}/.svn ]]; then
rm -rf ${project_name}
svn co https://svnpub.iter.org/codac/iter/codac/icdev/units/m-${project_name}/trunk/
mv trunk ${project_name}
fi
cd ${project_name}
svn up
status=$?
while [[ ${status} != 0 ]]; do
svn cleanup
svn up
status=$?
done
fi
cid=$((cid+1))
cd ${current_dir}
################################################################################################################
#Section 2
#Get PLC data from SVN
ok=$(echo ${mask} | cut -c ${cid})
#if [[ ${ok} != "0" ]]; then
# plc_proj_folder=src/main/resources/52HV05-PLC-7103
# export_folder=${plc_proj_folder}/export
# if [[ -d ${project_name}/${export_folder} ]]; then
# rm -rf ${project_name}-IN/${export_folder}
# cp -rf ${project_name}/${export_folder} ${project_name}-IN/${export_folder}
# fi
#fi
cid=$((cid+1))
cd ${current_dir}
################################################################################################################
#Section 3
#SDD(-cool) Generation
ok=$(echo ${mask} | cut -c ${cid})
if [[ ${ok} != "0" ]]; then
cp -rf ${project_name}/src/main/resources tmp_resources
rm -rf ${project_name}/*
cp -rf ${project_name}-IN/* ${project_name}/
cp -rf ${project_name}-IN/.[^.]* ${project_name}/
rm -rf tmp_resources/qst-gyrotron-fast-controller/Configurations
cp -rn tmp_resources/* ${project_name}/src/main/resources/
rm -rf tmp_resources
# /bin/cp -rf /opt/codac/marte2-extensions/templates ${project_name,,}-sdd-in/SDD_IN/
# /bin/cp -f templates/* ${project_name,,}-sdd-in/SDD_IN/templates
cd ${project_name,,}-sdd-in/SDD_IN
./sdd-generate.sh
rm -rf templates
fi
cid=$((cid+1))
cd ${current_dir}
################################################################################################################
#Section 4
#Post Patches
ok=$(echo ${mask} | cut -c ${cid})
if [[ ${ok} != "0" ]]; then
# cat patches/EC-GN-P01-PCF0CORE_sddPreDriverConf.patch ${project_name}/src/main/epics/iocBoot/iocEC-GN-P01-PCF0CORE/sddPreDriverConf.cmd > sddPreDriverConf_patched.cmd
# mv -f sddPreDriverConf_patched.cmd ${project_name}/src/main/epics/iocBoot/iocEC-GN-P01-PCF0CORE/sddPreDriverConf.cmd
cat patches/EC-GN-P01-PCF0CORE_userPreDriverConf.patch ${project_name}/src/main/epics/iocBoot/iocEC-GN-P01-PCF0CORE/userPreDriverConf.cmd > userPreDriverConf_patched.cmd
mv -f userPreDriverConf_patched.cmd ${project_name}/src/main/epics/iocBoot/iocEC-GN-P01-PCF0CORE/userPreDriverConf.cmd
# sed -i 's+# Add all the support libraries needed by this IOC+# Add all the support libraries needed by this IOC\n-include $(EPICS_ROOT)/mk/asyn.mk\n-include $(EPICS_ROOT)/mk/picmg.mk\n-include $(EPICS_ROOT)/mk/stream.mk\n-include $(EPICS_ROOT)/mk/nisync-epics.mk\n-include $(EPICS_ROOT)/mk/nisync-generalTime.mk\n-include $(EPICS_ROOT)/mk/nixseries-epics.mk\n-include $(EPICS_ROOT)/mk/pxi6259-epics.mk\n-include $(EPICS_ROOT)/mk/pxi6528-epics.mk+g' EC-GN-JA-PCF/src/main/epics/EC-GN-P01App/src/Makefile
# sed -i 's+epicsEnvSet("\(.*\)")+epicsEnvSet("\1:${TOP}/iocBoot/iocEC-GN-P01-PCF0CORE")+g' EC-GN-JA-PCF/src/main/epics/iocBoot/iocEC-GN-P01-PCF0CORE/envSystem
fi
cid=$((cid+1))
cd ${current_dir}
################################################################################################################
#Section 5
#ZIP generation
ok=$(echo ${mask} | cut -c ${cid})
if [[ ${ok} != "0" ]]; then
cd ${current_dir}
dateId=$(date +'%Y-%m-%d_%H-%M-%S_%N')
zip -r ${project_name}-${dateId}.zip ${project_name} -x ${project_name}/.svn\* -x ${project_name}/src/main/boy/unified-control-lib\*
nKeep=3
nBackups=$(ls -t ${project_name}-*.zip | wc -l)
if [[ ${nBackups} -gt ${nKeep} ]]; then
nRemovals=$(( ${nBackups} - ${nKeep} ))
toRemove=$(ls -t ${project_name}-*.zip | tail -n ${nRemovals})
rm -f ${toRemove}
fi
fi
cid=$((cid+1))
cd ${current_dir}
################################################################################################################
#Section 6
#SVN Sync
ok=$(echo ${mask} | cut -c ${cid})
if [[ ${ok} != "0" ]]; then
cd ${project_name}
mvn clean
svn st | grep ^? | awk '{print " --force "$2}' | xargs svn add
svn st | grep ^! | awk '{print " --force "$2}' | xargs svn rm
svn ci -m "Generated on ${dateId}"
cd ${current_dir}
fi
cid=$((cid+1))
cd ${current_dir}
################################################################################################################
#Section 7
#Project Compilation
ok=$(echo ${mask} | cut -c ${cid})
if [[ ${ok} != "0" ]]; then
cd ${project_name}
mvn clean package -O -Drelease=final
cd ${current_dir}
cp -rf ${project_name}/target/* target/
fi