Class: Xezat::Validator::Pkgconfig

Inherits:
Object
  • Object
show all
Defined in:
lib/xezat/validator/pkgconfig.rb

Instance Method Summary collapse

Instance Method Details

#validate(variables) ⇒ Object



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
# File 'lib/xezat/validator/pkgconfig.rb', line 8

def validate(variables)
  pcdir = File::join(variables[:D], 'usr', 'lib', 'pkgconfig')
  result = true
  details = []
  if Dir::exists?(pcdir)
    Find::find(pcdir) do |file|
      if file.end_with?('.pc')
        File::foreach(file) { |line|
          unless line.index('@').nil?
            result = false
            details << "#{file.gsub(variables[:D], '')}: contains @"
            break
          end
          if line.start_with?('Libs:') && line.index(' -l').nil?
            result = false
            details << "#{file.gsub(variables[:D], '')}: no library flags found"
            break
          end
        }
      end
    end
  else
    result = nil
  end
  [result, details.empty? ? nil : details.join($/)]
end