serverlessgems 0.4.1 → 0.4.2

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: f45e4781de3600f9c61880c3b508a2955a393332efff18d980bbc2ef0ebc88ab
4
- data.tar.gz: f3d78701b967fb4fc01a0ad7f332ec83690a38f0f86a0549a210d984e8b362ae
3
+ metadata.gz: 4180b95b85ce932e83e67ba621485a458e1d7cff1d673af091eee2c80fc957e5
4
+ data.tar.gz: 9b84b2f954ea096fc9a2c9b8243cd771847926c8b0b26023baa802f85d771030
5
5
  SHA512:
6
- metadata.gz: f7182eb8a6bafde793df547b4e8aa93a09160dfdc01181f5909fe6327971186f1c45e9d1e42d82ca65afcb98c8bf52785b877f9f9c6eb1385a8a3f4fd5b97ab4
7
- data.tar.gz: 8d6d08fdc726541ce96b1d3a7fc56a2e324f816018e5f96705883994b2a084160bbe213d91ba043f3ab5e9dcbbc20e85cfca2227df68458810f40b2307a22cfd
6
+ metadata.gz: acb02e4538a245354e35904f9b4ebd308bd768d9a87273c3b8ac2bf7bf217ce8575492ef4d5d8be8a1d8fb53a9bced3ea8a17afd10446eee95596d2df4714c5b
7
+ data.tar.gz: df2bdc6db711f9d8599233e49fb8183006f6b14a41c28b93bfb4e48eea9f313e1af148d650238c8c4c2d778d68a6554069b2d931f6552a8b03f3eeb6ef3c491e
data/CHANGELOG.md CHANGED
@@ -3,6 +3,9 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  This project *loosely tries* to adhere to [Semantic Versioning](http://semver.org/).
5
5
 
6
+ ## [0.4.2] - 2025-10-10
7
+ - fix gem detection ffi - gnu suffix and clean up incompatible platform variants
8
+
6
9
  ## [0.4.1] - 2024-06-22
7
10
  - standardrb and updates
8
11
 
@@ -56,9 +56,9 @@ module Jets::Gems
56
56
  * Unavailable: <%= missing_gem['gem_name'] -%> Available versions: <%= available.join(' ') %>
57
57
  <% end %>
58
58
  Your current serverlessgems source: #{gems_source}
59
-
59
+
60
60
  Jets is unable to build a deployment package that will work on AWS Lambda without the required pre-compiled gems. To remedy this, you can:
61
-
61
+
62
62
  * Use another gem that does not require compilation.
63
63
  * Create your own custom layer with the gem: http://rubyonjets.com/docs/extras/custom-lambda-layers/
64
64
  <% if agree.yes? -%>
@@ -72,10 +72,10 @@ module Jets::Gems
72
72
  * You can try redeploying again after a few minutes.
73
73
  * Non-reported gems may take days or even longer to be built.
74
74
  <% end -%>
75
-
75
+
76
76
  Compiled gems usually take some time to figure out how to build as they each depend on different libraries and packages.
77
77
  More info: http://rubyonjets.com/docs/serverlessgems/
78
-
78
+
79
79
  EOL
80
80
  erb = ERB.new(template, trim_mode: "-") # trim mode https://stackoverflow.com/questions/4632879/erb-template-removing-the-trailing-line
81
81
  erb.result(binding)
@@ -156,9 +156,9 @@ module Jets::Gems
156
156
  # On new 2021 macbook with m1 chip: the gems are being saved in a folder like so:
157
157
  # nokogiri-1.12.5-arm64-darwin
158
158
  # The GEM_REGEXP accounts for this case.
159
- GEM_REGEXP = /-(arm|x)\d+.*-(darwin|linux)/
159
+ GEM_REGEXP = /-(arm|x|aarch)\d+.*-(darwin|linux)(?:-gnu)?/
160
160
  def other_compiled_gems
161
- paths = Dir.glob("#{Jets.build_root}/stage/opt/ruby/gems/#{Jets::Gems.ruby_folder}/gems/*{-darwin,-linux}")
161
+ paths = Dir.glob("#{Jets.build_root}/stage/opt/ruby/gems/#{Jets::Gems.ruby_folder}/gems/*{-darwin,-linux}*")
162
162
  paths.map { |p| File.basename(p).sub(GEM_REGEXP, "") }
163
163
  end
164
164
 
@@ -19,6 +19,64 @@ module Jets::Gems::Extract
19
19
  say "Unpacking into #{dest}"
20
20
  FileUtils.mkdir_p(dest)
21
21
  unzip(zipfile_path, dest)
22
+ cleanup_incompatible_platform_variants
23
+ end
24
+
25
+ # Removes incompatible platform variants to prevent RubyGems from choosing the wrong one
26
+ # For AWS Lambda, we want to keep only x86_64-linux variants and remove others
27
+ def cleanup_incompatible_platform_variants
28
+ gems_dir = "#{Jets.build_root}/stage/opt/ruby/gems/#{Jets::Gems.ruby_folder}/gems"
29
+ specs_dir = "#{Jets.build_root}/stage/opt/ruby/gems/#{Jets::Gems.ruby_folder}/specifications"
30
+ return unless Dir.exist?(gems_dir)
31
+
32
+ # Find all gem directories for this gem name
33
+ gem_dirs = Dir.glob("#{gems_dir}/#{gem_name}-*").select do |path|
34
+ File.directory?(path) && File.basename(path).start_with?(gem_name)
35
+ end
36
+
37
+ # Group by base gem name (without platform suffix)
38
+ gem_groups = {}
39
+ gem_dirs.each do |dir|
40
+ name = File.basename(dir)
41
+ # Handle platform-specific gem names like nokogiri-1.18.10-x86_64-linux-gnu
42
+ base_name = name.sub(/-(x86_64-linux-gnu|aarch64-linux-gnu|arm64-linux-gnu|i386-linux-gnu|powerpc-linux-gnu|sparc-linux-gnu|mips-linux-gnu|riscv-linux-gnu|loongarch-linux-gnu|sw_64-linux-gnu|hppa-linux-gnu|ia64-linux-gnu|s390-linux-gnu|x86_64|arm64|aarch64|i386|powerpc|sparc|mips|riscv|loongarch|sw_64|hppa|ia64|s390).*/, "")
43
+ gem_groups[base_name] ||= []
44
+ gem_groups[base_name] << {dir: dir, name: name}
45
+ end
46
+
47
+ # For each gem group, keep only x86_64-linux variants
48
+ gem_groups.each do |base_name, variants|
49
+ next if variants.size <= 1 # No cleanup needed if only one variant
50
+
51
+ say "Found #{variants.size} platform variants for #{base_name}:"
52
+ variants.each { |v| say " - #{v[:name]}" }
53
+
54
+ # Find x86_64-linux variants (preferred for AWS Lambda)
55
+ x86_64_variants = variants.select { |v| v[:name].include?("-x86_64-linux-gnu") || v[:name].include?("-x86_64-linux") }
56
+
57
+ if x86_64_variants.any?
58
+ # Keep x86_64-linux variants, remove others
59
+ keep_variants = x86_64_variants
60
+ remove_variants = variants - x86_64_variants
61
+ else
62
+ # If no x86_64-linux variants, keep the first one alphabetically
63
+ keep_variants = [variants.min_by { |v| v[:name] }]
64
+ remove_variants = variants - keep_variants
65
+ end
66
+
67
+ say "Keeping: #{keep_variants.map { |v| v[:name] }.join(", ")}"
68
+ say "Removing: #{remove_variants.map { |v| v[:name] }.join(", ")}"
69
+
70
+ # Remove incompatible variants
71
+ remove_variants.each do |variant|
72
+ say "Removing incompatible variant: #{variant[:name]}"
73
+ FileUtils.rm_rf(variant[:dir])
74
+
75
+ # Also remove the corresponding gemspec
76
+ gemspec_path = "#{specs_dir}/#{variant[:name]}.gemspec"
77
+ FileUtils.rm_f(gemspec_path) if File.exist?(gemspec_path)
78
+ end
79
+ end
22
80
  end
23
81
 
24
82
  # ensure that we always have the full gem name
@@ -1,5 +1,5 @@
1
1
  module Jets
2
2
  module Gems
3
- VERSION = "0.4.1"
3
+ VERSION = "0.4.2"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: serverlessgems
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tung Nguyen
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2024-06-22 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: gems
@@ -94,7 +93,6 @@ dependencies:
94
93
  - - ">="
95
94
  - !ruby/object:Gem::Version
96
95
  version: '0'
97
- description:
98
96
  email:
99
97
  - tongueroo@gmail.com
100
98
  executables: []
@@ -131,7 +129,6 @@ homepage: https://github.com/boltops-tools/serverlessgems
131
129
  licenses:
132
130
  - MIT
133
131
  metadata: {}
134
- post_install_message:
135
132
  rdoc_options: []
136
133
  require_paths:
137
134
  - lib
@@ -146,8 +143,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
146
143
  - !ruby/object:Gem::Version
147
144
  version: '0'
148
145
  requirements: []
149
- rubygems_version: 3.5.13
150
- signing_key:
146
+ rubygems_version: 3.6.7
151
147
  specification_version: 4
152
148
  summary: Client Library works with Serverless Gems API for Jets Ruby Serverless Framework
153
149
  test_files: []