Per the call today, I found two trivial places to put in support for the OS_Detect framework -- install_cluster and generic-setup. It's actually quite perfect -- if the OS_Detect framework is borked, nothing will work (e.g., most/all of the packages won't install properly).

REMEMBER: We decided to make OS_Detect be, quite literally, the gatekeeper for all OSCAR supported systems. Specifically, if OS_Detect says that this is an unsupported system, then install_cluster will refuse to run. Hence, the modules in OS_Detect must be updated when we include support for a new system (e.g., write a short CentOS.pm and/or ScientificLinux.pm and/or ...).

So I modified install_cluster and generic-setup in my local copy. However, I didn't commit them, because:

1. There is no Mandrake.pm module to recognize Mandrake distro's.
2. There is no module to recognize RedHat 9 (but I think we don't care anymore, right? I ask because generic-setup recognizes it, and I effectively took that support out)

I've attached both a patch showing my changes to install_cluster and generic-setup as well as new versions of the files (to see the whole files rather than in patch form).

Fernando -- do you think you could write a Mandrake.pm in the Near Future? Or do we care if the trunk is borked for MDK for the short time it takes Fernando to write Mandrake.pm?

FWIW: I updated the RedHat.pm module to include support for RHEL AS|WS 4U1 (it already supported 3U[235]). I also improved the error detection in the OS_Detect and OCA bases (mostly corner cases that no one will run into).

Comments?

--
{+} Jeff Squyres
{+} The Open MPI Project
{+} http://www.open-mpi.org/
Index: scripts/generic-setup
===================================================================
--- scripts/generic-setup	(revision 3829)
+++ scripts/generic-setup	(working copy)
@@ -1,6 +1,6 @@
 #!/usr/bin/env perl
 #
-# Copyright (c) 2002-2003 The Trustees of Indiana University.  
+# Copyright (c) 2002-2005 The Trustees of Indiana University.  
 #                         All rights reserved.
 # 
 # This file is part of the OSCAR software package.  For license
@@ -19,7 +19,7 @@
 use lib "$ENV{OSCAR_HOME}/lib";
 use POSIX;
 use Carp;
-use OSCAR::Distro;
+use OSCAR::OCA::OS_Detect;
 use Getopt::Long;
 use File::Basename;
 use File::Copy;
@@ -54,6 +54,9 @@
             'test|t',
             'verbose|v!'
             ) || usage();
+die "Unable to determine operating system"
+    if (1 != OSCAR::OCA::OS_Detect::open());
+my $os = $OS_Detect->{query}();
 
 # set package name
 my $pkg_name = $ENV{OSCAR_PACKAGE_HOME};
@@ -78,7 +81,7 @@
 if ($options{arch}) {
     $march = $options{arch};
 } else {
-    chop ($march = `uname -m`);
+    $march = $os->{arch};
     $march = "i386" if $march =~ /^i[3456]86$/;
 }
 
