-
Notifications
You must be signed in to change notification settings - Fork 10
/
Rakefile
90 lines (76 loc) · 2.87 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/usr/bin/rake -T
require 'simp/rake'
class RsyncPkg < Simp::Rake::Pkg
def define_check_facl
desc "Check the .rsync.facl file for unknown files"
task :check_facl do
# First, check to make sure that we actually have a facl entry for
# everything in our tree.
Dir.chdir('rsync') do
facl_files = File.read('.rsync.facl').split("\n").collect{|x| if x =~ /^#\s+file:\s+(.*)\s*$/ then x = $1 end }.compact
present_files = []
Find.find('.') do |path|
Find.prune if File.symlink?(path)
# Skip these since they're only build files/dirs.
Find.prune if [
'./.rsync.facl',
'./build',
'./dist',
'./Rakefile',
'./README'
].include?(path)
Find.prune if path =~ /.*\/\.git.*/
Find.prune if File.basename(path) == '.shares'
if path =~ /^\.\/(.*)/ then present_files << $1 end
end
file_diff = present_files - facl_files
unless file_diff.empty?
raise(Exception,"Error: The following files do not have FACL entries:\n #{file_diff.sort.uniq.join("\n ")}")
end
# Now, check that the facl file has valid entries for the existing
# tree.
facl_test = %x{setfacl --test --restore=.rsync.facl 2>&1}.split("\n")
# We have a situation where we could either get the ClamAV CVD files or
# incremental CLD files. This is extra super fun so we have to parse the
# data set if the check fails.
if !$?.success?
bad_results = []
facl_test.each_with_index do |x,i|
if x =~ /No such file or directory/
bad_results << facl_test[i]
end
end
facl_test.delete_if{|x| x =~ /No such file or directory/ }
bad_results.map!{ |x| x = x.split(':')[1].strip}
clamav_hits = []
bad_results.each_with_index do |x,i|
if x =~ /clamav\/.*\.c(v|l)d/
clamav_hits << bad_results[i]
end
end
bad_results.delete_if{|x| x =~ /clamav\/.*\.c(v|l)d/}
if bad_results.empty?
# This just returns the DB name that got missed.
clamav_hits.each do |hit|
next if facl_test.index{|x| x =~ /#{hit.split('.')[0..-2].join('.')}/}
bad_results << hit
end
end
unless bad_results.empty?
raise(Exception,"Error: The following had rsync FACL errors:\n #{bad_results.sort.uniq.join("\n ")}")
end
end
end
end
end
def define
define_check_facl
super
# Add on the needed prereqs
Rake::Task['pkg:tar'].enhance([:check_facl])
end
end
RsyncPkg.new(File.dirname(__FILE__)) do |t|
t.ignore_changes_list << "#{t.pkg_name}/rsync/Global/clamav"
::CLOBBER.include("#{t.base_dir}/rsync/Global/clamav/*")
end