mirror of
https://github.com/donl/homebrew-cask-versions.git
synced 2026-07-20 06:16:57 -06:00
accepts a single argument, which is a relative path to a pkg inside the extracted Cask; homebrew-cask will attempt to install this pkg after the Cask is extracted via `installer` because of the many different ways uninstallers work, this has several features: - `:script`: a script in the Cask which serves as an uninstaller (e.g. Vagrant, VirtualBox), uses `:args`, and `:input` keys to interact with said script - `:pkgutil`: a regexp which captures all package_ids installed by this cask; homebrew-cask will list all files installed under these ids and remove them - `:launchctl`: a list of bundle_ids for services that should be removed by homebrew-cask - `:files`: a fallback list of files to manually remove; helps when uninstallers miss something refs #661
44 lines
1.3 KiB
Ruby
44 lines
1.3 KiB
Ruby
class Cask::PkgInstaller
|
|
def initialize(cask, command=Cask::SystemCommand)
|
|
@cask = cask
|
|
@command = command
|
|
end
|
|
|
|
def install
|
|
@cask.installers.each do |installer|
|
|
ohai "Running installer for #{@cask}; your password may be necessary."
|
|
@command.run("installer", {
|
|
:sudo => true,
|
|
:args => %W[-pkg #{installer} -target /]
|
|
})
|
|
end
|
|
end
|
|
|
|
def uninstall
|
|
@cask.uninstallables.each do |uninstall_options|
|
|
ohai "Running uninstall process for #{@cask}; your password may be necessary."
|
|
if uninstall_options.key? :script
|
|
@command.run(@cask.destination_path.join(uninstall_options[:script]), uninstall_options.merge(:sudo => true))
|
|
end
|
|
|
|
if uninstall_options.key? :pkgutil
|
|
pkgs = Cask::Pkg.all_matching(uninstall_options[:pkgutil], @command)
|
|
pkgs.each(&:uninstall)
|
|
end
|
|
|
|
if uninstall_options.key? :launchctl
|
|
[*uninstall_options[:launchctl]].each do |service|
|
|
ohai "Removing launchctl service #{service}"
|
|
@command.run('launchctl', :args => ['remove', service], :sudo => true)
|
|
end
|
|
end
|
|
|
|
if uninstall_options.key? :files
|
|
uninstall_options[:files].each do |file|
|
|
ohai "Removing file #{file}"
|
|
@command.run('rm', :args => [file], :sudo => true)
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|