summaryrefslogtreecommitdiff
path: root/lib/facter/debian_nextcodename.rb
blob: 654fe204a4635f0a3d1f107a6d03666a631bce37 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
begin
  require 'facter/util/debian'
rescue LoadError
  require "#{File.dirname(__FILE__)}/util/debian"
end

def debian_codename_to_next(codename, release)
  if release == "testing"
    return "sid"
  elsif release == "unstable"
    return "experimental"
  else
    codenames = Facter::Util::Debian::CODENAMES
    versions  = Facter::Util::Debian::CODENAMES.invert
    current_version = versions[codename]
    return codenames[(current_version.to_i + 1).to_s]
  end
end

Facter.add(:debian_nextcodename) do
  confine :operatingsystem => 'Debian'
  setcode do
    debian_codename_to_next(Facter.value('debian_codename'), Facter.value('debian_release'))
  end
end