@@ -220,19 +223,14 @@
     if ($options{distro}) {
 	($name, $ver) = split /-/, $options{distro};
     } else {
-	($name, $ver) = OSCAR::Distro::which_distro_server();
+        $name = $os->{linux_distro};
+        $ver = $os->{linx_distro_version};
 
 	# translate distro names
-	if ($name eq "redhat") {
-	    if ($ver eq "3as") {
-		$name = "rhel";
-		$ver = "3";
-	    } elsif ($ver eq "el4") {
-		$name = "rhel";
-		$ver = "4";
-	    } else {
-		$name = "rh";
-	    }
+	if ($name eq "redhat-el-as" || $name eq "redhat-el-ws") {
+            $name = "rhel";
+	} elsif ($name eq "redhat") {
+	    $name = "rh";
 	} elsif ($name eq "fedora") {
 	    $name = "fc";
 	} elsif ($name eq "mandrake") {
@@ -260,7 +258,7 @@
   displayed in the STDOUT of the command as comment.
 
  Options:
-   --arch|-a      : override locally detected architecture (uname -m !)
+   --arch|-a      : override locally detected architecture
    --distro  D-V  : translated distro string (for testing only!)
    --erase|-e     : erase packages with same name from RPM pool (tftpboot/rpm)
    --help|-h      : display this help text
Index: install_cluster
===================================================================
--- install_cluster	(revision 3829)
+++ install_cluster	(working copy)
@@ -6,8 +6,8 @@
 #                     All rights reserved.
 # Copyright 2002 International Business Machines
 #                Sean Dague <[EMAIL PROTECTED]>
-# Copyright (c) 2002 The Trustees of Indiana University.  
-#                    All rights reserved.
+# Copyright (c) 2002-2005 The Trustees of Indiana University.  
+#                         All rights reserved.
 #
 # $Id$
 # 
@@ -34,7 +34,7 @@
 use lib cwd() . "/lib";
 use vars qw($VERSION);
 use OSCAR::Logger;
-use OSCAR::Distro;
+use OSCAR::OCA::OS_Detect;
 use POSIX;
 use Carp;
 use OSCAR::Database;
@@ -193,6 +193,15 @@
 $ENV{LC_NUMERIC} = "C";
 $ENV{LC_TIME} = "C";
 
+# Check to see if this is a supported platform
+
+oscar_log_subsection("Checking if this is a supported platform");
+if (1 != OSCAR::OCA::OS_Detect::open()) {
+    print("ERROR: This is an unsupported system.  Specifically, no module in OSCAR/OCA/OS_Detect positively identified this as a supported system.\n");
+    die("Cannot continue");
+}
+my $os = $OS_Detect->{query}();
+
 # add entries to path that we know we will need
 
 $ENV{PATH} = $ENV{PATH} .
@@ -273,10 +282,9 @@
 oscar_log_subsection("Hostname: $shorthostname");
 oscar_log_subsection("Domainname: $domainname");
 oscar_log_subsection("Network interface: $adapter");
-my ($distro_name, $distro_version) = which_distro_server();
-oscar_log_subsection("Linux distribution: $distro_name $distro_version");
+oscar_log_subsection("Linux distribution: $os->{linux_distro} $os->{linux_distro_version}");
 oscar_log_subsection("Kernel version: " . (uname)[2]);
-oscar_log_subsection("Architecture: " . (uname)[4]);
+oscar_log_subsection("Architecture: $os->{arch}");
 oscar_log_subsection("Running in directory: " . cwd());
 oscar_log_subsection("PATH: " . $ENV{PATH});
 
@@ -295,12 +303,6 @@
 OSCAR requires that you choose another hostname.
 Aborting the install.\n");
 }
-if ($distro_name eq "UnknownLinux") {
-    carp("
-##########################################################################
-   WARNING: Installing OSCAR on an unsupported distribution of Linux!
-##########################################################################\n");
-}
 if (!$ENV{DISPLAY}) {
     die("
 ERROR: Your \"DISPLAY\" environment variable is not set, probably
#!/usr/bin/perl

# Copyright 2004 Revolution Linux
#           Benoit des Ligneris <[EMAIL PROTECTED]>
# Copyright (c) 2003, The Board of Trustees of the University of Illinois.
#                     All rights reserved.
# Copyright 2002 International Business Machines
#                Sean Dague <[EMAIL PROTECTED]>
# Copyright (c) 2002-2005 The Trustees of Indiana University.  
#                         All rights reserved.
#
# $Id: install_cluster 3782 2005-10-04 20:41:05Z naughton $
# 
#   This program is free software; you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation; either version 2 of the License, or
#   (at your option) any later version.
 
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
 
#   You should have received a copy of the GNU General Public License
#   along with this program; if not, write to the Free Software
#   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

#   This is the oscar installation program.  It must be called with
#   one argument which is the installation network device

use strict;
use Cwd qw(chdir cwd);

use lib cwd() . "/lib";
use vars qw($VERSION);
use OSCAR::Logger;
use OSCAR::OCA::OS_Detect;
use POSIX;
use Carp;
use OSCAR::Database;

# First of all, enforce that the user running this script is 'root'

croak "You must be 'root' to run this script.  Aborting" if ($< != 0);

# Validate the interface before we do too much...

my %nics;
open IN, "/sbin/ifconfig |" || die "ERROR: Unable to query NICs\n";
while( <IN> ) {
        next if /^\s/ || /^lo\W/;
        chomp;
        s/\s.*$//;
        $nics{$_} = 1;
}
close IN;

my $adapter = shift;
die "
ERROR: A valid NIC must be specified for the cluster private network.

Valid NICs: ".join( ", ", sort keys %nics )."\n\n"
        unless $adapter && exists $nics{$adapter};

# If $OSCAR_HOME is not set, then set it with whatever came in from
# configure's --prefix.

if (!defined($ENV{OSCAR_HOME})) {
    my $found = 0;

    # Look for an output file from configure that specifies where
    # OSCAR_HOME should be.  First look relative to this directory,
    # then look in /etc/profile.d.

    if (-f "scripts/oscar_home.sh" &&
        open(OH, "grep OSCAR_HOME scripts/oscar_home.sh|")) {
        $found = 1;
    } elsif (-f "/etc/profile.d/oscar_home.sh" &&
             open(OH, "grep OSCAR_HOME /etc/profile.d/oscar_home.sh|")) {
        $found = 1;
    }

    # If we found it, read and use it.  Otherwise, complain and exit.

    if ($found == 1) {
        my $temp = <OH>;
        chomp($temp);
        close(OH);

        my ($bogus, $oscar_home) = split(/=/, $temp);
        $ENV{OSCAR_HOME} = $oscar_home;
        printf("Manually setting OSCAR_HOME to: $ENV{OSCAR_HOME}\n");
    } else {
            die("ERROR: You must (at a minimum) run configure first.\n");
    }
}

# Now check to see if there is an $ENV{OSCAR_HOME} directory, and if
# so, if we're in it.

if (! -d $ENV{OSCAR_HOME}) {
    die("ERROR: The environment variable \$OSCAR_HOME was set, but the 
directory 
that it points to ($ENV{OSCAR_HOME}) does not exist!");
}
if (!chdir($ENV{OSCAR_HOME})) {
    die("ERROR: The environment variable \$OSCAR_HOME was set, but could not 
change into the directory that it points to ($ENV{OSCAR_HOME})!");
}

# Get OSCAR's version

my $oscar_version;
if (!open (V, "VERSION")) {
    die("ERROR: Unable to open OSCAR's VERSION file");
}
while (<V>) {
    chomp;
    $oscar_version = $_;
}
close(V);

# Once here, we know that $ENV{OSCAR_HOME} is set, it exists, we can
# get in it, and we have successfully read the VERSION file from it.
# So we should be good to go for the rest of the installation.

# Setup the lockfile

my $lockfile = "$ENV{OSCAR_HOME}/.install_cluster_lockfile";

# Set perl to autoflush all output

$| = 1;

# END processing to remove the lockfile when we die(), exit, or otherwise
# cease to exist.
END {
    unlink $lockfile if $lockfile && -f $lockfile;
}

# Check for the lockfile (this is certainly not foolproof -- it's just
# "good enough")

if (-f $lockfile) {
    open(LOCKFILE, $lockfile);
    my $pid = <LOCKFILE>;
    close(LOCKFILE);
    # chmod($pid);  DNL ASKS: WHO THINKS THIS DOES ANYTHING CORRECT?
    chomp $pid;  #  DNL: Perhaps this was meant?
    print "There is an OSCAR installer lockfile that says an installer 
process\n";
    print "is still running with process id $pid. Checking if that is true 
...\n";
    if( kill 0, $pid ) {
        print "There is a process running with that process id.\n";
        print "If this is no an OSCAR installer process, remove\n";
        print "the following file and run $0 again:\n";
        print "$lockfile\n";
        undef $lockfile; # Prevent END processing from deleting lockfile.
        exit(0);
    } else {
        print "There is no process running with process id $pid.\n";
        print "Removing lockfile $lockfile and continuing.\n";
        unlink $lockfile;
    }
}

# Write our PID to the lockfile

open(LOCKFILE, ">$lockfile");
print LOCKFILE $$;
close(LOCKFILE);

# Setup to capture all stdout/stderr

my $oscar_logfile = $ENV{OSCAR_HOME} . "/oscarinstall.log";
if (!open (STDOUT,"| tee $oscar_logfile") || !open(STDERR,">&STDOUT")) {
    die("ERROR: Cannot tee stdout/stderr into the OSCAR logfile:
   $oscar_logfile
Aborting the install.\n");
}

# First output banner

oscar_log_section("Running OSCAR install_cluster script");

# Fix to make multi lingualness work

$ENV{LANG} = "C";
$ENV{LC_ALL} = "C";
$ENV{LANGUAGE} = "C";
$ENV{LC_COLLATE} = "C";
$ENV{LC_CTYPE} = "C";
$ENV{LC_MESSAGES} = "C";
$ENV{LC_MONETARY} = "C";
$ENV{LC_NUMERIC} = "C";
$ENV{LC_TIME} = "C";

# Check to see if this is a supported platform

oscar_log_subsection("Checking if this is a supported platform");
if (1 != OSCAR::OCA::OS_Detect::open()) {
    print("ERROR: This is an unsupported system.  Specifically, no module in 
OSCAR/OCA/OS_Detect positively identified this as a supported system.\n");
    die("Cannot continue");
}
my $os = $OS_Detect->{query}();

# add entries to path that we know we will need

$ENV{PATH} = $ENV{PATH} .
    ':/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin';

# Sanity check: ensure that /tftpboot/rpm exists

oscar_log_subsection("Quick sanity check for /tftpboot/rpm");
if (! -d "/tftpboot/rpm") {
    print("ERROR: /tftpboot/rpm directory does not exist.  You must create this 
directory\nand copy all of your distro RPMs there before running 
install_cluster.\n");
    die("Cannot continue");
}

# Ensure that the package scripts are executable (wizard_prep runs
# some of them)

system("chmod 755 packages/*/scripts/*");

my $pqtv = `rpm -q --quiet --qf '%{VERSION}' perl-Qt 2>/dev/null`;
if ( $pqtv && $pqtv < 3 ) {
  !system("rpm -e perl-Qt") or warn("Couldn't remove perl-Qt");
  oscar_log_subsection("Removing installed perl-Qt RPM because version is < 3");
}

# get rid of installed tftp-server, it conflicts with atftp
# (there should be a check whether this is an RPM based distro here!)
if (!system("rpm -q tftp-server >/dev/null 2>&1")) {
  oscar_log_subsection("Removing installed tftp-server RPM, this conflicts with 
OSCAR atftp-server");
  !system("rpm -e tftp-server") or warn("Couldn't remove tftp-server");
}

# TJN (10/4/2005): Note, a fairly evil, totally non-obvious issue 
#    occurs if you have /tftpboot setup as a symlink,
#    e.g., /tftpboot -> /var/tftpboot/,  and remove 'tftp-server'. 
#    What happens is the '/tftpboot' dir (symlink) gets removed!  
#    This is b/c '/tftpboot' is part of the RPM file manifest for 
#    tftp-server (at least as of v0.33-3 it does). 
#
#    Adding a sanity check after the RPM removes to check for this case!

croak "\nError: \'/tftpboot\' is gone!" if(! -d "/tftpboot" );


# Run the wizard_prep script

my $cmd = "cd $ENV{OSCAR_HOME}/scripts && ./wizard_prep";
oscar_log_subsection("Running: \"$cmd\"");
!system($cmd)
    or die("Oscar Wizard preparation script failed to complete");
oscar_log_subsection("Successfully ran wizard_prep");
#
# HORRIBLE HACK ALERT -- FIXING MANDRAKE SNAFU
#
#print __FILE__,":",__LINE__,":INC:",join(", ",@INC),"\n";
my %incs = map { $_ => 1 } @INC;
foreach ( `perl -e 'print "\$_\n" foreach [EMAIL PROTECTED]'` ) {
        chomp;
        eval "use lib \"$_\"" unless $incs{$_};
}
undef %incs;
#print __FILE__,":",__LINE__,":INC:",join(", ",@INC),"\n";

# Seed ODA
system("oda modify_records oscar.interface~$adapter");
$adapter = `oda read_records oscar.interface`;

$ENV{OSCAR_HEAD_INTERNAL_INTERFACE}=$adapter;

oscar_log_section("Prerequisites installed");

# Print some environment information

oscar_log_subsection("OSCAR version: $oscar_version");
my $hostname = (uname)[1];
my ($shorthostname, $domainname) = split(/\./,$hostname,2);
oscar_log_subsection("Command line invocation: $0 $adapter " . 
                     join(" ", @ARGV));
oscar_log_subsection("Hostname: $shorthostname");
oscar_log_subsection("Domainname: $domainname");
oscar_log_subsection("Network interface: $adapter");
oscar_log_subsection("Linux distribution: $os->{linux_distro} 
$os->{linux_distro_version}");
oscar_log_subsection("Kernel version: " . (uname)[2]);
oscar_log_subsection("Architecture: $os->{arch}");
oscar_log_subsection("Running in directory: " . cwd());
oscar_log_subsection("PATH: " . $ENV{PATH});

# Do some basic sanity checks -- fail immediately if we can tell right
# now that this install won't [eventually] succeed.

if ($shorthostname eq "localhost") {
    die("
ERROR: Your hostname is \"localhost\".
OSCAR requires that you choose another hostname.
Aborting the install.\n");
}
if ($hostname eq "localhost.localdomain") {
    die("
ERROR: Your hostname is \"localhost.localdomain\".
OSCAR requires that you choose another hostname.
Aborting the install.\n");
}
if (!$ENV{DISPLAY}) {
    die("
ERROR: Your \"DISPLAY\" environment variable is not set, probably
indicating that you are not running in an X windows environment.
OSCAR requires that you run the installer in an X windows environment.
Aborting the install.\n");
}

# Check for 2 rpms 1 from each CD

my @filesystem=glob("/tftpboot/rpm/filesystem*rpm");
my @rsync=glob("/tftpboot/rpm/rsync*rpm");
if ((scalar(@filesystem)==0) || (scalar(@rsync)==0)) {
    die("RPMs missing in /tftpboot/rpm/ (did you copy all CDs?)");
}

# Now start the execution

chdir("scripts") or die("Couldn't chdir to scripts");

# Only setup what we have to get to the OSCAR wizard.  All the rest of
# server prep is going to be driven after the first panel of
# questions.

$cmd = "./oscar_wizard";
oscar_log_subsection("Running: \"$cmd\"");
!system("$cmd 2>&1") 
    or die("Oscar Wizard failed to run successfully");
oscar_log_subsection("Successfully ran oscar_wizard");

oscar_log_subsection("Successfully ran OSCAR install_cluster script");

# All done.
#!/usr/bin/env perl
#
# Copyright (c) 2002-2005 The Trustees of Indiana University.  
#                         All rights reserved.
# 
# This file is part of the OSCAR software package.  For license
# information, see the COPYING file in the top level directory of the
# OSCAR source distribution.
#
# Generic setup script for copying distro and arch specific RPMs/packages
# from distro/*/ to /tftpboot/rpm. Can also be used for deleting RPMs from
# the /tftpboot/rpm package pool.
#
# $Id: generic-setup 3486 2005-08-14 22:08:57Z dnl $
#
# (c) 2005 Erich Focht <[EMAIL PROTECTED]>

use strict;
use lib "$ENV{OSCAR_HOME}/lib";
use POSIX;
use Carp;
use OSCAR::OCA::OS_Detect;
use Getopt::Long;
use File::Basename;
use File::Copy;

sub vprint;

# One must always protect oneself.
#
die "\$OSCAR_HOME: not defined.\n" unless exists $ENV{OSCAR_HOME};
die "$ENV{OSCAR_HOME}: not a directory.\n" unless -d $ENV{OSCAR_HOME};
die "$ENV{OSCAR_HOME}: not accessible.\n" unless -x $ENV{OSCAR_HOME};
die "\$OSCAR_PACKAGE_HOME: not defined.\n" unless exists 
$ENV{OSCAR_PACKAGE_HOME};
die "$ENV{OSCAR_PACKAGE_HOME}: not a directory.\n" unless -d 
$ENV{OSCAR_PACKAGE_HOME};
die "$ENV{OSCAR_PACKAGE_HOME}: not accessible.\n" unless -x 
$ENV{OSCAR_PACKAGE_HOME};

# Different distros require different RPMs. Different architectures, too.

my $base_dir= $ENV{OSCAR_PACKAGE_HOME} . "/distro";
my $oscar_pkg_pool = '/tftpboot/rpm';   # No env var, using name in Package.pm

# configure command line options parsing
Getopt::Long::Configure("ignore_case"); # ignore case
Getopt::Long::Configure("auto_abbrev"); # allow abbreviated input

my %options;
GetOptions( \%options,
            'arch|a',
            'distro|d=s',
            'erase|e',
            'help|h',
            'pool|p=s',
            'test|t',
            'verbose|v!'
            ) || usage();
die "Unable to determine operating system"
    if (1 != OSCAR::OCA::OS_Detect::open());
my $os = $OS_Detect->{query}();

# set package name
my $pkg_name = $ENV{OSCAR_PACKAGE_HOME};
$pkg_name =~ s:^.*\/::g;

# force verbose output if --test was selected
$options{verbose} = 1 if exists $ENV{DEBUG_OSCAR_SETUP} || $options{test};

if ($options{pool}) {
    $oscar_pkg_pool = $options{pool};
}

usage() if ($options{help});

# Quick sanity check
if (! -d $oscar_pkg_pool) {
    croak("Directory $oscar_pkg_pool does not exist");
}

# Which architecture are we dealing with?
my $march;
if ($options{arch}) {
    $march = $options{arch};
} else {
    $march = $os->{arch};
    $march = "i386" if $march =~ /^i[3456]86$/;
}

#
# Packages to which command applies. If empty, use all packages!
#
my @argpkgs = @ARGV;

################################
## Do the job
################################

# List of RPM files found in the distro-specific directories
my @pkgfiles;

# Find first compatible subdirectory
# Note ordering, later occurrence of identical filenames overwrite earlier.
# ../RPMS, common-arch, and distro-compat dir.
#
my @src_dirs;
push @src_dirs, "../RPMS" if (-d "$base_dir/../RPMS");
push @src_dirs, "common-rpms" if (-d "$base_dir/common-rpms");
for my $dir (distro_compat()) {
    if (-d "$base_dir/$dir") {
        push @src_dirs, $dir;
        last;
    }
}
print "Distro specific packages come from\n\t$base_dir/"
       . join("\n\t$base_dir/",@src_dirs)."\n";

# List packages.
#
my %pkglist = map { /([^\/]+)$/, $_ } map { glob("$base_dir/$_/*") } @src_dirs;
vprint "Available Packages:\n\t".join( "\n\t", map {"$_: $pkglist{$_}"} keys 
%pkglist )."\n";

#
# No packages on the argument line? Then take all packages.
#
@argpkgs = keys %pkglist unless @argpkgs;

###
# Copy packages to the package pool.
###
for my $pkg (@argpkgs) {
    
    my $basename;

    my @possibles = grep /^\Q$pkg\E[-\.]/, keys %pkglist;
    push @possibles, ($pkg) if exists $pkglist{$pkg};  # above fails for 
complete match.
    vprint "Matching packages:\n\t".join( "\n\t", @possibles )."\n" if 
@possibles > 1;
    unless ( @possibles ) {
        print STDERR "Package $pkg not found\n";
        next;
    }
    if( @possibles == 1 ) {
        $basename = $possibles[0];
    } else {
        $basename = (sort {length($a) <=> length($b)} @possibles)[0];
    }
    if ($options{erase}) {
        print " Delete $basename from $oscar_pkg_pool\n";
        unless( -f "$oscar_pkg_pool/$basename" && $options{test} ) {
            unlink( "$oscar_pkg_pool/$basename" ) ||
                croak("Error occured while deleting: $!");
        }
    } else {
        my $filename = $pkglist{$basename};
        my $msg = dirname($filename)."/${pkg}.txt";
        if (-f $msg) {
            print STDOUT "\n::::::::::::::-------------------------\n";
            open IN, "< $msg" or croak("Couldn't open $msg");
            my @lines = <IN>;
            close IN;
            print STDOUT map {": $_"} @lines;
            print STDOUT "::::::::::::::-------------------------\n";
        }
        print " Copy $filename -> $oscar_pkg_pool\n";
        if (!defined $options{test}) {
            copy($filename, $oscar_pkg_pool) ||
                croak("Error occured while copying: $!");
        }
    }
}

exit 0;

############################################################################
######## only subroutines below
############################################################################

sub vprint {
    print @_ if ($options{verbose});
}

#
# Compatibility chain of distro-specific RPM sources
#
sub distro_compat {
    my @compatlist;
    # get standard distro name and version
    my ($name, $ver) = distroname();

    # remove "." from version name
    my $ver1 = $ver;
    $ver1 =~ s/\.//;

    # remove part behind first dot in version name
    my $ver2 = $ver;
    $ver2 =~ s/\..*$//g;

    # the order is important!
    push @compatlist, $name . $ver  . "-" . $march;
    push @compatlist, $name . $ver;
    if( $ver1 ne $ver ) {
        push @compatlist, $name . $ver1 . "-" . $march;
        push @compatlist, $name . $ver1;
    }
    if( $ver2 ne $ver ) {
        push @compatlist, $name . $ver2 . "-" . $march;
        push @compatlist, $name . $ver2;
    }
    push @compatlist, $name         . "-" . $march;
    push @compatlist, $name;

    vprint("Compatlist: ".join(" ",@compatlist)."\n");
    return @compatlist;
}

#
# Standardized distribution subdirectory name.
# Currently based on the OSCAR::Distro.pm framework, should be migrated to
# OSCAR::OCA::OS_Detect as soon as that framework is complete.
#
sub distroname {
    my ($name, $ver);

    # override distro detection
    if ($options{distro}) {
        ($name, $ver) = split /-/, $options{distro};
    } else {
        $name = $os->{linux_distro};
        $ver = $os->{linx_distro_version};

        # translate distro names
        if ($name eq "redhat-el-as" || $name eq "redhat-el-ws") {
            $name = "rhel";
        } elsif ($name eq "redhat") {
            $name = "rh";
        } elsif ($name eq "fedora") {
            $name = "fc";
        } elsif ($name eq "mandrake") {
            $name = "mdk";
        }
    }
    return ($name,$ver);
}


sub usage {
    print <<END_USAGE;
Usage: generic-setup [options] [pkg1 pkg2 ...]

  Scan the distribution specific directories distro/\$distro\$version-\$arch
  and the common directory (distro/common-rpms) for best packages for
  current or specified architecture (or noarch). Either copy the package
  files to the OSCAR package repository (/tftpboot/rpm) or delete them
  from there.

  If package names are passed as arguments, actions are limited to these
  packages.

  When copying in packages, if a file named \$pkg.txt exists, it will be
  displayed in the STDOUT of the command as comment.

 Options:
   --arch|-a      : override locally detected architecture
   --distro  D-V  : translated distro string (for testing only!)
   --erase|-e     : erase packages with same name from RPM pool (tftpboot/rpm)
   --help|-h      : display this help text
   --pool|-p path : override setting of RPM pool path (default /tftpboot/rpm)
   --test|-t      : just test without copying or erasing files
   --verbose|-v   : verbose printout
END_USAGE
   exit(1);
}

Reply via email to