hackmac 0.1.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0e7376b8be3d88282d601b6bf2a1680d6147866948faba9eaadd2eb2002a5738
4
- data.tar.gz: dead5492fc2cb69bcaf477460d4bbb4f11353d2b43c018898169a15a4edba2f1
3
+ metadata.gz: 15cd2512b3c0b4cb1c9c3f1d586681a51adaceacc3d661b63e75b013dbc7204b
4
+ data.tar.gz: 64c08eaab561ba49ced63891e89bd30316d2fd1fbd31d7fa9e5b0499e91ce54c
5
5
  SHA512:
6
- metadata.gz: acad4d744c1ddb1a5e36916a47d837f3f425e708211626beef9492657b56a4898efb4a32e2129363b571cbc87a2a6020ac3df1ca028c10961de123e48e31b803
7
- data.tar.gz: 129f684ca08c553f3d115b9d88b46e00f68b8e822dadfd8f4e9700493a311cfd90356e9f08b4988b4610f731add13cabf5762d405cf0d1761df98ac534aac4df
6
+ metadata.gz: 43c74281e04acc699ff22180790871440d3bcefd6ebeb04eaf71332d797c4c339c3286e10ea326845f9fdb4f0dbb56ef69068ba8216267803e7d3eb10aa1204b
7
+ data.tar.gz: da44c84501b20c6d7b43089d3cc90dc4013555213b39b012532dcf95acb755d347288dfb0caae48d5877fa51d137a69425b9703e3fbcdaf3718155365cc57581
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.2.0
data/bin/efi CHANGED
@@ -7,6 +7,9 @@ class String
7
7
  include Term::ANSIColor
8
8
  end
9
9
  require 'tabulo'
10
+ require 'fileutils'
11
+ include FileUtils
12
+ require 'tmpdir'
10
13
 
11
14
  def x(cmd, verbose: true)
12
15
  prompt = cmd =~ /\A\s*sudo/ ? ?# : ?$
@@ -25,18 +28,19 @@ def x(cmd, verbose: true)
25
28
  output
26
29
  end
27
30
 
31
+ def ask(prompt)
32
+ print prompt.bold.yellow
33
+ gets =~ /\Ay/i
34
+ end
35
+
28
36
  def clone(from:, to:)
29
- print "Cloning from #{from} to #{to} now? (y/n) ".bold.yellow
30
- if gets !~ /\Ay/i
31
- return
32
- end
37
+ ask("Cloning from #{from} to #{to} now? (y/n) ") or return
33
38
  x %{sudo mkdir -v "/Volumes/#{from}"}
34
39
  x %{sudo mkdir -v "/Volumes/#{to}"}
35
40
  x %{sudo diskutil mount -mountPoint "/Volumes/#{from}" "#{from}"}
36
41
  x %{sudo diskutil mount -mountPoint "/Volumes/#{to}" "#{to}"}
37
42
  x %{rsync -nav --exclude ".*" --delete "/Volumes/#{from}/" "/Volumes/#{to}/"}
38
- print "This will be copied/deleted. Really do it? (y/n) ".bold.yellow
39
- if gets !~ /\Ay/i
43
+ unless ask("This will be copied/deleted. Really do it? (y/n) ")
40
44
  puts " *** Interrupted.".bold.yellow
41
45
  exit 1
42
46
  end
@@ -84,6 +88,10 @@ def usage
84
88
 
85
89
  argument PATH to the kext
86
90
 
91
+ kext_upgrade
92
+
93
+ argument PATH to the kext
94
+
87
95
  kexts list kexts versions by clover
88
96
 
89
97
  argument DEVICE (defaults to #{default_dev})
@@ -153,6 +161,32 @@ when 'kexts'
153
161
  when 'kext'
154
162
  path = ARGV.shift or fail 'need kext dir'
155
163
  puts Kext.new(path: path)
164
+ when 'kext_upgrade'
165
+ path = ARGV.shift or fail 'need kext dir'
166
+ kext = Kext.new(path: path, config: $config)
167
+ case
168
+ when kext.remote_version.nil?
169
+ puts "No source defined for #{kext}"
170
+ when kext.remote_version > kext.version
171
+ Dir.mktmpdir do |dir|
172
+ cd dir do
173
+ name, data = kext.remote_kext.download_asset
174
+ File.secure_write(name, data)
175
+ system "unzip #{name.inspect}"
176
+ kext_name = "#{kext.name}.kext"
177
+ if File.directory?(kext_name)
178
+ if ask("Really upgrade #{path.inspect} to version #{kext.remote_version}? (y/n) ")
179
+ rm_rf path
180
+ cp_r kext_name, path
181
+ end
182
+ else
183
+ fail "#{kext_name} could not be downloaded"
184
+ end
185
+ end
186
+ end
187
+ else
188
+ puts "#{kext} is already the latest version"
189
+ end
156
190
  when 'list'
157
191
  disks = Disks.new
158
192
  efis = []
data/hackmac.gemspec CHANGED
@@ -1,14 +1,14 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # stub: hackmac 0.1.1 ruby lib
2
+ # stub: hackmac 0.2.0 ruby lib
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "hackmac".freeze
6
- s.version = "0.1.1"
6
+ s.version = "0.2.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-01-28"
11
+ s.date = "2020-01-29"
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, "efi".freeze]
@@ -9,6 +9,8 @@ module Hackmac
9
9
  include Tins::StringVersion
10
10
 
11
11
  def initialize(github, auth: nil)
12
+ @github = github
13
+ @auth = auth
12
14
  account, repo = github.split(?/)
13
15
  @name = repo
14
16
  releases = URI.open(
@@ -16,16 +18,16 @@ module Hackmac
16
18
  http_basic_authentication: auth) { |o|
17
19
  JSON.parse(o.read, object_class: JSON::GenericObject)
18
20
  }
19
- if version = releases.map { |r|
21
+ if max_version = releases.map { |r|
20
22
  next unless r.tag_name.include?(?.)
21
- version = r.tag_name.delete '^.0-9'
23
+ tag = r.tag_name.delete '^.0-9'
22
24
  begin
23
- Version.new(version)
25
+ [ Version.new(tag), r ]
24
26
  rescue ArgumentError
25
27
  end
26
- }.compact.max
28
+ }.compact.max_by(&:first)
27
29
  then
28
- @version = version
30
+ @version, @release = max_version
29
31
  end
30
32
  end
31
33
 
@@ -33,6 +35,21 @@ module Hackmac
33
35
 
34
36
  attr_reader :version
35
37
 
38
+ attr_reader :github
39
+
40
+ attr_reader :auth
41
+
42
+ def download_asset
43
+ @release or return
44
+ asset = @release.assets.find { |a| a.name =~ /RELEASE.*zip/ } or return
45
+ data = URI.open(
46
+ (GITHUB_API_URL % github) + ("/assets/%s" % asset.id),
47
+ 'Accept' => 'application/octet-stream',
48
+ http_basic_authentication: auth
49
+ ) { |o| o.read }
50
+ return asset.name, data
51
+ end
52
+
36
53
  def inspect
37
54
  "#<#{self.class}: #{to_s}>"
38
55
  end
@@ -1,6 +1,6 @@
1
1
  module Hackmac
2
2
  # Hackmac version
3
- VERSION = '0.1.1'
3
+ VERSION = '0.2.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.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Florian Frank
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-01-28 00:00:00.000000000 Z
11
+ date: 2020-01-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gem_hadar