ffi-libarchive-binary 0.2.6-x64-mingw-ucrt

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: ab68f6e19d2bcda02d6a7b654c390f2eb3006ffc738545671bb9a4552030f5b4
4
+ data.tar.gz: bf88f9194954322e2ae3fae9b7ee5d77fc786eb2eec7ce1c9440d22a42c6f999
5
+ SHA512:
6
+ metadata.gz: dec33e11a21bc92fb77eeb67c3b823d96a98843b5b6c6f12a3a5a7f1e5d1442e7571cd86162468610356ba5e705fd4cb587deb1a4199459d7a9ca086e356a55d
7
+ data.tar.gz: 574d9085d407aed3dc3887922ec666e4ee1014306a901593a65c67654933c3b02e9e2a894049363bd576bb48bc7b4078ee64585831f1d32afbac5ff9752cf799
data/.gitignore ADDED
@@ -0,0 +1,15 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ Gemfile.lock
10
+ *.installed
11
+ ports/
12
+ vendor/
13
+ *.dll
14
+ *.dylib
15
+ *.so
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --require spec_helper
data/Gemfile ADDED
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gemspec
6
+
7
+ gem "gem-release"
8
+
9
+ gem "mini_portile2", "~> 2.0"
10
+ gem "rake", "~> 13.0"
11
+ gem "rspec", "~> 3.0"
data/README.adoc ADDED
@@ -0,0 +1,115 @@
1
+ = Binaries for ffi-libarchive
2
+
3
+ image:https://img.shields.io/gem/v/ffi-libarchive-binary.svg["Gem Version", link="https://rubygems.org/gems/ffi-libarchive-binary"]
4
+ image:https://github.com/fontist/ffi-libarchive-binary/actions/workflows/rspec.yml/badge.svg["Build Status", link="https://github.com/fontist/ffi-libarchive-binary/actions/workflows/rspec.yml"]
5
+
6
+ == Purpose
7
+
8
+ Contains pre-compiled and install-time-compiled binaries for ffi-libarchive.
9
+
10
+
11
+ == Installation
12
+
13
+ Add this line to your application's Gemfile:
14
+
15
+ [source,ruby]
16
+ ----
17
+ gem "ffi-libarchive-binary"
18
+ ----
19
+
20
+ And then execute:
21
+
22
+ [source,sh]
23
+ ----
24
+ $ bundle install
25
+ ----
26
+
27
+ Or install it yourself as:
28
+
29
+ [source,sh]
30
+ ----
31
+ $ gem install ffi-libarchive-binary
32
+ ----
33
+
34
+
35
+ == Usage
36
+
37
+ Require the gem and use calls from https://github.com/chef/ffi-libarchive[ffi-libarchive].
38
+
39
+ [source,ruby]
40
+ ----
41
+ require "ffi-libarchive-binary"
42
+
43
+ path = File.expand_path('file.pkg', __dir__)
44
+ flags = Archive::EXTRACT_PERM
45
+ reader = Archive::Reader.open_filename(path)
46
+
47
+ reader.each_entry do |entry|
48
+ reader.extract(entry, flags.to_i)
49
+ end
50
+
51
+ reader.close
52
+ ----
53
+
54
+
55
+ == Dependencies
56
+
57
+ * zlib
58
+ * Expat
59
+ * OpenSSL (for Linux only)
60
+
61
+ These dependencies are generally present on all systems.
62
+
63
+
64
+ == Development
65
+
66
+ We are following Sandi Metz's Rules for this gem, you can read the
67
+ http://robots.thoughtbot.com/post/50655960596/sandi-metz-rules-for-developers[description of the rules here].
68
+ All new code should follow these
69
+ rules. If you make changes in a pre-existing file that violates these rules you
70
+ should fix the violations as part of your contribution.
71
+
72
+
73
+ == Releasing
74
+
75
+ Releasing is done automatically with GitHub Action. Just bump and tag with `gem-release`.
76
+
77
+ For a patch release (0.0.x) use:
78
+
79
+ [source,ruby]
80
+ ----
81
+ gem bump --version patch --tag --push
82
+ ----
83
+
84
+ For a minor release (0.x.0) use:
85
+
86
+ [source,ruby]
87
+ ----
88
+ gem bump --version minor --tag --push
89
+ ----
90
+
91
+
92
+ == Contributing
93
+
94
+ First, thank you for contributing! We love pull requests from everyone. By
95
+ participating in this project, you hereby grant https://www.ribose.com[Ribose Inc.] the
96
+ right to grant or transfer an unlimited number of non exclusive licenses or
97
+ sub-licenses to third parties, under the copyright covering the contribution
98
+ to use the contribution by all means.
99
+
100
+ Here are a few technical guidelines to follow:
101
+
102
+ 1. Open an https://github.com/fontist/ffi-libarchive-binary/issues[issue] to discuss a new feature.
103
+ 1. Write tests to support your new feature.
104
+ 1. Make sure the entire test suite passes locally and on CI.
105
+ 1. Open a Pull Request.
106
+ 1. https://github.com/thoughtbot/guides/tree/master/protocol/git#write-a-feature[Squash your commits]
107
+ after receiving feedback.
108
+ 1. Party!
109
+
110
+
111
+ == License
112
+
113
+ This gem is distributed with a BSD 3-Clause license.
114
+
115
+ This gem is developed, maintained and funded by https://www.ribose.com/[Ribose Inc.]
data/Rakefile ADDED
@@ -0,0 +1,66 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rake/clean"
4
+ require "rubygems/package_task"
5
+ require_relative "lib/ffi-libarchive-binary/libarchive_recipe"
6
+
7
+ desc "Build install-compilation gem"
8
+ task "gem:native:any" do
9
+ sh "rake platform:any gem"
10
+ end
11
+
12
+ desc "Define the gem task to build on any platform (compile on install)"
13
+ task "platform:any" do
14
+ spec = Gem::Specification::load("ffi-libarchive-binary.gemspec").dup
15
+ task = Gem::PackageTask.new(spec)
16
+ task.define
17
+ end
18
+
19
+ platforms = [
20
+ ["x86-mingw32", "i686-w64-mingw32", "libarchive-13.dll"],
21
+ ["x64-mingw32", "x86_64-w64-mingw32", "libarchive-13.dll"],
22
+ ["x64-mingw-ucrt", "x86_64-w64-mingw32", "libarchive-13.dll"],
23
+ ["x86-linux", "i686-linux-gnu", "libarchive.so"],
24
+ ["x86_64-linux", "x86_64-linux-gnu", "libarchive.so"],
25
+ ["x86_64-darwin", "x86_64-darwin", "libarchive.dylib"],
26
+ ["arm64-darwin", "arm64-darwin", "libarchive.dylib"],
27
+ ]
28
+
29
+ platforms.each do |platform, host, lib|
30
+ desc "Build pre-compiled gem for the #{platform} platform"
31
+ task "gem:native:#{platform}" do
32
+ sh "rake compile[#{host}] platform:#{platform} gem"
33
+ end
34
+
35
+ desc "Define the gem task to build on the #{platform} platform (binary gem)"
36
+ task "platform:#{platform}" do
37
+ spec = Gem::Specification::load("ffi-libarchive-binary.gemspec").dup
38
+ spec.platform = Gem::Platform.new(platform)
39
+ spec.files += ["lib/ffi-libarchive-binary/#{lib}"]
40
+ spec.extensions = []
41
+ spec.dependencies.reject! { |d| d.name == "mini_portile2" }
42
+
43
+ task = Gem::PackageTask.new(spec)
44
+ task.define
45
+ end
46
+ end
47
+
48
+ desc "Compile binary for the target host"
49
+ task :compile, [:host] do |_t, args|
50
+ recipe = LibarchiveBinary::LibarchiveRecipe.new
51
+ recipe.host = args[:host] if args[:host]
52
+ recipe.cook_if_not
53
+ end
54
+
55
+ desc "Recompile binary"
56
+ task :recompile do
57
+ recipe = LibarchiveBinary::LibarchiveRecipe.new
58
+ recipe.cook
59
+ end
60
+
61
+ CLOBBER.include("pkg")
62
+ CLEAN.include("ports",
63
+ "tmp",
64
+ "lib/ffi-libarchive-binary/libarchive-13.dll",
65
+ "lib/ffi-libarchive-binary/libarchive.dylib",
66
+ "lib/ffi-libarchive-binary/libarchive.so")
data/ext/Makefile ADDED
@@ -0,0 +1,4 @@
1
+ # dummy Makefile, it is required to build an extension
2
+ all:
3
+ clean:
4
+ install:
data/ext/extconf.rb ADDED
@@ -0,0 +1,6 @@
1
+ $: << File.expand_path(File.join(File.dirname(__FILE__), "../lib"))
2
+
3
+ require "ffi-libarchive-binary/libarchive_recipe"
4
+
5
+ recipe = LibarchiveBinary::LibarchiveRecipe.new
6
+ recipe.cook_if_not
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ $: << File.expand_path("lib", __dir__)
4
+ require "ffi-libarchive-binary/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "ffi-libarchive-binary"
8
+ spec.version = LibarchiveBinary::VERSION
9
+ spec.authors = ["Ribose Inc."]
10
+ spec.email = ["open.source@ribose.com"]
11
+
12
+ spec.summary = "Binaries for ffi-libarchive"
13
+ spec.description = "Contains pre-compiled and install-time-compiled binaries for ffi-libarchive"
14
+ spec.homepage = "https://github.com/fontist/ffi-libarchive-binary"
15
+ spec.license = "BSD-3-Clause"
16
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.4.0")
17
+
18
+ spec.metadata["homepage_uri"] = spec.homepage
19
+ spec.metadata["source_code_uri"] = "https://github.com/fontist/ffi-libarchive-binary"
20
+ spec.metadata["changelog_uri"] = "https://github.com/fontist/ffi-libarchive-binary"
21
+
22
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
23
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features|bin|.github)/}) }
24
+ end
25
+ spec.bindir = "exe"
26
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
27
+ spec.require_paths = ["lib"]
28
+ spec.extensions = ['ext/extconf.rb']
29
+
30
+ spec.add_runtime_dependency "ffi-libarchive", "~> 1.0"
31
+ spec.add_runtime_dependency "mini_portile2", "~> 2.0"
32
+ end
@@ -0,0 +1,119 @@
1
+ require "mini_portile2"
2
+ require "pathname"
3
+
4
+ require_relative "zlib_recipe"
5
+ require_relative "libexpat_recipe"
6
+
7
+ module LibarchiveBinary
8
+ class LibarchiveRecipe < MiniPortile
9
+ ROOT = Pathname.new(File.expand_path("../..", __dir__))
10
+
11
+ def initialize
12
+ super("libarchive", "3.5.1")
13
+
14
+ @files << {
15
+ url: "https://www.libarchive.org/downloads/libarchive-3.5.1.tar.gz",
16
+ sha256: "9015d109ec00bb9ae1a384b172bf2fc1dff41e2c66e5a9eeddf933af9db37f5a"
17
+ }
18
+
19
+ @zlib_recipe = ZLibRecipe.new
20
+ @expat_recipe = LibexpatRecipe.new
21
+
22
+ @target = ROOT.join(@target).to_s
23
+ end
24
+
25
+ def configure_defaults
26
+ [
27
+ "--host=#{@host}",
28
+ "--disable-bsdtar",
29
+ "--disable-bsdcat",
30
+ "--disable-bsdcpio",
31
+ "--without-bz2lib",
32
+ "--without-libb2",
33
+ "--without-iconv",
34
+ "--without-lz4",
35
+ "--without-zstd",
36
+ "--without-lzma",
37
+ "--without-cng",
38
+ "--without-xml2",
39
+ "--with-expat",
40
+ "--with-openssl",
41
+ "--disable-acl",
42
+ ]
43
+ end
44
+
45
+ def configure
46
+ paths = [@zlib_recipe.path, @expat_recipe.path]
47
+ cflags = paths.map { |k| "-I#{k}/include" }.join(" ")
48
+ cmd = ["env", "CFLAGS=#{cflags}", "./configure"] + computed_options
49
+
50
+ execute("configure", cmd)
51
+
52
+ # drop default libexpat and zlib
53
+ libz = File.join(@zlib_recipe.path, "lib", "libz.a")
54
+ libexpat = File.join(@expat_recipe.path, "lib", "libexpat.a")
55
+
56
+ if LibarchiveBinary::windows?
57
+ # https://stackoverflow.com/a/14112368/902217
58
+ static_link_pref = "-Wl,-Bstatic,"
59
+ libz = libz.prepend(static_link_pref)
60
+ libexpat = libexpat.prepend(static_link_pref)
61
+ end
62
+
63
+ makefile = File.join(work_path, "Makefile")
64
+ replace_in_file(" -lz ", " #{libz} ", makefile)
65
+ replace_in_file(" -lexpat ", " #{libexpat} ", makefile)
66
+ end
67
+
68
+ def replace_in_file(search_str, replace_str, filename)
69
+ puts "Replace \"#{search_str}\" with \"#{replace_str}\" in #{filename}"
70
+
71
+ f = File.open(filename, "r")
72
+ content = f.read
73
+ f.close
74
+
75
+ content.gsub!(search_str, replace_str)
76
+
77
+ File.open(filename, "w") { |f| f << content }
78
+ end
79
+
80
+ def activate
81
+ @zlib_recipe.activate
82
+ @expat_recipe.activate
83
+
84
+ super
85
+ end
86
+
87
+ def cook_if_not
88
+ cook unless File.exist?(checkpoint)
89
+ end
90
+
91
+ def cook
92
+ @zlib_recipe.cook_if_not
93
+ @expat_recipe.cook_if_not
94
+
95
+ super
96
+
97
+ FileUtils.touch(checkpoint)
98
+ end
99
+
100
+ def checkpoint
101
+ File.join(@target, "#{self.name}-#{self.version}-#{self.host}.installed")
102
+ end
103
+
104
+ def patch
105
+ super
106
+
107
+ FileUtils.cp(Dir.glob(ROOT.join("updates", "config.*").to_s),
108
+ File.join(work_path, "build", "autoconf"))
109
+ end
110
+
111
+ def install
112
+ super
113
+
114
+ libs = Dir.glob(File.join(port_path, "{lib,bin}", "*"))
115
+ .grep(/\/(?:lib)?[a-zA-Z0-9\-]+\.(?:so|dylib|dll)$/)
116
+ FileUtils.cp_r(libs, ROOT.join("lib", "ffi-libarchive-binary"), verbose: true)
117
+ end
118
+ end
119
+ end
@@ -0,0 +1,46 @@
1
+ require "mini_portile2"
2
+
3
+ module LibarchiveBinary
4
+ # based on
5
+ class LibexpatRecipe < MiniPortile
6
+ ROOT = Pathname.new(File.expand_path("../..", __dir__))
7
+
8
+ def initialize
9
+ super("libexpat", "2.4.1")
10
+
11
+ @files << {
12
+ url: "https://github.com/libexpat/libexpat/releases/download/R_2_4_1/expat-2.4.1.tar.gz",
13
+ sha256: "a00ae8a6b96b63a3910ddc1100b1a7ef50dc26dceb65ced18ded31ab392f132b"
14
+ }
15
+
16
+ @target = ROOT.join(@target).to_s
17
+ end
18
+
19
+ def configure_defaults
20
+ [
21
+ "--host=#{@host}",
22
+ "--disable-shared",
23
+ "--enable-static",
24
+ ]
25
+ end
26
+
27
+ def configure
28
+ cmd = ["env", "CFLAGS=-fPIC", "LDFLAGS=-fPIC", "./configure"] + computed_options
29
+ execute("configure", cmd)
30
+ end
31
+
32
+ def checkpoint
33
+ File.join(@target, "#{self.name}-#{self.version}-#{self.host}.installed")
34
+ end
35
+
36
+ def cook_if_not
37
+ cook unless File.exist?(checkpoint)
38
+ end
39
+
40
+ def cook
41
+ super
42
+
43
+ FileUtils.touch(checkpoint)
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module LibarchiveBinary
4
+ VERSION = "0.2.6"
5
+ end
@@ -0,0 +1,89 @@
1
+ require "mini_portile2"
2
+ require "pathname"
3
+
4
+ module LibarchiveBinary
5
+ def self.windows?
6
+ RbConfig::CONFIG["target_os"] =~ /mingw32|mswin/
7
+ end
8
+
9
+ # inspired by https://github.com/sparklemotion/nokogiri/blob/35823bd/ext/nokogiri/extconf.rb#L655
10
+ class ZLibRecipe < MiniPortile
11
+ ROOT = Pathname.new(File.expand_path("../..", __dir__))
12
+
13
+ def initialize
14
+ super("zlib", "1.2.11")
15
+
16
+ @files << {
17
+ url: "http://zlib.net/fossils/zlib-1.2.11.tar.gz",
18
+ sha256: "c3e5e9fdd5004dcb542feda5ee4f0ff0744628baf8ed2dd5d66f8ca1197cb1a1"
19
+ }
20
+
21
+ @target = ROOT.join(@target).to_s
22
+ end
23
+
24
+ def configure_defaults
25
+ [
26
+ "--static"
27
+ ]
28
+ end
29
+
30
+ def configure
31
+ if LibarchiveBinary::windows?
32
+ Dir.chdir(work_path) do
33
+ mk = File.read("win32/Makefile.gcc")
34
+ File.open("win32/Makefile.gcc", "wb") do |f|
35
+ f.puts "BINARY_PATH = #{path}/bin"
36
+ f.puts "LIBRARY_PATH = #{path}/lib"
37
+ f.puts "INCLUDE_PATH = #{path}/include"
38
+ f.puts "SHARED_MODE = 0"
39
+ f.puts "LOC = -fPIC"
40
+ f.puts mk
41
+ end
42
+ end
43
+ else
44
+ cmd = ["env", "CFLAGS=-fPIC", "LDFLAGS=-fPIC", "./configure"] + computed_options
45
+ execute("configure", cmd)
46
+ end
47
+ end
48
+
49
+ def configured?
50
+ if LibarchiveBinary::windows?
51
+ Dir.chdir(work_path) do
52
+ !!(File.read("win32/Makefile.gcc") =~ /^BINARY_PATH/)
53
+ end
54
+ else
55
+ super
56
+ end
57
+ end
58
+
59
+ def compile
60
+ if LibarchiveBinary::windows?
61
+ execute("compile", "make -f win32/Makefile.gcc libz.a")
62
+ else
63
+ super
64
+ end
65
+ end
66
+
67
+ def install
68
+ if LibarchiveBinary::windows?
69
+ execute("install", "make -f win32/Makefile.gcc install")
70
+ else
71
+ super
72
+ end
73
+ end
74
+
75
+ def checkpoint
76
+ File.join(@target, "#{self.name}-#{self.version}-#{self.host}.installed")
77
+ end
78
+
79
+ def cook_if_not
80
+ cook unless File.exist?(checkpoint)
81
+ end
82
+
83
+ def cook
84
+ super
85
+
86
+ FileUtils.touch(checkpoint)
87
+ end
88
+ end
89
+ end
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "ffi-libarchive-binary/version"
4
+ require "pathname"
5
+
6
+ module LibarchiveBinary
7
+ class Error < StandardError; end
8
+
9
+ LIBRARY_PATH = Pathname.new(File.join(__dir__, "ffi-libarchive-binary"))
10
+
11
+ def self.lib_path
12
+ LIBRARY_PATH.join(lib_filename).to_s
13
+ end
14
+
15
+ def self.lib_filename
16
+ if FFI::Platform.windows?
17
+ "libarchive-13.dll"
18
+ elsif FFI::Platform.mac?
19
+ "libarchive.dylib"
20
+ else
21
+ "libarchive.so"
22
+ end
23
+ end
24
+ end
25
+
26
+ module Archive
27
+ module C
28
+ def self.ffi_lib(*args)
29
+ prefixed = args.map do |names|
30
+ paths = names.is_a?(Array) ? names : [names]
31
+ if paths.any? { |f| f.include?("libarchive") }
32
+ [LibarchiveBinary.lib_path] + paths
33
+ else
34
+ names
35
+ end
36
+ end
37
+
38
+ super(*prefixed)
39
+ end
40
+ end
41
+ end
42
+
43
+ require "ffi-libarchive"