Recognize Puppet node definitions
[ohcount] / ruby / print_arch
1 #!/usr/bin/env ruby
2 require 'mkmf'
3
4 arch = Config::expand(CONFIG["arch"])
5
6 distro = if File.exist?("/etc/issue")
7   # this is "", "CentOS" or "Ubuntu"
8   `cat /etc/issue`.split.first.downcase
9 end
10
11 unless ["centos", nil, "ubuntu"].include? distro
12         STDERR.puts "unhandled /etc/issue result: #{distro}"
13 end
14
15 # either <arch> or <arch>_<distro> if distro is non-null
16 puts [arch, distro].compact.join("_")