prebake 0.2.6 → 0.2.8
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 +4 -4
- data/lib/prebake/extractor.rb +8 -5
- data/lib/prebake/platform_gem_builder.rb +20 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5526a96f538034fd54828e704413a28c12d7ee26e6b7489bc93a8366615bab9d
|
|
4
|
+
data.tar.gz: 6f5c1ad1a6ae983ca8a0d7ddfbe13f633da314eefa5609716cb1c4a4569a804e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 616f1f3d581285820312d232bb64465cd179161f8c4b846db4d9c8904acfb08b92137651ceecb932eb83bee811ebdd6cf553dc764168bb2597b6916e8435c896
|
|
7
|
+
data.tar.gz: 4583a32a07fd38a498e3976a335fc106cae77e951c3a858d0a8d2df97af0c79fe2a08d397f7310779c551221412889d8903fa59f91fe566b629c2b5f40a87b95
|
data/lib/prebake/extractor.rb
CHANGED
|
@@ -19,8 +19,9 @@ module Prebake
|
|
|
19
19
|
|
|
20
20
|
# Copy only binary files (.so, .bundle, .dll) to extension_dir
|
|
21
21
|
Dir.glob(File.join(tmpdir, "**/*.{so,bundle,dll}")).each do |binary|
|
|
22
|
-
# Reject symlinks
|
|
22
|
+
# Reject symlinks and empty files
|
|
23
23
|
next if File.symlink?(binary)
|
|
24
|
+
next if File.size(binary).zero?
|
|
24
25
|
|
|
25
26
|
# Verify path is within tmpdir (prevent traversal)
|
|
26
27
|
real_binary = File.realpath(binary)
|
|
@@ -29,12 +30,14 @@ module Prebake
|
|
|
29
30
|
|
|
30
31
|
relative = binary.sub("#{tmpdir}/", "")
|
|
31
32
|
|
|
32
|
-
# Normalize paths from
|
|
33
|
-
#
|
|
34
|
-
# ext/<name>/<name>.so
|
|
35
|
-
# lib/<name>/<name>.so
|
|
33
|
+
# Normalize paths from cached gems where binaries were packaged
|
|
34
|
+
# from gem_dir build artifacts or dirty extension_dirs.
|
|
35
|
+
# ext/<name>/<name>.so → <name>.so (build artifact)
|
|
36
|
+
# lib/<name>/<name>.so → <name>/<name>.so (gem lib path)
|
|
37
|
+
# extension/<platform>/<ver>/<name>.so → <name>.so (extension_dir artifact)
|
|
36
38
|
relative = relative.sub(%r{\Aext/[^/]+/}, "") if relative.start_with?("ext/")
|
|
37
39
|
relative = relative.sub(%r{\Alib/}, "") if relative.start_with?("lib/")
|
|
40
|
+
relative = relative.sub(%r{\Aextensions?/[^/]+/[^/]+/}, "") if relative.start_with?("extension/", "extensions/")
|
|
38
41
|
|
|
39
42
|
dest = File.join(spec.extension_dir, relative)
|
|
40
43
|
FileUtils.mkdir_p(File.dirname(dest))
|
|
@@ -55,9 +55,28 @@ module Prebake
|
|
|
55
55
|
|
|
56
56
|
ext_dir = @spec.extension_dir
|
|
57
57
|
if ext_dir && File.directory?(ext_dir)
|
|
58
|
-
|
|
58
|
+
# Collect binaries at root and one level deep (e.g., nokogiri/nokogiri.so).
|
|
59
|
+
binaries = Dir.glob(File.join(ext_dir, "*.{so,bundle,dll}")) +
|
|
60
|
+
Dir.glob(File.join(ext_dir, "*/*.{so,bundle,dll}"))
|
|
61
|
+
|
|
62
|
+
# Ruby 4.0+ places compiled extensions in extension/<platform>/<abi>/
|
|
63
|
+
# within extension_dir. Collect these too, normalizing their paths
|
|
64
|
+
# to root level so the cached gem is layout-agnostic.
|
|
65
|
+
Dir.glob(File.join(ext_dir, "extension/*/*/*.{so,bundle,dll}")).each do |binary|
|
|
66
|
+
relative = binary.delete_prefix("#{ext_dir}/")
|
|
67
|
+
normalized = relative.sub(%r{\Aextension/[^/]+/[^/]+/}, "")
|
|
68
|
+
# Skip if a root-level binary with the same name already exists
|
|
69
|
+
next if binaries.any? { |b| b.delete_prefix("#{ext_dir}/") == normalized }
|
|
70
|
+
|
|
71
|
+
binaries << binary
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
binaries.each do |binary|
|
|
59
75
|
next if File.symlink?(binary)
|
|
76
|
+
next if File.size(binary).zero?
|
|
60
77
|
relative = binary.delete_prefix("#{ext_dir}/")
|
|
78
|
+
# Normalize extension/<platform>/<abi>/ paths to root level
|
|
79
|
+
relative = relative.sub(%r{\Aextension/[^/]+/[^/]+/}, "")
|
|
61
80
|
dest = File.join(build_dir, relative)
|
|
62
81
|
FileUtils.mkdir_p(File.dirname(dest))
|
|
63
82
|
FileUtils.cp(binary, dest)
|