Class: Hackmac::OCUpgrader
- Inherits:
-
Object
- Object
- Hackmac::OCUpgrader
- Includes:
- FileUtils::Verbose, AssetTools
- Defined in:
- lib/hackmac/oc_upgrader.rb
Overview
A class that handles the upgrade process for OpenCore bootloader files
The OCUpgrader class manages the workflow for upgrading OpenCore bootloader installations by retrieving remote release information, downloading and decompressing new versions, and performing file system operations to replace existing EFI files after ensuring the installation directory is properly configured
Instance Method Summary collapse
-
#initialize(mdev:, config:) ⇒ OCUpgrader
constructor
The initialize method sets up an OCUpgrader instance by configuring the installation directory based on the provided mount point and configuration.
-
#perform ⇒ Object
The perform method executes the OpenCore upgrade process by isolating the operation in a temporary directory.
-
#to_s ⇒ String
The to_s method returns a string representation of the object by formatting the installation directory path into a descriptive string that indicates where the OpenCore files will be installed.
Methods included from AssetTools
Constructor Details
#initialize(mdev:, config:) ⇒ OCUpgrader
The initialize method sets up an OCUpgrader instance by configuring the installation directory based on the provided mount point and configuration.
This method takes a mount device identifier and configuration object, then constructs the full path to the EFI installation directory by joining the mount path with the OpenCore EFI path specified in the configuration.
31 32 33 34 35 |
# File 'lib/hackmac/oc_upgrader.rb', line 31 def initialize(mdev:, config:) @config = config mount_path = Pathname.new('/Volumes').join(mdev) @install_dir = Pathname.new(mount_path).join(@config.oc.efi_path) end |
Instance Method Details
#perform ⇒ Object
The perform method executes the OpenCore upgrade process by isolating the operation in a temporary directory
This method handles the complete workflow for upgrading OpenCore bootloader files, including retrieving remote release information, downloading and decompressing the new version, and performing file system operations to replace existing EFI files after ensuring the installation directory is properly configured
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/hackmac/oc_upgrader.rb', line 48 def perform isolate do |dir| oc = OC.new(config: @config) name, data = oc.remote.download_asset if name File.secure_write(name, data) decompress(name) for f in @config.oc.files.map { |x| Pathname.new(x) } sf = Pathname.new(dir).join(@config.oc.install_path).join(f) cp sf, @install_dir.join(f.dirname) end else fail "#{oc} could not be downloaded" end end end |
#to_s ⇒ String
The to_s method returns a string representation of the object by formatting the installation directory path into a descriptive string that indicates where the OpenCore files will be installed
71 72 73 |
# File 'lib/hackmac/oc_upgrader.rb', line 71 def to_s 'Installation into %s' % @install_dir end |