common/tools/raptor/truclean.pl
author Simon Howkins <simonh@symbian.org>
Fri, 16 Oct 2009 15:11:28 +0100
changeset 680 81550e87fc91
parent 242 51e429810aba
permissions -rw-r--r--
Moved the generation of the release metadata entry for the MD5 zip outside of the parallel section, so it can't co-incide with the zipping of the binaries. Ensured that any errors generated when merging log files are not just hidden by putting them in the output file (which will render it not well-formed XML).
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
240
5705f5c8f10d Adding truclean step to the package build
Dario Sestito <darios@symbian.org>
parents:
diff changeset
     1
# Copyright (c) 2009 Symbian Foundation Ltd
5705f5c8f10d Adding truclean step to the package build
Dario Sestito <darios@symbian.org>
parents:
diff changeset
     2
# This component and the accompanying materials are made available
5705f5c8f10d Adding truclean step to the package build
Dario Sestito <darios@symbian.org>
parents:
diff changeset
     3
# under the terms of the License "Eclipse Public License v1.0"
5705f5c8f10d Adding truclean step to the package build
Dario Sestito <darios@symbian.org>
parents:
diff changeset
     4
# which accompanies this distribution, and is available
5705f5c8f10d Adding truclean step to the package build
Dario Sestito <darios@symbian.org>
parents:
diff changeset
     5
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
5705f5c8f10d Adding truclean step to the package build
Dario Sestito <darios@symbian.org>
parents:
diff changeset
     6
#
5705f5c8f10d Adding truclean step to the package build
Dario Sestito <darios@symbian.org>
parents:
diff changeset
     7
# Initial Contributors:
5705f5c8f10d Adding truclean step to the package build
Dario Sestito <darios@symbian.org>
parents:
diff changeset
     8
# Symbian Foundation Ltd - initial contribution.
5705f5c8f10d Adding truclean step to the package build
Dario Sestito <darios@symbian.org>
parents:
diff changeset
     9
#
5705f5c8f10d Adding truclean step to the package build
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    10
# Contributors:
5705f5c8f10d Adding truclean step to the package build
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    11
#
5705f5c8f10d Adding truclean step to the package build
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    12
# Description:
5705f5c8f10d Adding truclean step to the package build
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    13
# Extracts output text in <buildlog> context which doesn't belong to <recipe>'s
5705f5c8f10d Adding truclean step to the package build
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    14
5705f5c8f10d Adding truclean step to the package build
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    15
use strict;
5705f5c8f10d Adding truclean step to the package build
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    16
use Getopt::Long;
5705f5c8f10d Adding truclean step to the package build
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    17
242
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents: 240
diff changeset
    18
my $RELEASEABLES_DIR = "/releaseables";
240
5705f5c8f10d Adding truclean step to the package build
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    19
242
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents: 240
diff changeset
    20
my $releaseablesdir = "";
240
5705f5c8f10d Adding truclean step to the package build
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    21
my $packageexpr = '';
5705f5c8f10d Adding truclean step to the package build
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    22
my $help = 0;
5705f5c8f10d Adding truclean step to the package build
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    23
GetOptions((
5705f5c8f10d Adding truclean step to the package build
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    24
	'packageexpr:s' => \$packageexpr,
242
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents: 240
diff changeset
    25
	'releaseablesdir:s' => \$RELEASEABLES_DIR,
240
5705f5c8f10d Adding truclean step to the package build
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    26
	'help!' => \$help
5705f5c8f10d Adding truclean step to the package build
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    27
));
5705f5c8f10d Adding truclean step to the package build
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    28
5705f5c8f10d Adding truclean step to the package build
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    29
$packageexpr =~ m,([^/^\\]+)[/\\]([^/^\\]+),;
5705f5c8f10d Adding truclean step to the package build
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    30
my $layer_expr = $1;
5705f5c8f10d Adding truclean step to the package build
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    31
my $package_expr = $2;
5705f5c8f10d Adding truclean step to the package build
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    32
$help = 1 if (!$layer_expr or !$package_expr);
5705f5c8f10d Adding truclean step to the package build
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    33
5705f5c8f10d Adding truclean step to the package build
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    34
if ($help)
5705f5c8f10d Adding truclean step to the package build
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    35
{
5705f5c8f10d Adding truclean step to the package build
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    36
	print "Extracts text which doesn't belong to recipes from a raptor log file\n";
5705f5c8f10d Adding truclean step to the package build
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    37
	print "Usage: perl truclean.pl --packageexpr=LAYER_EXPR/PACKAGE_EXPR [OPTIONS]\n";
5705f5c8f10d Adding truclean step to the package build
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    38
	print "where:\n";
5705f5c8f10d Adding truclean step to the package build
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    39
	print "\tLAYER_EXPR can be * or the name of a layer\n";
5705f5c8f10d Adding truclean step to the package build
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    40
	print "\tPACKAGE_EXPR can be * or the name of a package\n";
5705f5c8f10d Adding truclean step to the package build
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    41
	print "and OPTIONS are:\n";
242
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents: 240
diff changeset
    42
	print "\t--releaseablesdir=DIR Use DIR as the root of the releaseables dir (default: $RELEASEABLES_DIR\n";
240
5705f5c8f10d Adding truclean step to the package build
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    43
	exit(0);
5705f5c8f10d Adding truclean step to the package build
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    44
}
5705f5c8f10d Adding truclean step to the package build
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    45
242
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents: 240
diff changeset
    46
