From 8ed7927e834be83087c40fb69dcd65c9c9885ec1 Mon Sep 17 00:00:00 2001 From: carlosg Date: Fri, 11 Aug 2006 14:53:08 +0000 Subject: 2006-08-11 Carlos Garnacho * Utils/Platform.pm (guess): make distribution detection more generic, remove lots of check_distro() functions. (ensure_distro_map): create a distro metamap, from now adding a new distro that behaves exactly like another will be one liner. (PLATFORM_INFO): remove some ancient (as in ooold) distros. * Init/Services.pm, Network/Hosts.pm, Network/Ifaces.pm, Shares/SMB.pm, Time/NTP.pm, Time/TimeDate.pm, Users/Users.pm: Unify parse/replace distro maps where necessary, make shorter those lists now that the distro metamap is there. --- ChangeLog | 13 ++ Init/Services.pm | 144 ++++------------- Network/Hosts.pm | 135 +++------------- Network/Ifaces.pm | 135 +++------------- Shares/SMB.pm | 42 ----- Time/NTP.pm | 40 ----- Time/TimeDate.pm | 113 +------------ Users/Users.pm | 37 ----- Utils/Platform.pm | 463 +++++++++++++++--------------------------------------- 9 files changed, 229 insertions(+), 893 deletions(-) diff --git a/ChangeLog b/ChangeLog index f534b59..17f793c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2006-08-11 Carlos Garnacho + + * Utils/Platform.pm (guess): make distribution detection more generic, + remove lots of check_distro() functions. + (ensure_distro_map): create a distro metamap, from now adding a new + distro that behaves exactly like another will be one liner. + (PLATFORM_INFO): remove some ancient (as in ooold) distros. + + * Init/Services.pm, Network/Hosts.pm, Network/Ifaces.pm, + Shares/SMB.pm, Time/NTP.pm, Time/TimeDate.pm, Users/Users.pm: Unify + parse/replace distro maps where necessary, make shorter those lists + now that the distro metamap is there. + 2006-08-05 Carlos Garnacho * Services.pm (get_gentoo_runlevel_status_by_service) diff --git a/Init/Services.pm b/Init/Services.pm index cb9c67a..0d71a83 100644 --- a/Init/Services.pm +++ b/Init/Services.pm @@ -33,68 +33,26 @@ sub get_runlevel_roles %dist_map = ( - "redhat-5.2" => "redhat-5.2", - "redhat-6.0" => "redhat-5.2", - "redhat-6.1" => "redhat-5.2", - "redhat-6.2" => "redhat-5.2", - "redhat-7.0" => "redhat-5.2", - "redhat-7.1" => "redhat-5.2", - "redhat-7.2" => "redhat-5.2", - "redhat-7.3" => "redhat-5.2", - "redhat-8.0" => "redhat-5.2", - "redhat-9" => "redhat-5.2", - "openna-1.0" => "redhat-5.2", - - "mandrake-7.1" => "redhat-5.2", - "mandrake-7.2" => "redhat-5.2", - "mandrake-9.0" => "redhat-5.2", - "mandrake-9.1" => "redhat-5.2", - "mandrake-9.2" => "redhat-5.2", - "mandrake-10.0" => "redhat-5.2", - "mandrake-10.1" => "redhat-5.2", - - "blackpanther-4.0" => "redhat-5.2", - - "conectiva-9" => "redhat-5.2", - "conectiva-10" => "redhat-5.2", - - "debian-2.2" => "debian-2.2", - "debian-3.0" => "debian-2.2", - "debian-sarge" => "debian-2.2", - "ubuntu-5.04" => "debian-2.2", - - "suse-7.0" => "redhat-5.2", - "suse-9.0" => "redhat-5.2", - "suse-9.1" => "redhat-5.2", - - "turbolinux-7.0" => "redhat-5.2", - "pld-1.0" => "redhat-5.2", - "pld-1.1" => "redhat-5.2", - "pld-1.99" => "redhat-5.2", - "fedora-1" => "redhat-5.2", - "fedora-2" => "redhat-5.2", - "fedora-3" => "redhat-5.2", - - "rpath" => "redhat-5.2", - - "vine-3.0" => "redhat-5.2", - "vine-3.1" => "redhat-5.2", - + "redhat-6.2" => "redhat-6.2", + "redhat-7.0" => "redhat-6.2", + "redhat-7.1" => "redhat-6.2", + "redhat-7.2" => "redhat-6.2", + "redhat-7.3" => "redhat-6.2", + "redhat-8.0" => "redhat-6.2", + "mandrake-9.0" => "redhat-6.2", + "conectiva-9" => "redhat-6.2", + "debian-3.0" => "debian-3.0", + "suse-9.0" => "redhat-6.2", + "pld-1.0" => "redhat-6.2", + "vine-3.0" => "redhat-6.2", "slackware-9.1.0" => "slackware-9.1.0", - "slackware-10.0.0" => "slackware-9.1.0", - "slackware-10.1.0" => "slackware-9.1.0", - - "gentoo" => "gentoo", - "vlos-1.2" => "gentoo", - - "freebsd-5" => "freebsd-5", - "freebsd-6" => "freebsd-5", - "freebsd-7" => "freebsd-5", + "gentoo" => "gentoo", + "freebsd-5" => "freebsd-5", ); %runlevels= ( - "redhat-5.2" => [["0", "HALT" ], + "redhat-6.2" => [["0", "HALT" ], ["1", "RECOVER" ], ["2", "NONE" ], ["3", "TEXT" ], @@ -102,7 +60,7 @@ sub get_runlevel_roles ["5", "GRAPHICAL" ], ["6", "REBOOT" ]], - "debian-2.2" => [["0", "HALT" ], + "debian-3.0" => [["0", "HALT" ], ["1", "RECOVER" ], ["2", "NONE" ], ["3", "NONE" ], @@ -148,62 +106,20 @@ sub get_sysv_paths my %dist_map = ( # gst_dist => [rc.X dirs location, init.d scripts location, relative path location] - "redhat-5.2" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], - "redhat-6.0" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], - "redhat-6.1" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], - "redhat-6.2" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], - "redhat-7.0" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], - "redhat-7.1" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], - "redhat-7.2" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], - "redhat-7.3" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], - "redhat-8.0" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], - "redhat-9" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], - "openna-1.0" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], - - "mandrake-7.1" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], - "mandrake-7.2" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], - "mandrake-9.0" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], - "mandrake-9.1" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], - "mandrake-9.2" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], - "mandrake-10.0" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], - "mandrake-10.1" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], - "mandrake-10.2" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], - "mandriva-2006.0" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], - "mandriva-2006.1" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], - - "yoper-2.2" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], - "blackpanther-4.0" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], - - "conectiva-9" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], - "conectiva-10" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], - - "debian-2.2" => ["$gst_prefix/etc", "$gst_prefix/etc/init.d", "../init.d"], - "debian-3.0" => ["$gst_prefix/etc", "$gst_prefix/etc/init.d", "../init.d"], - "debian-sarge" => ["$gst_prefix/etc", "$gst_prefix/etc/init.d", "../init.d"], - "ubuntu-5.04" => ["$gst_prefix/etc", "$gst_prefix/etc/init.d", "../init.d"], - "ubuntu-5.10" => ["$gst_prefix/etc", "$gst_prefix/etc/init.d", "../init.d"], - "ubuntu-6.04" => ["$gst_prefix/etc", "$gst_prefix/etc/init.d", "../init.d"], - - "suse-7.0" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d", "../"], - "suse-9.0" => ["$gst_prefix/etc/init.d", "$gst_prefix/etc/init.d", "../"], - "suse-9.1" => ["$gst_prefix/etc/init.d", "$gst_prefix/etc/init.d", "../"], - - "turbolinux-7.0" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], - - "pld-1.0" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], - "pld-1.1" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], - "pld-1.99" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], - - "fedora-1" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], - "fedora-2" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], - "fedora-3" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], - "fedora-4" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], - - "rpath" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], - - "vine-3.0" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], - "vine-3.1" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], - "ark" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], + "redhat-6.2" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], + "redhat-7.0" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], + "redhat-7.1" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], + "redhat-7.2" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], + "redhat-7.3" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], + "redhat-8.0" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], + "mandrake-9.0" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], + "yoper-2.2" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], + "conectiva-9" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], + "debian-3.0" => ["$gst_prefix/etc", "$gst_prefix/etc/init.d", "../init.d"], + "suse-9.0" => ["$gst_prefix/etc/init.d", "$gst_prefix/etc/init.d", "../"], + "pld-1.0" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], + "vine-3.0" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], + "ark" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], ); my $res; diff --git a/Network/Hosts.pm b/Network/Hosts.pm index 83dbc9a..54d02ac 100644 --- a/Network/Hosts.pm +++ b/Network/Hosts.pm @@ -33,65 +33,33 @@ sub run_hostname &Utils::Report::leave (); } -sub get_fqdn_parse_table +sub get_fqdn_dist { my %dist_map = ( - "redhat-5.2" => "redhat-6.2", - "redhat-6.0" => "redhat-6.2", - "redhat-6.1" => "redhat-6.2", - "redhat-6.2" => "redhat-6.2", - "redhat-7.0" => "redhat-6.2", - "redhat-7.1" => "redhat-6.2", - "redhat-7.2" => "redhat-7.2", - "redhat-8.0" => "redhat-7.2", - "redhat-9" => "redhat-7.2", - "openna-1.0" => "redhat-6.2", - "mandrake-7.1" => "redhat-6.2", - "mandrake-7.2" => "redhat-6.2", - "mandrake-9.0" => "redhat-6.2", - "mandrake-9.1" => "redhat-6.2", - "mandrake-9.2" => "redhat-6.2", - "mandrake-10.0" => "redhat-6.2", - "mandrake-10.1" => "redhat-6.2", - "mandrake-10.2" => "redhat-6.2", - "mandriva-2006.0" => "redhat-6.2", - "mandriva-2006.1" => "redhat-6.2", - "yoper-2.2" => "redhat-6.2", - "blackpanther-4.0" => "redhat-6.2", - "conectiva-9" => "redhat-6.2", - "conectiva-10" => "redhat-6.2", - "debian-2.2" => "debian-2.2", - "debian-3.0" => "debian-2.2", - "debian-sarge" => "debian-2.2", - "ubuntu-5.04" => "debian-2.2", - "ubuntu-5.10" => "debian-2.2", - "ubuntu-6.04" => "debian-2.2", - "suse-9.0" => "suse-9.0", - "suse-9.1" => "suse-9.0", - "turbolinux-7.0" => "redhat-7.0", - "pld-1.0" => "redhat-6.2", - "pld-1.1" => "redhat-6.2", - "pld-1.99" => "redhat-6.2", - "fedora-1" => "redhat-7.2", - "fedora-2" => "redhat-7.2", - "fedora-3" => "redhat-7.2", - "fedora-4" => "redhat-7.2", - "rpath" => "redhat-7.2", - "vine-3.0" => "redhat-6.2", - "vine-3.1" => "redhat-6.2", - "ark" => "redhat-6.2", + "redhat-6.2" => "redhat-6.2", + "redhat-7.0" => "redhat-6.2", + "redhat-7.1" => "redhat-6.2", + "redhat-7.2" => "redhat-7.2", + "redhat-8.0" => "redhat-7.2", + "mandrake-9.0" => "redhat-6.2", + "yoper-2.2" => "redhat-6.2", + "conectiva-9" => "redhat-6.2", + "debian-3.0" => "debian-2.2", + "suse-9.0" => "suse-9.0", + "pld-1.0" => "redhat-6.2", + "vine-3.0" => "redhat-6.2", + "ark" => "redhat-6.2", "slackware-9.1.0" => "suse-9.0", - "slackware-10.0.0" => "suse-9.0", - "slackware-10.1.0" => "suse-9.0", - "slackware-10.2.0" => "suse-9.0", - "gentoo" => "gentoo", - "vlos-1.2" => "gentoo", - "freebsd-5" => "freebsd-5", - "freebsd-6" => "freebsd-5", - "freebsd-7" => "freebsd-5", + "gentoo" => "gentoo", + "freebsd-5" => "freebsd-5", ); + return $dist_map{$Utils::Backend::tool{"platform"}}; +} + +sub get_fqdn_parse_table +{ my %dist_tables = ( "redhat-6.2" => @@ -185,7 +153,7 @@ sub get_fqdn_parse_table }, ); - my $dist = $dist_map{$Utils::Backend::tool{"platform"}}; + my $dist = &get_fqdn_dist (); return %{$dist_tables{$dist}} if $dist; &Utils::Report::do_report ("platform_no_table", $Utils::Backend::tool{"platform"}); @@ -194,63 +162,6 @@ sub get_fqdn_parse_table sub get_fqdn_replace_table { - my %dist_map = - ( - "redhat-5.2" => "redhat-6.2", - "redhat-6.0" => "redhat-6.2", - "redhat-6.1" => "redhat-6.2", - "redhat-6.2" => "redhat-6.2", - "redhat-7.0" => "redhat-6.2", - "redhat-7.1" => "redhat-6.2", - "redhat-7.2" => "redhat-7.2", - "redhat-8.0" => "redhat-7.2", - "redhat-9" => "redhat-7.2", - "openna-1.0" => "redhat-6.2", - "mandrake-7.1" => "redhat-6.2", - "mandrake-7.2" => "redhat-6.2", - "mandrake-9.0" => "redhat-6.2", - "mandrake-9.1" => "redhat-6.2", - "mandrake-9.2" => "redhat-6.2", - "mandrake-10.0" => "redhat-6.2", - "mandrake-10.1" => "redhat-6.2", - "mandrake-10.2" => "redhat-6.2", - "mandriva-2006.0" => "redhat-6.2", - "mandriva-2006.1" => "redhat-6.2", - "yoper-2.2" => "redhat-6.2", - "blackpanther-4.0" => "redhat-6.2", - "conectiva-9" => "redhat-6.2", - "conectiva-10" => "redhat-6.2", - "debian-2.2" => "debian-2.2", - "debian-3.0" => "debian-2.2", - "debian-sarge" => "debian-2.2", - "ubuntu-5.04" => "debian-2.2", - "ubuntu-5.10" => "debian-2.2", - "ubuntu-6.04" => "debian-2.2", - "suse-9.0" => "suse-9.0", - "suse-9.1" => "suse-9.0", - "turbolinux-7.0" => "redhat-7.0", - "pld-1.0" => "redhat-6.2", - "pld-1.1" => "redhat-6.2", - "pld-1.99" => "redhat-6.2", - "fedora-1" => "redhat-7.2", - "fedora-2" => "redhat-7.2", - "fedora-3" => "redhat-7.2", - "fedora-4" => "redhat-7.2", - "rpath" => "redhat-7.2", - "vine-3.0" => "redhat-6.2", - "vine-3.1" => "redhat-6.2", - "ark" => "redhat-6.2", - "slackware-9.1.0" => "suse-9.0", - "slackware-10.0.0" => "suse-9.0", - "slackware-10.1.0" => "suse-9.0", - "slackware-10.2.0" => "suse-9.0", - "gentoo" => "gentoo", - "vlos-1.2" => "gentoo", - "freebsd-5" => "freebsd-5", - "freebsd-6" => "freebsd-5", - "freebsd-7" => "freebsd-5", - ); - my %dist_tables = ( "redhat-6.2" => @@ -351,7 +262,7 @@ sub get_fqdn_replace_table }, ); - my $dist = $dist_map{$Utils::Backend::tool{"platform"}}; + my $dist = &get_fqdn_dist (); return %{$dist_tables{$dist}} if $dist; &Utils::Report::do_report ("platform_no_table", $Utils::Backend::tool{"platform"}); diff --git a/Network/Ifaces.pm b/Network/Ifaces.pm index 13f7043..41d06c7 100644 --- a/Network/Ifaces.pm +++ b/Network/Ifaces.pm @@ -1639,64 +1639,33 @@ sub set_pppconf_volume } } -sub get_interface_parse_table +sub get_interface_dist { my %dist_map = ( - "redhat-5.2" => "redhat-6.2", - "redhat-6.0" => "redhat-6.2", - "redhat-6.1" => "redhat-6.2", - "redhat-6.2" => "redhat-6.2", - "redhat-7.0" => "redhat-6.2", - "redhat-7.1" => "redhat-6.2", - "redhat-7.2" => "redhat-7.2", - "redhat-8.0" => "redhat-8.0", - "redhat-9" => "redhat-8.0", - "openna-1.0" => "redhat-6.2", - "mandrake-7.1" => "redhat-6.2", - "mandrake-7.2" => "redhat-6.2", - "mandrake-9.0" => "mandrake-9.0", - "mandrake-9.1" => "mandrake-9.0", - "mandrake-9.2" => "mandrake-9.0", - "mandrake-10.0" => "mandrake-9.0", - "mandrake-10.1" => "mandrake-9.0", - "mandrake-10.2" => "mandrake-9.0", - "mandriva-2006.0" => "mandrake-9.0", - "mandriva-2006.1" => "mandrake-9.0", - "yoper-2.2" => "redhat-6.2", - "blackpanther-4.0" => "mandrake-9.0", - "conectiva-9" => "conectiva-9", - "conectiva-10" => "conectiva-9", - "debian-3.0" => "debian-3.0", - "debian-sarge" => "debian-3.0", - "ubuntu-5.04" => "debian-3.0", - "ubuntu-5.10" => "debian-3.0", - "ubuntu-6.04" => "debian-3.0", - "suse-9.0" => "suse-9.0", - "suse-9.1" => "suse-9.0", - "turbolinux-7.0" => "redhat-6.2", - "pld-1.0" => "pld-1.0", - "pld-1.1" => "pld-1.0", - "pld-1.99" => "pld-1.0", - "fedora-1" => "redhat-7.2", - "fedora-2" => "redhat-7.2", - "fedora-3" => "redhat-7.2", - "fedora-4" => "redhat-7.2", - "rpath" => "redhat-7.2", - "vine-3.0" => "vine-3.0", - "vine-3.1" => "vine-3.0", - "ark" => "vine-3.0", + "redhat-6.2" => "redhat-6.2", + "redhat-7.0" => "redhat-6.2", + "redhat-7.1" => "redhat-6.2", + "redhat-7.2" => "redhat-7.2", + "redhat-8.0" => "redhat-8.0", + "mandrake-9.0" => "mandrake-9.0", + "yoper-2.2" => "redhat-6.2", + "conectiva-9" => "conectiva-9", + "debian-3.0" => "debian-3.0", + "suse-9.0" => "suse-9.0", + "pld-1.0" => "pld-1.0", + "vine-3.0" => "vine-3.0", + "ark" => "vine-3.0", "slackware-9.1.0" => "slackware-9.1.0", - "slackware-10.0.0" => "slackware-9.1.0", - "slackware-10.1.0" => "slackware-9.1.0", - "slackware-10.2.0" => "slackware-9.1.0", - "gentoo" => "gentoo", - "vlos-1.2" => "gentoo", - "freebsd-5" => "freebsd-5", - "freebsd-6" => "freebsd-5", - "freebsd-7" => "freebsd-5", + "gentoo" => "gentoo", + "freebsd-5" => "freebsd-5", ); - + + return $dist_map{$Utils::Backend::tool{"platform"}}; +} + +sub get_interface_parse_table +{ my %dist_tables = ( "redhat-6.2" => @@ -2353,7 +2322,7 @@ sub get_interface_parse_table }, ); - my $dist = $dist_map{$Utils::Backend::tool{"platform"}}; + my $dist = &get_interface_dist (); return %{$dist_tables{$dist}} if $dist; &Utils::Report::do_report ("platform_no_table", $Utils::Backend::tool{"platform"}); @@ -2362,62 +2331,6 @@ sub get_interface_parse_table sub get_interface_replace_table { - my %dist_map = - ( - "redhat-5.2" => "redhat-6.2", - "redhat-6.0" => "redhat-6.2", - "redhat-6.1" => "redhat-6.2", - "redhat-6.2" => "redhat-6.2", - "redhat-7.0" => "redhat-6.2", - "redhat-7.1" => "redhat-6.2", - "redhat-7.2" => "redhat-7.2", - "redhat-8.0" => "redhat-8.0", - "redhat-9" => "redhat-8.0", - "openna-1.0" => "redhat-6.2", - "mandrake-7.1" => "redhat-6.2", - "mandrake-7.2" => "redhat-6.2", - "mandrake-9.0" => "mandrake-9.0", - "mandrake-9.1" => "mandrake-9.0", - "mandrake-9.2" => "mandrake-9.0", - "mandrake-10.0" => "mandrake-9.0", - "mandrake-10.1" => "mandrake-9.0", - "mandrake-10.2" => "mandrake-9.0", - "mandriva-2006.0" => "mandrake-9.0", - "mandriva-2006.1" => "mandrake-9.0", - "yoper-2.2" => "redhat-6.2", - "blackpanther-4.0" => "mandrake-9.0", - "conectiva-9" => "conectiva-9", - "conectiva-10" => "conectiva-9", - "debian-3.0" => "debian-3.0", - "debian-sarge" => "debian-3.0", - "ubuntu-5.04" => "debian-3.0", - "ubuntu-5.10" => "debian-3.0", - "ubuntu-6.04" => "debian-3.0", - "suse-9.0" => "suse-9.0", - "suse-9.1" => "suse-9.0", - "turbolinux-7.0" => "redhat-6.2", - "pld-1.0" => "pld-1.0", - "pld-1.1" => "pld-1.0", - "pld-1.99" => "pld-1.0", - "fedora-1" => "redhat-7.2", - "fedora-2" => "redhat-7.2", - "fedora-3" => "redhat-7.2", - "fedora-4" => "redhat-7.2", - "rpath" => "redhat-7.2", - "vine-3.0" => "vine-3.0", - "vine-3.1" => "vine-3.0", - "ark" => "vine-3.0", - "slackware-9.1.0" => "slackware-9.1.0", - "slackware-10.0.0" => "slackware-9.1.0", - "slackware-10.1.0" => "slackware-9.1.0", - "slackware-10.2.0" => "slackware-9.1.0", - "gentoo" => "gentoo", - "vlos-1.2" => "gentoo", - "freebsd-5" => "freebsd-5", - "freebsd-6" => "freebsd-5", - "freebsd-7" => "freebsd-5", - ); - my %dist_tables = ( "redhat-6.2" => @@ -3052,7 +2965,7 @@ sub get_interface_replace_table } ); - my $dist = $dist_map{$Utils::Backend::tool{"platform"}}; + my $dist = &get_interface_dist (); return %{$dist_tables{$dist}} if $dist; &Utils::Report::do_report ("platform_no_table", $Utils::Backend::tool{"platform"}); diff --git a/Shares/SMB.pm b/Shares/SMB.pm index 9bb4aab..5abe981 100644 --- a/Shares/SMB.pm +++ b/Shares/SMB.pm @@ -129,63 +129,21 @@ sub get_distro_smb_file my %dist_map = ( - "redhat-6.0" => "redhat-6.2", - "redhat-6.1" => "redhat-6.2", "redhat-6.2" => "redhat-6.2", - "redhat-7.0" => "debian-3.0", "redhat-7.1" => "debian-3.0", "redhat-7.2" => "debian-3.0", "redhat-7.3" => "debian-3.0", "redhat-8.0" => "debian-3.0", - "redhat-9" => "debian-3.0", - "openna-1.0" => "redhat-6.2", - - "mandrake-7.1" => "redhat-6.2", - "mandrake-7.2" => "redhat-6.2", "mandrake-9.0" => "debian-3.0", - "mandrake-9.1" => "debian-3.0", - "mandrake-9.2" => "debian-3.0", - "mandrake-10.0" => "debian-3.0", - "mandrake-10.1" => "debian-3.0", - "mandrake-10.2" => "debian-3.0", - - "debian-2.2" => "debian-3.0", "debian-3.0" => "debian-3.0", - "debian-sarge" => "debian-3.0", - "suse-9.0" => "debian-3.0", - "suse-9.1" => "debian-3.0", - - "turbolinux-7.0" => "debian-3.0", - - "slackware-8.0.0" => "debian-3.0", - "slackware-8.1" => "debian-3.0", - "slackware-9.0.0" => "debian-3.0", "slackware-9.1.0" => "debian-3.0", - "slackware-10.0.0" => "debian-3.0", - "slackware-10.1.0" => "debian-3.0", - "slackware-10.2.0" => "debian-3.0", - "gentoo" => "debian-3.0", - "vlos-1.2" => "debian-3.0", - "archlinux" => "debian-3.0", - "pld-1.0" => "pld-1.0", - "pld-1.1" => "pld-1.0", - "pld-1.99" => "pld-1.0", - "fedora-1" => "debian-3.0", - "fedora-2" => "debian-3.0", - "fedora-3" => "debian-3.0", - "rpath" => "debian-3.0", - "vine-3.0" => "debian-3.0", - "vine-3.1" => "debian-3.0", - "freebsd-5" => "freebsd-5", - "freebsd-6" => "freebsd-5", - "freebsd-7" => "freebsd-5", ); my %dist_tables = diff --git a/Time/NTP.pm b/Time/NTP.pm index 309d426..741e256 100644 --- a/Time/NTP.pm +++ b/Time/NTP.pm @@ -27,60 +27,20 @@ sub get_config_file () { my %dist_map = ( - "redhat-6.0" => "redhat-6.2", - "redhat-6.1" => "redhat-6.2", "redhat-6.2" => "redhat-6.2", - "redhat-7.0" => "redhat-6.2", "redhat-7.1" => "redhat-6.2", "redhat-7.2" => "redhat-6.2", "redhat-7.3" => "redhat-6.2", "redhat-8.0" => "redhat-6.2", - "redhat-9" => "redhat-6.2", - "openna-1.0" => "redhat-6.2", - - "mandrake-7.1" => "redhat-6.2", - "mandrake-7.2" => "redhat-6.2", "mandrake-9.0" => "redhat-6.2", - "mandrake-9.1" => "redhat-6.2", - "mandrake-9.2" => "redhat-6.2", - "mandrake-10.0" => "redhat-6.2", - "mandrake-10.1" => "redhat-6.2", - - "debian-2.2" => "redhat-6.2", "debian-3.0" => "redhat-6.2", - "debian-sarge" => "redhat-6.2", - - "suse-7.0" => "redhat-6.2", "suse-9.0" => "redhat-6.2", - "suse-9.1" => "redhat-6.2", - - "turbolinux-7.0" => "redhat-6.2", - - "slackware-8.0.0" => "redhat-6.2", - "slackware-8.1" => "redhat-6.2", - "slackware-9.0.0" => "redhat-6.2", "slackware-9.1.0" => "redhat-6.2", - "slackware-10.0.0" => "redhat-6.2", - "slackware-10.1.0" => "redhat-6.2", - "gentoo" => "redhat-6.2", - "pld-1.0" => "pld-1.0", - "pld-1.1" => "pld-1.0", - "pld-1.99" => "pld-1.0", - "fedora-1" => "redhat-6.2", - "fedora-2" => "redhat-6.2", - "fedora-3" => "redhat-6.2", - - "rpath" => "redhat-6.2", - "vine-3.0" => "redhat-6.2", - "vine-3.1" => "redhat-6.2", - "freebsd-5" => "redhat-6.2", - "freebsd-6" => "redhat-6.2", - "freebsd-7" => "redhat-6.2", ); my %dist_table = diff --git a/Time/TimeDate.pm b/Time/TimeDate.pm index 8da8981..0b15a38 100644 --- a/Time/TimeDate.pm +++ b/Time/TimeDate.pm @@ -155,69 +155,32 @@ sub set_timezone return -1; } -sub conf_get_parse_table +sub get_dist { my %dist_map = ( - "redhat-6.0" => "redhat-6.2", - "redhat-6.1" => "redhat-6.2", "redhat-6.2" => "redhat-6.2", - "redhat-7.0" => "redhat-6.2", "redhat-7.1" => "redhat-6.2", "redhat-7.2" => "redhat-6.2", "redhat-7.3" => "redhat-6.2", "redhat-8.0" => "redhat-6.2", - "redhat-9" => "redhat-6.2", - "openna-1.0" => "redhat-6.2", - - "mandrake-7.1" => "redhat-6.2", - "mandrake-7.2" => "redhat-6.2", "mandrake-9.0" => "redhat-6.2", - "mandrake-9.1" => "redhat-6.2", - "mandrake-9.2" => "redhat-6.2", - "mandrake-10.0" => "redhat-6.2", - "mandrake-10.1" => "redhat-6.2", - - "debian-2.2" => "redhat-6.2", "debian-3.0" => "debian-3.0", - "debian-sarge" => "debian-3.0", - - "suse-7.0" => "redhat-6.2", "suse-9.0" => "redhat-6.2", - "suse-9.1" => "redhat-6.2", - - "turbolinux-7.0" => "redhat-6.2", - - "slackware-8.0.0" => "redhat-6.2", - "slackware-8.1" => "redhat-6.2", - "slackware-9.0.0" => "redhat-6.2", "slackware-9.1.0" => "redhat-6.2", - "slackware-10.0.0" => "redhat-6.2", - "slackware-10.1.0" => "redhat-6.2", - "slackware-10.2.0" => "redhat-6.2", - "gentoo" => "redhat-6.2", - "vlos-1.2" => "redhat-6.2", - "archlinux" => "archlinux", - "pld-1.0" => "redhat-6.2", - "pld-1.1" => "redhat-6.2", - "pld-1.99" => "redhat-6.2", - "fedora-1" => "redhat-6.2", - "fedora-2" => "redhat-6.2", - "fedora-3" => "redhat-6.2", - "rpath" => "redhat-6.2", - "vine-3.0" => "redhat-6.2", - "vine-3.1" => "redhat-6.2", - "freebsd-5" => "redhat-6.2", - "freebsd-6" => "redhat-6.2", - "freebsd-7" => "redhat-6.2", ); + return $dist_map{$Utils::Backend::tool{"platform"}}; +} + +sub conf_get_parse_table +{ my %dist_tables = ( "redhat-6.2" => @@ -264,7 +227,7 @@ sub conf_get_parse_table }, ); - my $dist = $dist_map {$Utils::Backend::tool{"platform"}}; + my $dist = &get_dist(); return %{$dist_tables{$dist}} if $dist; &Utils::Report::do_report ("platform_no_table", $Utils::backend::tool{"platform"}); @@ -273,66 +236,6 @@ sub conf_get_parse_table sub conf_get_replace_table { - my %dist_map = - ( - "redhat-6.0" => "redhat-6.2", - "redhat-6.1" => "redhat-6.2", - "redhat-6.2" => "redhat-6.2", - - "redhat-7.0" => "redhat-6.2", - "redhat-7.1" => "redhat-6.2", - "redhat-7.2" => "redhat-6.2", - "redhat-7.3" => "redhat-6.2", - "redhat-8.0" => "redhat-6.2", - "redhat-9" => "redhat-6.2", - "openna-1.0" => "redhat-6.2", - - "mandrake-7.1" => "redhat-6.2", - "mandrake-7.2" => "redhat-6.2", - "mandrake-9.0" => "redhat-6.2", - "mandrake-9.1" => "redhat-6.2", - "mandrake-9.2" => "redhat-6.2", - "mandrake-10.0" => "redhat-6.2", - "mandrake-10.1" => "redhat-6.2", - - "debian-2.2" => "redhat-6.2", - "debian-3.0" => "debian-3.0", - "debian-sarge" => "debian-3.0", - - "suse-7.0" => "redhat-6.2", - "suse-9.0" => "redhat-6.2", - "suse-9.1" => "redhat-6.2", - - "turbolinux-7.0" => "redhat-6.2", - - "slackware-8.0.0" => "redhat-6.2", - "slackware-8.1" => "redhat-6.2", - "slackware-9.0.0" => "redhat-6.2", - "slackware-9.1.0" => "redhat-6.2", - "slackware-10.0.0" => "redhat-6.2", - "slackware-10.1.0" => "redhat-6.2", - "slackware-10.2.0" => "redhat-6.2", - - "gentoo" => "redhat-6.2", - "vlos-1.2" => "redhat-6.2", - - "archlinux" => "archlinux", - - "pld-1.0" => "redhat-6.2", - "pld-1.1" => "redhat-6.2", - "pld-1.99" => "redhat-6.2", - "fedora-1" => "redhat-6.2", - "fedora-2" => "redhat-6.2", - "fedora-3" => "redhat-6.2", - "rpath" => "redhat-6.2", - - "vine-3.0" => "redhat-6.2", - "vine-3.1" => "redhat-6.2", - - "freebsd-5" => "redhat-6.2", - "freebsd-6" => "redhat-6.2", - ); - my %dist_tables = ( "redhat-6.2" => @@ -382,7 +285,7 @@ sub conf_get_replace_table }, ); - my $dist = $dist_map {$Utils::Backend::tool{"platform"}}; + my $dist = &get_dist (); return %{$dist_tables{$dist}} if $dist; &Utils::Report::do_report ("platform_no_table", $Utils::Backend::tool{"platform"}); diff --git a/Users/Users.pm b/Users/Users.pm index 1730429..304f1cb 100644 --- a/Users/Users.pm +++ b/Users/Users.pm @@ -225,59 +225,22 @@ my $freebsd_logindefs_defaults = { }; my $logindefs_dist_map = { - 'redhat-5.2' => $rh_logindefs_defaults, - 'redhat-6.0' => $rh_logindefs_defaults, - 'redhat-6.1' => $rh_logindefs_defaults, 'redhat-6.2' => $rh_logindefs_defaults, 'redhat-7.0' => $rh_logindefs_defaults, 'redhat-7.1' => $rh_logindefs_defaults, 'redhat-7.2' => $rh_logindefs_defaults, 'redhat-7.3' => $rh_logindefs_defaults, 'redhat-8.0' => $rh_logindefs_defaults, - 'redhat-9' => $rh_logindefs_defaults, - 'openna-1.0' => $rh_logindefs_defaults, - 'mandrake-7.1' => $rh_logindefs_defaults, - 'mandrake-7.2' => $rh_logindefs_defaults, 'mandrake-9.0' => $rh_logindefs_defaults, - 'mandrake-9.1' => $rh_logindefs_defaults, - 'mandrake-9.2' => $rh_logindefs_defaults, - 'mandrake-10.0' => $rh_logindefs_defaults, - 'mandrake-10.1' => $rh_logindefs_defaults, 'pld-1.0' => $rh_logindefs_defaults, - 'pld-1.1' => $rh_logindefs_defaults, - 'pld-1.99' => $rh_logindefs_defaults, 'fedora-1' => $rh_logindefs_defaults, - 'fedora-2' => $rh_logindefs_defaults, - 'fedora-3' => $rh_logindefs_defaults, - 'rpath' => $rh_logindefs_defaults, - 'debian-2.2' => $rh_logindefs_defaults, 'debian-3.0' => $rh_logindefs_defaults, - 'debian-sarge' => $rh_logindefs_defaults, - 'ubuntu-5.04' => $rh_logindefs_defaults, - 'ubuntu-5.10' => $rh_logindefs_defaults, - 'ubuntu-6.04' => $rh_logindefs_defaults, 'vine-3.0' => $rh_logindefs_defaults, - 'vine-3.1' => $rh_logindefs_defaults, 'gentoo' => $gentoo_logindefs_defaults, - 'vlos-1.2' => $gentoo_logindefs_defaults, 'archlinux' => $gentoo_logindefs_defaults, 'slackware-9.1.0' => $gentoo_logindefs_defaults, - 'slackware-10.0.0' => $gentoo_logindefs_defaults, - 'slackware-10.1.0' => $gentoo_logindefs_defaults, - 'slackware-10.2.0' => $gentoo_logindefs_defaults, - 'freebsd-4' => $freebsd_logindefs_defaults, 'freebsd-5' => $freebsd_logindefs_defaults, - 'freebsd-6' => $freebsd_logindefs_defaults, - 'freebsd-7' => $freebsd_logindefs_defaults, - 'suse-7.0' => $gentoo_logindefs_defaults, 'suse-9.0' => $gentoo_logindefs_defaults, - 'suse-9.1' => $gentoo_logindefs_defaults, - - # FIXME: I don't know about those, so using RH values for now. - 'turbolinux-7.0' => $rh_logindefs_defaults, - 'slackware-8.0.0' => $rh_logindefs_defaults, - 'slackware-8.1' => $rh_logindefs_defaults, - 'slackware-9.0.0' => $rh_logindefs_defaults, }; diff --git a/Utils/Platform.pm b/Utils/Platform.pm index 972cbd3..9cc50da 100644 --- a/Utils/Platform.pm +++ b/Utils/Platform.pm @@ -42,12 +42,12 @@ dbus_signal ("noPlatformDetected", []); # --- System guessing --- # my $PLATFORM_INFO = { - "debian-2.2" => [ "Debian GNU/Linux", "2.2", "Potato" ], "debian-3.0" => [ "Debian GNU/Linux", "3.0", "Woody" ], - "debian-sarge" => [ "Debian GNU/Linux", "3.1", "Sarge" ], + "debian-3.1" => [ "Debian GNU/Linux", "3.1", "Sarge" ], "ubuntu-5.04" => [ "Ubuntu Linux", "5.04", "Hoary" ], "ubuntu-5.10" => [ "Ubuntu Linux", "5.10", "Breezy" ], "ubuntu-6.04" => [ "Ubuntu Linux", "6.04", "Dapper" ], + "ubuntu-6.10" => [ "Ubuntu Linux", "6.10", "Edgy" ], "redhat-5.2" => [ "Red Hat Linux", "5.2", "Apollo" ], "redhat-6.0" => [ "Red Hat Linux", "6.0", "Hedwig" ], "redhat-6.1" => [ "Red Hat Linux", "6.1", "Cartman" ], @@ -76,10 +76,6 @@ my $PLATFORM_INFO = { "conectiva-10" => [ "Conectiva Linux", "10", "" ], "suse-9.0" => [ "SuSE Linux", "9.0", "" ], "suse-9.1" => [ "SuSE Linux", "9.1", "" ], - "turbolinux-7.0" => [ "Turbolinux", "7.0", "" ], - "slackware-8.0.0" => [ "Slackware", "8.0.0", "" ], - "slackware-8.1" => [ "Slackware", "8.1", "" ], - "slackware-9.0.0" => [ "Slackware", "9.0.0", "" ], "slackware-9.1.0" => [ "Slackware", "9.1.0", "" ], "slackware-10.0.0" => [ "Slackware", "10.0.0", "" ], "slackware-10.1.0" => [ "Slackware", "10.1.0", "" ], @@ -100,16 +96,61 @@ my $PLATFORM_INFO = { "fedora-2" => [ "Fedora Core", "2", "Tettnang" ], "fedora-3" => [ "Fedora Core", "3", "Heidelberg" ], "fedora-4" => [ "Fedora Core", "4", "Stentz" ], - "rpath" => [ "rPath Linux", "", "" ], + "rpath" => [ "rPath Linux" ], "ark" => [ "Ark Linux" ] }; + +sub ensure_distro_map +{ + my ($distro) = @_; + + # This is a distro metamap, if one distro + # behaves *exactly* like another, just specify it here + my %metamap = + ( + "blackpanther-4.0" => "mandrake-9.0", + "conectiva-10" => "conectiva-9", + "debian-3.1" => "debian-3.0", + "mandrake-7.1" => "redhat-6.2", + "mandrake-7.2" => "redhat-6.2", + "mandrake-9.1" => "mandrake-9.0", + "mandrake-9.2" => "mandrake-9.0", + "mandrake-10.0" => "mandrake-9.0", + "mandrake-10.1" => "mandrake-9.0", + "mandrake-10.2" => "mandrake-9.0", + "mandriva-2006.0" => "mandrake-9.0", + "mandriva-2006.1" => "mandrake-9.0", + "fedora-1" => "redhat-7.2", + "fedora-2" => "redhat-7.2", + "fedora-3" => "redhat-7.2", + "fedora-4" => "redhat-7.2", + "fedora-5" => "redhat-7.2", + "freebsd-6" => "freebsd-5", + "freebsd-7" => "freebsd-5", + "openna-1.0" => "redhat-6.2", + "pld-1.1" => "pld-1.0", + "pld-1.99" => "pld-1.0", + "redhat-9" => "redhat-8.0", + "rpath" => "redhat-7.2", + "slackware-10.0.0" => "slackware-9.1.0", + "slackware-10.1.0" => "slackware-9.1.0", + "slackware-10.2.0" => "slackware-9.1.0", + "suse-9.1" => "suse-9.0", + "ubuntu-5.04" => "debian-3.0", + "ubuntu-5.10" => "debian-3.0", + "ubuntu-6.06" => "debian-3.0", + "ubuntu-6.10" => "debian-3.0", + "vine-3.1" => "vine-3.0", + "vlos-1.2" => "gentoo" + ); + + return $metamap{$distro} if ($metamap{$distro}); + return $distro; +} sub check_lsb { my ($ver, $dist); -# my %vermap = -# ("3.0" => "woody"); - my %distmap = ("Debian" => "debian"), ("Mandrake" => "mandrake"), @@ -119,139 +160,12 @@ sub check_lsb $dist = lc (&Utils::Parse::get_sh ("/etc/lsb-release", "DISTRIB_ID")); $ver = lc (&Utils::Parse::get_sh ("/etc/lsb-release", "DISTRIB_RELEASE")); -# $ver = $vermap{$ver} if exists $vermap{$ver}; $dist = $distmap{$dist} if exists $dirmap{$dir}; return -1 if ($dist eq "") || ($ver eq ""); return "$dist-$ver"; } -sub check_debian -{ - my ($ver, $i); - my %vermap = - ("testing/unstable" => "sarge", - "3.1" => "sarge"); - - open DEBIAN, "$gst_prefix/etc/debian_version" or return -1; - chomp ($ver = ); - close DEBIAN; - - $ver = $vermap{$ver} if exists $vermap{$ver}; - - return "debian-$ver"; -} - - -sub check_redhat -{ - open RELEASE, "$gst_prefix/etc/redhat-release" or return -1; - while () - { - chomp; - if (/^Red Hat Linux.*\s+([0-9.]+)\s+.*/) - { - close RELEASE; - return "redhat-$1"; - } - } - close RELEASE; - return -1; -} - -sub check_openna -{ - open OPENNA, "$gst_prefix/etc/openna-release" or return -1; - while () - { - chomp; - if (/^OpenNA*/) - { - close OPENNA; - return "openna-$1"; - } - } - close OPENNA; - return -1; -} - -sub check_caldera -{ - open INSTALLED, "$gst_prefix/etc/.installed" or return -1; - while () - { - chomp; - if (/^OpenLinux-(.*)-.*/) - { - close INSTALLED; - return "caldera-$1"; - } - } - close INSTALLED; - return -1; -} - - -sub check_suse -{ - open RELEASE, "$gst_prefix/etc/SuSE-release" or return -1; - while () - { - chomp; - if (/^VERSION\s*=\s*(\S+)/) - { - close RELEASE; - return "suse-$1"; - } - } - close RELEASE; - return -1; -} - -sub check_mandrake -{ - open MANDRAKE, "$gst_prefix/etc/mandrake-release" or return -1; - while () - { - $ver = $_; - chomp ($ver); - if ($ver =~ /^Linux Mandrake release (\S+)/) - { - close MANDRAKE; - return "mandrake-$1"; - } - elsif ($ver =~ /^Mandrake( L|l)inux release ([\d\.]+)/i) - { - close MANDRAKE; - return "mandrake-$2"; - } - } - close MANDRAKE; - return -1; -} - -sub check_mandriva -{ - open MANDRIVA, "$gst_prefix/etc/mandriva-release" or return -1; - while () - { - $ver = $_; - chomp ($ver); - if ($ver =~ /^Linux Mandriva release (\S+)/) - { - close MANDRIVA; - return "mandriva-$1"; - } - elsif ($ver =~ /^Mandriva( L|l)inux release ([\d\.]+)/i) - { - close MANDRIVA; - return "mandriva-$2"; - } - } - close MANDRIVA; - return -1; -} - sub check_yoper { open YOPER, "$gst_prefix/etc/yoper-release" or return -1; @@ -279,49 +193,6 @@ sub check_yoper return -1; } -sub check_blackpanther -{ - open BLACKPANTHER, "$gst_prefix/etc/blackPanther-release" or return -1; - - while () - { - $ver = $_; - chomp ($ver); - if ($ver =~ /^Linux Black Panther release (\S+)/) - { - close BLACKPANTHER; - return "blackPanther-$1"; - } - elsif ($ver =~ /^Black Panther ( L|l)inux release ([\d\.]+)/i) - { - close BLACKPANTHER; - return "blackPanther-$2"; - } - } - - close BLACKPANTHER; - return -1; -} - -sub check_fedora -{ - open FEDORA, "$gst_prefix/etc/fedora-release" or return -1; - while () - { - $ver = $_; - chomp ($ver); - - if ($ver =~ /^Fedora Core release (\S+)/) - { - close FEDORA; - return "fedora-$1"; - } - } - - close FEDORA; - return -1; -} - sub check_rpath { open RPATH, "$gst_prefix/etc/distro-release" or return -1; @@ -347,133 +218,6 @@ sub check_rpath return -1; } -sub check_conectiva -{ - open RELEASE, "$gst_prefix/etc/conectiva-release" or return -1; - - while () - { - chomp; - - if (/^Conectiva Linux (\S+)/) - { - close RELEASE; - return "conectiva-$1"; - } - } - - close RELEASE; - return -1; -} - -sub check_turbolinux -{ - open RELEASE, "$gst_prefix/etc/turbolinux-release" or return -1; - while () - { - chomp; - if (/^Turbolinux\s.*\s([0-9.]+)\s.*/) - { - close RELEASE; - return "turbolinux-$1"; - } - } - close RELEASE; - return -1; -} - -sub check_slackware -{ - open RELEASE, "$gst_prefix/etc/slackware-version" or return -1; - while () - { - chomp; - if (/^Slackware ([0-9.]+)/) - { - close RELEASE; - return "slackware-$1"; - } - } - close RELEASE; - return -1; -} - -sub check_gentoo -{ - return "gentoo" if stat ("$gst_prefix/usr/portage"); - return -1; -} - -sub check_vlos -{ - open RELEASE, "$gst_prefix/etc/vlos-release" or return -1; - while () - { - chomp; - if (/^VLOS.*\s+([0-9.]+)/) - { - close RELEASE; - return "vlos-$1"; - } - } - close RELEASE; - return -1; -} - -sub check_archlinux -{ - return "archlinux" if stat ("$gst_prefix/etc/arch-release"); - return -1; -} - -sub check_linuxppc -{ - open RELEASE, "$gst_prefix/etc/redhat-release" or return -1; - while () - { - chomp; - if (/^LinuxPPC\s+(\S+)/) - { - close RELEASE; - return "linuxppc-$1"; - } - } - close RELEASE; - return -1; -} - -sub check_pld -{ - open RELEASE, "$gst_prefix/etc/pld-release" or return -1; - while () - { - chomp; - if(/^([0-9.]+) PLD Linux/) - { - close RELEASE; - return "pld-$1"; - } - } - close RELEASE; - return -1; -} - -sub check_vine -{ - open RELEASE, "$gst_prefix/etc/vine-release" or return -1; - while () - { - chomp; - if(/^Vine Linux ([0-9.]+)\s+.*/) - { - close RELEASE; - return "vine-$1"; - } - } - close RELEASE; - return -1; -} - sub check_ark { open ARK, "$gst_prefix/etc/ark-release" or return -1; @@ -535,6 +279,40 @@ sub check_solaris return -1; } +sub check_distro_file +{ + my ($file, $dist, $re, $map) = @_; + my ($ver); + local *FILE; + + open FILE, "$gst_prefix/$file" or return -1; + + while () + { + chomp; + + if ($_ =~ "$re") + { + $ver = $1; + $ver = $$map{$ver} if ($$map{$ver}); + + close FILE; + return "$dist-$ver"; + } + } + + close FILE; + return -1; +} + +sub check_file_exists +{ + my ($file, $distro) = @_; + + return $distro if &Utils::File::exists ($file); + return -1; +} + sub get_system { # get the output of 'uname -s', it returns the system we are running @@ -551,6 +329,8 @@ sub set_platform { if ($p eq $platform) { + $platform = &ensure_distro_map ($platform); + $Utils::Backend::tool{"platform"} = $gst_dist = $platform; &Utils::Report::do_report ("platform_success", $platform); &Utils::Report::end (); @@ -587,32 +367,51 @@ sub ensure_platform sub guess { my ($object) = @_; - - my %check = ( - # Red Hat check must run after Vine, Mandrake and Fedora, and Mandrake after BlackPanther - "Linux" => [ \&check_lsb, \&check_debian, \&check_caldera, \&check_suse, \&check_blackpanther, \&check_vine, - \&check_fedora, \&check_mandrake, \&check_mandriva, \&check_conectiva, \&check_linuxppc, \&check_redhat, \&check_openna, - \&check_turbolinux, \&check_slackware, \&check_vlos, \&check_gentoo, \&check_pld, \&check_rpath, \&check_archlinux, \&check_ark, \&check_yoper ], - "FreeBSD" => [ \&check_freebsd ], - "SunOS" => [ \&check_solaris ] - ); - my $plat; - - foreach $plat (keys %check) - { - if ($Utils::Backend::tool{"system"} =~ /$plat/) + my ($distro, $func); + my ($checks, $check); + + my %platform_checks = ( + "Linux" => [[ \&check_lsb ], + [ \&check_distro_file, "/etc/debian_version", "debian", "(.*)", { "testing/unstable" => "sarge" } ], + [ \&check_distro_file, "/etc/SuSE-release", "suse", "VERSION\s*=\s*(\S+)" ], + [ \&check_distro_file, "/etc/blackPanther-release", "blackpanther", "^Linux Black Panther release (\S+)" ], + [ \&check_distro_file, "/etc/blackPanther-release", "blackpanther", "^Black Panther ( L|l)inux release ([\d\.]+)" ], + [ \&check_distro_file, "/etc/vine-release", "vine", "^Vine Linux ([0-9.]+)" ], + [ \&check_distro_file, "/etc/fedora-release", "fedora", "^Fedora Core release (\S+)" ], + [ \&check_distro_file, "/etc/mandrake-release", "mandrake", "^Linux Mandrake release (\S+)" ], + [ \&check_distro_file, "/etc/mandrake-release", "mandrake", "^Mandrake( L|l)inux release ([\d\.]+)" ], + [ \&check_distro_file, "/etc/mandriva-release", "mandriva", "^Linux Mandriva release (\S+)" ], + [ \&check_distro_file, "/etc/mandriva-release", "mandriva", "^Mandriva( L|l)inux release ([\d\.]+)" ], + [ \&check_distro_file, "/etc/conectiva-release", "conectiva", "^Conectiva Linux (\S+)" ], + [ \&check_distro_file, "/etc/redhat-release", "redhat", "^Red Hat Linux.*\s+([0-9.]+)" ], + [ \&check_distro_file, "/etc/openna-release", "openna", "^OpenNA (\S+)" ], + [ \&check_distro_file, "/etc/slackware-version", "slackware", "^Slackware ([0-9.]+)" ], + [ \&check_distro_file, "/etc/vlos-release", "vlos", "^VLOS.*\s+([0-9.]+)" ], + [ \&check_file_exists, "/usr/portage", "gentoo" ], + [ \&check_distro_file, "/etc/pld-release", "pld", "^([0-9.]+) PLD Linux" ], + [ \&check_rpath ], + [ \&check_file_exists, "/etc/arch-release", "archlinux" ], + [ \&check_ark ], + [ \&check_yoper ], + ], + "FreeBSD" => [[ \&check_freebsd ]], + "SunOS" => [[ \&check_solaris ]] + ); + + $distro = $Utils::Backend::tool{"system"}; + $checks = $platform_checks{$distro}; + + foreach $check (@$checks) { + $func = shift (@$check); + $dist = &$func (@$check); + + # FIXME: is necessary ensure_platform? + if ($dist != -1 && &ensure_platform ($dist)) { - my ($check, $dist); - - foreach $check (@{$check{$plat}}) - { - $dist = &$check (); - if ($dist != -1 && &ensure_platform ($dist)) - { - $Utils::Backend::tool{"platform"} = $gst_dist = $dist; - return; - } - } + $dist = &ensure_distro_map ($dist); + $Utils::Backend::tool{"platform"} = $gst_dist = $dist; + &Utils::Report::do_report ("platform_success", $dist); + return; } } -- cgit v1.2.3