Module: Prebake::Glibc
- Defined in:
- lib/prebake/glibc.rb
Constant Summary collapse
- GNU_LIBC_PATTERN =
/GLIBC\s+(\d+(?:\.\d+)+)|GNU libc[^\n]*\s(\d+(?:\.\d+)+)/
Class Method Summary collapse
- .compatible?(required) ⇒ Boolean
- .detected_version ⇒ Object
- .linux? ⇒ Boolean
- .parse_version(output) ⇒ Object
- .reset! ⇒ Object
- .run_ldd ⇒ Object
Class Method Details
.compatible?(required) ⇒ Boolean
9 10 11 12 13 14 15 16 17 |
# File 'lib/prebake/glibc.rb', line 9 def self.compatible?(required) return true unless linux? return true if required.nil? detected = detected_version return false if detected.nil? Gem::Version.new(detected) >= Gem::Version.new(required) end |
.detected_version ⇒ Object
19 20 21 22 23 24 |
# File 'lib/prebake/glibc.rb', line 19 def self.detected_version return @detected_version if defined?(@detected_version) output = run_ldd @detected_version = output ? parse_version(output) : nil end |
.linux? ⇒ Boolean
31 32 33 |
# File 'lib/prebake/glibc.rb', line 31 def self.linux? RUBY_PLATFORM.include?("linux") end |
.parse_version(output) ⇒ Object
26 27 28 29 |
# File 'lib/prebake/glibc.rb', line 26 def self.parse_version(output) match = output.match(GNU_LIBC_PATTERN) match && (match[1] || match[2]) end |
.reset! ⇒ Object
35 36 37 |
# File 'lib/prebake/glibc.rb', line 35 def self.reset! remove_instance_variable(:@detected_version) if defined?(@detected_version) end |
.run_ldd ⇒ Object
39 40 41 42 43 44 45 46 |
# File 'lib/prebake/glibc.rb', line 39 def self.run_ldd out, status = Open3.capture2e("ldd", "--version") return nil unless status.success? out rescue Errno::ENOENT nil end |