mini_portile2 2.5.1 → 2.7.1

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: 1f30e371678c82b2de1219ec842fa298bf1e6acc47b2f210ebfda77939aed190
4
- data.tar.gz: 7ac927dc6453bf1532db4e55677cebefa115b17fffc43358ef68b8d80c967210
3
+ metadata.gz: 67e186927fefba71108ad1e3e0a0a27eb22c1baaeda1bb38c36f50f0257a7b26
4
+ data.tar.gz: bc0caaea80c4c30c56cd1ad7cfe303558bb282cc2230267721f9e09475f08a4e
5
5
  SHA512:
6
- metadata.gz: df62e128fdb0a950c7f6eb45ba97bdab7793b6e8b6e4a139dd5fe93913bffee194a5505114dfe421f6d64efb25ad17215eb8f1ecd8fdc1d40969aa2b888bebee
7
- data.tar.gz: c05f9262bdbb32fcdcda598c8ae0f16962219f39306ae9d4433b1e13af6e2c2ec181c33864ee99284ebe5f82828940ce3d96a9bb9a4ce00947ab56b7d3699252
6
+ metadata.gz: 0e9002455f2167d020f68386b628571d796f5ae3d1bc51b35b0dc17435de9ba520e6486cfe308cf70315d46fd8237c745befbb689b93d39c1624a461ff9a98af
7
+ data.tar.gz: d659050137d5deb3342ad9e026c0e66a7cbd030a15b9fd7133a4b653023ec552e38769705dfb5bf6fdc83170a8ed53519cd1c9157fadaa0b91eef6ef0855cc7c
@@ -1,23 +1,31 @@
1
1
  name: Continuous Integration
2
-
2
+ concurrency:
3
+ group: "${{github.workflow}}-${{github.ref}}"
4
+ cancel-in-progress: true
3
5
  on:
6
+ workflow_dispatch:
4
7
  push:
5
- branches: [main]
8
+ branches:
9
+ - main
10
+ - v*.*.x
11
+ tags:
12
+ - v*.*.*
6
13
  pull_request:
7
14
  types: [opened, synchronize]
8
- branches: [main]
15
+ branches:
16
+ - "*"
9
17
  schedule:
10
18
  - cron: "0 8 * * 5" # At 08:00 on Friday # https://crontab.guru/#0_8_*_*_5
11
- workflow_dispatch:
12
19
 
13
20
  jobs:
14
21
  test-unit:
15
22
  env:
16
23
  MAKEFLAGS: -j2
17
24
  strategy:
25
+ fail-fast: false
18
26
  matrix:
19
27
  platform: [ubuntu-latest, windows-latest]
20
- ruby: ["2.5", "2.6", "2.7", "3.0"]
28
+ ruby: ["2.3", "2.4", "2.5", "2.6", "2.7", "3.0", "head"]
21
29
  runs-on: ${{ matrix.platform }}
22
30
  steps:
23
31
  - name: configure git crlf on windows
@@ -38,6 +46,7 @@ jobs:
38
46
  env:
39
47
  MAKEFLAGS: -j2
40
48
  strategy:
49
+ fail-fast: false
41
50
  matrix:
42
51
  platform: [ubuntu-latest, windows-latest]
43
52
  ruby: ["3.0"]
data/CHANGELOG.md CHANGED
@@ -1,5 +1,49 @@
1
1
  ## mini_portile changelog
2
2
 
