Kaydet (Commit) 709845a4 authored tarafından Ivo Hinkelmann's avatar Ivo Hinkelmann

INTEGRATION: CWS native99 (1.6.132); FILE MERGED

2007/08/07 13:57:54 is 1.6.132.1: #i80411# new scp linker to simplify package restructuring
üst 5c9459bc
......@@ -4,9 +4,9 @@
#
# $RCSfile: work.pm,v $
#
# $Revision: 1.6 $
# $Revision: 1.7 $
#
# last change: $Author: ihi $ $Date: 2007-03-26 12:46:22 $
# last change: $Author: ihi $ $Date: 2007-08-20 15:29:46 $
#
# The Contents of this file are made available subject to
# the terms of GNU Lesser General Public License Version 2.1.
......@@ -97,7 +97,6 @@ sub setparfiles
my ($filename) = @_;
# input is the name of the list file
$filename =~ s/\@//; # removing the leading \@
my $filecontent = par2script::files::read_file($filename);
......@@ -105,13 +104,9 @@ sub setparfiles
my @parfiles = ();
my $parfilesref = \@parfiles;
for ( my $i = 0; $i <= $#{$filecontent}; $i++ )
{
my $oneline = ${$filecontent}[$i];
my $parfilesref = analyze_comma_separated_list($oneline, $parfilesref);
}
foreach ( @{$filecontent} ) { $parfilesref = analyze_comma_separated_list($_, $parfilesref); }
return \@parfiles;
return $parfilesref;
}
############################################
......@@ -123,18 +118,21 @@ sub make_complete_pathes_for_parfiles
{
my ($parfiles, $includes) = @_;
for ( my $i = 0; $i <= $#{$parfiles}; $i++ )
my $oneparfile;
foreach $oneparfile ( @{$parfiles} )
{
my $foundparfile = 0;
my $includepath;
for ( my $j = 0; $j <= $#{$includes}; $j++ )
foreach $includepath ( @{$includes} )
{
my $parfile = ${$includes}[$j] . $par2script::globals::separator . ${$parfiles}[$i];
my $parfile = "$includepath/$oneparfile";
if ( -f $parfile )
{
$foundparfile = 1;
${$parfiles}[$i] = $parfile;
$oneparfile = $parfile;
last;
}
}
......@@ -147,546 +145,258 @@ sub make_complete_pathes_for_parfiles
}
######################################################
# collecting one special item in all par files and
# including it into the script file
# collecting one special item in the par files and
# including it into the "definitions" hash
######################################################
sub put_item_into_collector
sub collect_definitions
{
my ( $item, $parfile, $collector ) = @_;
my $include = 0;
my ($parfilecontent) = @_;
for ( my $i = 0; $i <= $#{$parfile}; $i++ )
{
if ( ${$parfile}[$i] =~ /^\s*$item\s*\w+\s*$/ )
{
$include = 1;
}
if ( $include )
{
push(@{$collector}, ${$parfile}[$i]);
}
if (( $include ) && ( ${$parfile}[$i] =~ /^\s*End\s*$/i ))
{
$include = 0;
push(@{$collector}, "\n"); # empty line at the end
}
}
}
######################################################
# putting all collected items of one type
# into the script file
######################################################
my $multidefinitionerror = 0;
my @multidefinitiongids = ();
sub put_item_into_script
{
my ($script, $itemcollector) = @_;
for ( my $i = 0; $i <= $#{$itemcollector}; $i++ )
foreach $oneitem ( @par2script::globals::allitems )
{
push(@{$script}, ${$itemcollector}[$i]);
}
}
#######################################################################
# Collecting all gids of the type "searchitem" from the setup script
#######################################################################
sub get_all_gids_from_script
{
my ($itemcollector, $oneitem) = @_;
my $docollect = 0;
my $gid = "";
my %allitemhash = ();
my @allgidarray = ();
for ( my $i = 0; $i <= $#{$itemcollector}; $i++ )
{
if ( ${$itemcollector}[$i] =~ /^\s*\Q$oneitem\E\s+(\S+)\s*$/ )
for ( my $i = 0; $i <= $#{$parfilecontent}; $i++ )
{
my $gid = $1;
push(@allgidarray, $gid);
}
}
return \@allgidarray;
}
#######################################################################
# Collecting all items of the type "searchitem" from the setup script
#######################################################################
sub get_all_items_from_script
{
my ($scriptref, $searchitem) = @_;
my $line = ${$parfilecontent}[$i];
my @allitemarray = ();
my ($line, $gid, $counter, $itemkey, $itemvalue, $valuecounter);
for ( my $i = 0; $i <= $#{$scriptref}; $i++ )
{
$line = ${$scriptref}[$i];
if ( $line =~ /^\s*\Q$searchitem\E\s+(\S+)\s*$/ )
{
$gid = $1;
$counter = $i + 1;
my %oneitemhash = ();
$oneitemhash{'gid'} = $gid;
while (!( $line =~ /^\s*End\s*$/ ))
if ( $line =~ /^\s*$oneitem\s+(\w+)\s*$/ )
{
$line = ${$scriptref}[$counter];
$counter++;
if ( $line =~ /^\s*(.+?)\s*\=\s*(.+?)\s*\;\s*$/ ) # only oneliner!
{
$itemkey = $1;
$itemvalue = $2;
par2script::remover::remove_leading_and_ending_quotationmarks(\$itemvalue);
$oneitemhash{$itemkey} = $itemvalue;
}
$gid = $1;
$docollect = 1;
}
push(@allitemarray, \%oneitemhash);
}
}
return \@allitemarray;
}
########################################################
# Recursively defined procedure to order
# modules and directories
########################################################
sub get_children
{
my ($allitems, $startparent, $newitemorder) = @_;
for ( my $i = 0; $i <= $#{$allitems}; $i++ )
{
my $gid = ${$allitems}[$i]->{'gid'};
my $parent = "";
if ( ${$allitems}[$i]->{'ParentID'} ) { $parent = ${$allitems}[$i]->{'ParentID'}; }
if ( $parent eq $startparent )
{
push(@{$newitemorder}, $gid);
my $parent = $gid;
get_children($allitems, $parent, $newitemorder); # recursive!
}
}
}
########################################################
# Module and Directory have to be in the correct order
# in the setup script. This is an requirement by the
# old setup
########################################################
sub create_treestructure
{
my ($item, $allitems) = @_;
my @itemorder = ();
my @startparents = ();
if ( $item eq "Module" ) { push(@startparents, ""); }
if ( $item eq "Directory" )
{
push(@startparents, "PREDEFINED_PROGDIR");
push(@startparents, "PREDEFINED_KDEHOME");
push(@startparents, "PREDEFINED_HOMEDIR");
}
for ( my $i = 0; $i <= $#startparents; $i++ ) # if there is more than one toplevel item
{
get_children($allitems, $startparents[$i], \@itemorder);
}
return \@itemorder;
}
########################################################
# Creating the item collector for Module and
# Directory in the new sorted order
########################################################
sub create_sorted_itemcollector
{
my ($newitemorder, $collector, $oneitem) = @_;
@newitemcollector = ();
for ( my $i = 0; $i <= $#{$newitemorder}; $i++ )
{
my $gid = ${$newitemorder}[$i];
for ( my $j = 0; $j <= $#{$collector}; $j++ )
{
my $line = ${$collector}[$j];
if ( $line =~ /^\s*$oneitem\s+$gid\s*$/ )
else
{
$include = 1;
$docollect = 0;
}
if ( $include )
if ( $docollect )
{
push(@newitemcollector, $line);
}
my $currentline = $i;
my %oneitemhash;
if (($include) && ( $line =~ /^\s*End\s*$/i ))
{
$include = 0;
push(@newitemcollector, "\n"); # empty line at the end
last;
}
}
}
while (! ( ${$parfilecontent}[$currentline] =~ /^\s*End\s*$/i ) )
{
if ( ${$parfilecontent}[$currentline] =~ /^\s*(.+?)\s*\=\s*(.+?)\s*\;\s*$/ ) # only oneliner!
{
$itemkey = $1;
$itemvalue = $2;
return \@newitemcollector;
}
if ( $oneitem eq "Directory" ) { if ( $itemkey =~ "DosName" ) { $itemkey =~ s/DosName/HostName/; } }
if (( $oneitem eq "Directory" ) || ( $oneitem eq "File" ) || ( $oneitem eq "Unixlink" )) { if ( $itemvalue eq "PD_PROGDIR" ) { $itemvalue = "PREDEFINED_PROGDIR"; }}
if (( $itemkey eq "Styles" ) && ( $itemvalue =~ /^\s*(\w+)(\s*\;\s*)$/ )) { $itemvalue = "($1)$2"; }
############################################
# Every gid has to defined only once
# in the par files
############################################
$oneitemhash{$itemkey} = $itemvalue;
}
sub test_of_gid_uniqueness
{
my ($allitems) = @_;
$currentline++;
}
my @allgids = ();
# no hyphen allowed in gids -> cannot happen here because (\w+) is required for gids
if ( $gid =~ /-/ ) { par2script::exiter::exit_program("ERROR: No hyphen allowed in global id: $gid", "test_of_hyphen"); }
for ( my $i = 0; $i <= $#{$allitems}; $i++ )
{
my $gid = ${$allitems}[$i];
# test of uniqueness
if ( exists($allitemhash{$gid}) )
{
$multidefinitionerror = 1;
push(@multidefinitiongids, $gid);
}
if (! par2script::existence::exists_in_array($gid, \@allgids))
{
push(@allgids, $gid);
}
else
{
$par2script::globals::multidefinitionerror = 1;
push(@par2script::globals::multidefinitiongids, $gid);
$allitemhash{$gid} = \%oneitemhash;
}
}
}
}
############################################
# gids must not cotain hyphens
############################################
sub test_of_hyphen
{
my ($allitems) = @_;
for ( my $i = 0; $i <= $#{$allitems}; $i++ )
{
my $gid = ${$allitems}[$i];
if ( $gid =~ /\-/ )
{
par2script::exiter::exit_program("ERROR: No hyphen allowed in global id: $gid", "test_of_hyphen");
}
$par2script::globals::definitions{$oneitem} = \%allitemhash;
}
if ( $multidefinitionerror ) { par2script::exiter::multidefinitionerror(\@multidefinitiongids); }
# foreach $key (keys %par2script::globals::definitions)
# {
# print "Key: $key \n";
#
# foreach $key (keys %{$par2script::globals::definitions{$key}})
# {
# print "\t$key \n";
# }
# }
}
######################################################
# This function exists for compatibility reasons:
# In scp the string "DosName" is used, in the
# created script this is "HostName"
# Filling content into the script
######################################################
sub convert_dosname_to_hostname
sub put_oneitem_into_script
{
my ($collector) = @_;
my ( $script, $item, $itemhash, $itemkey ) = @_;
for ( my $i = 0; $i <= $#{$collector}; $i++ )
{
${$collector}[$i] =~ s/\bDosName\b/HostName/;
}
}
###########################################################
# This function exists for compatibility reasons:
# In scp the string "PD_PROGDIR" is often used, in the
# created script this is "PREDEFINED_PROGDIR"
###########################################################
sub convert_pdprogdir_to_predefinedprogdir
{
my ($collector) = @_;
for ( my $i = 0; $i <= $#{$collector}; $i++ )
{
${$collector}[$i] =~ s/\bPD_PROGDIR\b/PREDEFINED_PROGDIR/;
}
push(@{$script}, "$item $itemkey\n" );
my $content = "";
foreach $content (sort keys %{$itemhash->{$itemkey}}) { push(@{$script}, "\t$content = $itemhash->{$itemkey}->{$content};\n" ); }
push(@{$script}, "End\n" );
push(@{$script}, "\n" );
}
######################################################
# Single styles are in scp sometimes defined as:
# "Styles = cfg_string;". This has to be replaced
# in the script to
# "Styles = (cfg_string);"
# Creating the script
######################################################
sub setting_brackets_around_single_styles
sub create_script
{
my ($collector) = @_;
my @script = ();
my $oneitem;
for ( my $i = 0; $i <= $#{$collector}; $i++ )
foreach $oneitem ( @par2script::globals::allitems )
{
if ( ${$collector}[$i] =~ /^(\s*styles\s*\=\s*)(\w+)(\s*\;\s*)$/i )
if ( exists($par2script::globals::definitions{$oneitem}) )
{
my $start = $1;
my $styles = $2;
my $end = $3;
if ( $oneitem eq "Shortcut" ) { next; } # "Shortcuts" after "Files"
my $newline = $start . "\(" . $styles . "\)" . $end;
${$collector}[$i] = $newline;
if (( $oneitem eq "Module" ) || ( $oneitem eq "Directory" )) { write_sorted_items(\@script, $oneitem); }
else { write_unsorted_items(\@script, $oneitem); }
}
}
return \@script;
}
######################################################
# The scpzip and the setup require a script version
# in the Installation object. This has to be included
# for compatibility reasons. It will always be:
# "ScriptVersion = 100;"
# Adding script content for the unsorted items
######################################################
sub set_scriptversion_into_installation_object
sub write_unsorted_items
{
my ($collector) = @_;
my ( $script, $oneitem ) = @_;
my $newline = "\tScriptVersion = 100\;\n";
my $itemhash = $par2script::globals::definitions{$oneitem};
# determining the last line
my $lastline;
for ( my $i = 0; $i <= $#{$collector}; $i++ )
my $itemkey = "";
foreach $itemkey (sort keys %{$itemhash})
{
if ( ${$collector}[$i] =~ /^\s*End\s*$/i )
put_oneitem_into_script($script, $oneitem, $itemhash, $itemkey);
# special handling for Shortcuts after Files
if (( $oneitem eq "File" ) && ( exists($par2script::globals::definitions{"Shortcut"}) ))
{
$lastline = $i;
last;
my $shortcutkey;
foreach $shortcutkey ( keys %{$par2script::globals::definitions{"Shortcut"}} )
{
if ( $par2script::globals::definitions{"Shortcut"}->{$shortcutkey}->{'FileID'} eq $itemkey )
{
put_oneitem_into_script($script, "Shortcut", $par2script::globals::definitions{"Shortcut"}, $shortcutkey);
# and Shortcut to Shortcut also
my $internshortcutkey;
foreach $internshortcutkey ( keys %{$par2script::globals::definitions{"Shortcut"}} )
{
if ( $par2script::globals::definitions{"Shortcut"}->{$internshortcutkey}->{'ShortcutID'} eq $shortcutkey )
{
put_oneitem_into_script($script, "Shortcut", $par2script::globals::definitions{"Shortcut"}, $internshortcutkey);
}
}
}
}
}
}
splice(@{$collector}, $lastline, 0, $newline);
}
############################################
# transferring the par file content
# into the script file
############################################
######################################################
# Collecting all children of a specified parent
######################################################
sub collect_all_items
sub collect_children
{
my ($parfile) = @_;
my @setupscript = ();
my $setupscript = \@setupscript;
my ( $itemhash, $parent, $order ) = @_;
for ( my $i = 0; $i <= $#par2script::globals::allitems; $i++ )
my $item;
foreach $item ( keys %{$itemhash} )
{
my $oneitem = $par2script::globals::allitems[$i];
my @itemcollector = ();
my $itemcollector = \@itemcollector;
put_item_into_collector($oneitem, $parfile, $itemcollector);
# testing uniqueness of each gid
my $allgids = get_all_gids_from_script($itemcollector, $oneitem);
test_of_gid_uniqueness($allgids);
test_of_hyphen($allgids);
# renaming at directories "DosName" to "HostName" and "PD_PROGDIR" to "PREDEFINED_PROGDIR" (only for compatibility reasons)
if ( $oneitem eq "Directory" ) { convert_dosname_to_hostname($itemcollector); }
if (( $oneitem eq "Directory" ) || ( $oneitem eq "File" )) { convert_pdprogdir_to_predefinedprogdir($itemcollector); }
# sorting directories and modules (modules are also oneliner after pre2par!)
if (( $oneitem eq "Module" ) || ( $oneitem eq "Directory" ))
if ( $itemhash->{$item}->{'ParentID'} eq $parent )
{
my $allitems = get_all_items_from_script($itemcollector, $oneitem);
$newitemorder = create_treestructure($oneitem, $allitems);
$itemcollector = create_sorted_itemcollector($newitemorder, $itemcollector, $oneitem);
push(@{$order}, $item);
my $newparent = $item;
collect_children($itemhash, $newparent, $order);
}
# setting brackets around single styles: "styles = cfg_string;" -> "styles = (cfg_string);"
setting_brackets_around_single_styles($itemcollector);
# Installation objects need to get the script version (only for compatibility reasons)
if ( $oneitem eq "Installation" ) { set_scriptversion_into_installation_object($itemcollector); }
# putting the collector content into the setup script
put_item_into_script($setupscript, $itemcollector);
}
if ( $par2script::globals::multidefinitionerror ) { par2script::exiter::multidefinitionerror(); }
return $setupscript;
}
############################################
# Returning a complete definition block
# from the script
############################################
######################################################
# Adding script content for the sorted items
######################################################
sub get_definitionblock_from_script
sub write_sorted_items
{
my ($script, $gid) = @_;
my ( $script, $oneitem ) = @_;
my @codeblock = ();
my $startline = -1;
my $itemhash = $par2script::globals::definitions{$oneitem};
for ( my $i = 0; $i <= $#{$script}; $i++ )
{
if ( ${$script}[$i] =~ /^\s*\w+\s+$gid\s*$/ )
{
$startline = $i;
last;
}
}
my @itemorder = ();
my @startparents = ();
if ( $startline != -1 )
{
while (! ( ${$script}[$startline] =~ /^\s*End\s*$/i ) )
{
push(@codeblock, ${$script}[$startline]);
$startline++;
}
if ( $oneitem eq "Module" ) { push(@startparents, ""); }
elsif ( $oneitem eq "Directory" ) { push(@startparents, "PREDEFINED_PROGDIR"); }
else { die "ERROR: No root parent defined for item type $oneitem !\n"; }
push(@codeblock, ${$script}[$startline]);
}
# supporting more than one toplevel item
my $parent;
foreach $parent ( @startparents ) { collect_children($itemhash, $parent, \@itemorder); }
return \@codeblock;
my $itemkey;
foreach $itemkey ( @itemorder ) { put_oneitem_into_script($script, $oneitem, $itemhash, $itemkey); }
}
############################################
# Adding a complete definition block
# into the script
############################################
#######################################################################
# Collecting all assigned gids of the type "item" from the modules
# in the par files. Using a hash!
#######################################################################
sub add_definitionblock_into_script
sub collect_assigned_gids
{
my ($script, $newblock, $gid) = @_;
# adding the new block behind the block defined by $gid
my $insertline = -1;
my $count = 0;
for ( my $i = 0; $i <= $#{$script}; $i++ )
{
if ( ${$script}[$i] =~ /^\s*\w+\s+$gid\s*$/ )
{
$count = 1;
}
if (( $count ) && ( ${$script}[$i] =~ /^\s*End\s*$/i ))
{
$insertline = $i;
last;
}
}
my $allmodules = $par2script::globals::definitions{'Module'};
if ( $insertline != -1 )
my $item;
foreach $item ( @par2script::globals::items_assigned_at_modules )
{
$insertline = $insertline + 2;
# inserting an empty line at the end of the block if required
if (!(${$newblock}[$#{$newblock}] =~ /^\s*$/)) { push(@{$newblock}, "\n"); }
# inserting the new block
splice( @{$script}, $insertline, 0, @{$newblock} );
}
else
{
die "ERROR: Could not include definition block. Found no definition of $gid!\n";
}
if ( ! exists($par2script::globals::searchkeys{$item}) ) { par2script::exiter::exit_program("ERROR: Unknown type \"$item\" at modules.", "collect_assigned_gids"); }
}
my $searchkey = $par2script::globals::searchkeys{$item};
############################################
# Removing a complete definition block
# from the script
############################################
sub remove_definitionblock_from_script
{
my ($script, $gid) = @_;
my %assignitems = ();
my $modulegid = "";
my $startline = -1;
for ( my $i = 0; $i <= $#{$script}; $i++ )
{
if ( ${$script}[$i] =~ /^\s*\w+\s+$gid\s*$/i )
foreach $modulegid (keys %{$allmodules} )
{
$startline = $i;
last;
}
}
# print "Module $modulegid\n";
# my $content = "";
# foreach $content (sort keys %{$allmodules->{$modulegid}}) { print "\t$content = $allmodules->{$modulegid}->{$content};\n"; }
# print "End\n";
# print "\n";
if ( $startline != -1 )
{
my $endline = $startline;
if ( exists($allmodules->{$modulegid}->{$searchkey}) )
{
my $list = $allmodules->{$modulegid}->{$searchkey};
if ( $list =~ /^\s*\((.*?)\)\s*(.*?)\s*$/ ) { $list = $1; }
else { par2script::exiter::exit_program("ERROR: Invalid module list: $list", "collect_assigned_gids"); }
my $allassigneditems = par2script::converter::convert_stringlist_into_array_2($list, ",");
while (! ( ${$script}[$endline] =~ /^\s*End\s*$/i ) )
{
$endline++;
my $gid;
foreach $gid ( @{$allassigneditems} )
{
if ( exists($assignitems{$gid}) ) { $assignitems{$gid} = $assignitems{$gid} + 1; }
else { $assignitems{$gid} = 1; }
}
}
}
my $blocklength = $endline - $startline + 2; # "+2" because of endline and emptyline
splice(@{$script}, $startline, $blocklength);
}
}
############################################
# Returning the value for a given key
# from a definition block
############################################
sub get_value_from_definitionblock
{
my ($block, $key) = @_;
my $value = "";
for ( my $i = 0; $i <= $#{$block}; $i++ )
{
if ( ${$block}[$i] =~ /^\s*$key\s*\=\s*(.*?)\s*$/ )
{
$value = $1;
last;
}
$par2script::globals::assignedgids{$item} = \%assignitems;
}
par2script::remover::remove_leading_and_ending_whitespaces(\$value);
$value =~ s/\;\s*$//; # removing ending semicolons
return $value;
}
##################################################
......@@ -699,167 +409,16 @@ sub read_all_parfiles
my ($parfiles) = @_;
my @parfilecontent = ();
my $parfilename;
for ( my $i = 0; $i <= $#{$parfiles}; $i++ )
foreach $parfilename ( @{$parfiles} )
{
my $parfile = par2script::files::read_file(${$parfiles}[$i]);
add_array_into_array(\@parfilecontent, $parfile);
my $parfile = par2script::files::read_file($parfilename);
foreach ( @{$parfile} ) { push(@parfilecontent, $_); }
push(@parfilecontent, "\n");
}
return \@parfilecontent;
}
##########################################################
# Add the content of an array to another array
##########################################################
sub add_array_into_array
{
my ($basearray, $newarray) = @_;
for ( my $i = 0; $i <= $#{$newarray}; $i++ )
{
push(@{$basearray}, ${$newarray}[$i]);
}
}
##########################################################
# Collecting all subdirectories of a specified directory
##########################################################
sub collect_subdirectories
{
my ($parfile, $directorygid, $collector) = @_;
my $isdirectory = 0;
my $currentgid = "";
for ( my $i = 0; $i <= $#{$parfile}; $i++ )
{
my $oneline = ${$parfile}[$i];
if ( $oneline =~ /^\s*Directory\s+(\w+)\s*$/ )
{
$currentgid = $1;
$isdirectory = 1;
}
if (( $isdirectory ) && ( $oneline =~ /^\s*End\s*$/ )) { $isdirectory = 0; }
if ( $isdirectory )
{
if ( $oneline =~ /^\s*ParentID\s*=\s*(\w+)\s*\;\s*$/ )
{
my $parentgid = $1;
if ( $parentgid eq $directorygid )
{
# Found a child of the directory, that shall be removed
my %removeitem = ();
my $item = "Directory";
$removeitem{'gid'} = $currentgid;
$removeitem{'item'} = $item;
push(@{$collector}, \%removeitem);
# recursively checking additional children
collect_subdirectories($parfile, $currentgid, $collector);
}
}
}
}
}
##########################################################
# Collecting all items (Files and Shortcuts), that
# are located in the list of directories.
##########################################################
sub get_all_items_in_directories
{
my ($parfile, $directorygid, $item, $collector) = @_;
my $isitem = 0;
my $currentgid = "";
for ( my $i = 0; $i <= $#{$parfile}; $i++ )
{
my $oneline = ${$parfile}[$i];
if ( $oneline =~ /^\s*\Q$item\E\s+(\w+)\s*$/ )
{
$currentgid = $1;
$isitem = 1;
}
if (( $isitem ) && ( $oneline =~ /^\s*End\s*$/ )) { $isitem = 0; }
if ( $isitem )
{
if ( $oneline =~ /^\s*Dir\s*=\s*(\w+)\s*\;\s*$/ )
{
my $installdir = $1;
if ( $installdir eq $directorygid )
{
# Found an item, that shall be installed in the specific directory
my %removeitem = ();
$removeitem{'gid'} = $currentgid;
$removeitem{'item'} = $item;
push(@{$collector}, \%removeitem);
}
}
}
}
}
##########################################################
# Collecting all items (ProfileItems), that
# are located in the list of Profiles.
##########################################################
sub get_all_items_in_profile
{
my ($parfile, $profilegid, $item, $collector) = @_;
my $isitem = 0;
my $currentgid = "";
for ( my $i = 0; $i <= $#{$parfile}; $i++ )
{
my $oneline = ${$parfile}[$i];
if ( $oneline =~ /^\s*\Q$item\E\s+(\w+)\s*$/ )
{
$currentgid = $1;
$isitem = 1;
}
if (( $isitem ) && ( $oneline =~ /^\s*End\s*$/ )) { $isitem = 0; }
if ( $isitem )
{
if ( $oneline =~ /^\s*ProfileID\s*=\s*(\w+)\s*\;\s*$/ )
{
my $profilename = $1;
if ( $profilename eq $profilegid )
{
# Found an item, that shall be installed in the specific directory
my %removeitem = ();
$removeitem{'gid'} = $currentgid;
$removeitem{'item'} = $item;
push(@{$collector}, \%removeitem);
}
}
}
}
}
1;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment