dummy_foundation/update_repos.pl
changeset 4 60053dab7e2a
parent 3 8b87ea768cb8
child 5 c34a018f3291
equal deleted inserted replaced
3:8b87ea768cb8 4:60053dab7e2a
     1 #! perl
       
     2 
       
     3 use strict;
       
     4 
       
     5 # update_repos.pl
       
     6 
       
     7 my %repos;
       
     8 
       
     9 foreach my $layer ("os", "mw", "app")
       
    10 	{
       
    11 	opendir DIR, $layer;
       
    12 	my @packages = grep !/^\.\.?$/, readdir DIR;
       
    13 	closedir DIR;
       
    14 	foreach my $package (@packages)
       
    15 		{
       
    16 		$repos{"$layer/$package"} = 1;
       
    17 		}
       
    18 	}
       
    19 
       
    20 print join("\n",sort keys %repos,"","");
       
    21 
       
    22 my $tree = "/opt/hg/repos/sf/";
       
    23 
       
    24 foreach my $layer ("os", "mw", "app")
       
    25 	{
       
    26 	opendir DIR, "$tree$layer";
       
    27 	my @packages = grep !/^\.\.?$/, readdir DIR;
       
    28 	closedir DIR;
       
    29 	foreach my $package (@packages)
       
    30 		{
       
    31 		if (defined $repos{"$layer/$package"})
       
    32 			{
       
    33 			# this one is still relevant
       
    34 			next;
       
    35 			}
       
    36 		# package name has changed, I expect
       
    37 		print "Old package $layer/$package is now obsolete\n";
       
    38 		rename "$tree$layer/$package", "$tree"."obsolete/".$package;
       
    39 		}
       
    40 	}
       
    41 
       
    42 foreach my $repo (sort keys %repos)
       
    43 	{
       
    44 	print "\n\nProcessing $repo\n";
       
    45 	my ($layer,$package) = split /\//, $repo;
       
    46 	my $master = "$tree$repo/MCL_$package/.hg";
       
    47 	
       
    48 	if (-d $master)
       
    49 		{
       
    50 		# repo already exists - move it into place
       
    51 		rename "$tree$repo/MCL_$package/.hg", "$repo/.hg";
       
    52 		}
       
    53 	else
       
    54 		{
       
    55 		# New repo
       
    56 		print "New repository $repo\n";
       
    57 		mkdir "$tree$layer";
       
    58 		mkdir "$tree$layer/$package";
       
    59 		mkdir "$tree$layer/$package/MCL_$package";
       
    60 		}
       
    61 		
       
    62 	chdir $repo;
       
    63 	system("hg","init") if (!-d ".hg");
       
    64 	system("hg", "commit", "--addremove", "-m", "updated $repo");
       
    65 	chdir "../..";
       
    66 	rename "$repo/.hg", "$tree$repo/MCL_$package/.hg";
       
    67 	}
       
    68 
       
    69