Create two definitions - one that excludes CGI files and uses 664/775 and the other one that only includes CGI files and uses 775/775 - then you have to execDeploymentTasks.