releasing/cbrtools/perl/envsize
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
#!perl
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     2
# Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies).
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     3
# All rights reserved.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     4
# This component and the accompanying materials are made available
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     5
# under the terms of the License "Eclipse Public License v1.0"
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     6
# which accompanies this distribution, and is available
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     7
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     8
# 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     9
# Initial Contributors:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    10
# Nokia Corporation - initial contribution.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    11
# 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    12
# Contributors:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    13
# 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    14
# Description:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    15
# 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    16
#
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 FindBin;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    20
use lib "$FindBin::Bin";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    21
use Getopt::Long;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    22
use IniData;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    23
use RelData;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    24
use EnvDb;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    25
use Utils;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    26
use CommandController;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    27
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    28
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    29
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    30
# Globals.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    31
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    32
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    33
my $verbose = 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    34
my $iniData = IniData->New();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    35
my $commandController = CommandController->New($iniData, 'EnvSize');
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    36
my $comp;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    37
my $ver;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    38
my $quick;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    39
my $force;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    40
my $deltasize = 0;
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
# Main.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    44
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    45
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    46
ProcessCommandLine();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    47
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    48
my $envdb = EnvDb->Open($iniData, $verbose);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    49
$ver = $envdb->Version($comp) if (!$ver);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    50
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    51
EnvSize();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    52
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    53
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    54
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    55
# Subs.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    56
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    57
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    58
sub ProcessCommandLine {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    59
  Getopt::Long::Configure ("bundling");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    60
  my $help;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    61
  GetOptions("h" => \$help, "v+" => \$verbose, "q" => \$quick, 'f' => \$force, "d" => \$deltasize);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    62
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    63
  if ($help) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    64
    Usage(0);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    65
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    66
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    67
  if ($quick && $deltasize) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    68
    die "Error: It is not possible to use the -d and -q flags together\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    69
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    70
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    71
  $comp = shift @ARGV;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    72
  unless ($comp) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    73
    die "Error: No component name specified\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    74
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    75
  if (scalar @ARGV == 1) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    76
    $ver = shift @ARGV;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    77
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    78
  elsif (!scalar @ARGV == 0) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    79
    print "Error: Invalid number of arguments\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    80
    Usage(1);
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
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    84
sub Usage {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    85
  my $exitCode = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    86
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    87
  Utils::PrintDeathMessage($exitCode, "\nUsage: envsize [options] <component> <version>
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    88
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    89
options:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    90
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    91
-h  help
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    92
-v  verbose output (-vv very verbose)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    93
-f  (deprecated)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    94
-q  quick (don't print size of environment)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    95
-d  delta size (only matching versions)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    96
  
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    97
Note: It is not possible to use the -q and -d flags together.\n");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    98
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    99
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   100
sub EnvSize {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   101
  print "Size of component zips in local archive: ".$envdb->GetReleaseSize($comp, $ver)." bytes\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   102
  print "Size of whole environment zips in local archive: ".$envdb->GetEnvironmentSize($comp, $ver, 0)." bytes\n" if (!$quick && !$deltasize);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   103
  print "Size of environment zips in local archive that match the requested version: ".$envdb->GetEnvironmentSize($comp, $ver, $deltasize)." bytes\n" if (!$quick && $deltasize);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   104
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   105
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   106
__END__
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   107
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   108
=head1 NAME
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   109
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   110
EnvSize - Prints the size of the zip files of the component and its environment.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   111
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   112
=head1 SYNOPSIS
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   113
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   114
  envsize [options] component [version]
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   115
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   116
options:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   117
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   118
  -h  help
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   119
  -v  verbose output (-vv very verbose)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   120
  -q  quick; only print the size of the component, not its environment
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   121
  -d  delta size; only includes components that match the requested version
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   122
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   123
Note: It is not possible to use the C<-q> and C<-d> flags together.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   124
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   125
=head1 DESCRIPTION
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   126
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   127
Adds up the size of the zip files of the component. The result is printed,
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   128
in bytes.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   129
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   130
Unless you specify the C<-q> flag, it also adds up the sizes of all the
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   131
components that make up its environment, and prints that. (This, of course,
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   132
includes the component you specify).
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   133
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   134
If you specify the C<-d> flag it will add up the sizes of all the components in
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   135
the archive that match the version number specified.  This is useful if when you
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   136
create an environment you use the same version number for all new components,
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   137
you can see the size taken up by the components released in the new
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   138
environment, and not components which have been re-used.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   139
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   140
The first item of information is also shown in the output of C<viewnotes>.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   141
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   142
=head1 STATUS
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   143
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   144
Supported. If you find a problem, please report it to us.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   145
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   146
=head1 KNOWN BUGS
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   147
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   148
None.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   149
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   150
=head1 COPYRIGHT
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   151
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   152
 Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies).
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   153
 All rights reserved.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   154
 This component and the accompanying materials are made available
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   155
 under the terms of the License "Eclipse Public License v1.0"
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   156
 which accompanies this distribution, and is available
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   157
 at the URL "http://www.eclipse.org/legal/epl-v10.html".
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   158
 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   159
 Initial Contributors:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   160
 Nokia Corporation - initial contribution.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   161
 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   162
 Contributors:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   163
 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   164
 Description:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   165
 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   166
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   167
=cut