uh_parser/truclean.pl
changeset 281 b9b02349bd48
parent 258 08436a227940
child 297 822b287b5899
equal deleted inserted replaced
280:171a870d4d52 281:b9b02349bd48
    14 # Clean environment by removing releaseable files based on info.tsv
    14 # Clean environment by removing releaseable files based on info.tsv
    15 
    15 
    16 use strict;
    16 use strict;
    17 use Getopt::Long;
    17 use Getopt::Long;
    18 
    18 
    19 my $RELEASEABLES_DIR = "/releaseables";
    19 my $RELEASEABLES_DIR_DEFAULT = "\\build_info\\logs\\releaseables";
    20 
    20 
    21 my $releaseablesdir = "";
    21 my $releaseablesdir = "";
    22 my $packageexpr = '';
    22 my $packageexpr = '';
    23 my $help = 0;
    23 my $help = 0;
    24 GetOptions((
    24 GetOptions((
    25 	'packageexpr:s' => \$packageexpr,
    25 	'packageexpr:s' => \$packageexpr,
    26 	'releaseablesdir:s' => \$RELEASEABLES_DIR,
    26 	'releaseablesdir:s' => \$releaseablesdir,
    27 	'help!' => \$help
    27 	'help!' => \$help
    28 ));
    28 ));
    29 
    29 
    30 $packageexpr =~ m,([^/^\\]+)[/\\]([^/^\\]+),;
    30 $packageexpr =~ m,([^/^\\]+)[/\\]([^/^\\]+),;
    31 my $layer_expr = $1;
    31 my $layer_expr = $1;
    38 	print "Usage: perl truclean.pl --packageexpr=LAYER_EXPR/PACKAGE_EXPR [OPTIONS]\n";
    38 	print "Usage: perl truclean.pl --packageexpr=LAYER_EXPR/PACKAGE_EXPR [OPTIONS]\n";
    39 	print "where:\n";
    39 	print "where:\n";
    40 	print "\tLAYER_EXPR can be * or the name of a layer\n";
    40 	print "\tLAYER_EXPR can be * or the name of a layer\n";
    41 	print "\tPACKAGE_EXPR can be * or the name of a package\n";
    41 	print "\tPACKAGE_EXPR can be * or the name of a package\n";
    42 	print "and OPTIONS are:\n";
    42 	print "and OPTIONS are:\n";
    43 	print "\t--releaseablesdir=DIR Use DIR as the root of the releaseables dir (default: $RELEASEABLES_DIR\n";
    43 	print "\t--releaseablesdir=DIR Use DIR as the root of the releaseables dir (default: $RELEASEABLES_DIR_DEFAULT\n";
    44 	exit(0);
    44 	exit(0);
    45 }
    45 }
    46 
    46 
    47 $RELEASEABLES_DIR = $releaseablesdir if ($releaseablesdir);
    47 $releaseablesdir = $RELEASEABLES_DIR_DEFAULT if (!$releaseablesdir);
    48 
    48 
    49 my @layers = ();
    49 my @layers = ();
    50 if ($layer_expr eq '*')
    50 if ($layer_expr eq '*')
    51 {
    51 {
    52 	opendir(DIR, $RELEASEABLES_DIR);
    52 	opendir(DIR, $releaseablesdir);
    53 	@layers = readdir(DIR);
    53 	@layers = readdir(DIR);
    54 	closedir(DIR);
    54 	closedir(DIR);
    55 	@layers = grep(!/^\.\.?$/, @layers);
    55 	@layers = grep(!/^\.\.?$/, @layers);
    56 }
    56 }
    57 else
    57 else
    63 for my $layer (@layers)
    63 for my $layer (@layers)
    64 {
    64 {
    65 	my @packages = ();
    65 	my @packages = ();
    66 	if ($package_expr eq '*')
    66 	if ($package_expr eq '*')
    67 	{
    67 	{
    68 		opendir(DIR, "$RELEASEABLES_DIR/$layer");
    68 		opendir(DIR, "$releaseablesdir/$layer");
    69 		@packages = readdir(DIR);
    69 		@packages = readdir(DIR);
    70 		closedir(DIR);
    70 		closedir(DIR);
    71 		@packages = grep(!/^\.\.?$/, @packages);
    71 		@packages = grep(!/^\.\.?$/, @packages);
    72 	}
    72 	}
    73 	else
    73 	else
    78 	
    78 	
    79 	for my $package (@packages)
    79 	for my $package (@packages)
    80 	{
    80 	{
    81 		print "Processing package $layer/$package...\n";
    81 		print "Processing package $layer/$package...\n";
    82 
    82 
    83 		open(FILE, "$RELEASEABLES_DIR/$layer/$package/info.tsv");
    83 		open(FILE, "$releaseablesdir/$layer/$package/info.tsv");
    84 		while (<FILE>)
    84 		while (<FILE>)
    85 		{
    85 		{
    86 			my $line = $_;
    86 			my $line = $_;
    87 			
    87 			
    88 			if ($line =~ m,([^\t]*)\t([^\t]*)\t([^\t]*),)
    88 			if ($line =~ m,([^\t]*)\t([^\t]*)\t([^\t]*),)