29 lines
804 B
Ruby
Raw Normal View History

2016-08-18 22:11:42 +03:00
require "tmpdir"
require "hbc/container/base"
2016-09-24 13:52:43 +02:00
module Hbc
class Container
class Cab < Base
def self.me?(criteria)
cabextract = which("cabextract")
2016-08-18 22:11:42 +03:00
criteria.magic_number(/^(MSCF|MZ)/n) &&
!cabextract.nil? &&
2016-09-24 13:52:43 +02:00
criteria.command.run(cabextract, args: ["-t", "--", criteria.path.to_s]).stderr.empty?
end
2016-08-18 22:11:42 +03:00
2016-09-24 13:52:43 +02:00
def extract
if (cabextract = which("cabextract")).nil?
2016-09-24 13:52:43 +02:00
raise CaskError, "Expected to find cabextract executable. Cask '#{@cask}' must add: depends_on formula: 'cabextract'"
end
2016-08-18 22:11:42 +03:00
2016-09-24 13:52:43 +02:00
Dir.mktmpdir do |unpack_dir|
@command.run!(cabextract, args: ["-d", unpack_dir, "--", @path])
@command.run!("/usr/bin/ditto", args: ["--", unpack_dir, @cask.staged_path])
end
end
2016-08-18 22:11:42 +03:00
end
end
end