|
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 File::Path; |
|
26 |
|
27 |
|
28 # |
|
29 # Globals. |
|
30 # |
|
31 |
|
32 my $verbose = 0; |
|
33 my $dryrun = 0; |
|
34 my $iniData = IniData->New(); |
|
35 my $commandController = CommandController->New($iniData, 'RemoveSource'); |
|
36 my $envDb; |
|
37 my $comp; |
|
38 my $force; |
|
39 |
|
40 |
|
41 # |
|
42 # Main. |
|
43 # |
|
44 |
|
45 ProcessCommandLine(); |
|
46 RemoveSource(); |
|
47 |
|
48 |
|
49 # |
|
50 # Subs. |
|
51 # |
|
52 |
|
53 sub ProcessCommandLine { |
|
54 Getopt::Long::Configure ("bundling"); |
|
55 my $help; |
|
56 GetOptions('h' => \$help, 'v+' => \$verbose, 'd' => \$dryrun, 'f' => \$force); |
|
57 |
|
58 if ($help) { |
|
59 Usage(0); |
|
60 } |
|
61 |
|
62 $comp = shift @ARGV; |
|
63 |
|
64 unless ($#ARGV == -1) { |
|
65 print "Error: Invalid number of arguments\n"; |
|
66 Usage(1); |
|
67 } |
|
68 |
|
69 $envDb = EnvDb->Open($iniData, $verbose); |
|
70 } |
|
71 |
|
72 sub Usage { |
|
73 my $exitCode = shift; |
|
74 |
|
75 Utils::PrintDeathMessage($exitCode, "\nUsage: removesource [options] <component> |
|
76 |
|
77 options: |
|
78 |
|
79 -h help |
|
80 -d dry run - don't do anything, just state what would happen |
|
81 -v verbose output (-vv very verbose) |
|
82 -f force - even delete write-protected stuff\n"); |
|
83 } |
|
84 |
|
85 sub RemoveSource { |
|
86 if (defined $comp) { |
|
87 $envDb->DeleteSource($comp, $dryrun, $force); |
|
88 } |
|
89 else { |
|
90 print "About to remove the source for the entire environment. Continue? [y/n] "; |
|
91 my $response = <STDIN>; |
|
92 if ($response =~ /^y$/i) { |
|
93 my $versionInfo = $envDb->VersionInfo(); |
|
94 foreach my $thisComp (sort keys %{$versionInfo}) { |
|
95 eval { |
|
96 $envDb->DeleteSource($thisComp, $dryrun, $force); |
|
97 }; |
|
98 print "Problem removing source for \"$thisComp\" - continuing with others: $@\n" if $@; |
|
99 } |
|
100 } |
|
101 } |
|
102 } |
|
103 |
|
104 __END__ |
|
105 |
|
106 =head1 NAME |
|
107 |
|
108 RemoveSource - Removes the source code for one component or all |
|
109 |
|
110 =head1 SYNOPSIS |
|
111 |
|
112 removesource [options] [<component>] |
|
113 |
|
114 options: |
|
115 |
|
116 -h help |
|
117 -d dry run - only states what would happen, doesn't actually do it |
|
118 -f force - even deletes write protected stuff |
|
119 -v verbose output (-vv very verbose) |
|
120 |
|
121 =head1 DESCRIPTION |
|
122 |
|
123 Deletes the source code for a particular component. If no component is specifies, deletes all known source code in your environment. |
|
124 |
|
125 =head1 KNOWN BUGS |
|
126 |
|
127 None. |
|
128 |
|
129 =head1 COPYRIGHT |
|
130 |
|
131 Copyright (c) 2000-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
132 All rights reserved. |
|
133 This component and the accompanying materials are made available |
|
134 under the terms of the License "Eclipse Public License v1.0" |
|
135 which accompanies this distribution, and is available |
|
136 at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
137 |
|
138 Initial Contributors: |
|
139 Nokia Corporation - initial contribution. |
|
140 |
|
141 Contributors: |
|
142 |
|
143 Description: |
|
144 |
|
145 |
|
146 =cut |