buildframework/helium/tools/preparation/getenv.pl
author lorewang
Wed, 17 Nov 2010 16:16:57 +0800
changeset 693 9dfe674c217c
parent 588 c7c26511138f
permissions -rw-r--r--
update release info
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
     1
#============================================================================ 
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
     2
#Name        : getenv.pl 
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
     3
#Part of     : Helium 
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
     4
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
     5
#Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
     6
#All rights reserved.
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
     7
#This component and the accompanying materials are made available
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
     8
#under the terms of the License "Eclipse Public License v1.0"
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
     9
#which accompanies this distribution, and is available
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    10
#at the URL "http://www.eclipse.org/legal/epl-v10.html".
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    11
#
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    12
#Initial Contributors:
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    13
#Nokia Corporation - initial contribution.
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    14
#
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    15
#Contributors:
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    16
#
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    17
#Description: Cleaned version.
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    18
#============================================================================
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    19
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
    20
use strict;         # strict naming rules
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
    21
use Cwd;            # figuring out directories
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
    22
use Data::Dumper;   # debugging purposes
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
    23
use XML::Simple;    # for using xml parser
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
    24
use File::Copy;     # for copying files
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
    25
use Getopt::Long;   # parameter handling
1
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    26
Getopt::Long::Configure( "bundling_override","ignore_case_always" );
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
    27
use File::Temp qw/ tempdir /; # for creating unique temp directories
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
    28
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
    29
# uncomment to get temp dir debug traces
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
    30
$File::Temp::DEBUG = 1;
1
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    31
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    32
# variables for commandline params
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
    33
my( $param_help,          # print help
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
    34
    $param_server,        # manually select server
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
    35
    $param_release_path,  # where are the releases located in the server
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
    36
    $param_debug,         # parameter for controlling extra debug prints
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
    37
    $param_latest,        # just grab the latest build (requires product name)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
    38
    $param_keepgoing,     # continue even if dependency is missing
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
    39
    $param_print_only,    # do nothing but print system calls
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
    40
    $param_skipITD,       # do not extract internal, testsources and documentation
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
    41
    $param_emuenv,        # extract only emulator environment
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
    42
    $param_start_directly,# starts extracting directly without waiting user acceptance
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
    43
    $param_product,       # manually insert product name
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
    44
    $param_skip_deps,     # do not extract dependencies
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
    45
    $param_grace,         # do not check for grace access
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
    46
    @param_exclude,       # exclude list
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
    47
    @param_include,       # include list
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
    48
    @force_include,       # force include list
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
    49
    $param_all );         # extract all zips
1
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    50
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    51
# read commandline parameters
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
    52
my $result = GetOptions('help'      => \$param_help,            # print help
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
    53
                        'h'         => \$param_help,            # print help
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
    54
                        'latest'    => \$param_latest,          # just grab the latest build (requires product name)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
    55
                        'server=s'  => \$param_server,          # manually select server
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
    56
                        'path=s'    => \$param_release_path,    # extract this release directly
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
    57
                        'verbose'   => \$param_debug,           # verbose debug print
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
    58
                        'k'         => \$param_keepgoing,       # continue even if there is any problems
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
    59
                        'p'         => \$param_print_only,      # do nothing but print system calls
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
    60
                        'skipitd'   => \$param_skipITD,         # Deprecated: do not extract internal, testsources and documentation
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
    61
                        'emu'       => \$param_emuenv,          # Deprecated: extract only emulator environment
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
    62
                        'start'     => \$param_start_directly,  # starts extracting directly without waiting user acceptance
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
    63
                        'product=s' => \$param_product,         # manually insert product name
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
    64
                        'x=s'       => \@param_exclude,         # filer list for excluding zips
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
    65
                        'exclude=s' => \@param_exclude,         # filer list for excluding zips
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
    66
                        'i=s'       => \@param_include,         # filer list for including zips
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
    67
                        'include=s' => \@param_include,         # filer list for including zips
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
    68
                        'f=s'       => \@force_include,         # filer list for including zips if default tag is false
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
    69
                        'force=s'   => \@force_include,         # filer list for including zips if default tag is false
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
    70
                        'all'       => \$param_all,             # extract all zip whether default tag is true or false
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
    71
                        'nodeps'    => \$param_skip_deps,       # do not extract dependencies
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
    72
                        'grace'     => \$param_grace);          # try to DL from GRACE
1
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    73
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    74
# enums for error situations
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    75
my $warning = 1;
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    76
my $promptUser = 2;
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    77
my $dependencyMissing = 3;
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    78
my $cannotContinue = 4;
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    79
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    80
# common global variables
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
    81
my $metaDataXml;            # path to metadata file
1
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    82
my $currentReleaseXml;      # path to currentRelease.xml if exists
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    83
my $pathToReleaseFolder;    # path to server that has releases
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    84
my $defaultServiceName;     # default name for service (s60rnd)
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
    85
my $pathToUnzip;            # path to unzip tool
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
    86
my $tmpDlDir;               # path to temp dir where we'll DL packages to
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
    87
my $tmpDir;                 # path to temp dir where we extract packages from
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
    88
my $returnValue;            # holds the error codes coming from 7-zip
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
    89
my $graceServer;            # path to local grace server if accessible
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
    90
my $logFile;                # log file for troubleshooting
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
    91
my %packageHash;            # hash containing zips to extract
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
    92
my @finalZipList;           # contains final list of files to unzip
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
    93
my $getEnvVersion;          # version of this getenv script
1
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    94
my $defaultPathToServer;    # default value for the server
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    95
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    96
# list of GRACE samba shares - must match to @graceNameList
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
    97
my @hydraList = ();
1
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    98
# must match to @graceList
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
    99
my @hydraNameList = ();
1
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   100
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   101
#these 2 lists need to match                    
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   102
my @serviceList = ();
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   103
my @serviceNameList = ();
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   104
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   105
# default values
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   106
$tmpDir = FixPaths( getcwd )."temp";
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   107
$tmpDlDir = FixPaths( getcwd )."DlTemp";
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   108
$defaultServiceName = undef;
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   109
#$logFile = getcwd."/getenv.log";
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   110
$pathToReleaseFolder = undef;
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   111
$defaultPathToServer = undef;
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   112
$pathToUnzip = "7za";
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   113
$getEnvVersion = "2.4.9";
588
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   114
 
