Created
October 12, 2012 16:20
-
-
Save mheffner/3880063 to your computer and use it in GitHub Desktop.
grab platform
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# This module provides build platform lookup in the form qaweb requires. | |
# | |
module BuildPlatform | |
def self.get_platform(env) | |
"#{BuildPlatform.get_os}.#{BuildPlatform.get_arch(env)}" | |
end | |
def self.get_os | |
if File.exist?("/etc/fedora-release") | |
rel = File.read("/etc/fedora-release").chomp | |
m = rel.match(/Fedora release ([0-9]+) /) | |
raise "Unable to match Fedora release: #{rel}" unless m | |
"fedora_#{m[1]}" | |
elsif File.exist?("/etc/redhat-release") | |
rel = File.read("/etc/redhat-release").chomp | |
m = rel.match(/Red Hat Enterprise Linux Server release 5\.[0-9]/) | |
raise "Unknown RHEL release: #{rel}" unless m | |
"rhel_5.1" | |
elsif File.exist?("/etc/debian_version") | |
lsb = %x{lsb_release -cs}.chomp | |
case lsb | |
when "squeeze" | |
"debian_squeeze_6.0" | |
when "lenny" | |
"debian_lenny_5.0.3" | |
when "natty" | |
"ubuntu_11.04" | |
when "maverick" | |
"ubuntu_10.10" | |
when "lucid" | |
"ubuntu_10.04" | |
when "karmic" | |
"ubuntu_9.10" | |
else | |
raise "Unknown Debian version: #{lsb}" | |
end | |
else | |
raise "Unknown Linux Distribution!" | |
end | |
end | |
def self.get_arch(env) | |
# Check if we are forced to 32-bit | |
if env['BUILD_32BITONLY'] && !env['BUILD_32BITONLY'].empty? | |
return "i386" | |
end | |
uname = %x{uname -m}.chomp | |
case uname | |
when "x86_64" | |
"x86_64" | |
else | |
"i386" | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment