diff options
author | intrigeri <intrigeri@boum.org> | 2016-03-16 14:23:08 +0000 |
---|---|---|
committer | intrigeri <intrigeri@boum.org> | 2016-03-16 14:23:08 +0000 |
commit | 46b2f3d2e8c9c8646dfd51280c634ce517d795e6 (patch) | |
tree | ca4e9d9448b51b075c4c98f752c7281c636e23cb /lib/facter/debian_release.rb | |
parent | 3630285006d9fb60c5fbecebc976623c37dd1395 (diff) | |
parent | 8c8bd7bb1e5cc0f5297db9629ece783452233d1f (diff) |
Merge remote-tracking branch 'shared/master' into bugfix/reboot-required-jessie
Diffstat (limited to 'lib/facter/debian_release.rb')
-rw-r--r-- | lib/facter/debian_release.rb | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/lib/facter/debian_release.rb b/lib/facter/debian_release.rb new file mode 100644 index 0000000..2c334cc --- /dev/null +++ b/lib/facter/debian_release.rb @@ -0,0 +1,38 @@ +begin + require 'facter/util/debian' +rescue LoadError + require "#{File.dirname(__FILE__)}/util/debian" +end + +def debian_codename_to_release(codename) + stable = Facter::Util::Debian::STABLE + versions = Facter::Util::Debian::CODENAMES.invert + release = nil + if codename == "sid" + release = "unstable" + elsif versions.has_key? codename + version = versions[codename].to_i + if version == stable + release = "stable" + elsif version < stable + release = "stable" + for i in version..stable - 1 + release = "old" + release + end + elsif version == stable + 1 + release = "testing" + end + end + if release.nil? + Facter.warn("Could not determine release from codename #{codename}!") + end + return release +end + +Facter.add(:debian_release) do + has_weight 99 + confine :operatingsystem => 'Debian' + setcode do + debian_codename_to_release(Facter.value('debian_codename')) + end +end |