pngcheck 0.2.5-x86_64-darwin → 0.2.7-x86_64-darwin

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: 6ef6b5400dda798aa679ae92fc2d815eb5e5331dd5fb5a9c0a5ef3e928bfeef8
4
- data.tar.gz: 20f435518b35ee7de06b74dbe82da2b455993341c5c95a112c76dc5ddf920df0
3
+ metadata.gz: 1de5186d209d74838d4f546594e1741748a0c7adc6c67e5b819e7e0e0d5eba8b
4
+ data.tar.gz: b31022f4fcb4fa51e4c885b52333889b95bbf0752b273f22963cf79aac65c229
5
5
  SHA512:
6
- metadata.gz: b92367c4009e877e1ad8d27501b0377c506c4d58a904f75ab427bcc1c2fa763e3b3e3b49dbd667c128cdd1253f47a4037ace5e3889c03ac56a032968597088c6
7
- data.tar.gz: 956795e0fe1c16f5fb8c01c49ef9bd81decffda368de047affc8aebef4e11a641b9ee583ba61c85cd73bbb8883382a6adc20c19cea240f5d07ca1c0833ac3032
6
+ metadata.gz: 3639117bd7bef8f51fcc8ae70ae68c1669b4802732bce03b2cc19c7eca05f45ed7d50dbf8ddc8cc1b6880da3afc56ca503611e1a1d956be69762e70f15daa516
7
+ data.tar.gz: e6f0410c1bab664e049707e747a45a468d6e43752694094ffd570a8e7061e49e3251008ff3396ce132502810993c614907e1f716b4f18efeb348a7aea75200f7
data/Rakefile CHANGED
@@ -3,6 +3,7 @@
3
3
  require "bundler/gem_tasks"
4
4
  require "rspec/core/rake_task"
5
5
  require "rubocop/rake_task"
6
+ require_relative "ext/layout"
6
7
 
7
8
  RSpec::Core::RakeTask.new(:spec)
8
9
  RuboCop::RakeTask.new
@@ -20,14 +21,24 @@ task "gem:native:any" do
20
21
  sh "rake platform:any gem"
21
22
  end
22
23
 
24
+ desc "Download pngcheck source"
25
+ task :pngcheck do
26
+ test_cmd = "test -f #{PNGCHECK_LOCAL}"
27
+ wget_cmd = "wget -nc -nv -O #{PNGCHECK_LOCAL} #{PNGCHECK_URI}"
28
+ sh "#{test_cmd} || #{wget_cmd}"
29
+ end
30
+ task compile: :pngcheck
31
+
23
32
  require "rubygems/package_task"
24
33
 
25
34
  desc "Define the gem task to build on any platform (compile on install)"
26
35
  task "platform:any" do
27
36
  spec = Gem::Specification::load("pngcheck.gemspec").dup
37
+ spec.files << PNGCHECK_LOCAL
28
38
  task = Gem::PackageTask.new(spec)
29
39
  task.define
30
40
  end
41
+ task "gem:native:any": :pngcheck
31
42
 
32
43
  File.readlines(".cross_rubies", chomp: true).each do |platform|
33
44
  desc "Build pre-compiled gem for the #{platform} platform"
@@ -53,6 +64,7 @@ require "rake/clean"
53
64
  CLOBBER.include("pkg")
54
65
  CLEAN.include("ports",
55
66
  "tmp",
67
+ PNGCHECK_LOCAL,
56
68
  "lib/pngcheck/*.dll",
57
69
  "lib/pngcheck/*.dylib",
58
70
  "lib/pngcheck/*.so")
data/ext/layout.rb ADDED
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ PNGCHECK_ARCH = "pngcheck-3.0.3.tar.gz"
4
+ PNGCHECK_URI = "http://www.libpng.org/pub/png/src/#{PNGCHECK_ARCH}"
5
+ PNGCHECK_LOCAL = "ext/#{PNGCHECK_ARCH}"
@@ -8,17 +8,23 @@ require "shellwords"
8
8
  require "open3"
9
9
  require_relative "version"
10
10
 
11
+ ROOT = Pathname.new(File.expand_path("../..", __dir__))
12
+ require "#{ROOT}/ext/layout.rb"
13
+
11
14
  module PngCheck
12
15
  class Recipe < MiniPortile
13
- ROOT = Pathname.new(File.expand_path("../..", __dir__))
14
16
  COMMON_FLAGS = "-shared -fPIC -Wall -O -DUSE_ZLIB"
15
17
 
16
- def files_to_load
18
+ def files_to_load_all
17
19
  @files << {
18
- url: "http://www.libpng.org/pub/png/src/pngcheck-3.0.3.tar.gz",
20
+ url: "file:#{ROOT}/#{PNGCHECK_LOCAL}", # "http://www.libpng.org/pub/png/src/pngcheck-3.0.3.tar.gz"
19
21
  sha256: "c36a4491634af751f7798ea421321642f9590faa032eccb0dd5fb4533609dee6", # rubocop:disable Layout/LineLength
20
22
  }