$RELEASEABLES_DIR = $releaseablesdir if ($releaseablesdir);
240
5705f5c8f10d Adding truclean step to the package build
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    47
5705f5c8f10d Adding truclean step to the package build
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    48
my @layers = ();
5705f5c8f10d Adding truclean step to the package build
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    49
if ($layer_expr eq '*')
5705f5c8f10d Adding truclean step to the package build
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    50
{
242
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents: 240
diff changeset
    51
	opendir(DIR, $RELEASEABLES_DIR);
240
5705f5c8f10d Adding truclean step to the package build
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    52
	@layers = readdir(DIR);
5705f5c8f10d Adding truclean step to the package build
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    53
	closedir(DIR);
5705f5c8f10d Adding truclean step to the package build
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    54
	@layers = grep(!/^\.\.?$/, @layers);
5705f5c8f10d Adding truclean step to the package build
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    55
}
5705f5c8f10d Adding truclean step to the package build
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    56
else
5705f5c8f10d Adding truclean step to the package build
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    57
{
5705f5c8f10d Adding truclean step to the package build
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    58
	push(@layers, $layer_expr);
5705f5c8f10d Adding truclean step to the package build
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    59
}
5705f5c8f10d Adding truclean step to the package build
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    60
#for (@layers) {print "$_\n"};
5705f5c8f10d Adding truclean step to the package build
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    61
5705f5c8f10d Adding truclean step to the package build
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    62
for my $layer (@layers)
5705f5c8f10d Adding truclean step to the package build
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    63
{
5705f5c8f10d Adding truclean step to the package build
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    64
	my @packages = ();
5705f5c8f10d Adding truclean step to the package build
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    65
	if ($package_expr eq '*')
5705f5c8f10d Adding truclean step to the package build
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    66
	{
242
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents: 240
diff changeset
    67
		opendir(DIR, "$RELEASEABLES_DIR/$layer");
240
5705f5c8f10d Adding truclean step to the package build
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    68
		@packages = readdir(DIR);
5705f5c8f10d Adding truclean step to the package build
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    69
		closedir(DIR);
5705f5c8f10d Adding truclean step to the package build
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    70
		@packages = grep(!/^\.\.?$/, @packages);
5705f5c8f10d Adding truclean step to the package build
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    71
	}
5705f5c8f10d Adding truclean step to the package build
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    72
	else
5705f5c8f10d Adding truclean step to the package build
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    73
	{
5705f5c8f10d Adding truclean step to the package build
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    74
		push(@packages, $package_expr);
5705f5c8f10d Adding truclean step to the package build
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    75
	}
5705f5c8f10d Adding truclean step to the package build
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    76
	#for (@pacakges) {print "$_\n"};
5705f5c8f10d Adding truclean step to the package build
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    77
	
5705f5c8f10d Adding truclean step to the package build
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    78
	for my $package (@packages)
5705f5c8f10d Adding truclean step to the package build
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    79
	{
5705f5c8f10d Adding truclean step to the package build
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    80
		print "Processing package $layer/$package...\n";
5705f5c8f10d Adding truclean step to the package build
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    81
242
51e429810aba Modularized Raptor parser scripts
Dario Sestito <darios@symbian.org>
parents: 240
diff changeset
    82
		open(FILE, "$RELEASEABLES_DIR/$layer/$package/info.tsv");
240
5705f5c8f10d Adding truclean step to the package build
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    83
		while (<FILE>)
5705f5c8f10d Adding truclean step to the package build
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    84
		{
5705f5c8f10d Adding truclean step to the package build
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    85
			my $line = $_;
5705f5c8f10d Adding truclean step to the package build
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    86
			
5705f5c8f10d Adding truclean step to the package build
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    87
			if ($line =~ m,([^\t]*)\t([^\t]*)\t([^\t]*),)
5705f5c8f10d Adding truclean step to the package build
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    88
			{
5705f5c8f10d Adding truclean step to the package build
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    89
				my $file = $1;
5705f5c8f10d Adding truclean step to the package build
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    90
				my $type = $2;
5705f5c8f10d Adding truclean step to the package build
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    91
				my $config = $3;
5705f5c8f10d Adding truclean step to the package build
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    92
				
5705f5c8f10d Adding truclean step to the package build
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    93
				if (-f $file)
5705f5c8f10d Adding truclean step to the package build
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    94
				{
5705f5c8f10d Adding truclean step to the package build
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    95
					print "removing file: '$file'\n";
5705f5c8f10d Adding truclean step to the package build
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    96
					unlink($file);
5705f5c8f10d Adding truclean step to the package build
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    97
				}
5705f5c8f10d Adding truclean step to the package build
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    98
				else
5705f5c8f10d Adding truclean step to the package build
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    99
				{
5705f5c8f10d Adding truclean step to the package build
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   100
					print "WARNING: file '$file' doesn't exist.\n";
5705f5c8f10d Adding truclean step to the package build
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   101
				}
5705f5c8f10d Adding truclean step to the package build
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   102
			}
5705f5c8f10d Adding truclean step to the package build
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   103
			else
5705f5c8f10d Adding truclean step to the package build
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   104
			{
5705f5c8f10d Adding truclean step to the package build
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   105
				print "WARNING: line '$line' doesn't match the expected tab-separated pattern\n";
5705f5c8f10d Adding truclean step to the package build
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   106
			}
5705f5c8f10d Adding truclean step to the package build
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   107
		}
5705f5c8f10d Adding truclean step to the package build
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   108
		close(FILE);
5705f5c8f10d Adding truclean step to the package build
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   109
	}
5705f5c8f10d Adding truclean step to the package build
Dario Sestito <darios@symbian.org>
parents:
diff changeset
   110
}