# NOTE This task needs work! # It needs to generalize more to give greater control # over which files get what permissions. # It also might be extended to do copyright tagging. require 'reap/task' # ___ _ _ _____ _ # | _ \___ _ _ _ __ (_)_____(_)___ _ _ ___ |_ _|_ _ __| |__ # | _/ -_) '_| ' \| (_-<_-< / _ \ ' \(_-< | |/ _` (_-< / / # |_| \___|_| |_|_|_|_/__/__/_\___/_||_/__/ |_|\__,_/__/_\_\ # # = File Permissions Task class Reap::Perm < Reap::Task section_required true task_desc "Normalize ownership and permissions of files." task_help %{ reap perm Normalizes file permissions. user user name to use group group name to use } alias_method :perm, :task def run perm.group ||= perm.user perm.filemod ||= 644 perm.dirmod ||= 755 puts "Reap is shelling out work to chmod..." # misc misc = FileList.new misc.include('[A-Z]*') misc.exclude('InstalledFiles') chmod( misc ) unless misc.empty? # lib libs = FileList.new libs.include('lib/**/*') libs.exclude('lib/CVS/**/*') libs.include('packages/*/lib/**/*') libs.exclude('packages/*/lib/CVS/**/*') libs.exclude('packages/CVS/**/*') chmod( libs ) unless libs.empty? # bin bins = FileList.new bins.include('bin/**/*') bins.exclude('bin/CVS/**/*') bins.include('packages/*/bin/**/*') bins.exclude('packages/*/bin/CVS/**/*') bins.exclude('packages/CVS/**/*') chmod( bins, 755 ) unless bins.empty? end # support functions def chmod( file_list, file_mode=644, dir_mode=755 ) dirs, files = file_list.partition{ |l| File.directory?(l) } unless files.empty? fstr = '"' + files.join('" "') + '"' sh %{chmod #{file_mode} #{fstr}} end unless dirs.empty? fstr = '"' + dirs.join('" "') + '"' sh %{chmod #{dir_mode} #{fstr}} end end def run_chown puts "NOT YET IMPLEMENTED" end # def _chown( file_list, user, group ) # fstr = '"' + file_list.join('" "') + '"' # if user # if group # sh %{chown #{user}.#{group} #{fstr}} # else # sh %{chown #{user} #{fstr}} # end # end # end end