Permalink
Browse files

Autodetect Mandriva Linux. Fixes issue #357.

  • Loading branch information...
1 parent 27c48be commit 5967ed7e7185ed9aac5df7348dc7b9e3bc4d07ae @FooBarWidget FooBarWidget committed Nov 17, 2009
Showing with 68 additions and 36 deletions.
  1. +2 −0 NEWS
  2. +40 −25 lib/phusion_passenger/dependencies.rb
  3. +26 −11 lib/phusion_passenger/platform_info.rb
View
2 NEWS
@@ -13,6 +13,8 @@ Release 2.2.6
'helper_server.sock failed: Resource temporarily unavailable'
errors.
* Some Ruby 1.9 compatibility fixes. Issue #398.
+ * The installer now displays correct dependency installation instructions
+ for Mandriva Linux.
Release 2.2.5
@@ -112,12 +112,14 @@ def self.fastthread_required?
end
end
if RUBY_PLATFORM =~ /linux/
- case PlatformInfo.linux_distro
- when :ubuntu, :debian
+ tags = PlatformInfo.linux_distro_tags
+ if tags.include?(:debian)
dep.install_command = "apt-get install build-essential"
- when :rhel, :fedora, :centos
+ elsif tags.include?(:mandriva)
+ dep.install_command = "urpmi gcc-c++"
+ elsif tags.include?(:redhat)
dep.install_command = "yum install gcc-c++"
- when :gentoo
+ elsif tags.include?(:gentoo)
dep.install_command = "emerge -av gcc"
end
elsif RUBY_PLATFORM =~ /darwin/
@@ -142,12 +144,14 @@ def self.fastthread_required?
end
end
if RUBY_PLATFORM =~ /linux/
- case PlatformInfo.linux_distro
- when :ubuntu, :debian
+ tags = PlatformInfo.linux_distro_tags
+ if tags.include?(:debian)
dep.install_command = "apt-get install ruby1.8-dev"
- when :rhel, :fedora, :centos
+ elsif tags.include?(:mandriva)
+ dep.install_command = "urpmi urpmi ruby-RubyGems"
+ elsif tags.include?(:redhat)
dep.install_command = "yum install ruby-devel"
- when :gentoo
+ elsif tags.include?(:gentoo)
dep.install_command = "emerge -av ruby"
end
elsif RUBY_PLATFORM =~ /freebsd/
@@ -218,12 +222,14 @@ def self.fastthread_required?
end
end
if RUBY_PLATFORM =~ /linux/
- case PlatformInfo.linux_distro
- when :ubuntu, :debian
+ tags = PlatformInfo.linux_distro_tags
+ if tags.include?(:debian)
dep.install_command = "apt-get install apache2-mpm-prefork"
- when :rhel, :fedora, :centos
+ elsif tags.include?(:mandriva)
+ dep.install_command = "urpmi apache"
+ elsif tags.include?(:redhat)
dep.install_command = "yum install httpd"
- when :gentoo
+ elsif tags.include?(:gentoo)
dep.install_command = "emerge -av apache"
end
elsif RUBY_PLATFORM =~ /freebsd/
@@ -243,14 +249,17 @@ def self.fastthread_required?
end
end
if RUBY_PLATFORM =~ /linux/
- case PlatformInfo.linux_distro
- when :ubuntu, :debian
+ tags = PlatformInfo.linux_distro_tags
+ if tags.include?(:debian)
dep.install_command = "apt-get install apache2-prefork-dev"
dep.provides = [Apache2]
- when :rhel, :fedora, :centos
+ elsif tags.include?(:mandriva)
+ dep.install_command = "urpmi apache-devel"
+ dep.provides = [Apache2]
+ elsif tags.include?(:redhat)
dep.install_command = "yum install httpd-devel"
dep.provides = [Apache2]
- when :gentoo
+ elsif tags.include?(:gentoo)
dep.install_command = "emerge -av apache"
dep.provides = [Apache2]
end
@@ -270,12 +279,14 @@ def self.fastthread_required?
end
end
if RUBY_PLATFORM =~ /linux/
- case PlatformInfo.linux_distro
- when :ubuntu, :debian
+ tags = PlatformInfo.linux_distro_tags
+ if tags.include?(:debian)
dep.install_command = "apt-get install libapr1-dev"
- when :rhel, :fedora, :centos
+ elsif tags.include?(:mandriva)
+ dep.install_command = "urpmi libapr-devel"
+ elsif tags.include?(:redhat)
dep.install_command = "yum install apr-devel"
- when :gentoo
+ elsif tags.include?(:gentoo)
dep.install_command = "emerge -av apr"
end
elsif RUBY_PLATFORM =~ /darwin/
@@ -297,9 +308,11 @@ def self.fastthread_required?
end
end
if RUBY_PLATFORM =~ /linux/
- case PlatformInfo.linux_distro
- when :ubuntu, :debian
+ tags = PlatformInfo.linux_distro_tags
+ if tags.include?(:debian)
dep.install_command = "apt-get install libaprutil1-dev"
+ elsif tags.include?(:mandriva)
+ dep.install_command = "urpmi libapr-util-devel"
end
elsif RUBY_PLATFORM =~ /darwin/
dep.install_instructions = "Please install Apache from MacPorts, which will " <<
@@ -364,10 +377,12 @@ def self.fastthread_required?
end
end
if RUBY_PLATFORM =~ /linux/
- case PlatformInfo.linux_distro
- when :ubuntu, :debian
+ tags = PlatformInfo.linux_distro_tags
+ if tags.include?(:debian)
dep.install_command = "apt-get install zlib1g-dev"
- when :rhel, :fedora, :centos
+ elsif tags.include?(:mandriva)
+ dep.install_command = "urpmi zlib1-devel"
+ elsif tags.include?(:redhat)
dep.install_command = "yum install zlib-devel"
end
end
@@ -501,33 +501,48 @@ def self.library_extension
# An identifier for the current Linux distribution. nil if the operating system is not Linux.
def self.linux_distro
+ tags = linux_distro_tags
+ if tags
+ return tags.first
+ else
+ return nil
+ end
+ end
+
+ # Autodetects the current Linux distribution and return a number of identifier tags.
+ # The first tag identifies the distribution while the other tags indicate which
+ # distributions it is likely compatible with.
+ # Returns nil if the operating system is not Linux.
+ def self.linux_distro_tags
if RUBY_PLATFORM !~ /linux/
return nil
end
lsb_release = read_file("/etc/lsb-release")
if lsb_release =~ /Ubuntu/
- return :ubuntu
+ return [:ubuntu, :debian]
elsif File.exist?("/etc/debian_version")
- return :debian
+ return [:debian]
elsif File.exist?("/etc/redhat-release")
redhat_release = read_file("/etc/redhat-release")
if redhat_release =~ /CentOS/
- return :centos
- elsif redhat_release =~ /Fedora/ # is this correct?
- return :fedora
+ return [:centos, :redhat]
+ elsif redhat_release =~ /Fedora/
+ return [:fedora, :redhat]
+ elsif redhat_release =~ /Mandriva/
+ return [:mandriva, :redhat]
else
# On official RHEL distros, the content is in the form of
# "Red Hat Enterprise Linux Server release 5.1 (Tikanga)"
- return :rhel
+ return [:rhel, :redhat]
end
elsif File.exist?("/etc/suse-release")
- return :suse
+ return [:suse]
elsif File.exist?("/etc/gentoo-release")
- return :gentoo
+ return [:gentoo]
else
- return :unknown
+ return [:unknown]
end
- # TODO: Slackware, Mandrake/Mandriva
+ # TODO: Slackware
end
- memoize :linux_distro
+ memoize :linux_distro_tags
end

0 comments on commit 5967ed7

Please sign in to comment.