Software-Packager-Aix

 view release on metacpan or  search on metacpan

lib/Software/Packager/Aix.pm  view on Meta::CPAN

        close LPPNAME;
}

################################################################################
# Function:	_find_disk_usage()
# Description:	This method finds the disk usage for the package directories.
# Arguments:	None.
# Returns:	The disk usage.
#
sub _find_disk_usage
{
    my $self = shift;
    my $dir = $self->tmp_dir();
    my $cwd = getcwd();
    chdir $dir;
    
    # find the directories
   my @directories = `find . ! -type d -exec dirname {} \\; | sort -u`;

    # find the disk usage
    my $usage;
    foreach my $dir (@directories)
    {
        chomp $dir;
        $dir = "./" if $dir eq ".";
        $usage .= `du -s $dir |awk '{print substr(\$2,2) " " \$1}'`;
    }

    chdir $cwd;
    return $usage;
}

################################################################################
# Function:	_create_package_structure()
# Description:	This method creates the package structure for the package under
#		the tmp directory.
# Arguments:	None.
# Returns:	None.
#
sub _create_package_structure
{
        my $self = shift;
        my $tmp_dir = $self->tmp_dir();

	my $lpp_type = $self->_find_lpp_type();
        foreach my $object ($self->get_object_list())
        {
		my $destination = "$tmp_dir". $object->destination();
                my $source = $object->source();
                my $type = $object->type();
                my $mode = $object->mode();
                my $user = $object->user();
                my $group = $object->group();

		if ($type =~ /directory/i)
		{
			unless (-d $destination)
                        {
                            mkpath($destination, 0, oct($mode));
                        }
                        unless (system("chown $user $destination") eq 0)
                        {
                            warn "Error: Couldn't set the user to \"$user\" for \"$destination\": $!\n";
                            return undef;
                        }
                        unless (system("chgrp $group $destination") eq 0)
                        {
                            warn "Error: Couldn't set the group to \"$group\" for \"$destination\": $!\n";
                            return undef;
                        }
		}
                elsif ($type =~ /file/i)
                {
                        my $directory = dirname($destination);
                        unless (-d $directory)
                        {
				mkpath($directory, 0, 0755);
                        }
                        unless (copy($source, $destination))
			{
				warn "Error: Couldn't copy $source to $destination: $!\n";
			}
                        unless (system("chown $user $destination") eq 0)
                        {
                            warn "Error: Couldn't set the user to \"$user\" for \"$destination\": $!\n";
                            return undef;
                        }
                        unless (system("chgrp $group $destination") eq 0)
                        {
                            warn "Error: Couldn't set the group to \"$group\" for \"$destination\": $!\n";
                            return undef;
                        }
                        unless (system("chmod $mode $destination") eq 0)
                        {
                            warn "Error: Couldn't set the mode to \"$mode\" for \"$destination\": $!\n";
                            return undef;
                        }
                }
                elsif ($type =~ /hard/i)
		{
                        unless (link $source, $destination)
                        {
                            warn "Error: Could not create hard link from $source to $destination:\n$!\n";
                            return undef;
                        }
                }
                elsif ($type =~ /soft/i)
		{
                        unless (symlink $source, $destination)
                        {
                                warn "Error: Could not create soft link from $source to $destination:\n$!\n";
                                return undef;
                        }
                }
                else
                {
                        warn "Warning: Don't know what type of object \"$destination\" is.\n";
                }
        }

	# Now we need to remove the user_liblpp.a and root_liblpp.a so that they
	# are not added to the space requirements in the file lpp_name
	unlink "$tmp_dir/user_liblpp.a";
	unlink "$tmp_dir/root_liblpp.a" if -f "$tmp_dir/root_liblpp.a";

        return 1;
}

################################################################################
# Function:	_create_control_files()
# Description:	This method creates the lpp control files (liblpp.a). as well as
#		creating the apply list and inventory which are essentially
#		required files.
#		check what sort of install we have.
#		A share install will only have one liblpp.a in
#		/usr/share/lpp/PROGRAM/liblpp.a
#		A user install will only have one liblpp.a in 
#		/usr/lpp/PROGRAM/liblpp.a
#		A root install will have two liblpp.a files in 
#		/usr/lpp/PROGRAM/liblpp.a and
#		/usr/lpp/PROGRAM../inst_root/liblpp.a
# Arguments:	None.
# Returns:	true on success else undef.



( run in 0.780 second using v1.01-cache-2.11-cpan-5511b514fd6 )