hackmac 0.5.0 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e2851fee08cfaeb92db3644dbd04eecb12379c8410f10c75599601f9984d0333
4
- data.tar.gz: 6678f56e13c11dd0914091afc54328dc10c06546e04019e37a787a37175b4ce4
3
+ metadata.gz: 7af767d33e759f56b3859b180902074c8dee41ede4dca8e1ce386d78f3876b07
4
+ data.tar.gz: '0940a4ff2b917c27084d84ffef63315471199e973c06fe72843f1ad45efd1f66'
5
5
  SHA512:
6
- metadata.gz: 1cb71be5755a5d04960cfaf09f16f6584026a0df680e1884b16c597558769b684deb0e546deeaa51ec51d61e4860cc56357012771f1bc05bc9d3761c95e63f87
7
- data.tar.gz: 3bc28aea413bdcbfcdf3eeb84dd31876c8d34d732a6ffa8be8daa81753214ec4b60c302bc92b6e1abb7b82be7db3bbc7ae59745798fa66313a45c4ecadbf5086
6
+ metadata.gz: d870311c137b9c23858c59577cdd08fc0711f3d7d74bbcdd8b4c63fe982625f2918a44f2698620b87e66e00f0d09d81d640c99b425b30bb690a421c81a5920b0
7
+ data.tar.gz: 7f47b532331beff3df16b6808e6365e514662098d8538101f1b43dcb8d782be0979ec61d9172e7178f6067c826b07d25fe0100d7c5e46a4b8cf18559febb45f7
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.0
1
+ 0.8.0
data/bin/efi CHANGED
@@ -63,6 +63,8 @@ def usage
63
63
 
64
64
  argument PATH to the kext
65
65
 
66
+ argument FORCE == 'force' => always upgrade
67
+
66
68
  kexts list kexts versions by clover
67
69
 
