Class: Hackmac::KextUpgrader
- Inherits:
-
Object
- Object
- Hackmac::KextUpgrader
- Includes:
- FileUtils
- Defined in:
- lib/hackmac/kext_upgrader.rb
Instance Method Summary collapse
-
#initialize(path:, config:, force: false) ⇒ KextUpgrader
constructor
A new instance of KextUpgrader.
- #perform ⇒ Object
Constructor Details
#initialize(path:, config:, force: false) ⇒ KextUpgrader
Returns a new instance of KextUpgrader.
9 10 11 |
# File 'lib/hackmac/kext_upgrader.rb', line 9 def initialize(path:, config:, force: false) @path, @config, @force = path, config, force end |
Instance Method Details
#perform ⇒ Object
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 |
# File 'lib/hackmac/kext_upgrader.rb', line 38 def perform isolate do |dir| kext = Kext.new(path: @path, config: @config) case when kext.remote_version.nil? puts "No source defined for #{kext}" when kext.remote_version > kext.version || @force name, data = kext.remote_kext.download_asset if name File.secure_write(name, data) decompress(name) kext_pathes = [] Find.find(dir) do |path| if File.directory?(path) case File.basename(path) when /\A\./ Find.prune when "#{kext.name}.kext" kext_pathes.unshift path when *@config.kext.sources[kext.name]&.plugins?&.map { |p| p + '.kext' } then kext_pathes << path end end end kext_pathes.each do |kext_path| old_path = (Pathname.new(@path).dirname + File.basename(kext_path)).to_s if ask("Really upgrade #{old_path.inspect} to version #{kext.remote_version}? (y/n) ") rm_rf old_path cp_r kext_path, old_path end end else fail "#{kext.remote_kext.name} could not be downloaded" end else puts "#{kext} is already the latest version" end end end |