Skip to content

Commit cf3b048

Browse files
scubaboe76
authored andcommitted
Resolve gem dependencies across "supported" environments (#142)
1 parent 2979af9 commit cf3b048

File tree

1 file changed

+81
-0
lines changed
  • test/integration/helpers/serverspec

1 file changed

+81
-0
lines changed
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# -*- coding: utf-8 -*-
2+
# vim: ft=ruby
3+
4+
# Global source defined as https://rubygems.org
5+
source 'https://rubygems.org'
6+
7+
# Attempt to fingerprint OS from /etc/os-release where available
8+
if File.file?("/etc/os-release")
9+
10+
os_family = ''
11+
os_version = ''
12+
os_version_full = ''
13+
14+
# Strip necessary granularity from os-release
15+
File.open("/etc/os-release").grep(/(^ID=(.*)$|^VERSION="(.*)"$|^VERSION_ID="(.*)")/) do |line|
16+
17+
# OS family (Debian/CentOS/Ubuntu)
18+
if ( line =~ /^ID=\S/ )
19+
os_family = line.split('=')[1]
20+
puts "IDENTIFIED os_family = " + os_family
21+
end
22+
23+
# Major revision
24+
if ( line =~ /^VERSION_ID="(.*)"$/ )
25+
os_version = line.split('=')[1].tr('"','')
26+
puts "IDENTIFIED os_version = " + os_version
27+
end
28+
29+
# Vanity name
30+
if ( line =~ /^VERSION="(.*)"$/ )
31+
os_version_full = line.split('=')[1]
32+
puts "IDENTIFIED os_version_full = " + os_version_full
33+
end
34+
35+
end
36+
37+
# Pinning is broken into os_family and then os_version
38+
# to try and avoid conflict.
39+
case os_family
40+
41+
when /debian/
42+
# os_family: Debian os_version dependent pins
43+
case os_version
44+
when /7/
45+
puts "busser-serverspec is no longer natively supported on: " + os_version_full
46+
when /8/
47+
gem 'net-ssh', '~> 4.2.0'
48+
else
49+
puts "Your distribution is either too old, or supported without pins: " + os_version_full
50+
end
51+
52+
when /centos/
53+
# os_family: centos os_version dependent pins
54+
print "Switching on " + os_version
55+
case os_version
56+
when /6/
57+
puts "busser-serverspec has no native supported on: " + os_version_full
58+
when /7/
59+
gem 'net-ssh', '~> 4.2.0'
60+
else
61+
puts "Your distribution is either too old, or supported without pins: " + os_version_full
62+
end
63+
64+
when /ubuntu/
65+
# os_family: ubuntu os_version dependent pins
66+
case os_version
67+
when /14.04/
68+
puts "busser-serverspec is no longer natively supported on: " + os_version_full
69+
when /16.04/
70+
puts "busser-serverspec is currently supported natively on: " + os_version_full
71+
else
72+
puts "Your distribution is either too old, or supported without pins: " + os_version_full
73+
end
74+
75+
# No helper support provided
76+
else
77+
puts "No Gemfile helper support exists for os_family: " + os_family
78+
end
79+
else
80+
puts "No Gemfile helper support provided for this suite."
81+
end

0 commit comments

Comments
 (0)