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:) ⇒ void
constructor
The initialize method sets up an OCUpgrader instance by configuring the installation directory based on the provided mount point and configuration.
-
#perform ⇒ void
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:) ⇒ void
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.
33 34 35 36 37 |
# File 'lib/hackmac/oc_upgrader.rb', line 33 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 ⇒ void
This method returns an undefined value.
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
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/hackmac/oc_upgrader.rb', line 52 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
75 76 77 |
# File 'lib/hackmac/oc_upgrader.rb', line 75 def to_s 'Installation into %s' % @install_dir end |