releasing/cbrtools/perl/CleanEnv
changeset 607 378360dbbdba
parent 602 3145852acc89
equal deleted inserted replaced
591:22486c9c7b15 607:378360dbbdba
       
     1 #!perl
       
     2 # Copyright (c) 2000-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 EnvDb;
       
    24 use CommandController;
       
    25 use CleanEnv;
       
    26 
       
    27 
       
    28 #
       
    29 # Globals.
       
    30 #
       
    31 
       
    32 my $verbose = 0;
       
    33 my $iniData = IniData->New();
       
    34 my $commandController = CommandController->New($iniData, 'CleanEnv');
       
    35 my $reallyClean = 0;
       
    36 my $force = 0;
       
    37 
       
    38 
       
    39 #
       
    40 # Main.
       
    41 #
       
    42 
       
    43 ProcessCommandLine();
       
    44 CleanEnv::CleanEnv($iniData, $reallyClean, $force, $verbose);
       
    45 print "Environment cleaned.\n" if ($force);
       
    46 
       
    47 
       
    48 #
       
    49 # Subs.
       
    50 #
       
    51 
       
    52 sub ProcessCommandLine {
       
    53   Getopt::Long::Configure ("bundling");
       
    54   my $help;
       
    55   GetOptions('h' => \$help, 'r' => \$reallyClean, 'f' => \$force, 'v+' => \$verbose);
       
    56 
       
    57   if ($help) {
       
    58     Usage(0);
       
    59   }
       
    60 
       
    61   unless ($#ARGV == -1) {
       
    62     print "Error: Invalid number of arguments\n";
       
    63     Usage(1);
       
    64   }
       
    65 }
       
    66 
       
    67 sub Usage {
       
    68   my $exitCode = shift;
       
    69 
       
    70   Utils::PrintDeathMessage($exitCode, "\nUsage: cleanenv [options]
       
    71 
       
    72 options:
       
    73 
       
    74 -h  help
       
    75 -r  really clean
       
    76 -f  force (don't prompt)
       
    77 -v  verbose output (-vv very verbose)\n");
       
    78 }
       
    79 
       
    80 __END__
       
    81 
       
    82 =head1 NAME
       
    83 
       
    84 CleanEnv - Restores an environment to a clean state.
       
    85 
       
    86 =head1 SYNOPSIS
       
    87 
       
    88   cleanenv [options]
       
    89 
       
    90 options:
       
    91 
       
    92   -h  help
       
    93   -r  really clean
       
    94   -f  force (don't prompt)
       
    95   -v  verbose output (-vv very verbose)
       
    96 
       
    97 =head1 DESCRIPTION
       
    98 
       
    99 Provides the user with the option of:
       
   100 
       
   101 =over 4
       
   102 
       
   103 =item *
       
   104 
       
   105 Re-installing dirty components.
       
   106 
       
   107 =item *
       
   108 
       
   109 Removing files of unknown origin.
       
   110 
       
   111 =back
       
   112 
       
   113 Normally when scanning an environment certain directories and files are ignored from the point of view of C<unknown origin> status (see the document I<Installation Guide> for more details), for example intermediate build files. The C<-r> switch causes C<CleanEnv> to not ignore any files when performing it's scan, and hence do a more comprehensive clean.
       
   114 
       
   115 Normally it will ask you if you want to delete files, and/or reinstall components. The -f flag supresses these questions, and should be used with care.
       
   116 
       
   117 =head1 KNOWN BUGS
       
   118 
       
   119 None.
       
   120 
       
   121 =head1 COPYRIGHT
       
   122 
       
   123  Copyright (c) 2000-2009 Nokia Corporation and/or its subsidiary(-ies).
       
   124  All rights reserved.
       
   125  This component and the accompanying materials are made available
       
   126  under the terms of the License "Eclipse Public License v1.0"
       
   127  which accompanies this distribution, and is available
       
   128  at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
   129  
       
   130  Initial Contributors:
       
   131  Nokia Corporation - initial contribution.
       
   132  
       
   133  Contributors:
       
   134  
       
   135  Description:
       
   136  
       
   137 
       
   138 =cut