1
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   115
print "S60 RnD environment getter v.$getEnvVersion\n\n";
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   116
printLog( "getenv.pl version $getEnvVersion" );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   117
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   118
# The actual functionality
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   119
if( $param_grace ) {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   120
# ToDo: find more clever way to figure out access
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   121
    $graceServer = FindGraceServer( );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   122
}
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   123
else {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   124
#   print "GRACE access is temporary disabled due to access problems\nEnable GRACE access by running getenv.pl -grace\n";
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   125
}
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   126
ValidateInputs( );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   127
printLog( "Following release we will extract: $metaDataXml" );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   128
PrintFinalWarning( );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   129
DownloadRelease( );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   130
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   131
exit 0;
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   132
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   133
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   134
sub ValidateInputs {
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   135
  print_help( ) if ( $param_help );
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   136
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   137
  if( @param_exclude and @param_include ) {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   138
    HandleError( "you cant specify include and exclude lists at the same time!", $cannotContinue );
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   139
  }
1
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   140
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   141
  # checking wheter we are in root of the substituted drive (if -start param is not specified)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   142
  if( ! $param_start_directly and
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   143
      ! getcwd =~ /[a-zA-Z]:\// and
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   144
        $param_keepgoing ) {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   145
    HandleError( "You should run getenv only in root of the substituted drive\nYou can use -k as keep going parameter if you think it is ok to proceed", $cannotContinue );
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   146
  }
1
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   147
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   148
  # ok we are in root. Is the drive empty?
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   149
  my $xmlFile = 0;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   150
  my $driveEmpty = 1;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   151
  
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   152
  opendir( ROOT, "/" ) or HandleError( "cant read root dir: $!", $warning );
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   153
  my @filesFound = readdir( ROOT );
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   154
  closedir( ROOT );
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   155
  foreach my $file( @filesFound ) {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   156
      next if $file =~ /^\.[\.]?$/;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   157
      next if $file =~ /getenv/;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   158
      $xmlFile = 1 if $file =~ /.*metadata.*\.xml/;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   159
      $xmlFile = 1 if $file =~ /currentRelease\.xml/;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   160
      $driveEmpty = 0;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   161
  }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   162
  
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   163
  printLog( "xml files: $xmlFile" );
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   164
  printLog( "drive empty: $driveEmpty" );
1
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   165
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   166
  # if drive is not empty and no xmls found ==> print warning (if -start param not specified)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   167
  if( ! $param_start_directly and ! $xmlFile and ! $driveEmpty ) {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   168
      HandleError( "The drive you are about to extract environment is not empty!\nHit CTRL-C to break now or <enter> to continue", $promptUser );
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   169
  }
1
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   170
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   171
  # if there is valid metadata.xml in root, params like path or latest doesn't make any sense
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   172
  if( $xmlFile ) {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   173
      foreach my $file( @filesFound ) {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   174
          if( $file =~ /.*metadata(_(\d*))?.xml$/i ) {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   175
              print "metadata file found!\n";
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   176
              if( ValidateXmlFile( getcwd.$file ) ) {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   177
                  $metaDataXml = getcwd.$file;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   178
                  last;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   179
              }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   180
          }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   181
      }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   182
  }
1
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   183
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   184
  if( $metaDataXml ) {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   185
    if( $param_latest or $param_release_path ) {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   186
          print "It doesnt make sense to use 'path' or 'latest' parameter while having metadata.xml in root!\n\n";
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   187
          print_help( );
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   188
          exit 0;
1
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   189
    }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   190
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   191
  # we should ask correct grace share if xmlfile !server !start       
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   192
    if( !$param_server and ! $param_start_directly ) {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   193
      print "For your convenience it is recommended to use HYDRA samba share close to you.\n";
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   194
      # prompt user wheter he wants to use GRACE
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   195
      my $networkAccessVerified = 0;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   196
      while( $networkAccessVerified eq 0 ) {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   197
        my $wantedServer = FixPaths( $hydraList[ ReturnMenuIndex( "Please select share closest to you", @hydraNameList ) ] );
1
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   198
    
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   199
        if( $wantedServer eq FixPaths( $hydraList[0] ) ) {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   200
              HandleError( "Please notice that access to $hydraList[0] will be removed from wk50 onwards. Now would be perfect time to get yourself a GRACE access.", $promptUser );
1
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   201
        }
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   202
      
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   203
        printLog( "selected: $wantedServer - accessing.." );
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   204
        if( opendir( GRACETEST, $wantedServer ) ) {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   205
          printLog( "connection tested OK" );
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   206
          $networkAccessVerified = 1;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   207
          $pathToReleaseFolder = $wantedServer;
1
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   208
        }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   209
        else {
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   210
              print "Unable to access $wantedServer\nPlease select another network share.\n";
1
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   211
        }
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   212
      }
1
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   213
    }
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   214
          
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   215
          # in case we have metadata in \ and -start defined, look grace automatically
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   216
    elsif( !$param_server and $param_start_directly ) {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   217
              $pathToReleaseFolder = FindGraceServer( );
1
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   218
    }
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   219
  }
1
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   220
    
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   221
  # ToDo: if there is not metadata.xml in root check if we have already env. Possibly update?
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   222
  
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   223
  # is 'path' parameter is used, find out (wheter there exists) valid metadata.xml
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   224
  if( $param_release_path ) {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   225
    if( $param_latest or $param_product ) {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   226
      print "It doesnt make sense to use 'path' or 'latest' parameter while having metadata.xml in root!\n\n";
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   227
      print_help( );
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   228
      exit 0;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   229
    }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   230
    $metaDataXml = FixPaths( $param_release_path );
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   231
    $metaDataXml .= SearchValidXml( $metaDataXml );
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   232
    printLog( "setting metadata: $metaDataXml" );
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   233
  }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   234
  
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   235
  # handle server parameter
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   236
  # simply just verify accessablility and fix path
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   237
  if( $param_server ) {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   238
      $pathToReleaseFolder = FixPaths( $param_server );
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   239
      opendir( OPENTEST, $pathToReleaseFolder ) or HandleError( "Unable to access given server path: $pathToReleaseFolder\n$!", $cannotContinue );
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   240
      closedir( OPENTEST );
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   241
  }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   242
  
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   243
  # param_latest is used to just get latest release - requires product
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   244
  if( $param_latest ) {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   245
    if( $param_product ) {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   246
      $param_product = FixPaths( $param_product );
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   247
      
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   248
      # once the network share is unavailable then tries to find grace share
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   249
      $pathToReleaseFolder = FindGraceServer( );
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   250
      
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   251
      opendir( RELDIR, $pathToReleaseFolder.$defaultServiceName.$param_product ) or die "unable to open $pathToReleaseFolder$defaultServiceName$param_product\n$!";
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   252
      # scan all xml files to @files_found
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   253
# salmarko starts
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   254
      my @files_found = grep { /^pf_|^S60_|^dfs_/i } readdir RELDIR;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   255
# salmarko ends
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   256
      close RELDIR;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   257
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   258
      if( @files_found ) {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   259
          foreach( reverse sort ( @files_found ) ) {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   260
              # we only want to get the last dir name..
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   261
              s/.*\///i;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   262
              my $productToDl = $pathToReleaseFolder.$defaultServiceName.$param_product;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   263
              $productToDl .= FixPaths( $_ );
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   264
              print "Searching metadata.xml files from $productToDl\n" if $param_debug;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   265
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   266
              $metaDataXml = SearchValidXml( $productToDl ) ;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   267
              if( $metaDataXml ) {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   268
                  $metaDataXml = $productToDl.$metaDataXml;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   269
                  printLog( "selected xml: $metaDataXml" );
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   270
                  last;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   271
              }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   272
          }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   273
      }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   274
      else {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   275
          HandleError( "cannot find releases from $pathToReleaseFolder$defaultServiceName$param_product", $cannotContinue );
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   276
      }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   277
    }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   278
    else {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   279
        die "If you specify -latest parameter you have to define -product also!\n";
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   280
    }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   281
  }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   282
  
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   283
  # use wizard to find out what to DL
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   284
  if( ! $metaDataXml ) {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   285
      printLog( "Not enought valid inputs provided - running wizard..." );
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   286
      RunWizard( );
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   287
  }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   288
  
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   289
  # check wheter metadata and currentRelease adds up
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   290
  if( -e FixPaths( getcwd )."currentRelease.xml") {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   291
      printLog( "CurrenRelease.xml exists. Checking wheter update is possible" );
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   292
      
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   293
      # compare service, product and release with xml files
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   294
      my $CurrentRelXmlParser = new XML::Simple( );
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   295
      my $currentReleaseData = $CurrentRelXmlParser->XMLin( FixPaths( getcwd )."currentRelease.xml" );
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   296
      
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   297
      my $xmlParser = new XML::Simple( );
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   298
      my $xmlData = $xmlParser->XMLin( $metaDataXml );
1
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   299
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   300
# salmarko starts
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   301
      my $currentRelease = '';
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   302
      my $newRelease = '';
1
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   303
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   304
      if ( !defined $xmlData->{releaseDetails}->{dependsOf}->{service}->{name} ) { # no dependencies, lets compare current to new
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   305
          # compare services
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   306
          if( $currentReleaseData->{releaseDetails}->{releaseID}->{service}->{name} ne
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   307
                  $xmlData->{releaseDetails}->{releaseID}->{service}->{name} ) {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   308
              HandleError( "Can not extract ".$xmlData->{releaseDetails}->{releaseID}->{service}->{name} .
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   309
              " release on top of ".$currentReleaseData->{releaseDetails}->{releaseID}->{service}->{name}, $cannotContinue );
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   310
          }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   311
          # compare products
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   312
          if( $currentReleaseData->{releaseDetails}->{releaseID}->{product}->{name} ne
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   313
                  $xmlData->{releaseDetails}->{releaseID}->{product}->{name} ) {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   314
              HandleError( "Can not extract ".$xmlData->{releaseDetails}->{releaseID}->{product}->{name} .
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   315
              " release on top of ".$currentReleaseData->{releaseDetails}->{releaseID}->{product}->{name}, $cannotContinue );
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   316
          }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   317
          printLog( "service and product matches.. checking release" );
1
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   318
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   319
          $currentRelease = $currentReleaseData->{releaseDetails}->{releaseID}->{release}->{name};
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   320
          $newRelease = $xmlData->{releaseDetails}->{releaseID}->{release}->{name};
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   321
      }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   322
      else{
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   323
          # compare services
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   324
          if( $currentReleaseData->{releaseDetails}->{releaseID}->{service}->{name} ne
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   325
                  $xmlData->{releaseDetails}->{dependsOf}->{service}->{name} ) {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   326
              HandleError( "Can not extract ".$xmlData->{releaseDetails}->{dependsOf}->{service}->{name} .
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   327
              " release on top of ".$currentReleaseData->{releaseDetails}->{releaseID}->{service}->{name}, $cannotContinue );
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   328
          }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   329
          # compare products
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   330
          if( $currentReleaseData->{releaseDetails}->{releaseID}->{product}->{name} ne
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   331
                  $xmlData->{releaseDetails}->{dependsOf}->{product}->{name} ) {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   332
              HandleError( "Can not extract ".$xmlData->{releaseDetails}->{dependsOf}->{product}->{name} .
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   333
              " release on top of ".$currentReleaseData->{releaseDetails}->{releaseID}->{product}->{name}, $cannotContinue );
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   334
          }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   335
          printLog( "service and product matches.. checking release" );
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   336
          
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   337
          # compare releases
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   338
          $currentRelease = $currentReleaseData->{releaseDetails}->{releaseID}->{release}->{name};
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   339
          $newRelease = $xmlData->{releaseDetails}->{dependsOf}->{release}->{name};
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   340
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   341
          if ( $currentRelease =~ m/^(S60_\d_\d+_\d{6})/i or $currentRelease =~ m/^(pf_\d{4}_\d{6})/ ) {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   342
              $currentRelease = $1;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   343
          }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   344
          else {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   345
              HandleError( "Current release info unknown or missing: $currentRelease", $cannotContinue );
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   346
          }
1
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   347
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   348
          if ( $newRelease =~ m/^(S60_\d_\d+_\d{6})/i or $newRelease =~ m/^(pf_\d{4}_\d{6})/ ) {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   349
              $newRelease = $1;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   350
          }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   351
          else {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   352
              HandleError( "New release info unknown or missing: $newRelease", $cannotContinue );
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   353
          }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   354
      }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   355
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   356
      printLog( "current release: $currentRelease" );
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   357
      printLog( "release to extract: $newRelease" );
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   358
#salmarko ends
1
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   359
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   360
      if( $currentRelease ne $newRelease ) {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   361
          HandleError( "Can not extract $newRelease release on top of $currentRelease", $cannotContinue );
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   362
      }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   363
      printLog( "release matches - update possible" );
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   364
      
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   365
      $currentRelease = FixPaths( getcwd )."currentRelease.xml";
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   366
  }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   367
  # check wheter we can use c-disc as temp
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   368
  my $df = getFreeDisk(  $ENV{'TEMP'}  );
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   369
  
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   370
  if( $df > 2147483648 && $df < 2147483648000 ) {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   371
    printLog( "amount of free space seems sane: $df" );
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   372
    $tmpDir = FixPaths( tempdir( CLEANUP => 0 ) );
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   373
    printLog( "setting tmpDir: $tmpDir" );
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   374
    $tmpDlDir = FixPaths( tempdir( CLEANUP => 0 ) );
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   375
    printLog( "setting tmpDlDir: $tmpDlDir" );
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   376
  }
1
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   377
}
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   378
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   379
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   380
# Make sure paths are as perl likes 'em
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   381
# change '\' ==> '/' and make sure last char is /
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   382
sub FixPaths {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   383
    my $tmpParam = shift;
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   384
    $tmpParam =~ s/\\/\//g;
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   385
    
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   386
    if( substr( $tmpParam, -1 ) eq "/" ) {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   387
        return $tmpParam;
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   388
    }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   389
    else {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   390
        return $tmpParam."/";
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   391
    }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   392
}
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   393
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   394
# smarter handling of logging
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   395
sub printLog {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   396
    foreach my $trace ( @_ ) {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   397
        if( $param_debug ) {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   398
            # we should print traces for STDOUT as well
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   399
            my ($sec,$min,$hr) = localtime();
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   400
        printf( "%02d:%02d:%02d: ", $hr, $min, $sec );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   401
            print $trace."\n";
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   402
        }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   403
    
588
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   404
        # first open/create log file
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   405
        #open( LOGFILE, ">> $logFile" ) or handleError( "cant create log file: $!", $warning );
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   406
        eval {
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   407
            open( LOGFILE, ">> getcwd.'/output/logs/getenv.log'" );
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   408
        }; 
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   409
        if ($@) #if exception
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   410
        {
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   411
            open( LOGFILE, ">> getcwd.'/getenv.log'" ) or handleError( "cant create log file: $!", $warning );
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   412
        }
1
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   413
        # we should print traces for log file
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   414
        my ($sec,$min,$hr) = localtime();
588
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   415
        printf LOGFILE ( "%02d:%02d:%02d: ", $hr, $min, $sec );
1
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   416
        print LOGFILE $trace."\n";
588
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
   417
		close (LOGFILE);
1
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   418
    }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   419
}
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   420
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   421
sub HandleError {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   422
    my( $errorString, $errorType ) = @_;
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   423
    printLog( "HandleError: $errorString, type: $errorType" );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   424
    
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   425
    if( $errorType eq $warning ) {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   426
        print "\nWARNING: $errorString\n";
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   427
    }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   428
    if( $errorType eq $promptUser ) {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   429
        print "\nWARNING: $errorString\n\n";
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   430
        print "Press <enter> to continue..\n" if( ! $param_start_directly );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   431
        my $selection = <STDIN> if( ! $param_start_directly );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   432
    }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   433
    elsif( $errorType eq $dependencyMissing ) {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   434
        if( $param_keepgoing ) {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   435
            print "\nERROR: Required dependency missing: $errorString\n\n";
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   436
        }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   437
        else {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   438
            die "ERROR: all the needed dependencies doesn't exist!\n$errorString\nIf you think it is ok to ignore this error you can use -k as keep-going parameter\nYou should report this to administrator of the server\n\ngetenv will now exit\n\n";
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   439
        }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   440
    }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   441
    elsif( $errorType eq $cannotContinue ) {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   442
        if( $param_keepgoing ) {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   443
            print "\nWARNING: $errorString\n\n";
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   444
        }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   445
        else {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   446
            die "\nERROR:\n============\n$errorString\ngetenv will now exit\nIf you think it is ok to ignore this error you can use -k as keep going parameter\n\n";
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   447
        }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   448
    }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   449
}
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   450
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   451
# checks wheter the xml file seems sane (has service, product and name set)
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   452
sub ValidateXmlFile {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   453
    my $xmlFile = shift( @_ );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   454
    printLog( "Validating $xmlFile" );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   455
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   456
    # open the xml file and check wheter it is something we want
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   457
    my $dependencyXmlParser = new XML::Simple( );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   458
    my $dependencyData = $dependencyXmlParser->XMLin( $xmlFile );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   459
    
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   460
    # if releaseDetails->releaseID->service&product&release are found consider this as valid file
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   461
    if( $dependencyData->{releaseDetails}->{releaseID}->{service}->{name} and
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   462
            $dependencyData->{releaseDetails}->{releaseID}->{product}->{name} and
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   463
            $dependencyData->{releaseDetails}->{releaseID}->{release}->{name} ) {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   464
        # return xml file with path
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   465
        printLog( "xml file OK" );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   466
        return 1;
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   467
    }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   468
    else {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   469
        printLog( "xml file doesn't seem to be sane!" );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   470
        return 0;
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   471
    }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   472
}
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   473
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   474
sub print_help {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   475
    print "
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   476
usage
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   477
=====
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   478
getenv.pl [params]
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   479
  getenv.pl             use no parameters to run small wizard
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   480
  getenv.pl -h(elp)     print help
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   481
  getenv.pl -k          keep going even when errors occurs
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   482
  getenv.pl -p          do nothing, but print system calls
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   483
  getenv.pl -emu        DEPRECATED - prefer filtering: get only emulator environment
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   484
  getenv.pl -start      starts extracting without user confirmation (nice for scripts)
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   485
  getenv.pl -nodeps     do not download dependencies for the release
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   486
  getenv.pl -skipitd    DEPRECATED - prefer filtering: skips useless doc, internal, tsrc zips
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   487
  getenv.pl -verbose    print debug traces
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   488
  getenv.pl -Include    include only some types of packages (emu, src, tsrc)
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   489
  getenv.pl -eXclude    exclude some types of packages (emu, src, tsrc)
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   490
  getenv.pl -all        extract all zips
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   491
  getenv.pl -Force      forces to extract some filtered packages ( tsrc ) including default zips
1
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   492
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   493
examples
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   494
========
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   495
  get latest PRODUCT release:
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   496
      getenv.pl -latest -product PRODUCT
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   497
  get s60 release from server \\\\SERVER\\LOCATION:
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   498
      getenv.pl -server \\\\SERVER\\LOCATION
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   499
  get s60 release located in \\\\SERVER\\LOCATION\\BUILDS\\PRODUCT\\RELEASE:
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   500
      getenv.pl -path \\\\SERVER\\LOCATION\\BUILDS\\PRODUCT\\RELEASE
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   501
  get s60 release pointed with -path and print verbose messages:
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   502
      getenv.pl -path \\\\SERVER\\LOCATION\\BUILDS\\PRODUCT\\RELEASE -verbose
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   503
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   504
Filtering
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   505
=========
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   506
  You can include or exclude certain types of packages to unzip.
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   507
  For example you can unzip only emulator binaries with -include emu (or -i emu)
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   508
  Or if you don't want test sources and documents use -exclude tsrc (or -x tsrc)
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   509
  Possible filters are emu, src, tsrc and we can put plenty more into metadata.xml if needed
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   510
  To get latest PRODUCT emulator environment use
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   511
      getenv.pl -latest -product PRODUCT -i emu
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   512
  To get only custom build without winscw binaries use
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   513
      getenv.pl -path \\\\SERVER\\LOCATION\\BUILDS\\PRODUCT\\RELEASE -x emu
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   514
";
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   515
    exit 0;
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   516
}
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   517
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   518
    
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   519
    
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   520
    
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   521
    
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   522
# returns file name of correct xml file in given directory
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   523
sub SearchValidXml {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   524
    my $searchDir = shift @_;
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   525
    printLog( "finding valid xml files from: $searchDir" );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   526
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   527
    # validate xml files from selected directory
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   528
    opendir( XMLDIR, $searchDir ) or die "can't open $searchDir: $!";
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   529
    # scan all xml files to @xmlFiles
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   530
    my @xmlFiles = grep /\.xml$/, readdir XMLDIR;
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   531
    close XMLDIR;
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   532
#   print Dumper( @xmlFiles );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   533
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   534
    # sort files in ascenting order (so latest comes first: _001
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   535
    @xmlFiles = sort {$b cmp $a} (@xmlFiles);
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   536
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   537
    foreach my $xmlCandidate ( @xmlFiles ) {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   538
        printLog( "xmlfile: $xmlCandidate" );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   539
        # open the xml file and check wheter it is something we want
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   540
        my $xmlParser = new XML::Simple( );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   541
        my $releaseData = $xmlParser->XMLin( $searchDir."/".$xmlCandidate );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   542
        
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   543
        # if releaseDetails->releaseID->service&product&release are found consider this as valid file
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   544
        if( $releaseData->{releaseDetails}->{releaseID}->{service}->{name} and
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   545
                $releaseData->{releaseDetails}->{releaseID}->{product}->{name} and
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   546
                $releaseData->{releaseDetails}->{releaseID}->{release}->{name} ) {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   547
            # return xml file with path
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   548
            return $xmlCandidate;
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   549
        }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   550
    }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   551
    
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   552
    # in case we came until here the xml file is not found
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   553
    HandleError( "Valid release_metadata.xml file was not found from $searchDir", $cannotContinue );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   554
}
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   555
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   556
sub RunWizard {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   557
    print "Server is heavily loaded and therefore also download times might be drawn out.\nFor your convenience it is recommended to use samba share close to you.\n";
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   558
# salmarko starts
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   559
    if( !$param_server ) {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   560
# salmarko ends
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   561
        # prompt user wheter he wants to use GRACE
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   562
        my $wantedServer;
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   563
        my $networkAccessVerified = 0;
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   564
        while( $networkAccessVerified eq 0 ) {
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   565
            $wantedServer = FixPaths( $hydraList[ ReturnMenuIndex( "Please select share closest to you", @hydraNameList ) ] );
1
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   566
            
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   567
            if( $wantedServer eq FixPaths( $hydraList[0] ) ) {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   568
                HandleError( "Please notice that access to $hydraList[0] will be removed from wk50 onwards. Now would be perfect time to get yourself GRACE access.", $promptUser );
1
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   569
            }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   570
        
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   571
            printLog( "selected: $wantedServer - accessing.." );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   572
            if( opendir( GRACETEST, $wantedServer ) ) {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   573
                printLog( "connection tested OK" );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   574
                $networkAccessVerified = 1;
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   575
                $pathToReleaseFolder = $wantedServer;
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   576
            }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   577
            else {
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   578
        die "Unable to access $wantedServer\nPlease select another network share.\n";
1
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   579
            }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   580
        }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   581
        my $wantedService = $serviceList[ ReturnMenuIndex( "Please select GRACE Service.", @serviceNameList)];
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   582
        printLog( "selected: $wantedServer.$wantedService - accessing.." );
179
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
   583
        local *GRACETEST2;
1
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   584
        if( opendir( GRACETEST2, $wantedServer.$wantedService ) ) {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   585
            printLog( "serviceconnection tested OK" );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   586
            $defaultServiceName = $wantedService
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   587
            }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   588
            else {
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   589
            die "Unable to access $wantedServer.$wantedService\nPlease select another network share or service.\n";
1
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   590
            }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   591
    }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   592
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   593
    # find & select correct product from the server
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   594
    my @productFiles = FindAvailableProducts( );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   595
    if( ! @productFiles ) {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   596
        HandleError( "Server seem to be empty!\nPlease check the server path: $pathToReleaseFolder$defaultServiceName\n$!", $cannotContinue );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   597
    }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   598
    my $product = PrintSelectMenu( "Products found from server", @productFiles );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   599
    $product = FixPaths( $product );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   600
    printLog( "selected product: $product" );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   601
    
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   602
    # find & select correct release from above selected path
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   603
    my @releaseFiles = FindAvailableReleases( $product );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   604
    if( ! @releaseFiles ) {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   605
        HandleError( "Cant find any releases from: $pathToReleaseFolder$defaultServiceName.$product\n$!", $cannotContinue );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   606
    }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   607
    my $release = PrintSelectMenu( "Releases found from server", @releaseFiles );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   608
    $release = FixPaths( $release );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   609
    printLog( "selected release: $release" );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   610
    
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   611
    # select correct xml file from selected release
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   612
    $metaDataXml = SearchValidXml( $pathToReleaseFolder.$defaultServiceName.$product.$release );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   613
    $metaDataXml = $pathToReleaseFolder.$defaultServiceName.$product.$release.$metaDataXml;
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   614
    printLog( "selected metadata: $metaDataXml" );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   615
}
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   616
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   617
# check what products is there under servers release path
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   618
sub FindAvailableProducts {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   619
    opendir( DIR, $pathToReleaseFolder.$defaultServiceName )
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   620
        or HandleError( "Can't open directory: $pathToReleaseFolder$defaultServiceName\n$!", $cannotContinue );
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   621
  my @productFiles = grep /^pf_|^S60|^DFS|^50_|^pf./i, readdir (DIR);
1
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   622
    printLog( @productFiles );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   623
    closedir( DIR );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   624
    
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   625
    # return found releases sorted
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   626
    return sort( @productFiles );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   627
}
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   628
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   629
# print selection menus
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   630
sub PrintSelectMenu {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   631
    my( $topic, @inputArray ) = @_;
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   632
    
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   633
    # print topic line
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   634
    print "\n\n$topic:\n";
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   635
    for( my $i = length( $topic ); $i>=0; $i-- ) {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   636
        print "=";
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   637
    }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   638
    print "\n";
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   639
    
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   640
    # print actual selections
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   641
    my $counter = 0;
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   642
    foreach my $line( @inputArray ) {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   643
        $counter ++;
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   644
        print "$counter:\t$line\n";
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   645
    }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   646
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   647
    print "\n\nx:\texit\n";
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   648
    print "\nselection: ";
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   649
    my $selection = <STDIN>;
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   650
    chop( $selection );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   651
    
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   652
    exit 1 if( $selection eq 'x' );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   653
    
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   654
    # check user input
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   655
    while( ! $selection =~ /\d*/ and
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   656
                    $selection > $counter )
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   657
        {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   658
            if( $selection =~ /\d*/ ) {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   659
                print "Invalid selection. Please check value from the list above\n";
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   660
            }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   661
            else {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   662
                print "Please insert numerical value from the list\n";
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   663
            }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   664
            print "\nselection: ";
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   665
            $selection = <STDIN>;
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   666
            chop( $selection );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   667
            
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   668
            exit 1 if( $selection eq 'x' );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   669
        }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   670
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   671
    # return array index
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   672
    $selection--;
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   673
    return( $inputArray[$selection] );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   674
}
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   675
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   676
# print selection menus
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   677
sub ReturnMenuIndex {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   678
    my( $topic, @inputArray ) = @_;
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   679
    
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   680
    # print topic line
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   681
    print "\n\n$topic:\n";
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   682
    for( my $i = length( $topic ); $i>=0; $i-- ) {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   683
        print "=";
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   684
    }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   685
    print "\n";
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   686
    
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   687
    # print actual selections
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   688
    my $counter = 0;
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   689
    foreach my $line( @inputArray ) {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   690
        $counter ++;
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   691
        print "$counter:\t$line\n";
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   692
    }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   693
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   694
    print "\n\nx:\texit\n";
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   695
    print "\nselection: ";
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   696
    my $selection = <STDIN>;
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   697
    chop( $selection );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   698
    
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   699
    exit 1 if( $selection eq 'x' );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   700
    
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   701
    # check user input
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   702
    while( ! $selection =~ /\d*/ and
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   703
                    $selection > $counter )
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   704
        {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   705
            if( $selection =~ /\d*/ ) {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   706
                print "Invalid selection. Please check value from the list above\n";
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   707
            }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   708
            else {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   709
                print "Please insert numerical value from the list\n";
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   710
            }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   711
            print "\nselection: ";
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   712
            $selection = <STDIN>;
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   713
            chop( $selection );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   714
            
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   715
            exit 1 if( $selection eq 'x' );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   716
        }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   717
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   718
    # return array index
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   719
    $selection--;
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   720
    return $selection;
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   721
}
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   722
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   723
# check what releases are there under selected product
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   724
sub FindAvailableReleases {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   725
    my $selectedProduct = shift( @_ );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   726
    printLog( "searching available releases from $selectedProduct" );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   727
#   print $serverPath.$selectedProduct."\n";
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   728
    opendir( DIR, $pathToReleaseFolder.$defaultServiceName .$selectedProduct ) or die "Can't open dir: $!\n";
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   729
#   my @releaseFiles = grep { /S60_\d_\d.*/ } readdir (DIR);
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   730
# salmarko starts
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   731
  #my @releaseFiles = grep /^pf_|^S60|^DFS|^50_|^pf./i, readdir (DIR);
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   732
  # s3laine: Better way to exclude "." and ".." entries. The previous will fail
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   733
  # if the release name includes dots. 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   734
  my @releaseFiles = grep { $_ ne '.' and $_ ne '..' } readdir (DIR); 
1
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   735
# salmarko ends
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   736
#   print Dumper( @releaseFiles );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   737
    closedir (DIR);
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   738
#TODO: maybe we should also check wheter xml files exists in release
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   739
    return sort {$b cmp $a} ( @releaseFiles );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   740
}
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   741
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   742
# maybe we should print warning only 
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   743
sub PrintFinalWarning {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   744
    if( ! $param_start_directly ) {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   745
        # we'll print warnings only if extracting on top of something else (aka not empty dir)
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   746
#       print "About to start extracting\n$metaDataXml";
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   747
#       print "\nHit ctrl-C now to abort, otherwise press enter to continue\n\n";
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   748
#       my $selection = <STDIN>;
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   749
        print scalar(localtime). ": start fetching environment\n";
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   750
    }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   751
}
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   752
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   753
# handles controlled downloading of the environment pointed by $metaDataXml
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   754
sub DownloadRelease {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   755
    # open wanted metadata.xml file
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   756
    my $xmlParser = new XML::Simple( );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   757
    my $data = $xmlParser->XMLin( $metaDataXml );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   758
    
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   759
    # parse download directory based on given arguments and xml file to $releaseLocationInServer
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   760
    my $releaseLocationInServer;
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   761
    if( ! $param_release_path ) {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   762
        $releaseLocationInServer = ParseDownloadDir( $data );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   763
    }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   764
    else {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   765
        $releaseLocationInServer = $param_release_path;
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   766
    }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   767
    
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   768
    # read files from the xml to %packageHash
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   769
    GeneratePackageHash( $data, $releaseLocationInServer );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   770
    printLog( "package hash generated" );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   771
    
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   772
    # insert needed files to @finalZipList
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   773
    SortFilesToFinalLists( );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   774
    printLog( "files sorted to final zip list" );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   775
    
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   776
    # check if there is dependencies we need to extract as well
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   777
    if( ! $param_skip_deps and
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   778
            $data->{releaseDetails}->{dependsOf}->{service} ) {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   779
        # read from xml where can we get dependeny
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   780
        my $dependsOfService = $data->{releaseDetails}->{dependsOf}->{service}->{name};
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   781
        my $dependsOfProduct = $data->{releaseDetails}->{dependsOf}->{product}->{name};
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   782
        my $dependsOfRelease = $data->{releaseDetails}->{dependsOf}->{release}->{name};
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   783
    
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   784
        printLog( "First dl: $dependsOfService $dependsOfProduct $dependsOfRelease" );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   785
        
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   786
        # add dependency files to finalLists
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   787
        AddDependencies( $dependsOfService, $dependsOfProduct, $dependsOfRelease );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   788
    }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   789
    
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   790
    # we should check wheter there already exists old build (currentRelease.xml) and reduct the files
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   791
    if( -e FixPaths( getcwd )."currentRelease.xml" ) {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   792
        # reduct old DL'd files (currentrelease.xml and it's dependencies)
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   793
        # passing param '1' as for printing
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   794
        RemoveThisXmlFromFinalList( FixPaths( getcwd )."currentRelease.xml", 1 );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   795
    }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   796
    if( VerifyFinalZipList( ) or $param_keepgoing ) {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   797
        # extract the environment
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   798
        GetEnv( );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   799
    }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   800
}
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   801
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   802
# return download directory from the metadata.xml
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   803
sub ParseDownloadDir {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   804
    my $data = shift( @_ );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   805
    my $releaseLocationInServer;
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   806
    
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   807
    # parse dl directory into $releaseDirectory
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   808
    $releaseLocationInServer = $data->{releaseDetails}->{releaseID}->{service}->{name} . "/";
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   809
    $releaseLocationInServer .= $data->{releaseDetails}->{releaseID}->{product}->{name} ."/";
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   810
    $releaseLocationInServer .= $data->{releaseDetails}->{releaseID}->{release}->{name} ."/";
179
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
   811
    local *DEPTEST;
1
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   812
    
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   813
    # check if we can find this release from GRACE
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   814
    if( $graceServer ) {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   815
        if( -e $graceServer.$releaseLocationInServer."grace.txt" ) {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   816
            printLog( "dl dir: $graceServer$releaseLocationInServer" );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   817
            return $graceServer.$releaseLocationInServer;
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   818
        }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   819
        else {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   820
            printLog( "dl dir: $pathToReleaseFolder$releaseLocationInServer" );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   821
            return $pathToReleaseFolder.$releaseLocationInServer;
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   822
        }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   823
    }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   824
    else {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   825
        # while call to remove dependency xmls is recursive, we dont know actual DL path
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   826
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   827
        if( opendir( DEPTEST, $pathToReleaseFolder.$releaseLocationInServer ) ) {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   828
            return $pathToReleaseFolder.$releaseLocationInServer;
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   829
        }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   830
        else {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   831
            return $defaultPathToServer.$releaseLocationInServer;
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   832
        }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   833
    }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   834
}
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   835
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   836
# generates %packageHash that contains data about needed files
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   837
# param: xml data handle
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   838
sub GeneratePackageHash {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   839
    my( $xmlDataHandle, $releaseInServer )  = @_;
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   840
    my $finalState = 0;
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   841
    printLog( "parse filenames to extract to packageHah" );
179
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
   842
    no strict 'refs';
1
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   843
        
179
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
   844
# Incase if we have only one package in the release to extract, then in the case
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
   845
# the Xml::Simple::XMLin is not creating keys inside $xmlDataHandle->{releaseFiles}->{package}
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
   846
# with package names. So to address it, the below part of code is done..
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
   847
####
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
   848
    if(exists $xmlDataHandle->{releaseFiles}->{package}->{name}){
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
   849
        my $pkgName = $xmlDataHandle->{releaseFiles}->{package}->{name};
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
   850
        my $tmphash = $xmlDataHandle->{releaseFiles}->{package};
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
   851
        delete $tmphash->{name} ;
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
   852
        delete $xmlDataHandle->{releaseFiles}->{package};
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
   853
        $xmlDataHandle->{releaseFiles}->{package}->{$pkgName} = $tmphash;
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
   854
    }
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
   855
#####
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
   856
1
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   857
    # generate new hash of zips to DL for %packageHash
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   858
    # foreach my $key( sort { $xmlDataHandle{a}->{'state'} <=> $xmlDataHandle{b}->{'state'} } %{$xmlDataHandle->{releaseFiles}->{'package'} } ){
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   859
    foreach my $key( keys(%{$xmlDataHandle->{releaseFiles}->{package} } ) ) {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   860
        printLog( "adding $key to packageHash" );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   861
        ${packageHash}{$key}{path} = FixPaths( $releaseInServer );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   862
        ${packageHash}{$key}{type} = $xmlDataHandle->{releaseFiles}->{package}->{$key}->{'type'};
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   863
        ${packageHash}{$key}{state} = $xmlDataHandle->{releaseFiles}->{package}->{$key}->{'state'};
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   864
        ${packageHash}{$key}{extract} = $xmlDataHandle->{releaseFiles}->{package}->{$key}->{'extract'};
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   865
        ${packageHash}{$key}{default} = $xmlDataHandle->{releaseFiles}->{package}->{$key}->{'default'};
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   866
    # added 5th of September 2008 by salmarko, include all zips
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   867
    if ( $param_all ) {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   868
      ${packageHash}{$key}{default} = "true";
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   869
    }
1
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   870
        if ($xmlDataHandle->{releaseFiles}->{package}->{$key}->{'filters'}){
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   871
            ${packageHash}{$key}{s60filter} = $xmlDataHandle->{releaseFiles}->{package}->{$key}->{'filters'};
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   872
        }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   873
        elsif ($xmlDataHandle->{releaseFiles}->{package}->{$key}->{'s60filter'}) {;
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   874
            ${packageHash}{$key}{s60filter} = $xmlDataHandle->{releaseFiles}->{package}->{$key}->{'s60filter'};
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   875
        }   
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   876
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   877
    # added 5th of September 2008 by salmarko, include zips marked as false if -f parameter equals
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   878
    if ( ${packageHash}{$key}{default} eq "false" ) {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   879
      if ( @force_include ) {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   880
        foreach my $include( @force_include ) {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   881
          if ( FindFromList( $include,${packageHash}{$key}{s60filter} ) ) {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   882
            ${packageHash}{$key}{default} = "true";
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   883
          }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   884
        }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   885
      }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   886
      if ( @param_include ){
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   887
        foreach my $include( @param_include ) {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   888
          if ( FindFromList( $include,${packageHash}{$key}{s60filter} ) ) {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   889
            ${packageHash}{$key}{default} = "true";
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   890
          }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   891
        }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   892
      }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
   893
    }
1
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   894
        # find out what is the latest state
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   895
        if( $finalState < $xmlDataHandle->{releaseFiles}->{package}->{$key}->{'state'} ) {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   896
            $finalState = $xmlDataHandle->{releaseFiles}->{package}->{$key}->{'state'};
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   897
        }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   898
    }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   899
    
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   900
    # we should check wheter this xml has servicepacks
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   901
    my $spName = $xmlDataHandle->{servicePacks}->{servicePack}->{name};
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   902
    # always increase final state
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   903
    $finalState ++;
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   904
    if( $spName ) {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   905
        printLog( "spname: $spName" );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   906
        $finalState ++;
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   907
        my $spFileName = $xmlDataHandle->{servicePacks}->{servicePack}->{file}->{name};
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   908
        # if we get spFileName we should extract SP zip
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   909
        if( $spFileName ) {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   910
            printLog( "spFileName: $spFileName" );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   911
            ${packageHash}{$spFileName}{path} = FixPaths( $releaseInServer );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   912
            ${packageHash}{$spFileName}{type} = "zip";
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   913
            ${packageHash}{$spFileName}{state} = $finalState;
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   914
            ${packageHash}{$spFileName}{extract} = "single";
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   915
            ${packageHash}{$spFileName}{default} = "true";
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   916
            $finalState ++;
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   917
        }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   918
        # if there is servicePack->instructions we should read specianInstructions file
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   919
        my $specialInstructions = $xmlDataHandle->{servicePacks}->{servicePack}->{instructions};
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   920
        if( $specialInstructions ) {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   921
            printLog( "read special instructions" );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   922
        }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   923
    }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   924
    # in case there is > 1 SP's in one XML file
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   925
    else {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   926
        foreach( keys(%{$xmlDataHandle->{servicePacks}->{servicePack} } ) ) {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   927
#       foreach my $tmparray( $xmlDataHandle->{servicePacks}->{servicePack} ) {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   928
            printLog( "spname: $_" );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   929
            my $spFileName = $xmlDataHandle->{servicePacks}->{servicePack}->{$_}->{file}->{name};
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   930
            printLog( "spFileName: $spFileName" );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   931
            ${packageHash}{$spFileName}{path} = FixPaths( $releaseInServer );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   932
            ${packageHash}{$spFileName}{type} = "zip";
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   933
            ${packageHash}{$spFileName}{state} = $finalState;
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   934
            ${packageHash}{$spFileName}{extract} = "single";
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   935
            ${packageHash}{$spFileName}{default} = "true";
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   936
            $finalState ++;
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   937
        }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   938
    }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   939
}
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   940
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   941
# inserts files on beginning of @finalZipList so they are readable in correct order when extracting (dependencies first)
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   942
sub SortFilesToFinalLists {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   943
    foreach my $zips( sort { $packageHash{$b}->{'state'} <=> $packageHash{$a}->{'state'} } keys %packageHash ) {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   944
        if( $packageHash{$zips}->{'default'} eq 'true' ) {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   945
            my $tmpHash = $packageHash{$zips};
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   946
            $tmpHash->{'filename'} = $zips;
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   947
            unshift @finalZipList, $tmpHash;
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   948
        }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   949
    }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   950
    %packageHash = 0;
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   951
}
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   952
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   953
sub AddDependencies {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   954
    # parameters contains info which release needs to be DL'd first
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   955
    my( $dependsOfService, $dependsOfProduct, $dependsOfRelease ) = @_;
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   956
    my $dependsOf = $dependsOfService ."/". $dependsOfProduct ."/". $dependsOfRelease ."/";
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   957
    
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   958
    # if we are here, dependecies really exists..
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   959
#   print "the package has dependency: $dependsOf\n";
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   960
#   print "so calling self with $serverPath and $dependsOf\n";
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   961
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   962
    # first we'll have to find correct xml file
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   963
    my $xmlPath;
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   964
    # if we are DL'ing from custom path ==> first check relative path
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   965
    if( $param_release_path ) {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   966
        # best guess is $param_release_path\..\..\..\$dependsOf even though it is not very common situation
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   967
        my $dependencyPath = FixPaths( $param_release_path ) . "../../../" . FixPaths( $dependsOf );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   968
        if( -e $dependencyPath."release_metadata.xml" ) {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   969
            printLog( $dependencyPath ."release_metadata.xml exists - setting dependencyPath accordingly" );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   970
            $xmlPath = $dependencyPath;
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   971
        }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   972
        # in case it is not in relative path we should try finding it from release server
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   973
        elsif( -e $pathToReleaseFolder.$dependsOf."release_metadata.xml" ) {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   974
            printLog( $dependencyPath ."release_metadata.xml not not exist - setting dependencyPath accordingly" );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   975
            $xmlPath = $pathToReleaseFolder.$dependsOf;
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   976
        }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   977
    }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   978
    # param_release_path not defined
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   979
    else {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   980
        $xmlPath = $pathToReleaseFolder.$dependsOf;
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   981
    }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   982
    printLog( "xmlpath: $xmlPath" );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   983
    
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   984
    if (!-e $xmlPath && $param_keepgoing) {return;}
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   985
    
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   986
    my $dependecyXml = SearchValidXml( $xmlPath );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   987
    printLog( "xml candidate: $dependecyXml" );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   988
    # open the xml file and check wheter it is the one we want
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   989
    my $dependencyXmlParser = new XML::Simple( );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   990
    my $dependencyData = $dependencyXmlParser->XMLin( $xmlPath.$dependecyXml );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   991
    
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   992
    # read releaseDetails from xml candidate
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   993
    my $tmpServiceName = $dependencyData->{releaseDetails}->{releaseID}->{service}->{name};
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   994
    my $tmpProductName = $dependencyData->{releaseDetails}->{releaseID}->{product}->{name};
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   995
    my $tmpReleaseName = $dependencyData->{releaseDetails}->{releaseID}->{release}->{name};
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   996
    
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   997
    
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   998
    printLog( "tmpServiceName:   $tmpServiceName tmpProductName:   $tmpProductName tmpReleaseName:   $tmpReleaseName" );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   999
    printLog( "dependsOfService: $dependsOfService dependsOfProduct: $dependsOfProduct dependsOfRelease: $dependsOfRelease" );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1000
    
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1001
    # compare xml candidate's data to dependency data
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1002
    if( $tmpServiceName eq $dependsOfService and
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1003
            $tmpProductName eq $dependsOfProduct and
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1004
            $tmpReleaseName eq $dependsOfRelease ) {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1005
        printLog( "MATCH!" );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1006
        
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1007
        my $dependencyLocationInServer;
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1008
        
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1009
        if(! $param_release_path ) {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1010
            $dependencyLocationInServer = ParseDownloadDir( $dependencyData );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1011
        }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1012
        else {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1013
            $dependencyLocationInServer = $xmlPath;
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1014
        }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1015
        printLog( "So calling downloadRelease with serverpath: $dependencyLocationInServer, metadatafile: $dependsOf$dependecyXml" );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1016
        
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1017
        # read files from dependency xml to %packageHash
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1018
        GeneratePackageHash( $dependencyData, $dependencyLocationInServer );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1019
        printLog( "dependency package hash generated" );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1020
    
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1021
        # insert needed files to @finalZipList
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1022
        SortFilesToFinalLists( );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1023
        printLog( "dependency files sorted to final zip list" );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1024
        
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1025
        # check if there is still dependencies we need to extract
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1026
        if( $dependencyData->{releaseDetails}->{dependsOf}->{service} ) {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1027
            # read from xml where can we get dependeny
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1028
            my $dependsOfService = $dependencyData->{releaseDetails}->{dependsOf}->{service}->{name};
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1029
            my $dependsOfProduct = $dependencyData->{releaseDetails}->{dependsOf}->{product}->{name};
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1030
            my $dependsOfRelease = $dependencyData->{releaseDetails}->{dependsOf}->{release}->{name};
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1031
        
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1032
            printLog( "First dl: $dependsOfService $dependsOfProduct $dependsOfRelease" );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1033
            
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1034
            # add dependency files to finalLists
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1035
            AddDependencies( $dependsOfService, $dependsOfProduct, $dependsOfRelease );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1036
        }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1037
    }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1038
    else {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1039
        HandleError( "Dependency release $xmlPath.$dependecyXml doesnt seem to match with actual downloadable", $cannotContinue );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1040
    }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1041
}
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1042
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1043
sub RemoveThisXmlFromFinalList {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1044
    my( $xmlFileName, $printRemoving ) = @_;
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1045
    
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1046
    printLog( "Removing contents of $xmlFileName from finalziplist" );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1047
    
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1048
    my $currentReleaseXmlParser = new XML::Simple( );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1049
    my $currentReleaseXmlHandle = $currentReleaseXmlParser->XMLin( $xmlFileName );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1050
    if( $printRemoving ) {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1051
        print $currentReleaseXmlHandle->{releaseDetails}->{releaseID}->{release}->{name};
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1052
        print " exists already => extracting only delta\n\n";
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1053
    }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1054
    
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1055
    # generate packageHash for old release
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1056
    my $location = ParseDownloadDir( $currentReleaseXmlHandle );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1057
    GeneratePackageHash( $currentReleaseXmlHandle, $location );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1058
    
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1059
    # remove files from @finalZipList
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1060
    ReductFilesFromFinalLists( );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1061
    
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1062
    # remove already DL'd dependency zips
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1063
    if( $currentReleaseXmlHandle->{releaseDetails}->{dependsOf}->{service} ) {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1064
        printLog( "already DL'd dependency needs to be removed as well:" );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1065
        
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1066
        my $xmlToRemove;
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1067
        
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1068
        # parse $dependsOf from xml
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1069
        my $dependsOfServiceToRemove = FixPaths( $currentReleaseXmlHandle->{releaseDetails}->{dependsOf}->{service}->{name} );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1070
        my $dependsOfProductToRemove = FixPaths( $currentReleaseXmlHandle->{releaseDetails}->{dependsOf}->{product}->{name} );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1071
        my $dependsOfReleaseToRemove = FixPaths( $currentReleaseXmlHandle->{releaseDetails}->{dependsOf}->{release}->{name} );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1072
        
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1073
        my $dependsOf = $dependsOfServiceToRemove.$dependsOfProductToRemove.$dependsOfReleaseToRemove;
179
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
  1074
        local *TMPTEST;
1
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1075
        
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1076
        # find out where the release came from
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1077
        if( $param_release_path ) {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1078
            # best guess is $param_release_path\..\..\..\$dependsOf even though it is not very common situation
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1079
            my $dependencyPath = FixPaths( $param_release_path ) . "../../../" . FixPaths( $dependsOf );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1080
            if( -e $dependencyPath."release_metadata.xml" ) {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1081
                printLog( $dependencyPath ."release_metadata.xml exists - setting pathTo ReleaseFolder accordingly" );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1082
                $xmlToRemove = $dependencyPath;
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1083
            }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1084
            # in case it is not in relative path we should try finding it from release server
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1085
            elsif( -e $pathToReleaseFolder.$dependsOf."release_metadata.xml" ) {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1086
                printLog( $dependencyPath ."release_metadata.xml not not exist - setting pathToReleaseFolder accordingly" );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1087
                $xmlToRemove = $pathToReleaseFolder.$dependsOf;
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1088
            }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1089
        }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1090
        elsif( opendir( TMPTEST, $pathToReleaseFolder.$dependsOf ) ) {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1091
            $xmlToRemove = $pathToReleaseFolder.$dependsOf;
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1092
        }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1093
        else {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1094
            $xmlToRemove = $defaultPathToServer.$dependsOf;
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1095
        }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1096
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1097
        #my $xmlToRemove = $pathToReleaseFolder;
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1098
        
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1099
        $xmlToRemove .= SearchValidXml( $xmlToRemove );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1100
        printLog( "following xml needs to be removed also: $xmlToRemove" );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1101
        RemoveThisXmlFromFinalList( $xmlToRemove  );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1102
    }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1103
}
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1104
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1105
sub ReductFilesFromFinalLists {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1106
    printLog( "reducting files from finalziplist" );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1107
    foreach my $zips( sort { $packageHash{$b}->{'state'} <=> $packageHash{$a}->{'state'} } keys %packageHash ) {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1108
        printLog( "matching $zips" );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1109
        if( $packageHash{$zips}->{'default'} eq 'true' ) {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1110
            my $tmpHash = $packageHash{$zips};
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1111
#           $tmpHash->{'filename'} = $zips;
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1112
#           unshift @finalZipList, $tmpHash;
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1113
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1114
            # if $tmpHash->{'filename'} eq can be found from finalziplist -> pop
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1115
            foreach my $finalZip( @finalZipList ) {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1116
# path contains ../../../ so wont match ==>
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1117
#               if( $finalZip->{filename} eq $zips and
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1118
#                       $finalZip->{path} eq %packageHash->{$zips}->{'path'} ) {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1119
                if( $finalZip->{filename} eq $zips ) {
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
  1120
              printLog( "removing $finalZip->{path} $finalZip->{filename} from dl list" );
1
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1121
                            $finalZip->{default} = "false";
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1122
                }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1123
            }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1124
        }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1125
    }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1126
    %packageHash = 0;
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1127
}
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1128
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1129
# verifying that files in @finalZipList really exists
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1130
sub VerifyFinalZipList {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1131
    print "Verifying all the zips exists... ";
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1132
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1133
    my $counter = 0;
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1134
    
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1135
    foreach my $file( @finalZipList ) {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1136
        my $tmpFileName = $file->{path}.$file->{filename};
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1137
        printLog( "Checking $tmpFileName.." );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1138
        opendir( VERIFYDIR, $file->{path} ) or HandleError( $file->{path}, $dependencyMissing );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1139
        # scan all xml files to @xmlFiles
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1140
        my @matchingFiles = grep /$file->{filename}/i, readdir VERIFYDIR;
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1141
        
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1142
        if( ! @matchingFiles ) {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1143
            HandleError( $file->{path}.$file->{filename}, $dependencyMissing );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1144
            
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1145
            # if we are here there is missing file but keep_going defined
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1146
            $file->{default} = "false";
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1147
        }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1148
        closedir VERIFYDIR;
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1149
        
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1150
        $counter++;
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1151
    }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1152
    
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1153
    print "done\n";
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1154
}
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1155
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1156
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1157
sub GetEnv {
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
  1158
  my $fileCounter = 0;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
  1159
  # first thing is to copy 7zip
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
  1160
  if( ! $param_print_only ) {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
  1161
    `7za --help`;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
  1162
    HandleError( "couldnt copy 7zip! make sure you have it in your system path!", $warning ) if ($? != 0);
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
  1163
    mkdir $tmpDir;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
  1164
    mkdir $tmpDlDir;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
  1165
  }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
  1166
  
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
  1167
  my $nmbrOfFiles = returnNmbrOfFiles( );
1
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1168
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1169
    printLog( "final zip list:" );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1170
    printLog( Dumper( @finalZipList ) );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1171
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1172
    # symsee 3.3.0 contains obsolete archive::zip, so we'll have to use system calls
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1173
    foreach my $file( @finalZipList ) {
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
  1174
    $fileCounter ++;
1
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1175
        $returnValue = 0;
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1176
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1177
        # skip not mandatory files
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1178
        next if( $file->{default} eq "false" );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1179
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1180
        # DEPRECATED parameters just for compatibility
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1181
        # Filter out some not wanted zip files
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1182
        # skip internal, testsources, docs
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1183
        if( $param_skipITD ) {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1184
            print "skipitd is deprecated and unmaintained parameter that will be removed in the future!\nInstead you should use \"getenv -x tsrc\"";
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1185
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1186
            printLog( "param skipITD used, checking wheter we have to skip: $file->{filename}" );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1187
            # skip if zip filename matches _internal.zip, _tsrc.zip, _doc.zip
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1188
            next if $file->{filename} =~ /internal.zip/;
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1189
            next if $file->{filename} =~ /tsrc.zip/;
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1190
            next if $file->{filename} =~ /doc.zip/;
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1191
        }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1192
        
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1193
        # DEPRECATED parameters just for compatibility
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1194
        # get only files needed for emulator and service packs
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1195
        if( $param_emuenv ) {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1196
            print "emu is deprecated and unmaintained parameter that will be removed in the future!\nInstead you should use \"getenv -i emu\"";
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1197
            my $skip = 1;
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1198
            
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1199
            printLog( "param emu used, checking wheter we have to skip: $file->{filename}" );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1200
            if( $file->{filename} =~ /winscw.zip/ or
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1201
                    $file->{filename} =~ /epoc32.zip/ or
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1202
                    $file->{filename} =~ /epoc32_tools.zip/ or
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1203
                    $file->{state} == 10 ) {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1204
                $skip = 0;
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1205
            }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1206
            next if $skip;
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1207
        }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1208
        
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1209
        my $skipByFilter = 0;
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1210
        # exclude files that has s60filter matching with exclude array
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1211
        if( @param_exclude ) {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1212
            foreach my $exclude( @param_exclude ) {
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
  1213
#       if( $exclude eq $file->{s60filter} ) {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
  1214
        if( FindFromList( $exclude, $file->{s60filter} ) ) {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
  1215
          printLog( "excluding $file->{filename} because $exclude matches $file->{s60filter}" );
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
  1216
          $skipByFilter = 1;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
  1217
          last;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
  1218
        }
1
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1219
            }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1220
        }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1221
        # include only files that has s60filter matching with include array
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1222
        elsif( @param_include ) {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1223
            $skipByFilter = 1;
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1224
            foreach my $include( @param_include ) {
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
  1225
#       if( $include eq $file->{s60filter} ) {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
  1226
        if( FindFromList( $include, $file->{s60filter} ) ) {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
  1227
          printLog( "including $file->{filename} because $include matches $file->{s60filter}" );
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
  1228
          $skipByFilter = 0;
1
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1229
                    last;
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1230
                }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1231
            }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1232
        }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1233
        next if $skipByFilter;
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1234
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1235
        # let's do some forking
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1236
        # parent process unzips from tmpdir and child DL's new package from network
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1237
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1238
        # fork new process
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1239
        my $pid = myFork();
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1240
        if( $pid ) {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1241
            # parent process copies/unzips packages to tmpDlDir
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1242
            printLog( "parent: extract packages to $tmpDlDir" );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1243
            printLog( "parent: Processing: $file->{filename}... " );
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
  1244
      print "Downloading[$fileCounter\/$nmbrOfFiles] $file->{filename}... ";
1
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1245
            
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1246
            if( $file->{extract} eq 'single' ) {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1247
                # copy single zipped packages to $tmpDlDir
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1248
                printLog( "parent: single zipped - copy to $tmpDlDir" );
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
  1249
        if( ! $param_print_only ) {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
  1250
          # Let's try 3 times to copy the file in case the server is busy, note this is a hack,
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
  1251
          # the correct way would be either to remove the file from release list so that the next run would get the file
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
  1252
          # or to check the for the error value before trying again. Although the error code seems to be '2' ie.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
  1253
          # 'File not found' so it is a little bit hard to distinguish between removed file and the server being busy.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
  1254
          # With more testing it some times returns also error code '9' ie. 'Bad file descriptor'.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
  1255
          copy( $file->{path} . $file->{filename}, $tmpDlDir ) or
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
  1256
          copy( $file->{path} . $file->{filename}, $tmpDlDir ) or
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
  1257
          copy( $file->{path} . $file->{filename}, $tmpDlDir ) or
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
  1258
            HandleError( "cant copy file $file->{path}$file->{filename} to $tmpDlDir", $warning );
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
  1259
        }
1
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1260
            }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1261
            elsif( $file->{extract} eq 'double' ) {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1262
                # unzip double zipped zips to $tmpDlDir
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1263
                # there shouldnt be much of these anymore
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1264
                printLog( "parent: double zipped - unzip to $tmpDlDir" );
179
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
  1265
                my $extrCmd = q{7za x -y "};
1
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1266
                $extrCmd .= $file->{path} . $file->{filename};
179
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
  1267
                $extrCmd .= q{" -o} . $tmpDlDir;
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
  1268
                if ( $^O =~ /linux/i){
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
  1269
                    $extrCmd .= " > /dev/null";
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
  1270
                }else{
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
  1271
                    $extrCmd .= " > NUL";
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
  1272
                }
1
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1273
                print "system: $extrCmd\n" if( $param_print_only );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1274
                printLog( "parent: system: $extrCmd" );;
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1275
                system( $extrCmd ) if( !$param_print_only );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1276
                if( $? ) {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1277
                    printLog( "Problem processing $file->{path} $file->{filename}: $?" );;
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1278
                    $returnValue = $?;
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1279
                    HandleZipError( $file->{path} . $file->{filename}, $? );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1280
                }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1281
            }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1282
            elsif( $file->{extract} eq 'save' ) {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1283
                # copy non-zipped files directly to environment ( getcwd )
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1284
                print "pure copy\n" if( $param_print_only );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1285
                printLog( "parent: pure copy from: ".$file->{path}.$file->{filename}." to: ".getcwd.$file->{filename} );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1286
                copy( $file->{path}.$file->{filename}, getcwd.$file->{filename} ) if( ! $param_print_only );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1287
            }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1288
            else {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1289
                HandleError( "unregocnised filetype: $file", $warning );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1290
            }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1291
            
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1292
            printLog( "parent: package in $tmpDlDir available.. waiting for child" );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1293
            waitpid($pid, 0);
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1294
            printLog( "parent: finished" );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1295
        }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1296
        elsif( $pid == 0 ) {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1297
# TODO: we should test wheter there is zips in $tmpDir
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1298
            printLog( "child: extract zips from $tmpDir to ".getcwd );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1299
            
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1300
            # extract from temp to extractDir
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1301
            UnzipFromTempToEnv( );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1302
            
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1303
            printLog( "child: finished" );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1304
            exit( 0 );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1305
        }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1306
        else {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1307
            # fork failed
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1308
            die "Cannot fork: $!\n";
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1309
        }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1310
        
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1311
        # this is after forking
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1312
        # move files from tmpDlDir => tmpDir
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
  1313
    printLog( "check is there file to move in tmpdldir" );
1
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1314
        my $somethingToCopy = 0;
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1315
        opendir( DLTEMP, $tmpDlDir ) or HandleError( "cant read $tmpDlDir dir: $!", $warning );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1316
        my @filesFound = readdir( DLTEMP );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1317
        closedir( DLTEMP );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1318
        foreach my $file( @filesFound ) {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1319
            next if $file =~ /^\.[\.]?$/;
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
  1320
      printLog( "in tmpdldir: $file" );
1
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1321
            $somethingToCopy = 1;
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1322
        }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1323
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1324
        if( $somethingToCopy ) {
179
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
  1325
            printLog( "move everything from $tmpDlDir to $tmpDir" ); 
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
  1326
            opendir( DLTEMP , $tmpDlDir );
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
  1327
            for (grep( !/^\.\.?$/, readdir(DLTEMP))){
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
  1328
                move("$tmpDlDir/$_", $tmpDir) or die("$tmpDlDir/$_ move failed :$!");
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
  1329
            }
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
  1330
            closedir( DLTEMP );
1
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1331
        }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1332
        
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1333
        if( $returnValue == 0 ) {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1334
            print "done\n";
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1335
            printLog( "done" );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1336
        }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1337
        else {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1338
            print "done, but errors occured!\n";
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1339
            printLog( "done, but errors occured" );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1340
        }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1341
    }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1342
    
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1343
    # current forking mechanism is leaving last package(s) to $tmpDir
179
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
  1344
    opendir(TEMPDIR,  $tmpDir);
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
  1345
    UnzipFromTempToEnv() if(scalar(grep( !/^\.\.?$/, readdir(TEMPDIR))) > 0);
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
  1346
    closedir(TEMPDIR);
1
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1347
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1348
    if( -e FixPaths( getcwd )."currentRelease.xml" ) {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1349
        unlink( FixPaths( getcwd )."currentRelease.xml" ) if( ! $param_print_only );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1350
    }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1351
    # copy the xml into $extractDir\buildData from $serverPath.$serviceName.$metaDataFile
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1352
    copy( $metaDataXml, FixPaths( getcwd )."currentRelease.xml" ) if( ! $param_print_only );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1353
    
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1354
    # cover trails
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1355
    unlink( "/7za.exe" ) if( ! $param_print_only );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1356
    if( ! $param_print_only ) {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1357
        printLog( "removing temp dir... " );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1358
        rmdir $tmpDir or HandleError( "Couldnt remove temp dir: $!", $warning );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1359
        rmdir $tmpDlDir or HandleError( "Couldnt remove temp dir: $!", $warning );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1360
        print scalar(localtime) . ": done fetching environment\n";
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1361
        printLog( "done" );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1362
    }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1363
}
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1364
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1365
sub UnzipFromTempToEnv {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1366
    # extract from temp to extractDir
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1367
    printLog( "child: unzip from temp" );
179
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
  1368
    my $finalUnzipCmd = qq{7za x -y "$tmpDir/*.zip" -o"}.getcwd.q{"};
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
  1369
    if ( $^O =~ /linux/i){
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
  1370
        $finalUnzipCmd .= " > /dev/null";
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
  1371
    }else{
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
  1372
        $finalUnzipCmd .= " > NUL";
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
  1373
    }
d8ac696cc51f helium_7.0-r14027
wbernard
parents: 1
diff changeset
  1374
1
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1375
    print "system: $finalUnzipCmd\n" if( $param_print_only );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1376
    printLog( "child: system: $finalUnzipCmd" );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1377
    system( $finalUnzipCmd ) if( !$param_print_only );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1378
#           if( $? ) {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1379
#               $returnValue = $?;
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1380
#               HandleZipError( $file->{path} . $file->{filename}, $? );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1381
#           }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1382
    
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1383
    # empty temp dir
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1384
    printLog( "child: empty temp dir" );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1385
    printLog( "child: unlink: $tmpDir" );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1386
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1387
    # dont handle errors - temp might be empty as well!
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1388
    opendir( TEMPDIR, $tmpDir );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1389
    my @zipFiles = grep /zip/, readdir TEMPDIR;
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1390
    foreach my $myfile( @zipFiles ) {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1391
        if( ! $param_print_only ) {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1392
            printLog( "child: unlink: $myfile" );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1393
            unlink( $tmpDir."/".$myfile );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1394
        }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1395
    }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1396
    closedir TEMPDIR;
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1397
}
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1398
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1399
# handles return values coming from 7zip
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1400
#   0 No error 
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1401
#   1 Warning (Non fatal error(s)). For example, some files were locked by other application during compressing. So they were not compressed. 
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1402
#   2 Fatal error 
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1403
#   7 Command line error 
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1404
#   8 Not enough memory for operation 
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1405
#   255 User stopped the process 
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1406
sub HandleZipError {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1407
    my( $filename, $errorCode ) = @_;
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1408
    
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1409
    if( $errorCode == 1 ) {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1410
        # warning
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1411
        printLog( "7zip reported warning during unzipping of $filename" );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1412
        print "Warning while unzipping $filename!\nSome files might be locked be other processes. It is possible that all the files werent extracted!\n";
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1413
    }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1414
    elsif( $errorCode == 2 ) {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1415
        # fatal error
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1416
        printLog( "possibly corrupted archive: $filename" );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1417
        print "Fatal error occured while extracting $filename!!\nPlease check you have enough disk space on ".getcwd."\n";
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1418
        print "Otherwise you should report this problem for the build team. Please include ".getcwd."\\getenv.log to the mail.";
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1419
    }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1420
    elsif( $errorCode == 7 ) {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1421
        # commandline error
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1422
        printLog( "there is command line error while unzipping $filename" );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1423
        print "7-zip is reporting command line error when unzipping $filename.";
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1424
        print "You should report this problem for the build team. Please include ".getcwd."\\getenv.log to the mail.";
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1425
    }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1426
    elsif( $errorCode == 8 ) {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1427
        # not enough memory
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1428
        printLog( "7zip reports not enough memory. Possibly disk full" );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1429
        print "Not enough memory to extract $filename!!\nPlease check you have enough disk space on ".getcwd.". Otherwise please try again\n";
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1430
    }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1431
    elsif( $errorCode == 255 ) {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1432
        # user aborted
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1433
        printLog( "User aborted extraction!!" );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1434
        print "User aborted extraction!\n$filename is not extracted completely and therefore your environment might not work as expected!";
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1435
    }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1436
    else {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1437
        # unspecified error
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1438
        printLog( "unspecified error: $errorCode while extracing: $filename\nPlease check you have enough free disk space" );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1439
    }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1440
}
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1441
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1442
# return path to accessible GRACE samba share
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1443
sub FindGraceServer {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1444
    if (defined $param_server) {return FixPaths( $param_server );}
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1445
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
  1446
    print "\nseeking possible hydra accesses. This might take a while.. ";
1
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1447
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1448
        my @graceAccessArray;
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
  1449
        foreach my $address( @hydraList ) {
1
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1450
            printLog( "accessing $address..." );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1451
            if( opendir( GRACETEST, $address ) ) {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1452
                push @graceAccessArray, $address;
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1453
                printLog( " success\n" );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1454
                close GRACETEST;
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1455
            }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1456
            else {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1457
                printLog( " fail" );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1458
            }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1459
        }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1460
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1461
    if( @graceAccessArray ) {
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
  1462
        print "done\nSelected HYDRA server: ", $graceAccessArray[0];
1
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1463
        if( scalar( @graceAccessArray ) > 1 ) {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1464
            
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1465
            # if start is defined && >1 grace shares available, we'll have to just guess correct share
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1466
            if( $param_start_directly ) {
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
  1467
                print( "More than one HYDRA shares accessible\n" );
1
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1468
                print Dumper( @graceAccessArray );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1469
                print "\nBecause -start parameter is provided we cant prompt user to select correct, lets pick first one from the list\n";
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1470
                print "You should use -server parameter to define the server\n";
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
  1471
                printLog( "-start defined and >1 hydra shares accessible" );
1
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1472
                printLog( @graceAccessArray );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1473
                printLog( "selecting first one: $graceAccessArray[0]" );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1474
                return FixPaths( $graceAccessArray[0] );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1475
            }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1476
            else {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1477
# salmarko starts
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
  1478
                return FixPaths( PrintSelectMenu( "Select reasonable HYDRA share", @graceAccessArray ) );
1
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1479
# salmarko ends
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1480
            }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1481
        }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1482
        else {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1483
# salmarko starts
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1484
            return FixPaths( $graceAccessArray[0] );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1485
# salmarko ends
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1486
        }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1487
    }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1488
    print "none found\n";
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1489
    return 0;   
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1490
}
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1491
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1492
# return name of the release from metadata.xml
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1493
sub ReturnReleaseName {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1494
    my $data = shift( @_ );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1495
    
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1496
    my $tempXmlParser = new XML::Simple( );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1497
    my $tempXmlHandle = $tempXmlParser->XMLin( $data );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1498
    
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1499
    # parse dl directory into $releaseDirectory
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1500
    return $tempXmlHandle->{releaseDetails}->{releaseID}->{release}->{name};
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1501
}
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1502
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1503
# retrurn name of the product from metadata.xml
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1504
sub ReturnProductName {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1505
    my $data = shift( @_ );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1506
    
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1507
    my $tempXmlParser = new XML::Simple( );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1508
    my $tempXmlHandle = $tempXmlParser->XMLin( $data );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1509
    
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1510
    # parse dl directory into $releaseDirectory
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1511
    return $tempXmlHandle->{releaseDetails}->{releaseID}->{product}->{name};
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1512
}
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1513
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1514
sub FindTempDir {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1515
    # it'll speed up extraction if we put temp dir to separate disk
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1516
    
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1517
}
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1518
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1519
# finds first param from second param(comma separated list)
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1520
sub FindFromList {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1521
    my( $itemToFind, $list ) = @_;
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1522
    my @itemList = split( /,/, $list );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1523
    foreach( @itemList ) {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1524
        return 1 if( $_ eq $itemToFind );
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1525
    }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1526
    
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1527
    return 0;
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1528
}
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1529
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1530
sub myFork()
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1531
    {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1532
    sleep(1);  #let buffers flush
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1533
    my $pid = fork();
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1534
    if(!defined($pid))
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1535
        {
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1536
        die "fork error\n";
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1537
        }
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1538
    return $pid;
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1539
    }
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
  1540
# try to grep amount of free disk space
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
  1541
sub getFreeDisk {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
  1542
  printLog( "getFreeDisk: $_[0]" );
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
  1543
  my $bytesfree;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
  1544
  my $d = $_[0];
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
  1545
  chomp($d);
1
be27ed110b50 Bringing in Helium, imaker and cmaker
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
  1546
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
  1547
  my $cmd = "call dir $d";
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
  1548
  my @dir = `$cmd 2>&1`;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
  1549
  return -1 if ($? != 0);
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
  1550
  my $dir = $dir[scalar(@dir) - 1]; # the last line
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
  1551
  chop($dir);
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
  1552
  
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
  1553
  printLog( "dir: $dir" );
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
  1554
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
  1555
  # clean up whitespaces
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
  1556
  $dir =~ s/^\s+//g;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
  1557
  $dir =~ s/\s+$//g;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
  1558
  $dir =~ s/\s{1,}/ /g;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
  1559
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
  1560
  # get rid of `X Dir(s)'
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
  1561
  @dir = split(/\s/, $dir);
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
  1562
  $dir = join("", @dir[2 .. scalar(@dir)]);
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
  1563
  # get digits only
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
  1564
  $dir =~ s/[^0-9]//g;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
  1565
  
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
  1566
  # free space in gigabytes
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
  1567
# $bytesfree = $dir/1073741824;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
  1568
  $bytesfree = $dir;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
  1569
  
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
  1570
  printLog( "returning: $bytesfree" );
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
  1571
  return $bytesfree;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
  1572
}
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
  1573
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
  1574
# returns amount of files set for extract from finalZipList
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
  1575
sub returnNmbrOfFiles {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
  1576
  my $count = 0;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
  1577
  
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
  1578
  foreach( @finalZipList ) {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
  1579
    $count++ if $_->{default};
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
  1580
  }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
  1581
  
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
  1582
  return $count;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
  1583
}
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents: 179
diff changeset
  1584