Class: PKGWizard::Mock

Inherits:
Object
  • Object
show all
Defined in:
lib/pkg-wizard/mock.rb

Class Method Summary collapse

Class Method Details

.srpm(args = {}) ⇒ Object

mandatory args

:profile
:resultdir
:srpm

Raises:

  • (ArgumentError)


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
# File 'lib/pkg-wizard/mock.rb', line 10

def self.srpm(args =  {})
  mock_profile = args[:profile]
  result_dir = args[:resultdir]
  srpm = args[:srpm]
  mock_args = args[:mock_args] || ""

  raise ArgumentError.new('Invalid mock profile') if mock_profile.nil?

  if not File.exist?(srpm) or (srpm !~ /src\.rpm$/)
    raise ArgumentError.new('Invalid SRPM')
  end

  raise ArgumentError.new('Invalid result dir') if result_dir.nil?


  if mock_profile.nil?
    raise Exception.new "Missing mock profile."
  end
  
  if result_dir.nil?
    raise Exception.new "Missing result_dir."
  end

  if not File.directory?(result_dir)
    raise Exception.new "Invalid result_dir #{result_dir}"
  end

  cmd = "/usr/bin/mock #{mock_args} -r #{mock_profile} --disable-plugin ccache --resultdir #{result_dir} #{srpm}"
  output = `#{cmd} 2>&1`
  if $? != 0
    raise Exception.new(output)
  end
  output
end