INTEGRATION: CWS native99 (1.4.132); FILE MERGED

2007/08/07 13:57:54 is 1.4.132.1: #i80411# new scp linker to simplify package restructuring
This commit is contained in:
Ivo Hinkelmann 2007-08-20 14:29:32 +00:00
parent 81fca5b6cb
commit 5c9459bccc

View file

@ -4,9 +4,9 @@
#
# $RCSfile: undefine.pm,v $
#
# $Revision: 1.4 $
# $Revision: 1.5 $
#
# last change: $Author: ihi $ $Date: 2007-03-26 12:46:08 $
# last change: $Author: ihi $ $Date: 2007-08-20 15:29:32 $
#
# The Contents of this file are made available subject to
# the terms of GNU Lesser General Public License Version 2.1.
@ -35,41 +35,7 @@
package par2script::undefine;
use par2script::existence;
use par2script::globals;
use par2script::remover;
use par2script::work;
##########################################################
# Collecting all undefines, that are listed
# in one par file
##########################################################
sub get_list_of_undefines
{
my ($item, $parfile) = @_;
my @collector =();
for ( my $i = 0; $i <= $#{$parfile}; $i++ )
{
if ( ${$parfile}[$i] =~ /^\s*$item\s*(\w+)\s*$/ )
{
my $gid = $1;
my $oneitem = $item;
$oneitem =~ s/^\s*Un//; # removing the "Un"
my %removeitem = ();
$removeitem{'gid'} = $gid;
$removeitem{'item'} = $oneitem;
push(@collector, \%removeitem);
}
}
return \@collector;
}
##########################################################
# Removing in the script all the gids, that are listed
@ -78,117 +44,46 @@ sub get_list_of_undefines
sub undefine_gids
{
my ($script, $parfile) = @_;
my ($parfilecontent) = @_;
my @allundefines = ();
for ( my $i = 0; $i <= $#par2script::globals::allitems; $i++ )
my $item;
foreach $item ( @par2script::globals::allitems )
{
my $oneitem = "Un" . $par2script::globals::allitems[$i];
my $unitem = "Un$item";
my $collector = get_list_of_undefines($oneitem, $parfile);
if ($#{$collector} > -1 ) { par2script::work::add_array_into_array(\@allundefines, $collector); }
}
if ($#allundefines > -1 )
{
for ( my $i = 0; $i <= $#allundefines; $i++ )
for ( my $i = 0; $i <= $#{$parfilecontent}; $i++ )
{
my $gid = $allundefines[$i]->{'gid'};
par2script::remover::remove_leading_and_ending_whitespaces(\$gid);
par2script::work::remove_definitionblock_from_script($script, $gid);
}
}
}
##########################################################
# Collecting all RemoveDirectories, that are listed
# in the par files
##########################################################
sub get_list_of_removeitems
{
my ($removeitem, $parfile) = @_;
my @collector =();
for ( my $i = 0; $i <= $#{$parfile}; $i++ )
{
if ( ${$parfile}[$i] =~ /^\s*\Q$removeitem\E\s+(\w+)\s*$/ )
{
my $gid = $1;
my $item = $removeitem;
$item =~ s/Remove//;
my %removeitem = ();
$removeitem{'gid'} = $gid;
$removeitem{'item'} = $oneitem;
push(@collector, \%removeitem);
}
}
return \@collector;
}
##########################################################
# Removing in the script complete directories.
# This includes subdirectories, files and shortcuts.
##########################################################
sub remove_complete_dirs
{
my ($script, $parfile) = @_;
my $removeitem = "RemoveDirectory";
my @allundefines = ();
my @alldirs = ();
my @removeitems = ("File", "Shortcut");
# Collecting all definitions of "RemoveDirectory"
my $oneremoveitem = "RemoveDirectory";
my $directremovedirs = get_list_of_removeitems($oneremoveitem, $parfile);
if ($#{$directremovedirs} > -1 )
{
par2script::work::add_array_into_array(\@allundefines, $directremovedirs);
par2script::work::add_array_into_array(\@alldirs, $directremovedirs);
# Collecting all subdirectories
for ( my $i = 0; $i <= $#{$directremovedirs}; $i++ )
{
my @collector = ();
my $dir = ${$directremovedirs}[$i];
my $directorygid = $dir->{'gid'};
par2script::work::collect_subdirectories($parfile, $directorygid, \@collector);
par2script::work::add_array_into_array(\@allundefines, \@collector);
par2script::work::add_array_into_array(\@alldirs, \@collector);
}
# Collecting Files and ShortCuts, that are installed in the collected directories
for ( my $i = 0; $i <= $#removeitems; $i++ )
{
for ( my $j = 0; $j <= $#alldirs; $j++ )
if ( ${$parfilecontent}[$i] =~ /^\s*$unitem\s*(\w+?)\s*$/ )
{
my @collector = ();
my $item = $removeitems[$i];
my $dir = $alldirs[$j];
my $directorygid = $dir->{'gid'};
par2script::work::get_all_items_in_directories($parfile, $directorygid, $item, \@collector);
par2script::work::add_array_into_array(\@allundefines, \@collector);
my $gid = $1;
delete($par2script::globals::definitions{$item}->{$gid});
}
}
}
}
if ($#allundefines > -1 )
##########################################################
# Collecting all subdirectories of a specified directory
##########################################################
sub collect_children_dirs
{
my ($gid, $collector) = @_;
my $diritem = "Directory";
my $parentkey = "ParentID";
if ( exists($par2script::globals::definitions{$diritem}) )
{
for ( my $i = 0; $i <= $#allundefines; $i++ )
my $onedefinition;
foreach $onedefinition (keys %{$par2script::globals::definitions{$diritem}})
{
my $gid = $allundefines[$i]->{'gid'};
print "Removing gid from script: $gid \n";
par2script::remover::remove_leading_and_ending_whitespaces(\$gid);
par2script::work::remove_definitionblock_from_script($script, $gid);
if ( $par2script::globals::definitions{$diritem}->{$onedefinition}->{$parentkey} eq $gid )
{
push(@{$collector}, $onedefinition);
collect_children_dirs($onedefinition, $collector);
}
}
}
}
@ -198,47 +93,58 @@ sub remove_complete_dirs
# This includes the Profile and its ProfileItems.
##########################################################
sub remove_complete_profile
sub remove_complete_item
{
my ($script, $parfile) = @_;
my ($item, $parfilecontent) = @_;
my $removeitem = "RemoveProfile";
my @allundefines = ();
my @alldirs = ();
my @removeitems = ("ProfileItem");
my $removeitem = "Remove$item";
my $dependentkey = "";
my $collect_children = 0;
my @gidcollector = ();
my @dependentitems = ();
# Collecting all definitions of "RemoveProfile"
my $oneremoveitem = "RemoveProfile";
my $directremoveprofiles = get_list_of_removeitems($oneremoveitem, $parfile);
if ($#{$directremoveprofiles} > -1 )
if ( $item eq "Profile" )
{
par2script::work::add_array_into_array(\@allundefines, $directremoveprofiles);
par2script::work::add_array_into_array(\@allprofiles, $directremoveprofiles);
# Collecting ProfileItems, that are written in the collected Profiles
for ( my $i = 0; $i <= $#removeitems; $i++ )
{
for ( my $j = 0; $j <= $#allprofiles; $j++ )
{
my @collector = ();
my $item = $removeitems[$i];
my $profile = $allprofiles[$j];
my $profilegid = $profile->{'gid'};
par2script::work::get_all_items_in_profile($parfile, $profilegid, $item, \@collector);
par2script::work::add_array_into_array(\@allundefines, \@collector);
}
}
@dependentitems = ("ProfileItem");
$dependentkey = "ProfileID";
}
elsif ( $item eq "Directory" )
{
@dependentitems = ("File", "Shortcut", "Unixlink");
$dependentkey = "Dir";
$collect_children = 1;
}
if ($#allundefines > -1 )
for ( my $i = 0; $i <= $#{$parfilecontent}; $i++ )
{
for ( my $i = 0; $i <= $#allundefines; $i++ )
if ( ${$parfilecontent}[$i] =~ /^\s*$removeitem\s*(\w+?)\s*$/ )
{
my $gid = $allundefines[$i]->{'gid'};
print "Removing gid from script: $gid \n";
par2script::remover::remove_leading_and_ending_whitespaces(\$gid);
par2script::work::remove_definitionblock_from_script($script, $gid);
my $onegid = $1;
push(@gidcollector, $onegid);
if ( $collect_children ) { collect_children_dirs($onegid, \@gidcollector); }
my $gid;
foreach $gid (@gidcollector)
{
delete($par2script::globals::definitions{$item}->{$gid});
# also deleting all dependent items, for example "ProfileItems" whose "ProfileID" is this "Profile"
my $depitem;
foreach $depitem ( @dependentitems )
{
if ( exists($par2script::globals::definitions{$depitem}) )
{
my $onedefinition;
foreach $onedefinition (keys %{$par2script::globals::definitions{$depitem}})
{
if ( $par2script::globals::definitions{$depitem}->{$onedefinition}->{$dependentkey} eq $gid )
{
delete($par2script::globals::definitions{$depitem}->{$onedefinition});
}
}
}
}
}
}
}
}