#!/usr/bin/perl
use strict;
use Getopt::Std;
use File::Basename;

BEGIN
  {
	# this enables us to redirect where it looks for other CSM files during development
	$::csmroot = $ENV{'CSM_ROOT'} ? $ENV{'CSM_ROOT'} : '/opt/csm';
	$::csmpm = "$::csmroot/pm";
	$::csmbin = "$::csmroot/bin";
  }
use lib $::csmpm;
use CSMDefs;
$::MSGMAPPATH = $ENV{'CSM_MSGMAPS'} ? $ENV{'CSM_MSGMAPS'} : '/opt/csm/msgmaps';

&show_supported_linux_distros;

my @aix_versions=qw(5.3 6.1);
#foreach my $version (@aix_versions) {    print "AIX:||:IBM:||:$version:||:GA\n"; } # mount the cd, and check for any additional RPMs in there
my $version; my $vios_version;
my %aix_to_vios= ("5.3" => ["1.4.1.0", "1.5", "1.5.2"]);

foreach $version (@aix_versions)
{
        print "AIX:||:AIX:||:$version:||:GA\n";
}

foreach $version (@aix_versions)
{
        foreach $vios_version (@{$aix_to_vios{$version}})
        {
                print "VIOS:||:VIOS:||:$vios_version:||:GA\n";
        }
}

sub show_supported_linux_distros
{
	my ($ostype, $osdistro, $osversion, $architecture, $svclevel);

	foreach my $key (sort keys %::distro_id)
	{
		$ostype       = "Linux"; # Only Linux is included in distro_id file
		$osdistro     = $::distro_id{$key}{'distro_name'};
		$osversion    = $::distro_id{$key}{'distro_version'};
		$architecture = $::distro_id{$key}{'arch'};
		$svclevel     = $::distro_id{$key}{'svc_level'};

		# Weed out the distros that are not relevant to OS_install environment
		next if (($ostype ne "Linux") or ($architecture ne "ppc64"));
		next if (($osdistro =~ /RedHat/) and ($osversion < 4));
		next if (($osdistro =~ /SLES/) and ($osversion < 9));

		print $ostype . ":||:";
		print $osdistro . ":||:";
		print $osversion . ":||:";
		print $svclevel . "\n";
	}
}
