releasing/cbrtools/perl/EnvDb.pm
author kelvzhu
Mon, 18 Oct 2010 16:16:46 +0800
changeset 655 3f65fd25dfd4
parent 602 3145852acc89
permissions -rw-r--r--
sync up SVN codes
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
602
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     1
# Copyright (c) 2000-2009 Nokia Corporation and/or its subsidiary(-ies).
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     2
# All rights reserved.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     3
# This component and the accompanying materials are made available
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     4
# under the terms of the License "Eclipse Public License v1.0"
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     5
# which accompanies this distribution, and is available
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     6
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     7
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     8
# Initial Contributors:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     9
# Nokia Corporation - initial contribution.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    10
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    11
# Contributors:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    12
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    13
# Description:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    14
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    15
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    16
package EnvDb;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    17
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    18
use strict;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    19
use MLDBM::Sync;                       # this gets the default, SDBM_File
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    20
use MLDBM qw(DB_File Storable);        # use Storable for serializing
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    21
use MLDBM qw(MLDBM::Sync::SDBM_File);  # use extended SDBM_File, handles values > 1024 bytes
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    22
use Fcntl qw(:DEFAULT);                # import symbols O_CREAT & O_RDWR for use with DBMs
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    23
use Cwd;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    24
use File::Find;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    25
use File::Copy;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    26
use File::Basename;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    27
use File::Path;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    28
use File::Spec;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    29
use Fcntl;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    30
use MrpData;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    31
use RelData;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    32
use DirHandle; # we're recursing in CrossCheckSourceDirectory, so this is slightly nicer than DIRHANDLEs
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    33
                # (though not actually necessary, as it happens)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    34