68
70
  argument DEVICE (defaults to #{default_dev})
@@ -70,6 +72,20 @@ def usage
70
72
  The EFI partion on DEVICE is used to find the clover kexts in
71
73
  subdirectory /Other.
72
74
 
75
+ diff EFI partition
76
+
77
+ argument DEVICE (defaults to #{default_dev})
78
+
79
+ Shows changes as a diff with git, passes arguments to diff command
80
+ after "--".
81
+
82
+ commit EFI partition
83
+
84
+ argument DEVICE (defaults to #{default_dev})
85
+
86
+ Commits changes with git, passes arguments to commit command
87
+ after "--".
88
+
73
89
  list shows boot disk information (which EFI partition was used)
74
90
 
75
91
  end
@@ -123,16 +139,18 @@ when /\Aun?mount\z/
123
139
  x %{sudo diskutil unmount "#{mdev}"}
124
140
  # TODO remove /Volumes/mdev if it is a symlink
125
141
  when /\Adiff\z/
126
- mdev = git_args(default: %w[ --color --stat ])
142
+ mdev = git_args(default: %w[ --color --stat --cached ])
127
143
  x %{sudo diskutil mount "#{mdev}"}
128
144
  cd "/Volumes/#{mdev}" do
145
+ x %{git add -A}
129
146
  x %{git diff #{Shellwords.join(ARGV)}}
130
147
  end
131
148
  when /\Acommit\z/
132
149
  mdev = git_args(default: %w[ -v ])
133
150
  x %{sudo diskutil mount "#{mdev}"}
134
151
  cd "/Volumes/#{mdev}" do
135
- system %{git commit -a #{Shellwords.join(ARGV)}} and
152
+ x %{git add -A}
153
+ system %{git commit #{Shellwords.join(ARGV)}} and
136
154
  x %{ git push }
137
155
  end
138
156
  when 'clone'
@@ -151,18 +169,22 @@ when 'kexts'
151
169
  puts 'EFI'.yellow.bold + " (#{mdev})".bold
152
170
  puts Tabulo::Table.new(on_efi, align_header: :left, border: :modern) { |t|
153
171
  t.add_column(:name, header_styler: bold_head)
154
- t.add_column(:itself, header: 'Version/Remote',
155
- styler: -> v, s { v.version < v.remote_version ? s.red : s.green rescue s.yellow },
156
- formatter: -> e { "%s %s %s" % [ e.version, ({ 0 => ?=, -1 => ?<, 1 => ?> }[e.version <=> e.remote_version] rescue nil), e.remote_version ] },
157
- header_styler: bold_head)
172
+ t.add_column(
173
+ :itself,
174
+ header: 'Version/Remote',
175
+ styler: -> v, s { v.version < v.remote_version ? s.red : s.green rescue s.yellow },
176
+ formatter: -> e { "%s %s %s" % [ e.version, ({ 0 => ?=, -1 => ?<, 1 => ?> }[e.version <=> e.remote_version] rescue nil), e.remote_version ] },
177
+ header_styler: bold_head
178
+ )
158
179
  t.add_column(:path, header_styler: bold_head)
159
180
  }.pack
160
181
  when 'kext'
161
182
  path = ARGV.shift or fail 'need kext dir'
162
183
  puts Kext.new(path: path)
163
184
  when 'kext_upgrade'
164
- path = ARGV.shift or fail 'need kext dir'
165
- Hackmac::KextUpgrader.new(path: path, config: $config).perform
185
+ path = ARGV.shift or fail 'need kext dir'
186
+ force = ARGV.shift == 'force'
187
+ Hackmac::KextUpgrader.new(path: path, config: $config, force: force).perform
166
188
  when 'list'
167
189
  disks = Disks.new
168
190
  efis = []
@@ -177,13 +199,25 @@ when 'list'
177
199
  e.Volumes =
178
200
  ContainerDisk.new(disk: e.ParentWholeDisk, limiter: 'internal').VolumesFromDisks
179
201
  end
202
+ aliases = $config.devices.to_h.each_with_object({}) do |(dk,dv),h|
203
+ h[dv[:name]] = dk
204
+ end
180
205
  puts Tabulo::Table.new(efis, align_header: :left, border: :modern) { |t|
181
- t.add_column(:Booted, styler: -> v, _ { v == ?☑ ? v.green : v.red }, header_styler: bold_head) { |e| e.Booted ? ?☑ : ?☐ }
206
+ t.add_column(
207
+ :Booted,
208
+ styler: -> v, _ { v == ?☑ ? v.green : v.red },
209
+ header_styler: bold_head
210
+ ) { |e| e.Booted ? ?☑ : ?☐ }
182
211
  t.add_column(:VolumeName, header_styler: bold_head)
212
+ t.add_column(:Alias, header_styler: bold_head) { |e| aliases[e.VolumeName] }
183
213
  t.add_column(:DeviceIdentifier, header_styler: bold_head)
184
214
  t.add_column(:ParentWholeDisk, header_styler: bold_head)
185
215
  t.add_column(:Volumes, header_styler: bold_head) { |e| e.Volumes * ?, }
186
- t.add_column(:MountPoint, styler: -> v, _ { v.empty? ? v : v.green }, header_styler: bold_head)
216
+ t.add_column(
217
+ :MountPoint,
218
+ styler: -> v, _ { v.empty? ? v : v.green },
219
+ header_styler: bold_head
220
+ )
187
221
  }.pack
188
222
  else
189
223
  fail "don't know how to #{command}"
@@ -1,19 +1,19 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # stub: hackmac 0.5.0 ruby lib
2
+ # stub: hackmac 0.8.0 ruby lib
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "hackmac".freeze
6
- s.version = "0.5.0"
6
+ s.version = "0.8.0"
7
7
 
8
8
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
9
9
  s.require_paths = ["lib".freeze]
10
10
  s.authors = ["Florian Frank".freeze]
11
- s.date = "2020-03-05"
11
+ s.date = "2020-08-17"
12
12
  s.description = "This ruby gem provides some useful tools for working with a Hackintosh.".freeze
13
13
  s.email = "flori@ping.de".freeze
14
14
  s.executables = ["gfxmon".freeze, "usb".freeze, "efi".freeze]
15
- s.extra_rdoc_files = ["README.md".freeze, "lib/hackmac.rb".freeze, "lib/hackmac/config.rb".freeze, "lib/hackmac/disks.rb".freeze, "lib/hackmac/kext.rb".freeze, "lib/hackmac/kext_source.rb".freeze, "lib/hackmac/kext_upgrader.rb".freeze, "lib/hackmac/plist.rb".freeze, "lib/hackmac/utils.rb".freeze, "lib/hackmac/version.rb".freeze]
16
- s.files = [".gitignore".freeze, "Gemfile".freeze, "README.md".freeze, "Rakefile".freeze, "VERSION".freeze, "bin/efi".freeze, "bin/gfxmon".freeze, "bin/usb".freeze, "hackmac.gemspec".freeze, "lib/hackmac.rb".freeze, "lib/hackmac/config.rb".freeze, "lib/hackmac/disks.rb".freeze, "lib/hackmac/kext.rb".freeze, "lib/hackmac/kext_source.rb".freeze, "lib/hackmac/kext_upgrader.rb".freeze, "lib/hackmac/plist.rb".freeze, "lib/hackmac/utils.rb".freeze, "lib/hackmac/version.rb".freeze]
15
+ s.extra_rdoc_files = ["README.md".freeze, "lib/hackmac.rb".freeze, "lib/hackmac/config.rb".freeze, "lib/hackmac/disks.rb".freeze, "lib/hackmac/kext.rb".freeze, "lib/hackmac/kext_download.rb".freeze, "lib/hackmac/kext_source.rb".freeze, "lib/hackmac/kext_upgrader.rb".freeze, "lib/hackmac/plist.rb".freeze, "lib/hackmac/utils.rb".freeze, "lib/hackmac/version.rb".freeze]
16
+ s.files = [".gitignore".freeze, "Gemfile".freeze, "README.md".freeze, "Rakefile".freeze, "VERSION".freeze, "bin/efi".freeze, "bin/gfxmon".freeze, "bin/usb".freeze, "hackmac.gemspec".freeze, "lib/hackmac.rb".freeze, "lib/hackmac/config.rb".freeze, "lib/hackmac/disks.rb".freeze, "lib/hackmac/kext.rb".freeze, "lib/hackmac/kext_download.rb".freeze, "lib/hackmac/kext_source.rb".freeze, "lib/hackmac/kext_upgrader.rb".freeze, "lib/hackmac/plist.rb".freeze, "lib/hackmac/utils.rb".freeze, "lib/hackmac/version.rb".freeze]
17
17
  s.homepage = "http://github.com/flori/hackmac".freeze
18
18
  s.rdoc_options = ["--title".freeze, "Hackmac - Some useful tools for working with a Hackintosh".freeze, "--main".freeze, "README.md".freeze]
19
19
  s.rubygems_version = "3.1.2".freeze
@@ -8,6 +8,7 @@ require 'hackmac/plist'
8
8
  require 'hackmac/disks'
9
9
  require 'hackmac/kext'
10
10
  require 'hackmac/kext_source'
11
+ require 'hackmac/kext_download'
11
12
  require 'hackmac/kext_upgrader'
12
13
  require 'hackmac/config'
13
14
  require 'hackmac/utils'
@@ -15,14 +15,14 @@ module Hackmac
15
15
  os: '/Applications/Install macOS Mojave.app'
16
16
  devices:
17
17
  main:
18
- name: EFI
19
- #backup:
20
- # name: BACKUP_EFI
18
+ name: 'OSX_EFI'
19
+ backup:
20
+ name: 'BACKUP_EFI'
21
21
  github:
22
22
  user: null
23
23
  access_token: null
24
24
  kext:
25
- efi_path: EFI/CLOVER/kexts/Other
25
+ efi_path: 'EFI/CLOVER/kexts/Other'
26
26
  sources:
27
27
  AppleALC:
28
28
  github: 'acidanthera/AppleALC'
@@ -30,19 +30,27 @@ module Hackmac
30
30
  github: 'acidanthera/IntelMausi'
31
31
  Lilu:
32
32
  github: 'acidanthera/Lilu'
33
- USBInjectAll:
34
- github: 'Sniki/OS-X-USB-Inject-All'
33
+ #USBInjectAll:
34
+ # github: 'Sniki/OS-X-USB-Inject-All'
35
35
  VirtualSMC:
36
36
  github: 'acidanthera/VirtualSMC'
37
+ debug: false
37
38
  plugins:
38
39
  - SMCProcessor
39
40
  - SMCSuperIO
41
+ BrcmPatchRAM2:
42
+ download:
43
+ name: 'BrcmPatchRAM'
44
+ version: '2.2.10'
45
+ url: 'https://bitbucket.org/RehabMan/os-x-brcmpatchram/downloads/RehabMan-BrcmPatchRAM-2018-0505.zip'
46
+ plugins:
47
+ - BrcmFirmwareData
40
48
  WhateverGreen:
41
49
  github: 'acidanthera/WhateverGreen'
42
50
  end
43
51
 
44
52
  def self.load
45
- path = File.expand_path('~/config')
53
+ path = File.expand_path('~/.config/hackmac')
46
54
  mkdir_p path
47
55
  ComplexConfig::Provider.config_dir = path
48
56
  config_path = File.join(path, 'hackmac.yml')
@@ -40,10 +40,20 @@ module Hackmac
40
40
  def remote_kext
41
41
  return @remote_kext if @remote_kext
42
42
  if @config
43
- if github = @config.kext.sources[name]&.github
43
+ source = @config.kext.sources[name] or return
44
+ case
45
+ when github = source&.github?
44
46
  auth = [ @config.github.user, @config.github.access_token ].compact
45
47
  auth.empty? and auth = nil
46
- @remote_kext = Hackmac::KextSource.new(github, auth: auth)
48
+ suffix =
49
+ case debug = source.debug?
50
+ when true then 'DEBUG'
51
+ when false then 'RELEASE'
52
+ when nil then nil
53
+ end
54
+ @remote_kext = Hackmac::KextSource.new(github, auth: auth, suffix: suffix)
55
+ when download = source&.download
56
+ @remote_kext = Hackmac::KextDownload.new(download.name, download.version, download.url)
47
57
  end
48
58
  end
49
59
  end
@@ -0,0 +1,39 @@
1
+ require 'open-uri'
2
+ require 'tins/string_version'
3
+
4
+ module Hackmac
5
+ class KextDownload
6
+ include Tins::StringVersion
7
+
8
+ def initialize(name, version, url)
9
+ @name = name
10
+ @url = url
11
+ @version = Version.new(version)
12
+ end
13
+
14
+ attr_reader :name
15
+
16
+ attr_reader :version
17
+
18
+ def download_asset
19
+ data = URI.open(
20
+ @url,
21
+ 'Accept' => 'application/octet-stream',
22
+ &:read
23
+ )
24
+ return File.basename(@url), data
25
+ end
26
+
27
+ def inspect
28
+ "#<#{self.class}: #{to_s}>"
29
+ end
30
+
31
+ def to_s
32
+ "#{name} #{version}"
33
+ end
34
+
35
+ def to_s
36
+ "#{name} #{version}"
37
+ end
38
+ end
39
+ end
@@ -8,9 +8,10 @@ module Hackmac
8
8
 
9
9
  include Tins::StringVersion
10
10
 
11
- def initialize(github, auth: nil)
12
- @github = github
13
- @auth = auth
11
+ def initialize(github, auth: nil, suffix: nil)
12
+ @github = github
13
+ @auth = auth
14
+ @suffix = (Regexp.quote(suffix) if suffix)
14
15
  account, repo = github.split(?/)
15
16
  @name = repo
16
17
  releases = URI.open(
@@ -41,12 +42,13 @@ module Hackmac
41
42
 
42
43
  def download_asset
43
44
  @release or return
44
- asset = @release.assets.find { |a| a.name =~ /RELEASE.*zip/i } or return
45
+ asset = @release.assets.find { |a| a.name =~ /#@suffix.*\.(zip|tar\.gz)\z/i } or return
45
46
  data = URI.open(
46
47
  (GITHUB_API_URL % github) + ("/assets/%s" % asset.id),
47
48
  'Accept' => 'application/octet-stream',
48
- http_basic_authentication: auth
49
- ) { |o| o.read }
49
+ http_basic_authentication: auth,
50
+ &:read
51
+ )
50
52
  return asset.name, data
51
53
  end
52
54
 
@@ -6,8 +6,8 @@ module Hackmac
6
6
  class KextUpgrader
7
7
  include FileUtils
8
8
 
9
- def initialize(path:, config:)
10
- @path, @config = path, config
9
+ def initialize(path:, config:, force: false)
10
+ @path, @config, @force = path, config, force
11
11
  end
12
12
 
13
13
  private
@@ -20,6 +20,19 @@ module Hackmac
20
20
  end
21
21
  end
22
22
 
23
+ def decompress(name)
24
+ print "Decompressing #{name.inspect}…"
25
+ case name
26
+ when /\.zip\z/i
27
+ system "unzip #{name.inspect}" or fail "Could not unzip #{name.inspect}"
28
+ when /\.tar\.gz\z/i
29
+ system "tar xfz #{name.inspect}" or fail "Could not tar xfz #{name.inspect}"
30
+ else
31
+ fail "Cannot decompress #{name.inspect}"
32
+ end
33
+ puts "done!"
34
+ end
35
+
23
36
  public
24
37
 
25
38
  def perform
@@ -28,11 +41,11 @@ module Hackmac
28
41
  case
29
42
  when kext.remote_version.nil?
30
43
  puts "No source defined for #{kext}"
31
- when kext.remote_version > kext.version
44
+ when kext.remote_version > kext.version || @force
32
45
  name, data = kext.remote_kext.download_asset
33
46
  if name
34
47
  File.secure_write(name, data)
35
- system "unzip #{name.inspect}" or fail "Could not unzip #{name.inspect}"
48
+ decompress(name)
36
49
  kext_pathes = []
37
50
  Find.find(dir) do |path|
38
51
  if File.directory?(path)
@@ -48,7 +61,6 @@ module Hackmac
48
61
  end
49
62
  end
50
63
  end
51
- p kext_pathes
52
64
  kext_pathes.each do |kext_path|
53
65
  old_path = (Pathname.new(@path).dirname + File.basename(kext_path)).to_s
54
66
  if ask("Really upgrade #{old_path.inspect} to version #{kext.remote_version}? (y/n) ")
@@ -1,6 +1,6 @@
1
1
  module Hackmac
2
2
  # Hackmac version
3
- VERSION = '0.5.0'
3
+ VERSION = '0.8.0'
4
4
  VERSION_ARRAY = VERSION.split('.').map(&:to_i) # :nodoc:
5
5
  VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
6
6
  VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hackmac
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Florian Frank
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-03-05 00:00:00.000000000 Z
11
+ date: 2020-08-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gem_hadar
@@ -149,6 +149,7 @@ extra_rdoc_files:
149
149
  - lib/hackmac/config.rb
150
150
  - lib/hackmac/disks.rb
151
151
  - lib/hackmac/kext.rb
152
+ - lib/hackmac/kext_download.rb
152
153
  - lib/hackmac/kext_source.rb
153
154
  - lib/hackmac/kext_upgrader.rb
154
155
  - lib/hackmac/plist.rb
@@ -168,6 +169,7 @@ files:
168
169
  - lib/hackmac/config.rb
169
170
  - lib/hackmac/disks.rb
170
171
  - lib/hackmac/kext.rb
172
+ - lib/hackmac/kext_download.rb
171
173
  - lib/hackmac/kext_source.rb
172
174
  - lib/hackmac/kext_upgrader.rb
173
175
  - lib/hackmac/plist.rb
@@ -176,7 +178,7 @@ files:
176
178
  homepage: http://github.com/flori/hackmac
177
179
  licenses: []
178
180
  metadata: {}
179
- post_install_message:
181
+ post_install_message:
180
182
  rdoc_options:
181
183
  - "--title"
182
184
  - Hackmac - Some useful tools for working with a Hackintosh
@@ -196,7 +198,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
196
198
  version: '0'
197
199
  requirements: []
198
200
  rubygems_version: 3.1.2
199
- signing_key:
201
+ signing_key:
200
202
  specification_version: 4
201
203
  summary: Some useful tools for working with a Hackintosh
202
204
  test_files: []