#
#  ROCK Linux specific administration (gets ignored when running on a
#  different Linux distribution).
#
#  20010507  Initial version (Pjotr)
#
#  $Id: rockadm.pl,v 1.1 2001/05/07 19:38:20 wrk Exp $
#

my $isrock = undef;

sub isRock
{
  if ($isrock==undef)
  {
    $isrock = (-e "/etc/conf/NOTE");
  }

  return $isrock;
}

sub is_base_bin
{
  my $fn = shift;
  return ((-x $fn) && (!-d $fn) && (!-l $fn) && (!-p $fn));
}

sub list_rock_base_bin
{
  (!isRock) && return;
  walk_rock_flists(\&is_base_bin);
}

sub list_rock_base_lib
{
  (!isRock) && return;
}

sub list_rock_base_etc
{
  (!isRock) && return;
  my $fn = shift;
  return ($fn =~ /\/etc\//);
}

return 1;

# --------------------------------------------------------------------

sub walk_rock_flists
{
   my ($callback) = @_;
   my @flists = filelist('/var/adm/flists');
   foreach my $fn (@flists)
   {
      open(FLIST,$fn) || print "Warning file $fn does not exist!";
      while (<FLIST>)
      {
        my ($pkg,$addfn) = split;
        $addfn = '/'.$addfn;
        # print "{$addfn}\n";
        if (&$callback($addfn))
	{
          # print $addfn;
          # print '.';
          push @twlist,$addfn;
	}
      }
      close(FLIST);
   }
   return @twlist;
}

# --------------------------------------------------------------------