use Utils;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    35
use CatData;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    36
use Carp;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    37
use Symbian::CBR::Component::Manifest;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    38
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    39
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    40
# Constants.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    41
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    42
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    43
use constant DB_NAME => "\\epoc32\\relinfo\\envdb";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    44
use constant STATUS_CLEAN => 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    45
use constant STATUS_DIRTY => 1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    46
use constant STATUS_PENDING_RELEASE => 2;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    47
use constant STATUS_INFORMATION_ONLY => 5;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    48
use constant STATUS_NOT_INSTALLED => 3;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    49
use constant STATUS_DIRTY_SOURCE => 4;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    50
use constant STATUS_STRING_PASSED => "clean";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    51
use constant STATUS_STRING_FAILED => "dirty";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    52
use constant STATUS_STRING_MISSING => "missing";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    53
use constant STATUS_STRING_PENDING_RELEASE => "pending release";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    54
use constant STATUS_STRING_NOT_INSTALLED => "not installed";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    55
use constant STATUS_STRING_DIRTY_SOURCE => "binaries clean, source dirty";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    56
use constant STATUS_STRING_INFORMATION_ONLY => "Information only";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    57
use constant SCAN_PROGRESS_TUNER => 50;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    58
use constant ACCEPTABLE_EVALID_FAILURES => "abld.bat"; # this is a regexp - use | to add more items. It is case-insensitive.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    59
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    60
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    61
# Public.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    62
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    63
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    64
sub Open {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    65
  my $pkg = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    66
  my $iniData = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    67
  my $verbose = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    68
  
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    69
  # Check that the environment is not on an illegal volume - INC105548
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    70
  Utils::CheckIllegalVolume($iniData);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    71
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    72
  my $dbName = Utils::PrependEpocRoot(DB_NAME);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    73
  my $dbDir = dirname($dbName);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    74
  unless (-e $dbDir) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    75
    Utils::MakeDir($dbDir);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    76
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    77
  my $db;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    78
  {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    79
    local $^W = 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    80
    tie (%{$db}, 'MLDBM::Sync', $dbName, O_CREAT|O_RDWR, 0666) || die "Couldn't open database DB_NAME: $!\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    81
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    82
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    83
  my $self = {iniData => $iniData,
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    84
	      db => $db,
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    85
        mrpcache => {},
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    86
	      verbose => ($verbose || 0)};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    87
  bless $self, $pkg;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    88
  return $self;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    89
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    90
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    91
sub Close {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    92
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    93
  untie %{$self};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    94
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    95
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    96
sub ComponentExistsInDatabase {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    97
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    98
  my $comp = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    99
  
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   100
  return 1 if (exists $self->{db}->{$comp});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   101
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   102
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   103
sub Version {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   104
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   105
  my $comp = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   106
  my $includeInformationOnlyEntries = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   107
  
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   108
  $comp = lc($comp); # Note, component names are always stored in lower case.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   109
  my $entry = $self->{db}->{$comp};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   110
  
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   111
  if (defined $entry) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   112
    if (!$includeInformationOnlyEntries && $entry->{status} eq STATUS_INFORMATION_ONLY) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   113
      # Some callers are not interested in information only entries
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   114
      return undef;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   115
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   116
    
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   117
    return $entry->{ver};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   118
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   119
  return undef;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   120
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   121
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   122
sub VersionInfo {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   123
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   124
  my $includeInformationOnlyEntries = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   125
  
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   126
  my $versionInfo;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   127
  foreach my $thisKey (keys %{$self->{db}}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   128
    if (!$includeInformationOnlyEntries) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   129
      # Some callers are not interested in information only entries
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   130
      next if ($self->{db}->{$thisKey}->{status} eq STATUS_INFORMATION_ONLY);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   131
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   132
    
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   133
    $versionInfo->{$thisKey} = $self->{db}->{$thisKey}->{ver};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   134
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   135
  return $versionInfo;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   136
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   137
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   138
sub SetVersion {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   139
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   140
  my $comp = lc(shift);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   141
  my $ver = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   142
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   143
  my $entry = $self->{db}->{$comp};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   144
  if (defined $ver) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   145
    if (defined $entry->{ver} and $entry->{status} != STATUS_PENDING_RELEASE) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   146
      $self->DeleteSignature($comp, $entry->{ver});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   147
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   148
    $entry->{ver} = $ver;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   149
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   150
    # Write entry to database.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   151
    $self->{db}->{$comp} = $entry;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   152
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   153
  else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   154
    # undefined version, so remove entry from database (if it was present).
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   155
    if (defined $entry) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   156
      delete $self->{db}->{$comp}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   157
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   158
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   159
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   160
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   161
sub InternalVersion {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   162
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   163
  my $comp = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   164
  $comp = lc($comp); # Note, component names are always stored in lower case.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   165
  my $entry = $self->{db}->{$comp};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   166
  if (defined $entry) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   167
    return $entry->{intVer};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   168
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   169
  return undef;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   170
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   171
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   172
sub SetInternalVersion {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   173
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   174
  my $comp = lc(shift);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   175
  my $intVer = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   176
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   177
  my $entry = $self->{db}->{$comp};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   178
  unless (defined $entry) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   179
    die "Error: $comp not found in environment database\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   180
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   181
  $entry->{intVer} = $intVer;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   182
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   183
  # Write entry to database.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   184
  $self->{db}->{$comp} = $entry;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   185
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   186
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   187
sub Status {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   188
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   189
  my $comp = lc(shift);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   190
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   191
  my $entry = $self->{db}->{$comp};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   192
  unless (defined $entry) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   193
    die "Error: $comp not found in environment database\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   194
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   195
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   196
  return $entry->{status};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   197
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   198
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   199
sub SetStatus {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   200
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   201
  my $comp = lc(shift);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   202
  my $status = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   203
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   204
  my $entry = $self->{db}->{$comp};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   205
  unless (defined $entry) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   206
    die "Error: $comp not found in environment database\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   207
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   208
  $entry->{status} = $status;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   209
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   210
  # Write entry to database.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   211
  $self->{db}->{$comp} = $entry;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   212
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   213
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   214
sub StatusString {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   215
  my $status = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   216
  if ($status == STATUS_CLEAN) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   217
    return STATUS_STRING_PASSED;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   218
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   219
  elsif ($status == STATUS_DIRTY) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   220
    return STATUS_STRING_FAILED;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   221
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   222
  elsif ($status == STATUS_PENDING_RELEASE) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   223
    return STATUS_STRING_PENDING_RELEASE;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   224
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   225
  elsif ($status == STATUS_DIRTY_SOURCE) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   226
    return STATUS_STRING_DIRTY_SOURCE;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   227
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   228
  elsif ($status == STATUS_INFORMATION_ONLY) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   229
    return STATUS_STRING_INFORMATION_ONLY;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   230
  }  
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   231
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   232
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   233
sub CheckCompName {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   234
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   235
  my $comp = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   236
  die "Error: Component name can't begin with .(dot) \"$comp\".\n" if ($comp =~ m/^\./);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   237
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   238
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   239
sub MrpName {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   240
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   241
  my $comp = lc(shift);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   242
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   243
  my $entry = $self->{db}->{$comp};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   244
  unless (defined $entry) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   245
    die "Error: $comp not found in environment database\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   246
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   247
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   248
  return $entry->{mrpName};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   249
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   250
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   251
sub SetMrpName {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   252
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   253
  my $comp = lc(shift);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   254
  my $mrpName = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   255
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   256
  my $entry = $self->{db}->{$comp};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   257
  unless (defined $entry) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   258
    die "Error: $comp not found in environment database\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   259
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   260
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   261
  $entry->{mrpName} = $mrpName;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   262
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   263
  # Write entry to database.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   264
  $self->{db}->{$comp} = $entry;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   265
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   266
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   267
sub ComponentsPendingRelease {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   268
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   269
  my %comps;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   270
  foreach my $thisComp (keys %{$self->{db}}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   271
    my $thisEntry = $self->{db}->{$thisComp};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   272
    if ($thisEntry->{status} == STATUS_PENDING_RELEASE) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   273
      $comps{$thisComp} = {mrpName => $thisEntry->{mrpName},
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   274
			   ver => $thisEntry->{ver},
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   275
			   intVer => $thisEntry->{intVer}};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   276
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   277
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   278
  return \%comps;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   279
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   280
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   281
sub GenerateSignature {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   282
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   283
  my $comp = lc (shift);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   284
  my $ver = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   285
  my $sigName = SignatureName($comp, $ver);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   286
  open (SIG, ">$sigName") or die "Error: Couldn't open $sigName: $!\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   287
  foreach my $thisBinZip (@{$self->RelevantBinaryZips($comp, $ver)}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   288
    foreach my $file (@{Utils::ListZip($thisBinZip, 1)}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   289
      my $fileER = Utils::PrependEpocRoot($file);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   290
      if (-f $fileER) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   291
        (my $mTime, my $size) = Utils::FileModifiedTimeAndSize($fileER);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   292
        unless (defined $size) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   293
          die "Error: Problem reading stats of \"$fileER\"\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   294
        }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   295
        if ($self->{verbose} > 1) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   296
          print "Adding signature entry for \"$file\"\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   297
          print "\tmTime: $mTime (", scalar gmtime($mTime), "\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   298
          print "\tsize:  $size\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   299
        }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   300
        print SIG "$file\t$mTime\t$size\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   301
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   302
      else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   303
        print "Warning: Unexpected entry in \"$thisBinZip\": \"$file\"\n         $comp $ver could be corrupt or tampered with\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   304
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   305
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   306
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   307
  close (SIG);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   308
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   309
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   310
sub GenerateFakeSignature {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   311
# As GenerateSignature, except the mtime and size of each file is set to zero.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   312
# This is intended to be used when validating against an external baseline.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   313
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   314
  my $comp = lc (shift);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   315
  my $ver = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   316
  my $sigName = SignatureName($comp, $ver);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   317
  open (SIG, ">$sigName") or die "Error: Couldn't open $sigName: $!\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   318
  foreach my $thisBinZip (@{$self->RelevantBinaryZips($comp, $ver)}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   319
    foreach my $file (@{Utils::ListZip($thisBinZip)}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   320
      print SIG "$file\t0\t0\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   321
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   322
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   323
  close (SIG);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   324
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   325
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   326
sub GenerateEmptySignature {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   327
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   328
  my $comp = lc (shift);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   329
  my $ver = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   330
  my $sigName = SignatureName($comp, $ver);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   331
  open (SIG, ">$sigName") or die "Error: Couldn't open $sigName: $!\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   332
  close (SIG);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   333
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   334
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   335
sub RemoveComponent {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   336
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   337
  my $comp = lc(shift);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   338
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   339
  # Read database entry.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   340
  my $entry = $self->{db}->{$comp};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   341
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   342
  if (defined $entry) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   343
    # Remove installed binaries.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   344
    if ($self->{verbose}) { print "Removing binaries from $comp $entry->{ver}...\n"; }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   345
    $self->DeleteFilesInSignature($comp, $entry->{ver});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   346
    $self->DeleteSignature($comp, $entry->{ver});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   347
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   348
    # Remove the database entry.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   349
    delete $self->{db}->{$comp};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   350
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   351
  else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   352
    print "$comp not currently installed, aborting removal of binaries\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   353
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   354
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   355
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   356
sub RefreshComponent {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   357
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   358
  my $comp = lc(shift);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   359
  my $overwrite = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   360
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   361
  # Read database entry.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   362
  my $entry = $self->{db}->{$comp};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   363
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   364
  if (!defined $entry) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   365
    print "$comp not currently installed; aborting refreshing of binaries\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   366
  } elsif ($entry->{status} == STATUS_PENDING_RELEASE) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   367
    print "$comp is pending release and cannot be refreshed; use 'preprel' to remove it from your environment\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   368
  } else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   369
    my $ver = $entry->{ver};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   370
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   371
    my $relData = RelData->Open($self->{iniData}, $comp, $ver, $self->{verbose}); # Dies if release not in archive
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   372
    $relData->WarnIfReleaseTooNew();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   373
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   374
    print "Removing $comp $ver..\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   375
    if ($self->{verbose}) { print "Removing binaries from $comp $ver...\n"; }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   376
    $self->DeleteFilesInSignature($comp, $entry->{ver});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   377
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   378
    print "Installing $comp $ver...\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   379
    $self->UnpackBinaries($comp, $ver, Utils::EpocRoot(), $overwrite);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   380
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   381
    my $status = ($self->CheckComp($comp))[0];
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   382
    if ($status == STATUS_DIRTY) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   383
      print "WARNING: Installed component does not match existing signature; updating signature\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   384
      $self->GenerateSignature($comp, $ver);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   385
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   386
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   387
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   388
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   389
sub DeleteSource {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   390
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   391
  my $thisComp = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   392
  my $dryrun = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   393
  my $force = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   394
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   395
  my $ver = $self->Version($thisComp);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   396
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   397
  if(!defined $ver) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   398
    die "ERROR: Unable to obtain version for $thisComp\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   399
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   400
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   401
  my $reldata = RelData->Open($self->{iniData}, $thisComp, $ver, $self->{verbose});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   402
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   403
  my $srcitems = $reldata->SourceItems;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   404
  foreach my $thisSrcItem (keys %$srcitems) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   405
    # If there are mappings and the source root is \\, perform mappings on filename. Otherwise prepend source root.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   406
    if($self->{iniData}->HasMappings() && Utils::SourceRoot() eq "\\") {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   407
      $thisSrcItem = $self->{iniData}->PerformMapOnFileName($thisSrcItem);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   408
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   409
    else{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   410
      $thisSrcItem = Utils::PrependSourceRoot($thisSrcItem);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   411
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   412
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   413
    if ($self->{verbose} || $dryrun) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   414
      my $dir = (-d $thisSrcItem)?" (directory)":"";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   415
      my $exists = (-e $thisSrcItem)?"":" (doesn't exist)";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   416
      my $verb = $dryrun?"Would remove":"Removing";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   417
      print "$verb $thisSrcItem$dir$exists\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   418
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   419
    {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   420
        local $SIG{__WARN__} = sub {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   421
            my $warn = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   422
	    $warn =~ s/ at .*?EnvDb\.pm line \d+//;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   423
	    print STDERR "WARNING: $warn";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   424
        };
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   425
        rmtree($thisSrcItem, 0, !$force) unless $dryrun;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   426
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   427
    my $directory = dirname($thisSrcItem);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   428
	
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   429
	my @items = @{Utils::ReadDir($directory)};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   430
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   431
	if (scalar @items == 1 && $items[0] =~ /^distribution\.policy$/i) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   432
	  unlink File::Spec->catdir($directory, shift @items) unless $dryrun;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   433
	}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   434
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   435
    if (-e $directory && (!scalar @items)) { # No items in dir or just a distribution.policy file in dir
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   436
      rmdir $directory or die "Error: Could not remove directory $directory: $!";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   437
      while (($directory = dirname($directory)) && -e $directory && !scalar @{Utils::ReadDir($directory)}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   438
        rmdir $directory or die "Error: Could not remove directory $directory: $!";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   439
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   440
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   441
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   442
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   443
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   444
sub CheckEnv {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   445
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   446
  my $displayProgress = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   447
  my $ignoreStandardIgnores = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   448
  my $warnNotError = shift; # When validating the MrpData, warnings will be produced
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   449
                           # instead of errors when checking paths lengths DEF099673
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   450
  
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   451
  unless (defined $displayProgress) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   452
    $displayProgress = 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   453
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   454
  unless (defined $ignoreStandardIgnores) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   455
    $ignoreStandardIgnores = 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   456
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   457
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   458
  my $overallStatus = STATUS_CLEAN;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   459
  my @dirtyComps;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   460
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   461
  if ($displayProgress) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   462
    print "Scanning environment";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   463
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   464
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   465
  $self->InitIgnores($ignoreStandardIgnores);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   466
  $self->ScanEnv($displayProgress);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   467
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   468
  my @mrpData;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   469
  my @errors;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   470
  foreach my $thisComp (sort keys %{$self->{db}}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   471
    (my $status, my $mrpData) = $self->CheckComp($thisComp, undef, $warnNotError);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   472
    my $ver = $self->{db}->{$thisComp}->{ver};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   473
    if ($status == STATUS_DIRTY || $status == STATUS_DIRTY_SOURCE) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   474
      $overallStatus = STATUS_DIRTY;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   475
      push (@dirtyComps, {comp => $thisComp, ver => $ver});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   476
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   477
    elsif ($status == STATUS_PENDING_RELEASE) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   478
      unless ($overallStatus == STATUS_DIRTY) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   479
        $overallStatus = STATUS_PENDING_RELEASE;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   480
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   481
      if (defined $mrpData) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   482
        push @mrpData, $mrpData;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   483
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   484
      else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   485
        push @errors, "Error: Problem extracting mrp data from $thisComp\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   486
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   487
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   488
    if ($displayProgress and not $self->{verbose}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   489
      print '.';
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   490
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   491
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   492
  if ($displayProgress and not $self->{verbose}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   493
    print "\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   494
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   495
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   496
  if ($#errors >= 0) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   497
    chomp $errors[$#errors];
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   498
    print @errors;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   499
    die "\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   500
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   501
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   502
  $self->RemoveBinsToIgnore();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   503
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   504
  my $unaccountedFiles = $self->UnaccountedEnvFiles();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   505
  if (scalar(@$unaccountedFiles) >= 1) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   506
    $overallStatus = STATUS_DIRTY;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   507
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   508
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   509
  my $duplicates = $self->Duplicates(\@mrpData);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   510
  if (scalar(@$duplicates) >= 1) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   511
    $overallStatus = STATUS_DIRTY;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   512
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   513
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   514
  return ($overallStatus, \@mrpData, \@dirtyComps, $unaccountedFiles, $duplicates);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   515
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   516
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   517
sub CheckComp {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   518
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   519
  my $comp = lc(shift);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   520
  my $keepGoing = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   521
  my $warnNotError = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   522
  
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   523
  unless (defined $keepGoing) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   524
    $keepGoing = 1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   525
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   526
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   527
  my $entry = $self->{db}->{$comp};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   528
  if (!defined $entry || $self->{db}->{$comp}->{status} == STATUS_INFORMATION_ONLY) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   529
    return (STATUS_NOT_INSTALLED);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   530
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   531
  my $oldstatus = $entry->{status};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   532
  my $ver = $entry->{ver};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   533
  die unless $ver;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   534
  my $passed = 1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   535
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   536
  my $doCheck = sub {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   537
    my $file = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   538
    my $sigMTime = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   539
    my $sigSize = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   540
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   541
    if (-e $file) { # Files might be installed in directories other than \epoc32, so do an explicit check.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   542
      $self->CheckFileAgainstEnvScan($file);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   543
      # Check the signature information against what is physically present in the environment.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   544
      (my $actualMTime, my $actualSize) = Utils::FileModifiedTimeAndSize($file);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   545
      if ($sigMTime != $actualMTime or $sigSize != $actualSize) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   546
        # File failed check.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   547
        $passed = 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   548
        if ($self->{verbose}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   549
          print "$comp $ver $file failed check\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   550
        }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   551
        if ($self->{verbose} > 1) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   552
          my $printableActualMTime = gmtime($actualMTime);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   553
          my $printableSigMTime = gmtime($sigMTime);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   554
          print "\tcurrent mtime:   $printableActualMTime\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   555
          print "\tsignature mtime: $printableSigMTime\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   556
          print "\tcurrent size:    $actualSize\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   557
          print "\tsignature size:  $sigSize\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   558
        }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   559
        unless ($keepGoing) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   560
          return 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   561
        }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   562
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   563
      else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   564
        # File passed check.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   565
        if ($self->{verbose} > 1) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   566
          print "$comp $ver $file passed\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   567
        }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   568
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   569
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   570
    else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   571
      # File missing.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   572
      $passed = 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   573
      if ($self->{verbose}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   574
        print "$comp $ver $file missing\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   575
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   576
      unless ($keepGoing) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   577
        return 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   578
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   579
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   580
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   581
    return 1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   582
  };
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   583
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   584
  my $mrpData;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   585
  die unless defined $entry->{status};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   586
  if ($entry->{status} == STATUS_PENDING_RELEASE) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   587
    eval {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   588
      unless (defined $entry->{mrpName}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   589
        die "Error: mrp name not specified for $comp\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   590
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   591
      $mrpData = $self->GetMrpData($comp);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   592
      $mrpData->Validate($warnNotError);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   593
      foreach my $thisBin (@{$mrpData->BinariesAndExports()}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   594
	$thisBin = Utils::PrependEpocRoot($thisBin);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   595
        $self->CheckFileAgainstEnvScan($thisBin);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   596
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   597
    };
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   598
    if ($@) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   599
      $mrpData = undef; # splat the MrpData in order to stop
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   600
                        # the envinfo/cleanenv.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   601
                        # We need to do this because the only
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   602
                        # way we have of returning an error is to
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   603
                        # fail to return the MRP.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   604
      if ($self->{verbose} == 0) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   605
        print "\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   606
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   607
      print "$comp: $@";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   608
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   609
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   610
  else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   611
    ExecuteSignature(SignatureName($comp, $ver), $doCheck);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   612
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   613
    if ($passed) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   614
      if ($oldstatus == STATUS_DIRTY) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   615
        $self->SetStatus($comp, STATUS_CLEAN);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   616
      } else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   617
        # Here we return the original status from the environment database,
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   618
        # which is probably STATUS_CLEAN but might by STATUS_DIRTY_SOURCE
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   619
        $self->SetStatus($comp, $oldstatus);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   620
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   621
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   622
    else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   623
      $self->SetStatus($comp, STATUS_DIRTY);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   624
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   625
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   626
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   627
  return ($self->Status($comp), $mrpData);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   628
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   629
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   630
sub ValidateEnv {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   631
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   632
  my $comp = lc(shift);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   633
  my $ver = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   634
  my $validatesource = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   635
  my $fullbincheck = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   636
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   637
  my $validatingExternalEnv = 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   638
  my $compsToValidate;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   639
  if (defined $comp and defined $ver) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   640
    if (scalar (keys %{$self->{db}}) > 0) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   641
      die "Error: Can't validate against an external environment, because the current environment database is not empty\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   642
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   643
    $validatingExternalEnv = 1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   644
    my $relData = RelData->Open($self->{iniData}, $comp, $ver, $self->{verbose});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   645
    $compsToValidate = $relData->Environment();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   646
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   647
  else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   648
    # Use the current environment.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   649
    foreach my $thisComp (sort keys %{$self->{db}}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   650
      $compsToValidate->{$thisComp} = $self->{db}->{$thisComp}->{ver};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   651
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   652
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   653
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   654
  my @failedComps;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   655
  foreach my $thisComp (sort keys %{$compsToValidate}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   656
    my $thisVer = $compsToValidate->{$thisComp};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   657
    my $result = $self->ValidateComp($thisComp, $thisVer, 0, $validatesource, 0, $fullbincheck);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   658
    if ($result == STATUS_DIRTY || $result == STATUS_DIRTY_SOURCE) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   659
      push (@failedComps, $thisComp);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   660
      if ($validatingExternalEnv) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   661
        # Add an entry even of components that failed. This makes it easier for the user to specify what needs to be re-released.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   662
        $self->SetVersion($thisComp, $thisVer);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   663
        if ($result == STATUS_DIRTY) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   664
          $self->GenerateFakeSignature($thisComp, $thisVer);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   665
        } elsif ($result == STATUS_DIRTY_SOURCE) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   666
          $self->GenerateSignature($thisComp, $thisVer);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   667
        }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   668
        $self->SetStatus($thisComp, $result);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   669
        my $relData = RelData->Open($self->{iniData}, $thisComp, $thisVer, $self->{verbose});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   670
        $self->SetMrpName($thisComp, $relData->MrpName());
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   671
        $self->SetInternalVersion($thisComp, $relData->InternalVersion());
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   672
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   673
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   674
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   675
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   676
  return \@failedComps;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   677
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   678
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   679
sub ValidateCompOld {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   680
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   681
  my $comp = lc(shift);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   682
  my $ver = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   683
  my $keepGoing = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   684
  my $validatesource = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   685
  my $keeptemp = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   686
  my $fullbincheck = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   687
  unless (defined $keepGoing) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   688
    $keepGoing = 1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   689
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   690
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   691
  my $status = STATUS_CLEAN;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   692
  die unless defined $ver;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   693
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   694
  my $entry = $self->{db}->{$comp};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   695
  if (defined $entry and $entry->{status} == STATUS_PENDING_RELEASE) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   696
    if ($ver eq $entry->{ver}) { # allow validation against other versions even if we're pending release
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   697
      return STATUS_PENDING_RELEASE;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   698
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   699
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   700
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   701
  my $relData = RelData->Open($self->{iniData}, $comp, $ver, $self->{verbose});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   702
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   703
  # Always validate binaries
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   704
  # I initially added an option to turn this off, but I decided that was overcomplexity
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   705
  # and I couldn't think of any use cases except tinkering with the release tools...
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   706
  print "Validating binaries $comp $ver...\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   707
  Utils::InitialiseTempDir($self->{iniData});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   708
  eval {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   709
    # Get a temporary copy of the released binaries.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   710
    my $tempDir = Utils::TempDir();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   711
    $self->UnpackBinaries($comp, $ver, $tempDir, 1); # 1 = overwrite
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   712
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   713
    # Call evalid to compare these with those installed in the environment.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   714
    # We now validate everything in the temp dir, not just \epoc32,
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   715
    # because some components release binaries outside \epoc32.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   716
    my $clean = $self->EvalidateDirectories($tempDir, Utils::PrependEpocRoot('.'), $keepGoing);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   717
    $status = ($clean)?(STATUS_CLEAN):(STATUS_DIRTY);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   718
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   719
    if ($clean and $fullbincheck) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   720
      # Ask the current mrp file for a list of binaries (using abld -what)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   721
      my $mrpData;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   722
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   723
      my $mrpPath = $relData->MrpName();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   724
      if($self->{iniData}->HasMappings() && Utils::SourceRoot() eq "\\") {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   725
        $mrpPath = $self->{iniData}->PerformMapOnFileName($mrpPath);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   726
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   727
      else{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   728
        $mrpPath = Utils::PrependSourceRoot($mrpPath);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   729
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   730
      if (!-f $mrpPath) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   731
        print "Not checking for new binaries; MRP file not present\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   732
      } else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   733
        eval {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   734
          $mrpData = New MrpData($relData->MrpName(), undef, undef, $self->{iniData}, $self->{verbose}); # undef = we're not preprel-ing it
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   735
        };
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   736
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   737
        if (!defined($mrpData)) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   738
          my $error = $@;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   739
          $error =~ s/\s*$//;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   740
          print "Not checking for new binaries; $error\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   741
        } else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   742
          my @binaries = @{$mrpData->Binaries()};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   743
          push @binaries, @{$mrpData->Exports()};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   744
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   745
          # Get list of binaries in the temporary copy
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   746
          my %oldbinaries;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   747
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   748
          my $sub = sub { # Subroutine to add files to %oldbinaries
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   749
            return if -d $_; # Check it's not a directory
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   750
            s/^\Q$tempDir\E[\/\\]?//; # Strip the temp dir path off
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   751
            s/\\/\//g; # Convert backslashes
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   752
            $oldbinaries{lc($_)}=1 unless (/^\.\.?$/) # Add to hash (unless it's .. or .)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   753
          };
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   754
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   755
          find( {wanted=>$sub, no_chdir=>1}, $tempDir); # Use no_chdir and s/.../ to get a full relative path. Second s/.../ converts backslashes to normal slashes
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   756
          foreach my $binary (@binaries) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   757
            $binary = lc($binary);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   758
            $binary =~ s/\\/\//g; # Convert backslashes to normal slashes
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   759
            if (exists $oldbinaries{$binary}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   760
              delete $oldbinaries{$binary};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   761
            } else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   762
              print "New binary file: $binary\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   763
              $status = STATUS_DIRTY;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   764
            }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   765
          }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   766
          foreach my $oldbinary (keys(%oldbinaries)) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   767
            print "Binary file no longer built: $oldbinary\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   768
	    $status = STATUS_DIRTY;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   769
          }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   770
	}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   771
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   772
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   773
  };
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   774
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   775
  if ($keeptemp) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   776
    print "Old release stored in \"".Utils::TempDir()."\"\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   777
  } else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   778
    Utils::RemoveTempDir();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   779
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   780
  if ($@) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   781
    die $@;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   782
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   783
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   784
  # We need to check if the categories for exports has changed or not...
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   785
  if ($status == STATUS_CLEAN) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   786
    foreach my $thisBinZip (@{$self->RelevantBinaryZips($comp, $ver)}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   787
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   788
      if($thisBinZip =~ /exports([a-z]).zip/i) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   789
        my $catInArchive = $1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   790
        # Open and read the corresponding exports category info file in the archive
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   791
        my $catData = CatData->Open($self->{iniData}, $comp, $ver, $catInArchive);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   792
        my $catWriteInCatDataFile;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   793
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   794
        # Obtain the category written the exports category info file, if unable to read skip check
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   795
        eval {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   796
          $catWriteInCatDataFile = $catData->Category();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   797
        };
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   798
        if ($@) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   799
          last;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   800
        }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   801
        # Check the categories match
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   802
        if($catInArchive !~ /^$catWriteInCatDataFile$/i){
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   803
          die "ERROR: Mismatch in category found in exports$catInArchive.txt for $comp $ver\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   804
        }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   805
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   806
        my $exportinfo = $catData->ExportInfo();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   807
        my $destinationDirBuffer;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   808
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   809
        # Using the export infomation as read for the exports category info file check the category of the export file.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   810
        foreach my $export (sort(keys %{$exportinfo})) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   811
          my $destinationDir;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   812
          my $classifySourceFlag = 1; # Classify source using function ClassifySourceFile only if set as 1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   813
          my $destination = $catData->ExportSource($export);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   814
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   815
          # Consider any mappings if defined
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   816
          if($self->{iniData}->HasMappings()){
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   817
            $destination = $self->{iniData}->PerformMapOnFileName($destination);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   818
          }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   819
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   820
          if(defined $destinationDirBuffer){
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   821
            ($destinationDir) = Utils::SplitFileName($destination);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   822
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   823
            if($destinationDirBuffer =~ /^\Q$destinationDir\E$/i){
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   824
              $classifySourceFlag = 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   825
            }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   826
          }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   827
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   828
          my $absolute_path = Utils::PrependSourceRoot($destination);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   829
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   830
    	  # validate only if source validation is requested or the source is present
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   831
    	  if($classifySourceFlag and ($validatesource or -e $absolute_path)){
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   832
                # Obtain the category from the source destinaton extracted for the exports category info file
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   833
    	    my ($catInEnv, $errors) = Utils::ClassifyPath($self->{iniData}, $destination, 0, 0, $comp); # verbose = 0 and logErrors = 0
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   834
    	    if ($catInEnv !~ /^$catInArchive$/i){
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   835
                  print "Change in category found (ENV) \"$catInEnv\" : (Archive) \"$catInArchive\" using $thisBinZip for file $export\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   836
    	      $status = STATUS_DIRTY;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   837
    	      last;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   838
    	    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   839
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   840
    	    $destinationDirBuffer = Utils::SplitFileName($destination);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   841
    	  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   842
        }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   843
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   844
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   845
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   846
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   847
  # We only bother validating source if we've discovered the binaries are clean.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   848
  # This implies that STATUS_DIRTY means the binaries are dirty, but the status of
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   849
  # the source code is undefined.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   850
  if ($validatesource && $status == STATUS_CLEAN) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   851
    print "Validating source for $comp $ver...\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   852
    Utils::InitialiseTempDir($self->{iniData});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   853
    eval {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   854
      # Get a temporary copy of the released source.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   855
      my $tempDir = Utils::TempDir();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   856
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   857
      my $changeInCat = $self->UnpackSource($comp, $ver, $tempDir, 1, 0, 1); # 1 = overwrite, 0 = do not show progress, 1 = validate
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   858
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   859
      if($changeInCat){
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   860
	print "Change in category found for $comp...\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   861
        $status = STATUS_DIRTY_SOURCE;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   862
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   863
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   864
      # The following code is the only place where a component can have its
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   865
      # status set to "dirty source code". This status was added when
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   866
      # the -s switch was added to ValidateEnv/Rel to validate source code.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   867
      # It would have been simpler to just set a component to 'dirty' when
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   868
      # the source code was dirty, but this was not possible for the following
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   869
      # reason. When envinfo -f gathers the state information of a component
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   870
      # (or, for that matter, some other command checks the environment is clean)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   871
      # this calls the CheckComp function. This ignores the status stored in
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   872
      # the environment database, and works it out afresh from the timestamps
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   873
      # on the individual files. Hence we needed to add a new status which
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   874
      # CheckComp would propagate through, so it can report the status
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   875
      # on envinfo. (Otherwise we would have to change CheckComp
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   876
      # so it also checked the status of each source code file eacb
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   877
      # time).
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   878
      #
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   879
      # It would be nice here to ensure we have all the source
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   880
      # installed, but I don't think there's a nice way of finding
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   881
      # out the directory that the source comes in. (Not without
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   882
      # unzipping the zip, and we might as well just evalidate it...)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   883
      #
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   884
      # This grim \. thing is not homage to the Great Geek Website
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   885
      # It is because evalid gets grumpy if you give it either \ or ''
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   886
      # as an argument. The first time is because \\ isn't a valid
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   887
      # directory separator in Win32 (!!) and the second is because
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   888
      # Perl doesn't think '' is a valid directory (which is probably
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   889
      # fair enough). Rather than file a defect against Windows,
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   890
      # let's pass in slightly silly arguments to evalid.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   891
      if ($status == STATUS_CLEAN) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   892
        print "Checking for changed or removed files\n" if ($self->{verbose});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   893
        my $clean = $self->EvalidateDirectories($tempDir, Utils::PrependSourceRoot('.'), $keepGoing);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   894
        $status = STATUS_DIRTY_SOURCE unless ($clean);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   895
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   896
      # The above checks will only have found changed or removed files.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   897
      # Files that have been added to the source won't be in the $tempDir,
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   898
      # so evalid won't pick them up and test them. So we have to
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   899
      # explicitly check for added files.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   900
      # Only bother doing this if we haven't found problems already.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   901
      if ($status == STATUS_CLEAN) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   902
        # Recurse through each directory in the temp dir, listing the
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   903
        # equivalent dir on the drive (i.e. the latest source). If there
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   904
        # are more files on the drive than in the source tree, source
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   905
        # is dirty.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   906
        print "Checking for added files\n" if ($self->{verbose});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   907
        eval {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   908
          $status = STATUS_DIRTY_SOURCE if ($self->CheckForAddedFiles($relData, $tempDir));
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   909
        };
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   910
        if ($@) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   911
          print "Warning: skipping the check for added files, for the component \"$comp\". All other source code validation checks passed. The reason is: $@";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   912
        }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   913
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   914
    };
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   915
    Utils::RemoveTempDir();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   916
    if ($@) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   917
      die $@;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   918
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   919
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   920
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   921
  if ($status == STATUS_CLEAN) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   922
    # Previously this SetVersion line was wrapped in an "if", so that
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   923
    # it didn't happen if $entry was defined - i.e. it was already in the
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   924
    # environment database. After discussion with Joe and James this behaviour
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   925
    # has been changed.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   926
    $self->SetVersion($comp, $ver);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   927
    $self->SetStatus($comp, $status);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   928
    $self->GenerateSignature($comp, $ver);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   929
    $self->SetMrpName($comp, $relData->MrpName());
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   930
    $self->SetInternalVersion($comp, $relData->InternalVersion());
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   931
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   932
  elsif ($entry && $entry->{status} &&
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   933
    $entry->{status} == STATUS_PENDING_RELEASE) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   934
    # Old status was pending release; so we don't do anything
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   935
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   936
  elsif ($status == STATUS_DIRTY) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   937
    if (defined $entry) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   938
      # The component used to be in the environment database
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   939
      # We set its status in case it used to be STATUS_DIRTY_SOURCE
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   940
      # and it's now STATUS_DIRTY.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   941
      $self->SetStatus($comp, $status);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   942
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   943
    # This component wasn't previously in the environment database;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   944
    # do nothing
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   945
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   946
  elsif ($status == STATUS_DIRTY_SOURCE) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   947
    if (defined $entry) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   948
      $self->SetStatus($comp, $status);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   949
      $self->GenerateSignature($comp, $ver);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   950
      # Because otherwise any 'envinfo' will reset a component status
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   951
      # to dirty, even if only its source is dirty
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   952
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   953
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   954
  print "Status ", StatusString($status), "\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   955
  return $status;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   956
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   957
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   958
sub ValidateComp {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   959
	my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   960
	my $comp = lc(shift);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   961
	my $ver = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   962
	my $keepGoing = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   963
	my $validatesource = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   964
	my $keeptemp = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   965
	my $fullbincheck = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   966
	unless ( defined $keepGoing ) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   967
	  $keepGoing = 1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   968
	}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   969
	my $manifestFromThisComponent = undef;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   970
	my $status = STATUS_CLEAN;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   971
	die unless defined $ver;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   972
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   973
	my $entry = $self->{db}->{$comp};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   974
	if (defined $entry and $entry->{status} == STATUS_PENDING_RELEASE) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   975
		if ($ver eq $entry->{ver}) { # allow validation against other versions even if we're pending release
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   976
			return STATUS_PENDING_RELEASE;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   977
		}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   978
	}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   979
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   980
	#Create a relData object for retrieving the mrpPath required for building the manifest object
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   981
	my $relData = RelData->Open( $self->{iniData}, $comp, $ver, $self->{verbose} );
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   982
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   983
	#Find the archive location for release and build the file path for loading the manifest file from the location
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   984
	my $relDir = $relData->{iniData}->PathData->LocalArchivePathForExistingComponent( $comp, $ver );
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   985
	my $manifestPath = File::Spec->catfile( $relDir, MANIFEST_FILE );
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   986
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   987
	#Check if manifest file exists
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   988
	if (-e $manifestPath) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   989
	#Define callback to validate files which don't have checksum defined in manifest file.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   990
	my $callback = sub {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   991
		my $filesToValidate = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   992
		my $manifestObject = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   993
		my $keepGoing = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   994
		{
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   995
			local $" = ", ";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   996
			print "No checksum found for file(s) @{$filesToValidate} - reverting to old evalid process.\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   997
		}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   998
		Utils::InitialiseTempDir($self->{iniData});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   999
		my $tempDir = Utils::TempDir();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1000
		my $epocFilePath = Utils::EpocRoot();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1001
		my $sourceFilePath = Utils::SourceRoot();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1002
		my $fullEvalidName = Utils::FindInPath('evalid.bat');
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1003
		my $clean = 1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1004
		my @files;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1005
		foreach  my $thisFile (@{$filesToValidate}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1006
			my $zipName;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1007
			my $file;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1008
			my $fileContentType = $manifestObject->GetFileInfo($thisFile, CONTENT_TYPE);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1009
			if ($fileContentType  eq 'source' or $fileContentType  eq 'export') {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1010
				my $cat = $manifestObject->GetFileInfo($thisFile, IPR_CATEGORY);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1011
				if ($fileContentType eq 'source') {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1012
					$zipName = "source".$cat;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1013
					$file = File::Spec->catfile($sourceFilePath, $thisFile) 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1014
				} else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1015
					$zipName = "exports".$cat;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1016
					$file = File::Spec->catfile($epocFilePath, $thisFile);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1017
				}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1018
			}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1019
			elsif ($fileContentType eq 'binary') {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1020
				my $platForm = $manifestObject->{files}{$thisFile}{'platform'}; 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1021
				if (defined $platForm) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1022
					$zipName = "binaries"."_".$platForm;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1023
				}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1024
				else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1025
					$zipName = "binaries";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1026
				}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1027
				$file = File::Spec->catfile($epocFilePath, $thisFile);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1028
			}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1029
			$zipName = $zipName.".zip";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1030
			my $zipPath = File::Spec->catfile($relDir,$zipName);  
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1031
			Utils::UnzipSingleFile($zipPath,$thisFile, $tempDir, $self->{verbose}, 1, $comp); #overwrite = 1
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1032
			push @files, [$thisFile, $file];
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1033
		}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1034
		foreach my $thisFile (@files) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1035
			my $firstPath = File::Spec->catfile($tempDir,shift(@$thisFile));
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1036
			my $secondPath = shift(@$thisFile);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1037
			open EVALID, "$fullEvalidName -c $firstPath $secondPath|" or die "Error: Couldn't run EValid: $!\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1038
			my $thisLine;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1039
			my $acceptablefailures = ACCEPTABLE_EVALID_FAILURES;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1040
			while ($thisLine = <EVALID>) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1041
				if ($thisLine =~ m/MISSING:|FAILED:|PROBLEM:/ && $thisLine !~ m/$acceptablefailures/i) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1042
					print $thisLine  if ($self->{verbose});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1043
					$clean = 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1044
					unless ($keepGoing) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1045
						Utils::RemoveTempDir();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1046
						return $clean;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1047
					}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1048
				}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1049
			}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1050
		}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1051
		Utils::RemoveTempDir();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1052
		return $clean;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1053
	};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1054
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1055
	#Load the manifest file to create a manifest object
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1056
	my $manifestFromBaselineComponent = Symbian::CBR::Component::Manifest->new( $manifestPath );
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1057
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1058
	my $mrpPath = Utils::RelativeToAbsolutePath( $relData->MrpName(), $self->{iniData}, SOURCE_RELATIVE );
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1059
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1060
	if ($fullbincheck && -e $mrpPath) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1061
		$manifestFromThisComponent = Symbian::CBR::Component::Manifest->new($mrpPath);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1062
	} else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1063
		if ($fullbincheck) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1064
			print "Not checking for new binaries; MRP file not present\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1065
		}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1066
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1067
		$manifestFromThisComponent = Symbian::CBR::Component::Manifest->new($manifestPath);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1068
		$manifestFromThisComponent->RefreshMetaData($comp, $ver);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1069
	}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1070
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1071
	#Compare the manifest objects
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1072
	eval {$status = $manifestFromThisComponent->Compare($manifestFromBaselineComponent, $validatesource, $keepGoing,$callback)};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1073
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1074
	#Check if Compare() completed without errors
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1075
	if (!$@) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1076
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1077
		#If $keeptemp set, unpack binaries to temp location
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1078
		if ( $keeptemp ) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1079
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1080
			Utils::InitialiseTempDir($self->{iniData});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1081
			# Get a temporary copy of the released binaries.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1082
			my $tempDir = Utils::TempDir();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1083
			$self->UnpackBinaries($comp, $ver, $tempDir, 1); # 1 = overwrite
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1084
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1085
			#If $validatesource is set, get temp copy of released sources
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1086
			$self->UnpackSource($comp, $ver, $tempDir, 1, 0, 1) if $validatesource;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1087
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1088
			print "Old release stored in \"".Utils::TempDir()."\"\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1089
		}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1090
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1091
		#If status is dirty, save manifest to temp location
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1092
		$self->SaveManifestToTempDir($comp, $manifestFromThisComponent) if $status == STATUS_DIRTY;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1093
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1094
		#Update the environemnt as done by validatecompold
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1095
		$self->UpdateEnvironment( $status, $entry, $relData );
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1096
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1097
		print "Status ", StatusString($status), "\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1098
		return $status;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1099
	}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1100
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1101
	else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1102
		print "$@Continuing with old validaterel process..\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1103
	}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1104
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1105
	}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1106
	else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1107
		print "Manifest file does not exist in the version $ver for component $comp..\nContinuing with old validaterel process..\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1108
	}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1109
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1110
	#Call the old validaterel process if manifest comparison is not possible
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1111
	$status = $self->ValidateCompOld( $comp, $ver, $keepGoing, $validatesource, $keeptemp, $fullbincheck );
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1112
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1113
	#If status is dirty during validatecompold, still we want to save manifest to temp location
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1114
	if ( defined $manifestFromThisComponent and ($status == STATUS_DIRTY or $status == STATUS_DIRTY_SOURCE) ) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1115
		$self->SaveManifestToTempDir($comp, $manifestFromThisComponent);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1116
	}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1117
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1118
	return $status;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1119
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1120
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1121
sub UpdateEnvironment {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1122
	my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1123
	my $status = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1124
	my $entry = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1125
	my $relData = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1126
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1127
	my $comp = $relData->Component();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1128
	my $ver = $relData->Version();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1129
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1130
	if ($status == STATUS_CLEAN) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1131
		# Previously this SetVersion line was wrapped in an "if", so that
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1132
		# it didn't happen if $entry was defined - i.e. it was already in the
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1133
		# environment database. After discussion with Joe and James this behaviour
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1134
		# has been changed.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1135
		$self->SetVersion( $comp, $ver );
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1136
		$self->SetStatus( $comp, $status );
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1137
		$self->GenerateSignature( $comp, $ver );
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1138
		$self->SetMrpName( $comp, $relData->MrpName() );
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1139
		$self->SetInternalVersion( $comp, $relData->InternalVersion() );
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1140
	}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1141
	elsif ($entry && $entry->{status} &&
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1142
		$entry->{status} == STATUS_PENDING_RELEASE) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1143
		# Old status was pending release; so we don't do anything
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1144
	}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1145
	elsif ($status == STATUS_DIRTY) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1146
		if (defined $entry) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1147
			# The component used to be in the environment database
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1148
			# We set its status in case it used to be STATUS_DIRTY_SOURCE
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1149
			# and it's now STATUS_DIRTY.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1150
			$self->SetStatus( $comp, $status );
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1151
		}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1152
		# This component wasn't previously in the environment database;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1153
		# do nothing
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1154
	}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1155
	elsif ($status == STATUS_DIRTY_SOURCE) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1156
		if (defined $entry) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1157
			$self->SetStatus( $comp, $status );
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1158
			$self->GenerateSignature( $comp, $ver );
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1159
			# Because otherwise any 'envinfo' will reset a component status
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1160
			# to dirty, even if only its source is dirty
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1161
		}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1162
	}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1163
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1164
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1165
sub SaveManifestToTempDir {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1166
	my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1167
	my $comp = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1168
	my $manifestFromThisComponent = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1169
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1170
	my $manifestTempFile = "manifest_".$comp.".xml";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1171
	my $manifestFile = $manifestFromThisComponent->Save( File::Spec->tmpdir(), $manifestTempFile );
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1172
#	my $manifestTempFile = File::Spec->catfile( File::Spec->tmpdir(), "manifest_".$comp.".xml" );
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1173
#	rename( $manifestFile, $manifestTempFile );
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1174
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1175
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1176
sub Duplicates {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1177
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1178
  my $mrpData = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1179
  my $installedComps = $self->VersionInfo();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1180
  my %binHash;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1181
  my @duplicates;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1182
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1183
  # First cross-check against the components about to be released.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1184
  foreach my $thisMrp (@{$mrpData}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1185
    my $comp = lc($thisMrp->Component());
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1186
    my $bins = $thisMrp->BinariesAndExports();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1187
    foreach my $thisBin (@$bins) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1188
      $thisBin = lc(Utils::PrependEpocRoot($thisBin));
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1189
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1190
      print "Checking $thisBin for duplicateness (pending release)\n" if ($self->{verbose}>1);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1191
      if (exists $binHash{$thisBin}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1192
 	push @duplicates, [$thisBin, $comp, $binHash{$thisBin}]; # $comp attempting to release $thisBin which has already been released by $binHash{$thisBin}";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1193
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1194
      else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1195
	$binHash{$thisBin} = $comp;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1196
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1197
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1198
    delete $installedComps->{$comp};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1199
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1200
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1201
  # Now cross-check against the other components in the environment.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1202
  foreach my $thisComp (keys %{$installedComps}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1203
    my $doCheck = sub {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1204
      my $file = lc(shift);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1205
      print "Checking $file for duplicateness\n" if ($self->{verbose}>1);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1206
      if (exists $binHash{$file}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1207
	push @duplicates, [$file, $binHash{$file}, $thisComp]; #"$binHash{$file} attempting to release $file which has already been released by $thisComp";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1208
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1209
      else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1210
	$binHash{$file} = $thisComp;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1211
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1212
    };
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1213
    my $sigName = SignatureName($thisComp, $installedComps->{$thisComp});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1214
    ExecuteSignature($sigName, $doCheck);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1215
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1216
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1217
  return \@duplicates;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1218
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1219
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1220
sub BinaryInfo {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1221
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1222
  my $binary = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1223
  unless (-e $binary) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1224
    die "Error: \"$binary\" does not exist\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1225
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1226
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1227
  (my $currentMTime, my $currentSize) = Utils::FileModifiedTimeAndSize($binary);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1228
  my $sigMTime;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1229
  my $sigSize;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1230
  my $sigName;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1231
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1232
  my $findBin = sub {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1233
    my $file = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1234
    if (lc($binary) eq lc($file)) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1235
      $sigMTime = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1236
      $sigSize = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1237
      $sigName = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1238
      return 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1239
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1240
    return 1; # Means continue;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1241
  };
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1242
  ExecuteAllSignatures($findBin);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1243
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1244
  my $comp;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1245
  my $ver;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1246
  my $pendingRelease = 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1247
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1248
  if (defined $sigMTime and defined $sigName) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1249
    ($comp, $ver) = $self->DecodeSignatureName($sigName);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1250
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1251
  else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1252
    # Binary not found in the signatures, so check for components pending release.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1253
    if (Utils::WithinEpocRoot($binary)) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1254
	      $binary = Utils::RemoveEpocRoot($binary); # remove EPOCROOT
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1255
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1256
    $binary =~ s!^[\\\/]!!; # remove leading slash
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1257
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1258
    foreach my $thisComp (keys %{$self->{db}}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1259
      if ($self->Status($thisComp) == STATUS_PENDING_RELEASE) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1260
        my $thisVer = $self->{db}->{$thisComp}->{ver};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1261
        my $thisMrpData = $self->GetMrpData($thisComp);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1262
        $thisMrpData->EnsureDoesNotExist();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1263
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1264
        if (grep /^\Q$binary\E$/i, @{$thisMrpData->Binaries()}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1265
          $pendingRelease = 1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1266
          $comp = $thisComp;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1267
          $ver = $thisVer;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1268
          last;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1269
        }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1270
        elsif (grep /^\Q$binary\E$/i, @{$thisMrpData->Exports()}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1271
          $pendingRelease = 1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1272
          $comp = $thisComp;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1273
          $ver = $thisVer;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1274
          last;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1275
        }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1276
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1277
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1278
    unless (defined $comp and defined $ver) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1279
      my $ignoreList = $self->{iniData}->BinariesToIgnore();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1280
      push (@$ignoreList, Utils::PrependEpocRoot('\\epoc32\\relinfo\\*'));
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1281
      foreach my $ignore (@$ignoreList) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1282
      $ignore =~ s/\\/\\\\/g;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1283
      $ignore =~ s/\./\\\./g;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1284
      $ignore =~ s/\*/\.\*/g;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1285
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1286
      if ($binary !~ /^\\/) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1287
        $ignore =~ s/^\\*//;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1288
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1289
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1290
      if ($binary =~ /^$ignore$/i) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1291
        die "Error: no information available for \"$binary\". It is not part of any component, but it is ignored by the 'ignore_binary' rule '$ignore'. This rule might be in your reltools.ini, or it might be one of the standard ignores.\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1292
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1293
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1294
      die "Error: No information available for \"$binary\". It's not even one of the files/directories that are ignored as standard.\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1295
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1296
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1297
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1298
  my $info;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1299
  push (@$info, ['Component:', $comp]);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1300
  push (@$info, ['Version:', $ver]);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1301
  if ($pendingRelease) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1302
    push (@$info, ['Status:', 'pending release']);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1303
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1304
  elsif ($currentMTime == $sigMTime and $currentSize == $sigSize) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1305
    push (@$info, ['Status:', 'clean']);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1306
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1307
  else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1308
    push (@$info, ['Status:', 'dirty']);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1309
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1310
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1311
  return $info;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1312
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1313
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1314
sub ListBins {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1315
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1316
  my $comp = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1317
  my $ver = $self->Version($comp);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1318
  die unless $ver;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1319
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1320
  if ($self->Status($comp) == STATUS_PENDING_RELEASE) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1321
    $self->ListBinsPendingRelease($comp, $ver);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1322
  } else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1323
    $self->ListBinsStandard($comp, $ver);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1324
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1325
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1326
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1327
sub GetMrpData {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1328
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1329
  my $compname = lc(shift);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1330
  my $entry = $self->{db}->{$compname};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1331
  die "Invalid component name \"$compname\"" unless $entry;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1332
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1333
  my $name = $entry->{mrpName};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1334
  unless ($self->{mrpcache}->{$name}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1335
    my $mrpData = MrpData->New($entry->{mrpName}, $entry->{ver}, $entry->{intVer}, $self->{iniData}, $self->{verbose});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1336
    my $namefrommrp = $mrpData->Component();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1337
    die "Error: Component name in MRP file is \"$namefrommrp\" whilst the name of this component in the environment database is \"$compname\".\n" unless (lc $compname eq lc $namefrommrp);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1338
    $self->{mrpcache}->{$name} = $mrpData;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1339
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1340
  return $self->{mrpcache}->{$name};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1341
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1342
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1343
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1344
sub GetMRPLocations {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1345
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1346
  my $componentName = lc(shift);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1347
  
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1348
  # If only the MRP location for a specified component is required...
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1349
  if ($componentName) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1350
    if (exists $self->{db}->{$componentName}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1351
      return (Utils::PrependSourceRoot($self->{db}->{$componentName}->{mrpName}));
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1352
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1353
    else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1354
      return undef;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1355
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1356
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1357
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1358
  # Otherwise all MRP locations are returned to the caller
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1359
  my @mrpLocations;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1360
  
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1361
  foreach my $component (keys %{$self->{db}}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1362
    push @mrpLocations, Utils::PrependSourceRoot($self->{db}->{$component}->{mrpName});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1363
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1364
  
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1365
  return @mrpLocations;  
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1366
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1367
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1368
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1369
# Private.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1370
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1371
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1372
sub ListBinsStandard {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1373
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1374
  my $comp = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1375
  my $ver = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1376
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1377
  my $info;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1378
  push (@$info, ['File', 'Status']);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1379
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1380
  my $sigName = SignatureName($comp, $ver);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1381
  my $gatherInfo = sub {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1382
    my $file = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1383
    my $sigMTime = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1384
    my $sigSize = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1385
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1386
    if (-e $file) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1387
      (my $actualMTime, my $actualSize) = Utils::FileModifiedTimeAndSize($file);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1388
      if (!defined $actualMTime or !defined $actualSize) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1389
	die "Error: Problem stating \"$file\"\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1390
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1391
      elsif ($sigMTime != $actualMTime or $sigSize != $actualSize) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1392
	push (@$info, [$file, STATUS_STRING_FAILED]);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1393
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1394
      else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1395
	push (@$info, [$file, STATUS_STRING_PASSED]);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1396
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1397
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1398
    else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1399
      push (@$info, [$file, STATUS_STRING_MISSING]);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1400
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1401
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1402
    return 1; # Means continue with next line in signature.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1403
  };
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1404
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1405
  ExecuteSignature($sigName, $gatherInfo);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1406
  return $info;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1407
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1408
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1409
sub ListBinsPendingRelease {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1410
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1411
  my $comp = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1412
  my $ver = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1413
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1414
  my $mrpData = $self->GetMrpData($comp);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1415
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1416
  my @info;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1417
  push @info, ['File', 'Status', 'Category'];
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1418
  foreach my $cat (@{$mrpData->BinaryCategories()}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1419
    foreach my $file (@{$mrpData->Binaries($cat)}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1420
      push @info, [$file, 'pending release', $cat];
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1421
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1422
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1423
  foreach my $cat (@{$mrpData->ExportCategories()}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1424
    foreach my $file (@{$mrpData->Exports($cat)}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1425
      push @info, [$file, 'pending release', $cat];
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1426
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1427
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1428
  # To do ideally: add another column to report which bld.inf each binary
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1429
  # comes from (if any). This requires quite a lot of internal restructuring
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1430
  # of MrpData.pm so will probably never happen... It's not worth the benefits.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1431
  return \@info;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1432
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1433
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1434
sub DESTROY {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1435
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1436
  $self->Close();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1437
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1438
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1439
sub EvalidateDirectories {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1440
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1441
  my $firstdirectory = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1442
  my $seconddirectory = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1443
  my $keepGoing = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1444
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1445
  my $clean = 1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1446
  my $fullEvalidName = Utils::FindInPath('evalid.bat');
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1447
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1448
  # Call evalid to compare these with those installed in the environment.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1449
  if ($self->{verbose} > 1) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1450
    print "Evalid command is $fullEvalidName -c $firstdirectory $seconddirectory\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1451
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1452
  open EVALID, "$fullEvalidName -c $firstdirectory $seconddirectory|" or die "Error: Couldn't run EValid: $!\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1453
  my $thisLine;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1454
  while ($thisLine = <EVALID>) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1455
    my $acceptablefailures = ACCEPTABLE_EVALID_FAILURES;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1456
    if ($thisLine =~ m/MISSING:|FAILED:|PROBLEM:/ && $thisLine !~ m/$acceptablefailures/i) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1457
      if ($self->{verbose}) { print $thisLine; }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1458
      $clean = 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1459
      unless ($keepGoing) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1460
        last;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1461
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1462
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1463
    elsif ($self->{verbose} > 1) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1464
      print $thisLine;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1465
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1466
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1467
  close EVALID;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1468
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1469
  return $clean;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1470
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1471
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1472
sub ScanEnv {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1473
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1474
  my $displayProgress = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1475
  my $progressTuner = 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1476
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1477
  my $processFileSub = sub {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1478
    if ($displayProgress) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1479
      ++$progressTuner;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1480
      if ($progressTuner >= SCAN_PROGRESS_TUNER) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1481
        $progressTuner = 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1482
        select STDOUT; $|=1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1483
        print ".";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1484
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1485
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1486
    my $thisFile = lc($File::Find::name);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1487
    Utils::TidyFileName(\$thisFile);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1488
    if (-f $thisFile) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1489
      $self->{envFileList}->{$thisFile} = 1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1490
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1491
    elsif (-d $thisFile and $self->CheckIgnoreDir($thisFile)) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1492
      $File::Find::prune = 1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1493
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1494
    elsif (-d $thisFile && !@{Utils::ReadDir($thisFile)}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1495
      # This is an empty directory.  It is not possible to own empty directories,
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1496
      #so this will be included in the unowned list
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1497
      $self->{envFileList}->{$thisFile} = 1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1498
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1499
  };
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1500
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1501
  my $cwd = cwd();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1502
  $cwd =~ s/:$/:\\/; # Needed because if at root, cwd() just returns drive_letter:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1503
  find($processFileSub, Utils::PrependEpocRoot('\\epoc32'));
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1504
  chdir ($cwd);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1505
  if ($displayProgress and $self->{verbose}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1506
    print "\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1507
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1508
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1509
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1510
sub CheckIgnoreDir {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1511
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1512
  my $dir = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1513
  if (exists $self->{ignoreDirs}->{$dir}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1514
    return 1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1515
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1516
  return 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1517
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1518
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1519
# Classify the ignores according to whether they correspond to directories or files. This allows the
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1520
# File::Find scan to prune directories to be ignored efficiently.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1521
sub InitIgnores {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1522
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1523
  my $ignoreStandardIgnores = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1524
  my $ignoreList;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1525
  unless ($ignoreStandardIgnores) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1526
    $ignoreList = $self->{iniData}->BinariesToIgnore();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1527
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1528
  push (@$ignoreList, '\\epoc32\\relinfo\\*'); # Need to always ignore \epoc32\relinfo since this contains the environment database.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1529
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1530
  foreach my $thisIgnore (@$ignoreList) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1531
    if ($thisIgnore =~ /(.*)\\\*$/) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1532
      my $dir = $1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1533
      Utils::TidyFileName(\$dir);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1534
      $self->{ignoreDirs}->{lc(Utils::PrependEpocRoot($dir))} = 1;  # Store dirs in a hash so they can be looked up fast.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1535
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1536
    else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1537
      push (@{$self->{ignoreFiles}}, Utils::PrependEpocRoot($thisIgnore));
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1538
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1539
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1540
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1541
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1542
sub CheckFileAgainstEnvScan {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1543
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1544
  my $file = lc(shift);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1545
  my $ok = 1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1546
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1547
  if (exists $self->{envFileList}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1548
    if (exists $self->{envFileList}->{$file}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1549
      # Exists, so remove from envFileList hash - any file names left in here at the end will be reported to the user.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1550
      delete $self->{envFileList}->{$file};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1551
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1552
    else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1553
      $ok = 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1554
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1555
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1556
  elsif (not -e $file) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1557
    $ok = 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1558
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1559
  return $ok;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1560
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1561
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1562
sub RemoveBinsToIgnore {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1563
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1564
  foreach my $thisIgnore (@{$self->{ignoreFiles}}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1565
    $thisIgnore =~ s/\\/\\\\/g;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1566
    $thisIgnore =~ s/\./\\\./g;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1567
    $thisIgnore =~ s/\*/\.\*/g;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1568
    foreach my $thisFile (keys %{$self->{envFileList}}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1569
      if ($thisFile =~ /$thisIgnore/i) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1570
	delete $self->{envFileList}->{$thisFile};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1571
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1572
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1573
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1574
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1575
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1576
sub UnaccountedEnvFiles {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1577
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1578
  my @unaccountedFiles = sort keys %{$self->{envFileList}};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1579
  return \@unaccountedFiles;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1580
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1581
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1582
sub DeleteSignature {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1583
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1584
  my $comp = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1585
  my $ver = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1586
  
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1587
  if ($self->{verbose} > 1) { print "Deleting signature file for $comp $ver\n"; }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1588
  my $sigName = SignatureName($comp, $ver);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1589
  unlink ($sigName) or print "Warning: Couldn't delete $sigName: $!\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1590
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1591
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1592
sub ExecuteAllSignatures {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1593
  my $sub = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1594
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1595
  opendir(DIR, Utils::PrependEpocRoot("\\epoc32\\relinfo")) or die "Error: Couldn't open directory \"" . Utils::PrependEpocRoot("\\epoc32\\relinfo") . "\": $!\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1596
  while (defined(my $file = readdir(DIR))) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1597
    if ($file =~ /\.sig$/) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1598
      my $continue = ExecuteSignature(Utils::PrependEpocRoot("\\epoc32\\relinfo\\$file"), $sub);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1599
      unless ($continue) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1600
	last;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1601
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1602
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1603
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1604
  closedir(DIR);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1605
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1606
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1607
sub ExecuteSignature {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1608
# For each line in the signature file, parse and call the given subroutine with the parsed variables.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1609
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1610
  my $sigName = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1611
  my $filessub = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1612
  my $directoriesSub = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1613
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1614
  my %directories;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1615
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1616
  my $continue = 1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1617
  open (SIG, $sigName) or die "Couldn't open $sigName for reading: $!\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1618
  while (my $line = <SIG>) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1619
    # Parse signature line.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1620
    (my $file, my $mTime, my $size) = split (/\t/, $line);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1621
    unless (defined $file and defined $mTime and defined $size) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1622
      die "Error: Invalid line in signature file $sigName\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1623
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1624
    $directories{dirname($file)} = 1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1625
    # Call subroutine.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1626
    $continue = &$filessub(Utils::PrependEpocRoot($file), $mTime, $size, $sigName);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1627
    unless ($continue) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1628
      last;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1629
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1630
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1631
  close (SIG);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1632
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1633
  if ($directoriesSub) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1634
    foreach my $directory (sort keys %directories) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1635
      &$directoriesSub(Utils::PrependEpocRoot($directory), $sigName);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1636
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1637
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1638
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1639
  return $continue;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1640
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1641
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1642
sub DeleteFilesInSignature {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1643
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1644
  my $comp = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1645
  my $ver = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1646
  my $sigName = SignatureName($comp, $ver);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1647
  my $filesDeletionSub = sub {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1648
    my $file = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1649
    if (-e $file) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1650
      if ($self->{verbose} > 1) { print "Deleting \"$file\"...\n"; }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1651
      unlink ($file) or die "Error: Couldn't delete \"$file\": $!\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1652
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1653
    return 1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1654
  };
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1655
  my $directoriesDeletionSub = sub {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1656
    my $directory = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1657
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1658
    if (-e $directory && !scalar @{Utils::ReadDir($directory)} ) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1659
      print "Removing directory $directory...\n" if ($self->{verbose});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1660
      rmdir $directory or die "Error: Could not remove directory $directory: $!\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1661
      while (($directory = dirname($directory)) && -e $directory && !scalar @{Utils::ReadDir($directory)}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1662
        print "Removing directory $directory...\n" if ($self->{verbose});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1663
        rmdir $directory or die "Error: Could not remove directory $directory: $!\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1664
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1665
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1666
  };
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1667
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1668
  ExecuteSignature($sigName, $filesDeletionSub, $directoriesDeletionSub);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1669
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1670
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1671
sub InstallComponent {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1672
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1673
  my $comp = lc(shift);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1674
  my $ver = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1675
  my $overwrite = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1676
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1677
  my $relData = RelData->Open($self->{iniData}, $comp, $ver, $self->{verbose});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1678
  $relData->WarnIfReleaseTooNew();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1679
  $self->UnpackBinaries($comp, $ver, Utils::EpocRoot(), $overwrite);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1680
  $self->GenerateSignature($comp, $ver);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1681
  $self->SetVersion($comp, $ver);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1682
  $self->SetMrpName($comp, $relData->MrpName());
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1683
  $self->SetInternalVersion($comp, $relData->InternalVersion());
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1684
  $self->SetStatus($comp, STATUS_CLEAN);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1685
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1686
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1687
sub UnpackBinaries {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1688
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1689
  my $comp = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1690
  my $ver = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1691
  my $where = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1692
  my $overwrite = (shift || $self->{overwrite});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1693
  foreach my $thisBinZip (@{$self->RelevantBinaryZips($comp, $ver)}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1694
    $overwrite = Utils::Unzip($thisBinZip, $where, $self->{verbose}, $overwrite);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1695
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1696
  
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1697
  $self->{overwrite} = $overwrite;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1698
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1699
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1700
sub RelevantBinaryZips {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1701
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1702
  my $comp = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1703
  my $ver = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1704
  $self->PathData()->CheckReleaseExists($comp, $ver);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1705
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1706
  my $requiredBinaries = $self->{iniData}->RequiredBinaries($comp);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1707
  my $relDir = $self->PathData->LocalArchivePathForExistingOrNewComponent($comp, $ver);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1708
  my @relevantBinaries = ();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1709
  foreach my $thisRelFile (@{Utils::ReadDir($relDir)}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1710
    if ($thisRelFile eq 'binaries.zip') {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1711
      push (@relevantBinaries, "$relDir\\$thisRelFile");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1712
      next;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1713
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1714
    if ($thisRelFile =~ /^binaries_(.*)\.zip$/) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1715
      my $category = $1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1716
      if ($requiredBinaries) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1717
	foreach my $requiredBinary (@$requiredBinaries) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1718
	  if (($category =~ /^$requiredBinary\_/) || ($category eq $requiredBinary)) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1719
	    push (@relevantBinaries, "$relDir\\$thisRelFile");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1720
	    last;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1721
	  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1722
	}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1723
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1724
      else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1725
	push (@relevantBinaries, "$relDir\\$thisRelFile");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1726
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1727
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1728
    elsif ($thisRelFile =~ /^exports[a-z].zip$/i) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1729
      push (@relevantBinaries, "$relDir\\$thisRelFile");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1730
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1731
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1732
  return \@relevantBinaries;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1733
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1734
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1735
sub UnpackSource {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1736
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1737
  my $comp = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1738
  my $ver = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1739
  my $where = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1740
  my $overwrite = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1741
  my $skipinstall = 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1742
  unless (defined $overwrite) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1743
    $overwrite = 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1744
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1745
  my $showProgress = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1746
  unless (defined $showProgress) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1747
    $showProgress = 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1748
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1749
  my $toValidate = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1750
  unless (defined $toValidate) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1751
    $toValidate = 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1752
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1753
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1754
  my $changeInCat = 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1755
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1756
  $self->PathData()->CheckReleaseExists($comp, $ver);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1757
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1758
  if ($where eq "\\") {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1759
    $where = Utils::SourceRoot();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1760
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1761
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1762
  # Unpack all categories of source code that are available.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1763
  my $relDir = $self->PathData->LocalArchivePathForExistingOrNewComponent($comp, $ver);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1764
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1765
  opendir(RELDIR, $relDir) or die "Error: can't opendir $relDir\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1766
  my @srcZipNames = grep {/source[a-z]\.zip/i} map {"$relDir\\$_"} readdir(RELDIR);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1767
  close RELDIR;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1768
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1769
  if ($self->{verbose} and scalar(@srcZipNames) == 0) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1770
    print "No source available for $comp $ver\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1771
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1772
  else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1773
    unless ($overwrite) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1774
      my $checkFailed = 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1775
      foreach my $thisSrcZip (@srcZipNames) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1776
        if (Utils::CheckZipFileContentsNotPresent($thisSrcZip, $where, $self->{iniData})) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1777
          $checkFailed = 1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1778
        }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1779
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1780
      if ($checkFailed) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1781
        warn "Warning: Above errors found, skipping the unpacking of $comp zips...\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1782
        $skipinstall = 1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1783
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1784
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1785
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1786
    unless($skipinstall){
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1787
      foreach my $thisSrcZip (@srcZipNames) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1788
        if ($showProgress) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1789
          my $significantDir = Utils::SignificantZipDir($thisSrcZip);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1790
          my $unzipDir  = Utils::ConcatenateDirNames($where, $significantDir);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1791
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1792
          if($self->{iniData}->HasMappings()){
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1793
            $unzipDir = $self->{iniData}->PerformMapOnFileName($unzipDir);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1794
          }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1795
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1796
          print "\tUnpacking \"$thisSrcZip\" into \"$unzipDir\"...\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1797
        }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1798
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1799
        $changeInCat = Utils::UnzipSource($thisSrcZip, $where, $self->{verbose}, $overwrite, $self->{iniData}, $toValidate, $comp);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1800
        if($changeInCat==1 && $toValidate ==1) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1801
          last;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1802
	}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1803
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1804
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1805
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1806
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1807
  return $changeInCat; # 1 = change in cat found, 0 = change in cat not found. Return value only used for validation.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1808
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1809
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1810
sub SignatureName {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1811
  my $comp = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1812
  my $ver = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1813
  croak unless defined $ver;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1814
  return Utils::PrependEpocRoot("\\epoc32\\relinfo\\$comp.$ver.sig");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1815
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1816
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1817
sub DecodeSignatureName {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1818
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1819
  my $sigName = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1820
  my $comp;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1821
  my $ver;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1822
  my $name = $sigName;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1823
  $name =~ s/.*\\epoc32\\relinfo\\(.*)\.sig/$1/;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1824
  foreach my $thisComp (keys %{$self->{db}}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1825
    my $thisVer = $self->{db}->{$thisComp}->{ver};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1826
    if ("$thisComp.$thisVer" eq $name) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1827
      $comp = $thisComp;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1828
      $ver = $thisVer;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1829
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1830
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1831
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1832
  unless (defined $comp and defined $ver) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1833
    die "Error: Couldn't decode signature name \"$sigName\"\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1834
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1835
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1836
  return ($comp, $ver);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1837
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1838
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1839
sub ComponentDir {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1840
  require Carp;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1841
  Carp->import;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1842
  confess ("Obsolete method called");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1843
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1844
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1845
sub ReleaseDir {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1846
  require Carp;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1847
  Carp->import;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1848
  confess ("Obsolete method called");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1849
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1850
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1851
sub PathData {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1852
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1853
  return $self->{iniData}->PathData();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1854
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1855
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1856
sub CheckForAddedFiles {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1857
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1858
  my $reldata = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1859
  my $tempdir = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1860
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1861
  # Here we have been asked to search for files that exist in the real source directory,
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1862
  # but don't exist in the temporary source directory.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1863
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1864
  my $foundextra = 0; # let's hope this stays zero
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1865
  foreach my $item (keys %{$reldata->SourceItems}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1866
    $item = Utils::PrependSourceRoot($item);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1867
    next unless -d $item; # we're only checking for added files, so we don't care unless this
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1868
                          # is a directory in which there ought to be files.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1869
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1870
    print "Looking for added files inside \"$item\"\n" if ($self->{verbose});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1871
    # Ah, the lovely Find::File
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1872
    find(sub {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1873
      my $tempfile = Utils::ConcatenateDirNames($tempdir, Utils::RemoveSourceRoot($File::Find::name));
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1874
      # Be careful with that line - an extra \\ anywhere and it breaks, such is DOS...
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1875
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1876
      print "Checking existence of \"$tempfile\"\n" if ($self->{verbose}>1);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1877
      unless (-e $tempfile) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1878
        print "\"$File::Find::name\" only exists in new source code.\n" if ($self->{verbose});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1879
        $foundextra++;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1880
        $File::Find::prune = 1 unless ($self->{verbose}); # skip some of the rest
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1881
      }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1882
    }, $item);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1883
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1884
    return $foundextra if ($foundextra && !$self->{verbose});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1885
        # don't bother scanning other directories unless it's verbose
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1886
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1887
    return $foundextra;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1888
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1889
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1890
sub GetReleaseSize {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1891
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1892
  my $comp = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1893
  my $ver = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1894
  $self->{relsize}->{$comp}->{$ver} = $self->AddUpReleaseSize($comp, $ver) unless defined $self->{relsize}->{$comp}->{$ver};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1895
  return $self->{relsize}->{$comp}->{$ver};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1896
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1897
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1898
sub AddUpReleaseSize {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1899
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1900
  my $comp = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1901
  my $version = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1902
  my $pathdata = $self->{iniData}->PathData();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1903
  my $path = $pathdata->LocalArchivePathForExistingComponent($comp, $version);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1904
  die "Component $comp $version didn't exist\n" unless $path;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1905
  opendir(DIR, $path) or die "Couldn't open directory \"$path\" because $!";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1906
  my @entries = grep { ! m/^\./ } readdir(DIR);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1907
  closedir DIR;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1908
  my $size = 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1909
  print "Adding up size of $comp $version\n" if ($self->{verbose});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1910
  foreach my $file (@entries) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1911
    my $full = $path . "\\" . $file;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1912
    $size += -s $full;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1913
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1914
  return $size;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1915
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1916
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1917
sub GetEnvironmentSize {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1918
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1919
  my $comp = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1920
  my $ver = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1921
  my $deltasize = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1922
  $self->{envsize}->{$comp}->{$ver} = $self->AddUpEnvSize($comp, $ver, $deltasize) if (!exists $self->{envsize}->{$comp}->{$ver});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1923
  return $self->{envsize}->{$comp}->{$ver};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1924
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1925
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1926
sub AddUpEnvSize {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1927
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1928
  my $maincomp = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1929
  my $mainver = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1930
  my $deltasize = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1931
  my $relData = RelData->Open($self->{iniData}, $maincomp, $mainver, $self->{verbose});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1932
  die "Component $maincomp version $mainver didn't exist\n" unless $relData;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1933
  my $compsToValidate = $relData->Environment();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1934
  my $size = 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1935
  while ((my $comp, my $ver) = each %$compsToValidate) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1936
    # If a delta size is requested and the component version does not
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1937
    # match the main component version then don't increment the size
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1938
    next if ($deltasize && ($mainver ne $ver));
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1939
    
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1940
    $size += $self->GetReleaseSize($comp, $ver);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1941
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1942
  return $size;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1943
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1944
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1945
1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1946
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1947
__END__
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1948
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1949
=head1 NAME
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1950
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1951
EnvDb.pm - A database to keep track of component versions installed on a development drive.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1952
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1953
=head1 DESCRIPTION
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1954
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1955
The database is implemented as a tied hash. It provides a persistent store of component / version pairs. Also provides facilities for checking and validating the contents of an environemnt.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1956
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1957
Each component has a status associated with it. The possible values are as follows:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1958
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1959
=over 4
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1960
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1961
=item C<STATUS_CLEAN>: the binaries on disk match those in the release packet
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1962
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1963
=item C<STATUS_DIRTY>: the binaries on disk don't appear to match those in the release packet
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1964
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1965
=item C<STATUS_DIRTY_SOURCE>: the binaries match, but the source code doesn't
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1966
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1967
=item C<STATUS_PENDING_RELEASE>: the component has been set to 'pending release'
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1968
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1969
=back
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1970
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1971
=head1 INTERFACE
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1972
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1973
=head2 Object Management
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1974
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1975
=head3 Open
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1976
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1977
Expects to be passed an C<IniData> reference and a verbosity level. Opens the C<EnvDb> on the current drive. If not already present, an empty databse is created. This must be done before any of the following interfaces are used.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1978
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1979
=head3 Close
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1980
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1981
Closes the database file.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1982
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1983
=head2 Data Management
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1984
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1985
=head3 Version
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1986
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1987
Expects to be passed a component name. Returns the version of the component that is currently installed. Returns undef if there is no version currently installed.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1988
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1989
=head3 VersionInfo
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1990
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1991
Returns a reference to an in memory hash containing component component name / version pairs for every entry in the database.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1992
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1993
=head3 SetVersion
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1994
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1995
Expects to be passed a component name and a optionally a version. If the version is specified, a database entry for the component is created, or, if it is already present, updated. If the version is not specified, and a database entry for the component entry exists, it is deleted.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1996
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1997
=head3 InternalVersion
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1998
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  1999
Expects to be passed a component name. Returns the internal version of the component that is currently installed. Returns undef if the component is not currently installed.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2000
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2001
=head3 SetInternalVersion
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2002
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2003
Expects to be passed a component name and an internal version. Dies if an entry for the component is not already present in the database. Store the component's internal version.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2004
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2005
=head3 Status
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2006
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2007
Expects to be passed a component name. Dies if an entry for the component is not already present in the database. Returns the component's last recorded status (which may be C<STATUS_CLEAN>, C<STATUS_DIRTY> or C<STATUS_PENDING_RELEASE>).
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2008
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2009
=head3 SetStatus
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2010
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2011
Expects to be passed a component name and a status integer. Dies if an entry for the component is not already present in the database. Updates the component's database entry with the new status.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2012
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2013
=head3 MrpName
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2014
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2015
Expects to be passed a component name. Dies if an entry for the component is not already present in the database. Returns the corresponding F<mrp> name.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2016
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2017
=head3 SetMrpName
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2018
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2019
Expects to be passed a component name and an F<mrp> name. Dies if an entry for the component is not already present in the database. Stores of the F<mrp> name of the component.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2020
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2021
=head3 ComponentsPendingRelease
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2022
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2023
Returns a reference to a hash of hash references. The primary hash key is component name. The secondary hashes each containing details a component that is pending release. The secondary hashes contain the following keys:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2024
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2025
 mrpName
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2026
 ver
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2027
 intVer
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2028
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2029
=head3 BinaryInfo
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2030
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2031
Expects to be passed the name of a binary file. Searches for this file name within the component signatures. If it is not found there, then checks for components that are pending release. C<MrpData> objects are then created for each of these to see if the binary file is about to be released. Dies if the file is still not found. Otherwise, returns a two dimentional array containing the component name, verion and current file status.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2032
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2033
=head3 ListBins
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2034
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2035
Expects to be passed a component name. Returns a 2D array containing all the file names owned by component and their current status. These facts will be in the first and second column; subsequent columns may hold further information. The table contains a header row describing what each column is.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2036
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2037
=head2 Environment Scans
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2038
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2039
=head3 CheckEnv
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2040
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2041
Performs a scan of the F<\epoc32> tree building a hash of all file names. Calls C<CheckComp> for all the components installed on the drive. C<CheckComp> will remove files that pass the check from the F<\epoc32> tree hash. Any file names left in the hash after all components have been checked will be printed to warn the user, since their origin is unknown to the release tools. The F<reltools.ini> keyword C<ignore_binary> my be used to specify (using file names with DOS style wild characters) binary files to be ignored in the checking process. As standard, the following are ignored:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2042
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2043
 \epoc32\relinfo\*
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2044
 \epoc32\build\*
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2045
 \epoc32\wins\c\*
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2046
 \epoc32\release\*.ilk
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2047
 \epoc32\release\*.bsc
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2048
 \epoc32\data\emulator\epoc.sys.ini
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2049
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2050
Returns the overall status of the environement after the check (which may be of value C<STATUS_CLEAN>, C<STATUS_DIRTY> or C<STATUS_PENDING_RELEASE>), a reference to a list of C<MrpData> objects that are pending release, a reference to a list of component that failed their check, and a reference to a list of unaccounted files.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2051
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2052
=head3 CheckComp
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2053
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2054
Expects to be passed a component name and optionally a scalar flag indicating if the check should continue after the first failure is found (true means continue). Details of any files that fail their check will be printed. Returns the status of the component after the check (which may be of value C<STATUS_CLEAN>, C<STATUS_DIRTY>, C<STATUS_DIRTY_SOURCE> or C<STATUS_PENDING_RELEASE>), and a reference to an C<MrpData> object if the status is C<STATUS_PENDING_RELEASE>.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2055
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2056
CheckComp does not check the source code files. In fact, if it determines the binaries match, then it returns either C<STATUS_CLEAN> or C<STATUS_DIRTY_SOURCE> depending on what the environment database says. A component will only ever attain the status of C<STATUS_DIRTY_SOURCE> through the operation of ValidateComp: effectively CheckComp just passes that information through, if the component otherwise appears clean.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2057
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2058
=head3 ValidateEnv
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2059
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2060
Calls C<ValidateComp> for all the components installed on the drive that don't have a status of I<pending release>. Returns a reference to a list of components names that failed. May optionally be passed a component name and version of an external environment against which to validate. This mode may only be used when the current environment database is empty. It causes a complete set of database entries to be written corresponding to the external environment. However, a dummy signature file will be generated for components that fail their validation which contains the names of the binaries released in the external environment, but zero last modified times and sizes. This is to ensure that C<CheckEnv> continues to report these components as C<STATUS_DIRTY>.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2061
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2062
=head3 ValidateComp
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2063
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2064
Expects to be passed a component name, a version and optionally two scalar flags indicating:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2065
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2066
=over 4
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2067
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2068
=item whether validation should continue after the first failure is found (true means continue)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2069
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2070
=item whether source code should be validated
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2071
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2072
=back
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2073
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2074
Makes use of Manifest.pm and constructs manifest object of the current environment using the mrp file for the components and another manifest object using the manifest file available in the archive location of the previous release for the component. These objects are compared for their similarity and shall return STATUS_CLEAN if everything validates OK and returns STATUS_DIRTY otherwise.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2075
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2076
If for some reasons, validation through manifest objects is not possible, then the call is transferred to the old process of validation described herewith as follows:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2077
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2078
The process returns the overall status of the release, which is C<STATUS_DIRTY> if there are dirty binaries, C<STATUS_DIRTY_SOURCE> if the binaries are clean but there is dirty source code, or C<CLEAN> if everything validates OK. C<STATUS_DIRTY_SOURCE> will only ever be set if source code validation is turned on; otherwise all components will be set to either C<CLEAN> or C<DIRTY>.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2079
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2080
If the validation passes, but there is currently no entry for the release in the database, an entry is created with details corresponding to the version being validated. Whether or not an entry previously existed, if the validation passes, the component's status is set to C<STATUS_CLEAN> and a signature file is generated. If the validation failed and there is already an entry in the database for the component, it's status is set to C<STATUS_DIRTY> or C<STATUS_DIRTY_SOURCE> as appropriate.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2081
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2082
If the overall process results in validating the component status as DIRTY, then the manifest information for the current environment will be generated and saved as a manifest file in a temporary location within local file system for use during release processes.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2083
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2084
=head2 Environment Management
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2085
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2086
=head3 InstallComponent
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2087
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2088
Expects to be passed a component name, and a version. Unpacks the component's binaries, and creates (or updates) a complete database entry from the provided version and information read out of the release's C<RelData> object.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2089
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2090
=head3 RemoveComponent
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2091
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2092
Expects to be passed a component name. Removes all the binary files associated with the installed version of the component, the component's signature file and the component's environment database record.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2093
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2094
=head3 DeleteSource
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2095
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2096
Expects to be passed a component name, a dryrun and a force flag. Removes all the source files associated with the installed version of the component. If dryrun is used the script just reports what it would do. If force is used the script would delete write-protected files.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2097
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2098
=head3 UnpackBinaries
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2099
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2100
Expects to be passed a component name, a version and a directory in which the release should be installed. Unpacks the component's binaries into the specified directory. The environment database is neither consulted, nor modified by this interface. It is intended to allow a set of released binaries to be temporarily unpacked (for example, for validation purposes)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2101
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2102
=head3 UnpackSource
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2103
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2104
Expects to be passed a component name, a version, a directory in which the release should be installed, a flag which represents the verbose level, a flag which represents to overwrite or not, an inidata and a flag which represent whether this process is for validation or not. Unpacks the component's source into the specified directory. The environment database is neither consulted, nor modified by this interface. Returns a change in category flag, when flag is 1 a change in category has been found. Change in category flag is only uses when a validation occurs.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2105
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2106
=head3 GetReleaseSize
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2107
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2108
Takes a component name and a version number. Returns the total size (in bytes) of the zips in the local archive making up a release.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2109
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2110
=head3 GetEnvironmentSize
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2111
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2112
Takes a component name and a version number. Returns the total size (in bytes) of the zips in the local archive making up the environment.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2113
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2114
=head2 Notable private methods
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2115
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2116
=head3 EvalidateDirectories
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2117
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2118
Expects to be passed two directory names; it will then run C<EValid> over the two. Returns a Boolean (whether the two directories match), and prints the results according to the verbosity level. If the verbosity level is 1 or greater, details of failures are printed. If the verbosity level is greater than 1, all C<EValid> output is printed.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2119
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2120
=head3 CheckForAddedFiles
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2121
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2122
This method checks to see if any files have been added to a component since it was packetised. It's part of source validation. It uses C<Find::File> to list all the files that are in a component's source code directory, then checks each of them are in a temporary directory which has been unzipped from the release packet.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2123
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2124
=head1 KNOWN BUGS
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2125
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2126
None.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2127
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2128
=head1 COPYRIGHT
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2129
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2130
 Copyright (c) 2000-2009 Nokia Corporation and/or its subsidiary(-ies).
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2131
 All rights reserved.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2132
 This component and the accompanying materials are made available
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2133
 under the terms of the License "Eclipse Public License v1.0"
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2134
 which accompanies this distribution, and is available
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2135
 at the URL "http://www.eclipse.org/legal/epl-v10.html".
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2136
 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2137
 Initial Contributors:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2138
 Nokia Corporation - initial contribution.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2139
 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2140
 Contributors:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2141
 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2142
 Description:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2143
 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2144
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
  2145
=cut