namespace :dyserver do LOCAL_BASE = '' DIST_BASE = "#{LOCAL_BASE}../../dyserver/" # To bootstrap: # $ to 1,pr # $ rake -f /dym$disk/dymax/dyserver dyserver:update project=ENV['PROJECT'] if project!='' local_base="/dym$disk/dymax/#{project}/dyserver" unless File.directory?(local_base) mkdir local_base end chdir local_base end # We must start in a dyserver project directory for relative # paths in cfg.spc to work. If the project wasn't defined and # the current dir is incorrect, we'll have to bail. current_dir=Dir.pwd if /\/dymax\/\d{3}\/dyserver$/i.match(current_dir) == nil abort "Current directory must be a dyserver project directory: $current_dir" end class ConfigSpc < Array def initialize super File.read('cfg.spc').downcase.split(/[\r\n]+/).grep(/^[^!]/) rescue super [] end def locally_configured? path member?(path.downcase) end end config_spc=ConfigSpc.new def fix_file filename case PLATFORM when /vms/i cmd= case filename when /\/images\// "set file/attr=rfm:stmlf #{File.unix_to_vms_path(filename)}" else "convert/fdl=dyulib:stream #{File.unix_to_vms_path(filename)} *.*" end puts cmd system cmd end end rule "public/images/submitgr.gif" "../web/submitgr.gif" do |task| cp task.source,task.name end local = FileList.new dist = FileList["#{DIST_BASE}**/*"].reject do |dist_path| local_path=dist_path.sub /#{DIST_BASE}/, LOCAL_BASE reject_path=File.directory?(dist_path) || config_spc.locally_configured?(local_path) local << local_path unless reject_path reject_path end local.each_index do |index| local_dir=File.dirname(local[index]) mkdir local_dir unless File.directory?(local_dir) file local[index] => dist[index] do copy dist[index], local[index] #bg> needs File.unix_to_vms_path, which is not yet written. #fix_file local[index] if /^public\//i.match local[index] end end desc "Update all distributed dyserver files from master copy" task :update => local end