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