;
}
close(FILE);
@field = split(/\s/, $firstline);
$j = @field;
for ($i = 0; $i < $j; $i++) {
if ($field[$i] =~ /\{/) {
$fileset{"fileset_name"} = $field[$i - 1] =~ /\>|\s+/ ? $file :
$field[$i - 1];
}
}
@output = split(/\n/, $out);
$j = @output;
for ($i = 0; $i < $j; $i++) {
if ($output[$i] !~ /\{|\}|\*/) {
@field = split(/\s/, $output[$i]);
$out = undef;
$out = "$fileset{fileset_name} ";
$description = undef;
@vrmf = split(/\./, $field[1]);
$vrmf[0] =~ s/^0+//;
$vrmf[1] =~ s/^0+//; if ($vrmf[1] == "") { $vrmf[1] = "0"; }
$vrmf[2] =~ s/^0+//; if ($vrmf[2] == "") { $vrmf[2] = "0"; }
$vrmf[3] =~ s/^0+//; if ($vrmf[3] == "") { $vrmf[3] = "0"; }
if ($vrmf[0] != "") {
$k = @field;
for ($l = 6; $l <= $k; $l++) {
$description = $description . " " . $field[$l];
}
$out = $out . "$field[0], $vrmf[0].$vrmf[1].$vrmf[2].$vrmf[3], $description";
}
}
push(@rv, $out);
}
return @rv;
}
}
else { return undef; }
}
# install_options(file, package)
# Outputs HTML for choosing install options
sub install_options
{
local(@token, $command, $i, $j, $file, $directory);
@token = split(/\//, $_[0]);
$i = @token;
for ( $j = 1; $j < $i - 1; $j++) {
$directory = join("/", $directory, $token[$j]);
}
$file = $token[$i-1];
print "\n";
print "\n";
print "| ", &hlink("$text{'aix_device'}", "aix_device"), " | \n";
print "$directory | \n";
print "
\n";
print "\n";
print "| ", &hlink("$text{'aix_software'}", "aix_software"), " | \n";
print "$file | \n";
print "
\n";
print "\n";
print "| ", &hlink("$text{'aix_preview'}", "aix_preview"), " | \n";
print " $text{'yes'}\n";
print " $text{'no'} | \n";
print "
\n";
print "\n";
print "| ", &hlink("$text{'aix_commit'}", "aix_commit"), " | \n";
print " $text{'yes'}\n";
print " $text{'no'} | \n";
print "
\n";
print "\n";
print "| ", &hlink("$text{'aix_save'}", "aix_save"), " | \n";
print " $text{'yes'}\n";
print " $text{'no'} | \n";
print "
\n";
print "\n";
print "| ", &hlink("$text{'aix_auto'}", "aix_auto"), " | \n";
print " $text{'yes'}\n";
print " $text{'no'} | \n";
print "
\n";
print "\n";
print "| ", &hlink("$text{'aix_extend'}", "aix_extend"), " | \n";
print " $text{'yes'}\n";
print " $text{'no'} | \n";
print "
\n";
print "\n";
print "| ", &hlink("$text{'aix_overwrite'}", "aix_overwrite"), " | \n";
print " $text{'yes'}\n";
print " $text{'no'} | \n";
print "
\n";
print "\n";
print "| ", &hlink("$text{'aix_verify'}", "aix_verify"), " | \n";
print " $text{'yes'}\n";
print " $text{'no'} | \n";
print "
\n";
# print "\n";
# print "| ", &hlink("$text{'aix_include'}", "aix_include"), " | \n";
# print " $text{'yes'}\n";
# print " $text{'no'} | \n";
# print "
\n";
print "\n";
print "| ", &hlink("$text{'aix_detail'}", "aix_detail"), " | \n";
print " $text{'yes'}\n";
print " $text{'no'} | \n";
print "
\n";
print "\n";
print "| ", &hlink("$text{'aix_process'}", "aix_process"), " | \n";
print " $text{'yes'}\n";
print " $text{'no'} | \n";
print "
\n";
print "\n";
print "| ", &hlink("$text{'aix_accept'}", "aix_accept"), " | \n";
print " $text{'yes'}\n";
print " $text{'no'} | \n";
print "
\n";
print "\n";
print "| ", &hlink("$text{'aix_license'}", "aix_license"), " | \n";
print " $text{'yes'}\n";
print " $text{'no'} | \n";
print "
\n";
print "\n";
print "| ", &hlink("$text{'aix_clean'}", "aix_clean"), " | \n";
print " $text{'yes'}\n";
print " $text{'no'} | \n";
print "
\n";
}
# install_package(file, package)
# Installs the package in the given file, with options from %in
sub install_package
{
local(@token, $command, $directory, $out);
@token = split(/\//, $_[0]);
$i = @token;
for ( $j = 1; $j < $i - 1; $j++) {
$directory = join("/", $directory, $token[$j]);
}
local $args = ($in{"preview"} ? "p" : "") .
($in{"commit"} ? "c" : "") .
($in{"save"} ? "" : "N") .
($in{"auto"} ? "g" : "") .
($in{"extend"} ? "X" : "") .
($in{"overwrite"} ? "F" : "") .
($in{"verify"} ? "v" : "") .
# ($in{"include"} ? "G" : "") .
($in{"detail"} ? "V2" : "") .
($in{"process"} ? "" : "S") .
($in{"accept"} ? "Y" : "") .
($in{"license"} ? "E" : "");
$command = "geninstall -I \"-a$args\" -d '$directory' '$fileset{fileset_name}' 2>&1";
if ($in{"clean"}) {
$args = "-C";
$command = "installp $args 2>&1";
}
local $out = &backquote_logged($command);
if (($?) || ($in{"preview"}) || ($in{"clean"})) {
return "$command
$out
";
}
return undef;
}
# check_files(package)
# Fills in the %files array with information about the files belonging
# to some package. Values in %files are path type user group mode size error link
sub check_files
{
local($_, $list, $i, $_, @w, %errs, %myfile, $epath, $path, $fileset, $file);
local $qm = quotemeta($_[0]);
$i = 0;
$list = join(' ', @_);
&open_execute_command(LSLPP, "lslpp -f -c $qm 2>&1 | grep -v '#'", 1, 1);
$out = ;
if ($out =~ /lslpp:/) {
&open_execute_command(RPM, "rpm -V $qm", 1, 1);
while() {
/^(.{8}) (.) (.*)$/;
if ($1 eq "missing ") { $errs{$3} = "Missing"; }
else {
$epath = $3;
@w = grep { $_ ne "." } split(//, $1);
$errs{$epath} =
join("\n", map { "Failed $etype{$_} check" } @w);
}
}
close(RPM);
&open_execute_command(RPM, "rpm -q $qm -l --dump", 1, 1);
while() {
chop;
if ($_ =~ /(contains no files)/) { return $i; }
@w = split(/ /);
$files{$i,'path'} = $w[0];
if ($w[10] ne "X") { $files{$i,'link'} = $w[10]; }
$files{$i,'type'} = $w[10] ne "X" ? 3 :
(-d &translate_filename($w[0]))? 1 :
$w[7] ? 5 : 0;
$files{$i,'user'} = $w[5];
$files{$i,'group'} = $w[6];
$files{$i,'size'} = $w[1];
$files{$i,'error'} = $w[7] ? "" : $errs{$w[0]};
$i++;
}
close(RPM);
}
else {
while($fileinfo = ) {
chop($fileinfo);
#Path:Fileset:File
($path, $fileset, $file) = split(/:/, $fileinfo);
%myfile = &file_info($file);
$files{$i,'path'} = $myfile{"path"};
$files{$i,'type'} = $myfile{"type"};
$files{$i,'user'} = $myfile{"uid"};
$files{$i,'group'} = $myfile{"gid"};
$files{$i,'mode'} = $myfile{"mode"};
$files{$i,'size'} = $myfile{"size"};
$files{$i,'link'} = $myfile{"link"};
$files{$i,'error'} = $myfile{"err"};
$i++;
}
}
close(LSLPP);
return $i;
}
# installed_file(file)
# Given a filename, fills %file with details of the given file and returns 1.
# If the file is not known to the package system, returns 0
# Usable values in %file are path type user group mode size packages
sub installed_file
{
local(%myfile);
local $qm = quotemeta($_[0]);
$out = &backquote_command("lslpp -wc $qm 2>&1 | grep -v '#'", 1);
if ($?) {
local($pkg, @w, $_);
undef(%file);
$pkg = &backquote_command("rpm -q -f $qm --queryformat \"%{NAME}-%{VERSION}\\n\" 2>&1", 1);
if ($pkg =~ /not owned/ || $?) { return 0; }
@pkgs = split(/\n/, $pkg);
&open_execute_command(RPM, "rpm -q $pkgs[0] -l --dump", 1);
while() {
chop;
@w = split(/ /);
if ($w[0] eq $_[0]) {
$file{'packages'} = join(' ', @pkgs);
$file{'path'} = $w[0];
if ($w[10] ne "X") { $files{$i,'link'} = $w[10]; }
$file{'type'} = $w[10] ne "X" ? 3 :
(-d &translate_filename($w[0])) ? 1 :
$w[7] ? 5 : 0;
$file{'user'} = $w[5];
$file{'group'}= $w[6];
$file{'mode'} = substr($w[4], -4);
$file{'size'} = $w[1];
last;
}
}
close(RPM);
}
else {
%myfile = &file_info($_[0]);
$file{'path'} = $myfile{"path"};
$file{'type'} = $myfile{"type"};
$file{'user'} = $myfile{"uid"};
$file{'group'} = $myfile{"gid"};
$file{'mode'} = $myfile{"mode"};
$file{'size'} = $myfile{"size"};
$file{'link'} = $myfile{"link"};
$file{'packages'} = $myfile{"package"};
}
return 1;
}
# delete_package(package)
# Totally remove some package
sub delete_package
{
local(%fileset, $file, $out, $rv);
local $temp = &transname();
local $qm = quotemeta($_[0]);
$file = &backquote_command("lslpp -L -c $qm 2>&1 | grep -v '#'", 1);
%fileset = &fileset_info($file);
$rv = &system_logged("geninstall -u $_[0] >$temp 2>&1");
local $out = &backquote_command("cat $temp");
&unlink_file($temp);
if ($rv) { return "$out
"; }
return undef;
}
sub fileset_info
{
local($_, $out, %fileset, $package_name, $fileset, $level, $state, $ptf_id,
$fix_state, $type, $description, $destination_dir, $uninstaller,
$msg_cat, $msg_set, $msg_num, $parent, $class);
%fileset = ();
($package_name, $fileset, $level, $state, $ptf_id, $fix_state,
$type, $description, $destination_dir, $uninstaller, $msg_cat,
$msg_set, $msg_num, $parent) = split(/:/, $_[0]);
($class, $stub) = split(/\./, $package_name);
$fileset{"class"} = $class;
$fileset{"package_name"} = $package_name;
$fileset{"fileset"} = $fileset;
$fileset{"level"} = $level;
$fileset{"state"} = $state;
$fileset{"ptf_id"} = $ptf_id;
$fileset{"fix_state"} = $fix_state;
$fileset{"type"} = $type;
$fileset{"description"} = $description;
$fileset{"destination_dir"} = $destination_dir;
$fileset{"uninstaller"} = $uninstaller;
$fileset{"msg_cat"} = $msg_cat;
$fileset{"msg_set"} = $msg_set;
$fileset{"msg_num"} = $msg_num;
$fileset{"parent"} = $parent;
return(%fileset);
}
sub file_info
{
local($_, %file, @out, $filename, $fileset, $type,
$dev, $ino, $mode, $nlink, $uid, $gid, @args, $rdev,
$size, $atime, $mtime, $ctime, $blksize, $blocks);
%file = ();
local $real;
if ($_[0] =~ /->/) {
($filename, $symlink) = split(/->/, $_[0]);
$real = &translate_filename($filename);
chop($filename);
($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size,
$atime, $mtime, $ctime, $blksize, $blocks) = lstat($real);
}
else {
$filename = $_[0];
$real = &translate_filename($filename);
($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size,
$atime, $mtime, $ctime, $blksize, $blocks) = stat($real);
}
local $qm = quotemeta($filename);
@out = &backquote_command("lslpp -wc $qm 2>&1", 1);
($stub, $fileset, $type) = split(/:/, $out[1]);
$file{"path"} = $filename;
$file{"dev"} = sprintf "%d,%d", $dev/256, $dev%256;
$file{"ino"} = $ino;
$file{"mode"} = sprintf "%o", $mode & 07777;
$file{"nlink"} = $nlink;
$file{"uid"} = getpwuid($uid);
$file{"gid"} = getgrgid($gid);
$file{"rdev"} = readlink($rdev);
$file{"size"} = $size ? $size : 0;
$file{"atime"} = scalar(localtime($atime));
$file{"mtime"} = scalar(localtime($mtime));
$file{"ctime"} = scalar(localtime($ctime));
$file{"blksize"} = $blksize;
$file{"blocks"} = $blocks;
$file{"link"} = readlink($real);
$file{"package"} = $fileset;
$file{"err"} = -e $real ? 0 : "Error";
$file{"type"} = -l $real ? 3 :
-d $real ? 1 :
0;
return(%file);
}
sub package_system
{
return $text{'aix_manager'};
}
sub package_help
{
return "installp lslpp";
}
1;