21
- if target_platform.eql?("aarch64-linux")
23
+ end
24
+
25
+ def files_to_load_cross
26
+ if target_platform.eql?("aarch64-linux") &&
27
+ !host_platform.eql?("aarch64-linux")
22
28
  @files << {
23
29
  url: "http://ports.ubuntu.com/pool/main/z/zlib/zlib1g-dev_1.2.11.dfsg-2ubuntu1.3_arm64.deb", # rubocop:disable Layout/LineLength
24
30
  sha256: "0ebadc1ff2a70f0958d4e8e21ffa97d9fa4da23555eaae87782e963044a26fcf", # rubocop:disable Layout/LineLength
@@ -28,17 +34,27 @@ module PngCheck
28
34
 
29
35
  def initialize
30
36
  super("pngcheck", "3.0.3")
31
- files_to_load
37
+ files_to_load_all
38
+ files_to_load_cross
32
39
  @target = ROOT.join(@target).to_s
33
40
  @printed = {}
34
41
  end
35
42
 
43
+ def lib_filename
44
+ @lib_filename ||=
45
+ if MiniPortile.windows?
46
+ "pngcheck.dll"
47
+ else
48
+ "pngcheck.so"
49
+ end
50
+ end
51
+
52
+ def lib_workpath
53
+ @lib_workpath ||= File.join(work_path, lib_filename)
54
+ end
55
+
36
56
  def make_cmd
37
- if MiniPortile.windows?
38
- "gcc #{COMMON_FLAGS} -o pngcheck.dll wrapper.c -lz"
39
- else
40
- "#{cc} #{cflags} #{COMMON_FLAGS} -o pngcheck.so wrapper.c -lz"
41
- end
57
+ "#{cc} #{cflags} #{COMMON_FLAGS} -o #{lib_filename} wrapper.c -lz"
42
58
  end
43
59
 
44
60
  def cook_if_not
@@ -50,35 +66,40 @@ module PngCheck
50
66
  FileUtils.touch(checkpoint)
51
67
  end
52
68
 
69
+ def download_file_file(uri, full_path)
70
+ if MiniPortile.windows?
71
+ FileUtils.mkdir_p File.dirname(full_path)
72
+ FileUtils.cp uri.to_s.delete_prefix("file:"), full_path
73
+ else
74
+ super
75
+ end
76
+ end
77
+
53
78
  def checkpoint
54
79
  File.join(@target, "#{name}-#{version}-#{host}.installed")
55
80
  end
56
81
 
57
82
  def configure
58
83
  FileUtils.cp(ROOT.join("ext", "wrapper.c"), work_path, verbose: false)
59
- if target_platform.eql?("aarch64-linux")
84
+ if target_platform.eql?("aarch64-linux") &&
85
+ !host_platform.eql?("aarch64-linux")
60
86
  extract_file("#{work_path}/../data.tar.xz", work_path.to_s)
61
87
  end
62
88
  end
63
89
 
64
- def libs_to_verify
65
- Dir.glob(ROOT.join("lib", "pngcheck",
66
- "pngcheck.{so,dylib,dll}"))
67
- end
68
-
69
- def verify_libs
70
- libs_to_verify.each do |l|
71
- out, st = Open3.capture2("file #{l}")
72
- out = out.strip
73
-
74
- raise "Failed to query file #{l}: #{out}" unless st.exitstatus.zero?
90
+ def verify_lib
91
+ begin
92
+ out, = Open3.capture2("file #{lib_workpath}")
93
+ rescue StandardError
94
+ message("Failed to call file, skipped library verification ...\n")
95
+ return
96
+ end
75
97
 
76
- if out.include?(target_format)
77
- message("Verifying #{l} ... OK\n")
78
- else
79
- raise "Invalid file format '#{out}', '#{@target_format}' expected"
80
- end
98
+ unless out.include?(target_format)
99
+ raise "Invalid file format '#{out.strip}', '#{@target_format}' expected"
81
100
  end
101
+
102
+ message("Verifying #{lib_workpath} ... OK\n")
82
103
  end
83
104
 
84
105
  def install
@@ -86,7 +107,7 @@ module PngCheck
86
107
  .grep(%r{/(?:lib)?[a-zA-Z0-9\-]+\.(?:so|dylib|dll)$})
87
108
 
88
109
  FileUtils.cp_r(libs, ROOT.join("lib", "pngcheck"), verbose: false)
89
- verify_libs
110
+ verify_lib
90
111
  end
91
112
 
92
113
  def execute(action, command, command_opts = {})
@@ -174,11 +195,11 @@ module PngCheck
174
195
 
175
196
  def cflags
176
197
  @cflags ||=
177
- if target_platform.eql?(host_platform) ||
178
- !target_platform.eql?("aarch64-linux")
179
- ""
180
- else
198
+ if target_platform.eql?("aarch64-linux") &&
199
+ !host_platform.eql?("aarch64-linux")
181
200
  "-I./usr/include -L./usr/lib/#{target_platform}-gnu"
201
+ else
202
+ ""
182
203
  end
183
204
  end
184
205
  # rubocop:enable Metrics/CyclomaticComplexity
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PngCheck
4
- VERSION = "0.2.5"
4
+ VERSION = "0.2.7"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pngcheck
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.2.7
5
5
  platform: x86_64-darwin
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-09-13 00:00:00.000000000 Z
11
+ date: 2022-09-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi
@@ -101,6 +101,7 @@ files:
101
101
  - bin/setup
102
102
  - ext/Makefile
103
103
  - ext/extconf.rb
104
+ - ext/layout.rb
104
105
  - ext/wrapper.c
105
106
  - lib/pngcheck.rb
106
107
  - lib/pngcheck/pngcheck.so