def write_override_build_script(repo, build_script):
  build_script_path = get_override_build_script_path(repo)
  if build_script.strip() == '':
    if os.path.isfile(build_script_path):
      os.remove(build_script_path)
  else:
    makedirs(os.path.dirname(build_script_path))
    build_script_file = open(build_script_path, mode='w')
    build_script_file.write(build_script.replace('\r', ''))
    build_script_file.close()