3
+ ### 2.7.1 / 2021-10-20
4
+
5
+ #### Packaging
6
+
7
+ A test artifact that has been included in the gem was being flagged by some users' security scanners because it wasn't a real tarball. That artifact has been updated to be a real tarball. [#108]
8
+
9
+
10
+ ### 2.7.0 / 2021-08-31
11
+
12
+ ### Added
13
+
14
+ The commands used for "make", "compile", and "cmake" are configurable via keyword arguments. [#107] (Thanks, @cosmo0920!)
15
+
16
+
17
+ ### 2.6.1 / 2021-05-31
18
+
19
+ #### Dependencies
20
+
21
+ Make `net-ftp` an optional dependency, since requiring it as a hard dependency in v2.5.2 caused warnings to be emitted by Ruby 2.7 and earlier. A warning message is emitted if FTP functionality is called and `net-ftp` isn't available; this should only happen in Ruby 3.1 and later.
22
+
23
+
24
+ ### 2.5.3 / 2021-05-31
25
+
26
+ #### Dependencies
27
+
28
+ Make `net-ftp` an optional dependency, since requiring it as a hard dependency in v2.5.2 caused warnings to be emitted by Ruby 2.7 and earlier. A warning message is emitted if FTP functionality is called and `net-ftp` isn't available; this should only happen in Ruby 3.1 and later.
29
+
30
+
31
+ ### 2.6.0 / 2021-05-31
32
+
33
+ ### Added
34
+
35
+ Recipes may build against a local directory by specifying `source_directory` instead of `files`. In
36
+ particular, this may be useful for debugging problems with the upstream dependency (e.g., use `git
37
+ bisect` in a local clone) or for continuous integration with upstream HEAD.
38
+
39
+
40
+ ### 2.5.2 / 2021-05-28
41
+
42
+ #### Dependencies
43
+
44
+ Add `net-ftp` as an explicit dependency to accommodate the upcoming Ruby 3.1 changes that move this and other gems out of the "default" gem set and into the "bundled" gem set. See https://bugs.ruby-lang.org/issues/17873 [#101]
45
+
46
+
3
47
  ### 2.5.1 / 2021-04-28
4
48
 
5
49
  #### Dependencies
data/Gemfile CHANGED
@@ -1,4 +1,6 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
+ gem "net-ftp" if Gem::Requirement.new("> 3.1.0.dev").satisfied_by?(Gem::Version.new(RUBY_VERSION))
4
+
3
5
  # Specify your gem's dependencies in mini_portile2.gemspec
4
6
  gemspec
data/README.md CHANGED
@@ -83,11 +83,72 @@ library into a namespaced structure.
83
83
  `#activate` ensures GCC will find this library and prefer it over a
84
84
  system-wide installation.
85
85
 
86
+ Some keyword arguments can be passed to the constructor to configure the commands used:
87
+
88
+ #### `gcc_command`
89
+
90
+ The compiler command that is used is configurable, and in order of preference will use:
91
+
92
+ - the `CC` environment variable (if present)
93
+ - the `gcc_command` value passed in to the constructor
94
+ - `RbConfig::CONFIG["CC"]`
95
+ - `"gcc"`
96
+
97
+ You can pass it in like so:
98
+
99
+ ``` ruby
100
+ MiniPortile.new("libiconv", "1.13.1", gcc_command: "cc")
101
+ ```
102
+
103
+ #### `make_command`
104
+
105
+ The configuration/make command that is used is configurable, and in order of preference will use:
106
+
107
+ - the `MAKE` environment variable (if present)
108
+ - the `make_command` value passed in to the constructor
109
+ - the `make` environment variable (if present)
110
+ - `"make"`
111
+
112
+ You can pass it in like so:
113
+
114
+ ``` ruby
115
+ MiniPortile.new("libiconv", "1.13.1", make_command: "nmake")
116
+ ```
117
+
86
118
 
87
119
  ### How to use (for cmake projects)
88
120
 
89
121
  Same as above, but instead of `MiniPortile.new`, call `MiniPortileCMake.new`.
90
122
 
123
+ #### `make_command`
124
+
125
+ This is configurable as above, except for Windows systems where it's hardcoded to `"nmake"`.
126
+
127
+ #### `cmake_command`
128
+
129
+ The cmake command used is configurable, and in order of preference will use:
130
+
131
+ - the `CMAKE` environment variable (if present)
132
+ - the `cmake_command` value passed in to the constructor
133
+ - `"cmake"`
134
+
135
+ You can pass it in like so:
136
+
137
+ ``` ruby
138
+ MiniPortileCMake.new("libfoobar", "1.3.5", cmake_command: "cmake3")
139
+ ```
140
+
141
+ ### Local source directories
142
+
143
+ Instead of downloading a remote file, you can also point mini_portile2 at a local source
144
+ directory. In particular, this may be useful for testing or debugging:
145
+
146
+ ``` ruby
147
+ gem "mini_portile2", "~> 2.0.0" # NECESSARY if used in extconf.rb. see below.
148
+ require "mini_portile2"
149
+ recipe = MiniPortile.new("libiconv", "1.13.1")
150
+ recipe.source_directory = "/path/to/local/source/for/library-1.2.3"
151
+ ```
91
152
 
92
153
  ### Directory Structure Conventions
93
154
 
@@ -1,7 +1,6 @@
1
1
  require 'rbconfig'
2
2
  require 'net/http'
3
3
  require 'net/https'
4
- require 'net/ftp'
5
4
  require 'fileutils'
6
5
  require 'tempfile'
7
6
  require 'digest'
@@ -31,7 +30,7 @@ end
31
30
  class MiniPortile
32
31
  attr_reader :name, :version, :original_host
33
32
  attr_writer :configure_options
34
- attr_accessor :host, :files, :patch_files, :target, :logger
33
+ attr_accessor :host, :files, :patch_files, :target, :logger, :source_directory
35
34
 
36
35
  def self.windows?
37
36
  RbConfig::CONFIG['target_os'] =~ /mswin|mingw/
@@ -47,7 +46,7 @@ class MiniPortile
47
46
  RbConfig::CONFIG['target_os'] =~ /mswin/
48
47
  end
49
48
 
50
- def initialize(name, version)
49
+ def initialize(name, version, **kwargs)
51
50
  @name = name
52
51
  @version = version
53
52
  @target = 'ports'
@@ -55,8 +54,23 @@ class MiniPortile
55
54
  @patch_files = []
56
55
  @log_files = {}
57
56
  @logger = STDOUT
57
+ @source_directory = nil
58
58
 
59
59
  @original_host = @host = detect_host
60
+
61
+ @gcc_command = kwargs[:gcc_command]
62
+ @make_command = kwargs[:make_command]
63
+ end
64
+
65
+ def source_directory=(path)
66
+ @source_directory = File.expand_path(path)
67
+ end
68
+
69
+ def prepare_build_directory
70
+ raise "source_directory is not set" if source_directory.nil?
71
+ output "Building #{@name} #{@version} from source at '#{source_directory}'"
72
+ FileUtils.mkdir_p(File.join(tmp_path, [name, version].join("-")))
73
+ FileUtils.rm_rf(port_path) # make sure we always re-install
60
74
  end
61
75
 
62
76
  def download
@@ -110,15 +124,16 @@ class MiniPortile
110
124
  def configure
111
125
  return if configured?
112
126
 
127
+ FileUtils.mkdir_p(tmp_path)
113
128
  cache_file = File.join(tmp_path, 'configure.options_cache')
114
129
  File.open(cache_file, "w") { |f| f.write computed_options.to_s }
115
130
 
131
+ command = Array(File.join((source_directory || "."), "configure"))
116
132
  if RUBY_PLATFORM=~/mingw|mswin/
117
133
  # Windows doesn't recognize the shebang.
118
- execute('configure', %w(sh ./configure) + computed_options)
119
- else
120
- execute('configure', %w(./configure) + computed_options)
134
+ command.unshift("sh")
121
135
  end
136
+ execute('configure', command + computed_options)
122
137
  end
123
138
 
124
139
  def compile
@@ -139,7 +154,7 @@ class MiniPortile
139
154
  end
140
155
 
141
156
  def configured?
142
- configure = File.join(work_path, 'configure')
157
+ configure = File.join((source_directory || work_path), 'configure')
143
158
  makefile = File.join(work_path, 'Makefile')
144
159
  cache_file = File.join(tmp_path, 'configure.options_cache')
145
160
 
@@ -157,9 +172,13 @@ class MiniPortile
157
172
  end
158
173
 
159
174
  def cook
160
- download unless downloaded?
161
- extract
162
- patch
175
+ if source_directory
176
+ prepare_build_directory
177
+ else
178
+ download unless downloaded?
179
+ extract
180
+ patch
181
+ end
163
182
  configure unless configured?
164
183
  compile
165
184
  install unless installed?
@@ -206,6 +225,14 @@ class MiniPortile
206
225
  File.expand_path(port_path)
207
226
  end
208
227
 
228
+ def gcc_cmd
229
+ (ENV["CC"] || @gcc_command || RbConfig::CONFIG["CC"] || "gcc").dup
230
+ end
231
+
232
+ def make_cmd
233
+ (ENV["MAKE"] || @make_command || ENV["make"] || "make").dup
234
+ end
235
+
209
236
  private
210
237
 
211
238
  def tmp_path
@@ -473,7 +500,6 @@ private
473
500
  def download_file_http(url, full_path, count = 3)
474
501
  filename = File.basename(full_path)
475
502
  with_tempfile(filename, full_path) do |temp_file|
476
- progress = 0
477
503
  total = 0
478
504
  params = {
479
505
  "Accept-Encoding" => 'identity',
@@ -482,7 +508,6 @@ private
482
508
  if total
483
509
  new_progress = (bytes * 100) / total
484
510
  message "\rDownloading %s (%3d%%) " % [filename, new_progress]
485
- progress = new_progress
486
511
  else
487
512
  # Content-Length is unavailable because Transfer-Encoding is chunked
488
513
  message "\rDownloading %s " % [filename]
@@ -530,16 +555,15 @@ private
530
555
  end
531
556
 
532
557
  def download_file_ftp(uri, full_path)
558
+ require "net/ftp"
533
559
  filename = File.basename(uri.path)
534
560
  with_tempfile(filename, full_path) do |temp_file|
535
- progress = 0
536
561
  total = 0
537
562
  params = {
538
563
  :content_length_proc => lambda{|length| total = length },
539
564
  :progress_proc => lambda{|bytes|
540
565
  new_progress = (bytes * 100) / total
541
566
  message "\rDownloading %s (%3d%%) " % [filename, new_progress]
542
- progress = new_progress
543
567
  }
544
568
  }
545
569
  if ENV["ftp_proxy"]
@@ -555,6 +579,8 @@ private
555
579
  end
556
580
  output
557
581
  end
582
+ rescue LoadError
583
+ raise LoadError, "Ruby #{RUBY_VERSION} does not provide the net-ftp gem, please add it as a dependency if you need to use FTP"
558
584
  rescue Net::FTPError
559
585
  return false
560
586
  end
@@ -568,14 +594,4 @@ private
568
594
  FileUtils.mkdir_p File.dirname(full_path)
569
595
  FileUtils.mv temp_file.path, full_path, :force => true
570
596
  end
571
-
572
- def gcc_cmd
573
- cc = ENV["CC"] || RbConfig::CONFIG["CC"] || "gcc"
574
- return cc.dup
575
- end
576
-
577
- def make_cmd
578
- m = ENV['MAKE'] || ENV['make'] || 'make'
579
- return m.dup
580
- end
581
597
  end
@@ -5,6 +5,11 @@ class MiniPortileCMake < MiniPortile
5
5
  "-DCMAKE_INSTALL_PREFIX=#{File.expand_path(port_path)}"
6
6
  end
7
7
 
8
+ def initialize(name, version, **kwargs)
9
+ super(name, version, **kwargs)
10
+ @cmake_command = kwargs[:cmake_command]
11
+ end
12
+
8
13
  def configure_defaults
9
14
  if MiniPortile.mswin?
10
15
  ['-G', 'NMake Makefiles']
@@ -21,7 +26,7 @@ class MiniPortileCMake < MiniPortile
21
26
  cache_file = File.join(tmp_path, 'configure.options_cache')
22
27
  File.open(cache_file, "w") { |f| f.write computed_options.to_s }
23
28
 
24
- execute('configure', %w(cmake) + computed_options + ["."])
29
+ execute('configure', [cmake_cmd] + computed_options + ["."])
25
30
  end
26
31
 
27
32
  def configured?
@@ -39,4 +44,8 @@ class MiniPortileCMake < MiniPortile
39
44
  return "nmake" if MiniPortile.mswin?
40
45
  super
41
46
  end
47
+
48
+ def cmake_cmd
49
+ (ENV["CMAKE"] || @cmake_command || "cmake").dup
50
+ end
42
51
  end
@@ -1,3 +1,3 @@
1
1
  class MiniPortile
2
- VERSION = "2.5.1"
2
+ VERSION = "2.7.1"
3
3
  end
@@ -31,12 +31,12 @@ Gem::Specification.new do |spec|
31
31
  spec.test_files = spec.files.grep(%r{^(test|spec|features|examples)/})
32
32
  spec.require_paths = ["lib"]
33
33
 
34
+ spec.required_ruby_version = ">= 2.3.0"
35
+
34
36
  spec.add_development_dependency "bundler", "~> 2.1"
35
37
  spec.add_development_dependency "minitar", "~> 0.7"
36
38
  spec.add_development_dependency "minitest", "~> 5.11"
37
39
  spec.add_development_dependency "minitest-hooks", "~> 1.5.0"
38
40
  spec.add_development_dependency "rake", "~> 13.0"
39
41
  spec.add_development_dependency "webrick", "~> 1.0"
40
-
41
- spec.required_ruby_version = ">= 2.3.0"
42
42
  end
data/test/helper.rb CHANGED
@@ -57,4 +57,20 @@ class TestCase < Minitest::Test
57
57
  ensure
58
58
  ENV['GIT_DIR'] = old
59
59
  end
60
+
61
+ def with_env(env)
62
+ before = ENV.to_h.dup
63
+ env.each { |k, v| ENV[k] = v }
64
+ yield
65
+ ensure
66
+ ENV.replace(before)
67
+ end
68
+
69
+ def without_env(*keys, &blk)
70
+ before = ENV.to_h.dup
71
+ keys.flatten.each { |k| ENV.delete(k) }
72
+ yield
73
+ ensure
74
+ ENV.replace(before)
75
+ end
60
76
  end
data/test/test_cmake.rb CHANGED
@@ -58,3 +58,33 @@ class TestCMake < TestCase
58
58
  assert File.exist?(binary), binary
59
59
  end
60
60
  end
61
+
62
+ class TestCMakeConfig < TestCase
63
+ def test_make_command_configuration
64
+ MiniPortile.stub(:mswin?, false) do
65
+ without_env("MAKE") do
66
+ assert_equal("make", MiniPortileCMake.new("test", "1.0.0").make_cmd)
67
+ assert_equal("xyzzy", MiniPortileCMake.new("test", "1.0.0", make_command: "xyzzy").make_cmd)
68
+ end
69
+ with_env("MAKE"=>"asdf") do
70
+ assert_equal("asdf", MiniPortileCMake.new("test", "1.0.0").make_cmd)
71
+ assert_equal("asdf", MiniPortileCMake.new("test", "1.0.0", make_command: "xyzzy").make_cmd)
72
+ end
73
+ end
74
+
75
+ MiniPortile.stub(:mswin?, true) do
76
+ assert_equal("nmake", MiniPortileCMake.new("test", "1.0.0").make_cmd)
77
+ end
78
+ end
79
+
80
+ def test_cmake_command_configuration
81
+ without_env("CMAKE") do
82
+ assert_equal("cmake", MiniPortileCMake.new("test", "1.0.0").cmake_cmd)
83
+ assert_equal("xyzzy", MiniPortileCMake.new("test", "1.0.0", cmake_command: "xyzzy").cmake_cmd)
84
+ end
85
+ with_env("CMAKE"=>"asdf") do
86
+ assert_equal("asdf", MiniPortileCMake.new("test", "1.0.0").cmake_cmd)
87
+ assert_equal("asdf", MiniPortileCMake.new("test", "1.0.0", cmake_command: "xyzzy").cmake_cmd)
88
+ end
89
+ end
90
+ end
data/test/test_cook.rb CHANGED
@@ -67,6 +67,32 @@ class TestCook < TestCase
67
67
  end
68
68
  end
69
69
 
70
+ class TestCookConfiguration < TestCase
71
+ def test_make_command_configuration
72
+ without_env("MAKE") do
73
+ assert_equal("make", MiniPortile.new("test", "1.0.0").make_cmd)
74
+ assert_equal("xyzzy", MiniPortile.new("test", "1.0.0", make_command: "xyzzy").make_cmd)
75
+ end
76
+ with_env("MAKE"=>"asdf") do
77
+ assert_equal("asdf", MiniPortile.new("test", "1.0.0").make_cmd)
78
+ assert_equal("asdf", MiniPortile.new("test", "1.0.0", make_command: "xyzzy").make_cmd)
79
+ end
80
+ end
81
+
82
+ def test_gcc_command_configuration
83
+ without_env("CC") do
84
+ expected_compiler = RbConfig::CONFIG["CC"] || "gcc"
85
+ assert_equal(expected_compiler, MiniPortile.new("test", "1.0.0").gcc_cmd)
86
+ assert_equal("xyzzy", MiniPortile.new("test", "1.0.0", gcc_command: "xyzzy").gcc_cmd)
87
+ end
88
+ with_env("CC"=>"asdf") do
89
+ assert_equal("asdf", MiniPortile.new("test", "1.0.0").gcc_cmd)
90
+ assert_equal("asdf", MiniPortile.new("test", "1.0.0", gcc_command: "xyzzy").gcc_cmd)
91
+ end
92
+ end
93
+ end
94
+
95
+
70
96
  class TestCookWithBrokenGitDir < TestCase
71
97
  #
72
98
  # this is a test for #69
@@ -113,3 +139,32 @@ class TestCookWithBrokenGitDir < TestCase
113
139
  end
114
140
  end
115
141
  end
142
+
143
+ class TestCookAgainstSourceDirectory < TestCase
144
+ attr_accessor :recipe
145
+
146
+ def setup
147
+ super
148
+
149
+ @recipe ||= MiniPortile.new("test mini portile", "1.0.0").tap do |recipe|
150
+ recipe.source_directory = File.expand_path("../assets/test mini portile-1.0.0", __FILE__)
151
+ end
152
+ end
153
+
154
+ def test_source_directory
155
+ recipe.cook
156
+
157
+ path = File.join(work_dir, "configure.txt")
158
+ assert(File.exist?(path))
159
+ assert_equal((recipe.configure_options + ["--prefix=#{recipe.path}"]).inspect,
160
+ File.read(path).chomp);
161
+
162
+ path = File.join(work_dir, "compile.txt")
163
+ assert(File.exist?(path))
164
+ assert_equal("[\"all\"]", File.read(path).chomp);
165
+
166
+ path = File.join(work_dir, "install.txt")
167
+ assert(File.exist?(path))
168
+ assert_equal("[\"install\"]", File.read(path).chomp);
169
+ end
170
+ end
@@ -18,10 +18,12 @@ describe "recipe download" do
18
18
  end
19
19
  end
20
20
 
21
- block.call
22
-
23
- thread.kill
24
- server.close
21
+ begin
22
+ block.call
23
+ ensure
24
+ thread.kill
25
+ server.close
26
+ end
25
27
 
26
28
  request_count.must_be :>, 0
27
29
  end
@@ -60,7 +62,7 @@ describe "recipe download" do
60
62
  @recipe.files << "file://#{path}"
61
63
  @recipe.download
62
64
  assert File.exist?(dest)
63
- Digest::MD5.file(dest).hexdigest.must_equal "5deffb997041bbb5f11bdcafdbb47975"
65
+ Digest::MD5.file(dest).hexdigest.must_equal "ee0e9f44e72213015ef976d5ac23931d"
64
66
  end
65
67
 
66
68
  it "other" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mini_portile2
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.1
4
+ version: 2.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luis Lavena
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2021-04-28 00:00:00.000000000 Z
13
+ date: 2021-10-20 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler
@@ -153,7 +153,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
153
153
  - !ruby/object:Gem::Version
154
154
  version: '0'
155
155
  requirements: []
156
- rubygems_version: 3.1.4
156
+ rubygems_version: 3.2.22
157
157
  signing_key:
158
158
  specification_version: 4
159
159
  summary: Simplistic port-like solution for developers