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 $ # $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 Contents of this file are made available subject to
# the terms of GNU Lesser General Public License Version 2.1. # the terms of GNU Lesser General Public License Version 2.1.
@ -35,41 +35,7 @@
package par2script::undefine; package par2script::undefine;
use par2script::existence;
use par2script::globals; 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 # Removing in the script all the gids, that are listed
@ -78,117 +44,46 @@ sub get_list_of_undefines
sub undefine_gids sub undefine_gids
{ {
my ($script, $parfile) = @_; my ($parfilecontent) = @_;
my @allundefines = (); my $item;
foreach $item ( @par2script::globals::allitems )
for ( my $i = 0; $i <= $#par2script::globals::allitems; $i++ )
{ {
my $oneitem = "Un" . $par2script::globals::allitems[$i]; my $unitem = "Un$item";
my $collector = get_list_of_undefines($oneitem, $parfile); for ( my $i = 0; $i <= $#{$parfilecontent}; $i++ )
if ($#{$collector} > -1 ) { par2script::work::add_array_into_array(\@allundefines, $collector); }
}
if ($#allundefines > -1 )
{
for ( my $i = 0; $i <= $#allundefines; $i++ )
{ {
my $gid = $allundefines[$i]->{'gid'}; if ( ${$parfilecontent}[$i] =~ /^\s*$unitem\s*(\w+?)\s*$/ )
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++ )
{ {
my @collector = (); my $gid = $1;
my $item = $removeitems[$i]; delete($par2script::globals::definitions{$item}->{$gid});
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);
} }
} }
} }
}
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'}; if ( $par2script::globals::definitions{$diritem}->{$onedefinition}->{$parentkey} eq $gid )
print "Removing gid from script: $gid \n"; {
par2script::remover::remove_leading_and_ending_whitespaces(\$gid); push(@{$collector}, $onedefinition);
par2script::work::remove_definitionblock_from_script($script, $gid); collect_children_dirs($onedefinition, $collector);
}
} }
} }
} }
@ -198,47 +93,58 @@ sub remove_complete_dirs
# This includes the Profile and its ProfileItems. # 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 $removeitem = "Remove$item";
my @allundefines = (); my $dependentkey = "";
my @alldirs = (); my $collect_children = 0;
my @removeitems = ("ProfileItem"); my @gidcollector = ();
my @dependentitems = ();
# Collecting all definitions of "RemoveProfile" if ( $item eq "Profile" )
my $oneremoveitem = "RemoveProfile";
my $directremoveprofiles = get_list_of_removeitems($oneremoveitem, $parfile);
if ($#{$directremoveprofiles} > -1 )
{ {
par2script::work::add_array_into_array(\@allundefines, $directremoveprofiles); @dependentitems = ("ProfileItem");
par2script::work::add_array_into_array(\@allprofiles, $directremoveprofiles); $dependentkey = "ProfileID";
}
# Collecting ProfileItems, that are written in the collected Profiles elsif ( $item eq "Directory" )
for ( my $i = 0; $i <= $#removeitems; $i++ ) {
{ @dependentitems = ("File", "Shortcut", "Unixlink");
for ( my $j = 0; $j <= $#allprofiles; $j++ ) $dependentkey = "Dir";
{ $collect_children = 1;
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);
}
}
} }
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'}; my $onegid = $1;
print "Removing gid from script: $gid \n"; push(@gidcollector, $onegid);
par2script::remover::remove_leading_and_ending_whitespaces(\$gid); if ( $collect_children ) { collect_children_dirs($onegid, \@gidcollector); }
par2script::work::remove_definitionblock_from_script($script, $gid);
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});
}
}
}
}
}
} }
} }
} }