author | Dario Sestito <darios@symbian.org> |
Mon, 20 Jul 2009 15:38:47 +0100 | |
changeset 18 | a101a0b5d6d7 |
permissions | -rw-r--r-- |
18
a101a0b5d6d7
Add utility to remove releasable files from under the epoc32 tree
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
1 |
# Copyright (c) 2009 Symbian Foundation Ltd |
a101a0b5d6d7
Add utility to remove releasable files from under the epoc32 tree
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
2 |
# This component and the accompanying materials are made available |
a101a0b5d6d7
Add utility to remove releasable files from under the epoc32 tree
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
3 |
# under the terms of the License "Eclipse Public License v1.0" |
a101a0b5d6d7
Add utility to remove releasable files from under the epoc32 tree
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
4 |
# which accompanies this distribution, and is available |
a101a0b5d6d7
Add utility to remove releasable files from under the epoc32 tree
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
5 |
# at the URL "http://www.eclipse.org/legal/epl-v10.html". |
a101a0b5d6d7
Add utility to remove releasable files from under the epoc32 tree
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
6 |
# |
a101a0b5d6d7
Add utility to remove releasable files from under the epoc32 tree
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
7 |
# Initial Contributors: |
a101a0b5d6d7
Add utility to remove releasable files from under the epoc32 tree
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
8 |
# Symbian Foundation Ltd - initial contribution. |
a101a0b5d6d7
Add utility to remove releasable files from under the epoc32 tree
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
9 |
# |
a101a0b5d6d7
Add utility to remove releasable files from under the epoc32 tree
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
10 |
# Contributors: |
a101a0b5d6d7
Add utility to remove releasable files from under the epoc32 tree
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
11 |
# |
a101a0b5d6d7
Add utility to remove releasable files from under the epoc32 tree
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
12 |
# Description: |
a101a0b5d6d7
Add utility to remove releasable files from under the epoc32 tree
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
13 |
# Remove releasable files from under the epoc32 tree |
a101a0b5d6d7
Add utility to remove releasable files from under the epoc32 tree
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
14 |
|
a101a0b5d6d7
Add utility to remove releasable files from under the epoc32 tree
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
15 |
use strict; |
a101a0b5d6d7
Add utility to remove releasable files from under the epoc32 tree
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
16 |
use Getopt::Long; |
a101a0b5d6d7
Add utility to remove releasable files from under the epoc32 tree
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
17 |
|
a101a0b5d6d7
Add utility to remove releasable files from under the epoc32 tree
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
18 |
my $RELEASABLES_DIR = "/releasables"; |
a101a0b5d6d7
Add utility to remove releasable files from under the epoc32 tree
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
19 |
|
a101a0b5d6d7
Add utility to remove releasable files from under the epoc32 tree
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
20 |
my $releasablesdir = ""; |
a101a0b5d6d7
Add utility to remove releasable files from under the epoc32 tree
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
21 |
my $packageexpr = ''; |
a101a0b5d6d7
Add utility to remove releasable files from under the epoc32 tree
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
22 |
my $help = 0; |
a101a0b5d6d7
Add utility to remove releasable files from under the epoc32 tree
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
23 |
GetOptions(( |
a101a0b5d6d7
Add utility to remove releasable files from under the epoc32 tree
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
24 |
'packageexpr:s' => \$packageexpr, |
a101a0b5d6d7
Add utility to remove releasable files from under the epoc32 tree
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
25 |
'releasablesdir:s' => \$RELEASABLES_DIR, |
a101a0b5d6d7
Add utility to remove releasable files from under the epoc32 tree
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
26 |
'help!' => \$help |
a101a0b5d6d7
Add utility to remove releasable files from under the epoc32 tree
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
27 |
)); |
a101a0b5d6d7
Add utility to remove releasable files from under the epoc32 tree
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
28 |
|
a101a0b5d6d7
Add utility to remove releasable files from under the epoc32 tree
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
29 |
$packageexpr =~ m,([^/^\\]+)[/\\]([^/^\\]+),; |
a101a0b5d6d7
Add utility to remove releasable files from under the epoc32 tree
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
30 |
my $layer_expr = $1; |
a101a0b5d6d7
Add utility to remove releasable files from under the epoc32 tree
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
31 |
my $package_expr = $2; |
a101a0b5d6d7
Add utility to remove releasable files from under the epoc32 tree
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
32 |
$help = 1 if (!$layer_expr or !$package_expr); |
a101a0b5d6d7
Add utility to remove releasable files from under the epoc32 tree
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
33 |
|
a101a0b5d6d7
Add utility to remove releasable files from under the epoc32 tree
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
34 |
if ($help) |
a101a0b5d6d7
Add utility to remove releasable files from under the epoc32 tree
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
35 |
{ |
a101a0b5d6d7
Add utility to remove releasable files from under the epoc32 tree
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
36 |
print "Remove releasable files from under the epoc32 tree\n"; |
a101a0b5d6d7
Add utility to remove releasable files from under the epoc32 tree
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
37 |
print "Usage: perl truclean.pl --packageexpr=LAYER_EXPR/PACKAGE_EXPR [OPTIONS]\n"; |
a101a0b5d6d7
Add utility to remove releasable files from under the epoc32 tree
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
38 |
print "where:\n"; |
a101a0b5d6d7
Add utility to remove releasable files from under the epoc32 tree
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
39 |
print "\tLAYER_EXPR can be * or the name of a layer\n"; |
a101a0b5d6d7
Add utility to remove releasable files from under the epoc32 tree
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
40 |
print "\tPACKAGE_EXPR can be * or the name of a package\n"; |
a101a0b5d6d7
Add utility to remove releasable files from under the epoc32 tree
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
41 |
print "and OPTIONS are:\n"; |
a101a0b5d6d7
Add utility to remove releasable files from under the epoc32 tree
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
42 |
print "\t--releasablesdir=DIR Use DIR as the root of the releasables dir (default: $RELEASABLES_DIR\n"; |
a101a0b5d6d7
Add utility to remove releasable files from under the epoc32 tree
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
43 |
exit(0); |
a101a0b5d6d7
Add utility to remove releasable files from under the epoc32 tree
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
44 |
} |
a101a0b5d6d7
Add utility to remove releasable files from under the epoc32 tree
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
45 |
|
a101a0b5d6d7
Add utility to remove releasable files from under the epoc32 tree
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
46 |
$RELEASABLES_DIR = $releasablesdir if ($releasablesdir); |
a101a0b5d6d7
Add utility to remove releasable files from under the epoc32 tree
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
47 |
|
a101a0b5d6d7
Add utility to remove releasable files from under the epoc32 tree
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
48 |
my @layers = (); |
a101a0b5d6d7
Add utility to remove releasable files from under the epoc32 tree
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
49 |
if ($layer_expr eq '*') |
a101a0b5d6d7
Add utility to remove releasable files from under the epoc32 tree
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
50 |
{ |
a101a0b5d6d7
Add utility to remove releasable files from under the epoc32 tree
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
51 |
opendir(DIR, $RELEASABLES_DIR); |
a101a0b5d6d7
Add utility to remove releasable files from under the epoc32 tree
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
52 |
@layers = readdir(DIR); |
a101a0b5d6d7
Add utility to remove releasable files from under the epoc32 tree
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
53 |
closedir(DIR); |
a101a0b5d6d7
Add utility to remove releasable files from under the epoc32 tree
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
54 |
@layers = grep(!/^\.\.?$/, @layers); |
a101a0b5d6d7
Add utility to remove releasable files from under the epoc32 tree
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
55 |
} |
a101a0b5d6d7
Add utility to remove releasable files from under the epoc32 tree
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
56 |
else |
a101a0b5d6d7
Add utility to remove releasable files from under the epoc32 tree
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
57 |
{ |
a101a0b5d6d7
Add utility to remove releasable files from under the epoc32 tree
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
58 |
push(@layers, $layer_expr); |
a101a0b5d6d7
Add utility to remove releasable files from under the epoc32 tree
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
59 |
} |
a101a0b5d6d7
Add utility to remove releasable files from under the epoc32 tree
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
60 |
#for (@layers) {print "$_\n"}; |
a101a0b5d6d7
Add utility to remove releasable files from under the epoc32 tree
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
61 |
|
a101a0b5d6d7
Add utility to remove releasable files from under the epoc32 tree
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
62 |
for my $layer (@layers) |
a101a0b5d6d7
Add utility to remove releasable files from under the epoc32 tree
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
63 |
{ |
a101a0b5d6d7
Add utility to remove releasable files from under the epoc32 tree
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
64 |
my @packages = (); |
a101a0b5d6d7
Add utility to remove releasable files from under the epoc32 tree
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
65 |
if ($package_expr eq '*') |
a101a0b5d6d7
Add utility to remove releasable files from under the epoc32 tree
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
66 |
{ |
a101a0b5d6d7
Add utility to remove releasable files from under the epoc32 tree
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
67 |
opendir(DIR, "$RELEASABLES_DIR/$layer"); |
a101a0b5d6d7
Add utility to remove releasable files from under the epoc32 tree
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
68 |
@packages = readdir(DIR); |
a101a0b5d6d7
Add utility to remove releasable files from under the epoc32 tree
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
69 |
closedir(DIR); |
a101a0b5d6d7
Add utility to remove releasable files from under the epoc32 tree
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
70 |
@packages = grep(!/^\.\.?$/, @packages); |
a101a0b5d6d7
Add utility to remove releasable files from under the epoc32 tree
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
71 |
} |
a101a0b5d6d7
Add utility to remove releasable files from under the epoc32 tree
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
72 |
else |
a101a0b5d6d7
Add utility to remove releasable files from under the epoc32 tree
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
73 |
{ |
a101a0b5d6d7
Add utility to remove releasable files from under the epoc32 tree
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
74 |
push(@packages, $package_expr); |
a101a0b5d6d7
Add utility to remove releasable files from under the epoc32 tree
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
75 |
} |
a101a0b5d6d7
Add utility to remove releasable files from under the epoc32 tree
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
76 |
#for (@pacakges) {print "$_\n"}; |
a101a0b5d6d7
Add utility to remove releasable files from under the epoc32 tree
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
77 |
|
a101a0b5d6d7
Add utility to remove releasable files from under the epoc32 tree
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
78 |
for my $package (@packages) |
a101a0b5d6d7
Add utility to remove releasable files from under the epoc32 tree
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
79 |
{ |
a101a0b5d6d7
Add utility to remove releasable files from under the epoc32 tree
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
80 |
print "Processing package $layer/$package...\n"; |
a101a0b5d6d7
Add utility to remove releasable files from under the epoc32 tree
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
81 |
|
a101a0b5d6d7
Add utility to remove releasable files from under the epoc32 tree
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
82 |
open(FILE, "$RELEASABLES_DIR/$layer/$package/info.tsv"); |
a101a0b5d6d7
Add utility to remove releasable files from under the epoc32 tree
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
83 |
while (<FILE>) |
a101a0b5d6d7
Add utility to remove releasable files from under the epoc32 tree
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
84 |
{ |
a101a0b5d6d7
Add utility to remove releasable files from under the epoc32 tree
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
85 |
my $line = $_; |
a101a0b5d6d7
Add utility to remove releasable files from under the epoc32 tree
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
86 |
|
a101a0b5d6d7
Add utility to remove releasable files from under the epoc32 tree
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
87 |
if ($line =~ m,([^\t]*)\t([^\t]*)\t([^\t]*),) |
a101a0b5d6d7
Add utility to remove releasable files from under the epoc32 tree
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
88 |
{ |
a101a0b5d6d7
Add utility to remove releasable files from under the epoc32 tree
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
89 |
my $file = $1; |
a101a0b5d6d7
Add utility to remove releasable files from under the epoc32 tree
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
90 |
my $type = $2; |
a101a0b5d6d7
Add utility to remove releasable files from under the epoc32 tree
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
91 |
my $config = $3; |
a101a0b5d6d7
Add utility to remove releasable files from under the epoc32 tree
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
92 |
|
a101a0b5d6d7
Add utility to remove releasable files from under the epoc32 tree
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
93 |
if (-f $file) |
a101a0b5d6d7
Add utility to remove releasable files from under the epoc32 tree
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
94 |
{ |
a101a0b5d6d7
Add utility to remove releasable files from under the epoc32 tree
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
95 |
print "removing file: '$file'\n"; |
a101a0b5d6d7
Add utility to remove releasable files from under the epoc32 tree
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
96 |
unlink($file); |
a101a0b5d6d7
Add utility to remove releasable files from under the epoc32 tree
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
97 |
} |
a101a0b5d6d7
Add utility to remove releasable files from under the epoc32 tree
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
98 |
else |
a101a0b5d6d7
Add utility to remove releasable files from under the epoc32 tree
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
99 |
{ |
a101a0b5d6d7
Add utility to remove releasable files from under the epoc32 tree
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
100 |
print "WARNING: file '$file' doesn't exist.\n"; |
a101a0b5d6d7
Add utility to remove releasable files from under the epoc32 tree
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
101 |
} |
a101a0b5d6d7
Add utility to remove releasable files from under the epoc32 tree
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
102 |
} |
a101a0b5d6d7
Add utility to remove releasable files from under the epoc32 tree
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
103 |
else |
a101a0b5d6d7
Add utility to remove releasable files from under the epoc32 tree
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
104 |
{ |
a101a0b5d6d7
Add utility to remove releasable files from under the epoc32 tree
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
105 |
print "WARNING: line '$line' doesn't match the expected tab-separated pattern\n"; |
a101a0b5d6d7
Add utility to remove releasable files from under the epoc32 tree
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
106 |
} |
a101a0b5d6d7
Add utility to remove releasable files from under the epoc32 tree
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
107 |
} |
a101a0b5d6d7
Add utility to remove releasable files from under the epoc32 tree
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
108 |
close(FILE); |
a101a0b5d6d7
Add utility to remove releasable files from under the epoc32 tree
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
109 |
} |
a101a0b5d6d7
Add utility to remove releasable files from under the epoc32 tree
Dario Sestito <darios@symbian.org>
parents:
diff
changeset
|
110 |
} |