clone_BOM.pl
author William Roberts <williamr@symbian.org>
Wed, 08 Jul 2009 16:15:03 +0100
changeset 16 35c6c3f66bc4
parent 13 f57f08cb4e1d
permissions -rw-r--r--
Updated now that sf/os/security package has moved from sfl to oss
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
13
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
     1
#!/usr/bin/perl -w
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
     2
# Copyright (c) 2009 Symbian Foundation Ltd
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
     3
# This component and the accompanying materials are made available
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
     4
# under the terms of the License "Eclipse Public License v1.0"
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
     5
# which accompanies this distribution, and is available
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
     6
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
     7
#
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
     8
# Initial Contributors:
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
     9
# Symbian Foundation Ltd - initial contribution.
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
    10
# 
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
    11
# Contributors:
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
    12
#
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
    13
# Description:
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
    14
# Perl script to clone or update all Foundation repositories based on content of 
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
    15
# BOM (bill of materials) file provided with a PDK release
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
    16
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
    17
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
    18
use strict;
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
    19
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
    20
use XML::DOM ();
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
    21
use Getopt::Long;
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
    22
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
    23
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
    24
my ($help,$verbose,$build_info,$rincoming,$rstatus,$rclean);
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
    25
my $username="";
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
    26
my $password="";
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
    27
my $rclone=1;
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
    28
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
    29
my $opts_err = GetOptions(
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
    30
  "h|help" => \$help,			# print Usage
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
    31
  "b|build-info=s" => \$build_info,		    # build info xml file
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
    32
  "u|user=s" => \$username, # user name when pushing to foundation
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
    33
  "p|password=s" => \$password, # password when pushing to foundation
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
    34
  "status!"=> \$rstatus,     #flag to request hg status for each repo
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
    35
  "incoming!"=>\$rincoming,   #flag to request incoming for each repo from sf repositories
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
    36
  "clean!"=>\$rclean, # flag to request clean the working source tree
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
    37
  "clone!"=>\$rclone, # flag to request clone   
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
    38
  "verbose!" => \$verbose,		#verbosity, currently only on or off (verbose or noverbose)
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
    39
) or die ("Error processing options\n\n" . Usage() );
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
    40
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
    41
# check if there were any extra parameters ignored by GetOptions
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
    42
@ARGV and die ("Input not understood - unrecognised paramters : @ARGV \n\n" . Usage() );
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
    43
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
    44
if ($help)
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
    45
{
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
    46
    print Usage();
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
    47
    exit;
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
    48
}
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
    49
if (! defined ($build_info))
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
    50
{
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
    51
    die ("Need to specify the BOM file, e.g. -b build-info.xml\n\n".Usage());
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
    52
}
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
    53
if (!-f $build_info) {die " Can't find build info file $build_info\n"}
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
    54
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
    55
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
    56
if (defined($rincoming) || ($rclone))
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
    57
{
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
    58
  ## if you are going to try any operations on foundation host need password 
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
    59
  if ($username eq "" || $password eq "")
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
    60
  {
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
    61
    print "Must supply your username and password to talk to Foundation host\n";
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
    62
    exit 1;
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
    63
  }
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
    64
}
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
    65
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
    66
my ( $parser, $buildinfoxml );
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
    67
eval
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
    68
{
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
    69
    $parser = XML::DOM::Parser->new();
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
    70
    $buildinfoxml    = $parser->parsefile($build_info);
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
    71
};
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
    72
if ( $@ )
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
    73
{
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
    74
    print "Fatal XML error processing build info file: $@";
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
    75
}
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
    76
my @baseline_entries = $buildinfoxml->getElementsByTagName('baseline');
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
    77
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
    78
foreach my $repository (@baseline_entries)
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
    79
{
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
    80
#    print $repository->toString();
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
    81
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
    82
    my $baseline = $repository->getFirstChild->getNodeValue;
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
    83
    # e.g. E:/hg_cache/mercurial_master_prod/sfl/MCL/sf/tools/swconfigtools/#2:fa09df6b7e6a
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
    84
    $baseline =~ m/(.*?)#\d*:(.*)$/; 
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
    85
    my $repo_path = $1;      # e.g. E:/hg_cache/mercurial_master_prod/sfl/MCL/sf/tools/swconfigtools/
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
    86
    my $changeset = $2; # e.g fa09df6b7e6a
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
    87
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
    88
    $repo_path =~ m/.*?(oss|sfl).(MCL|FCL)(.*$)/;
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
    89
    my $license = $1;
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
    90
    my $codeline =$2;
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
    91
    my $package =$3;
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
    92
    my $sf_repo = "https://$username:$password\@developer.symbian.org/$1/$2$package";
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
    93
    $sf_repo =~ s!\\!\/!g;
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
    94
    my @dirs = split /\//, $package;
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
    95
    my $destdir = pop @dirs;  # ignore the package name, because Mercurial will create that
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
    96
    # Ensure the directories already exist as far as the parent of the repository
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
    97
    my $local_path = "";
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
    98
    foreach my $dir (@dirs)
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
    99
    {
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
   100
      $local_path = ($local_path eq "") ? $dir : "$local_path/$dir";
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
   101
      if (!-d $local_path)
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
   102
      {
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
   103
        mkdir $local_path;
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
   104
      }
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
   105
    }
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
   106
    $local_path .= "/$destdir";   # this is where the repository will go
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
   107
    $local_path =~ s!\\!\/!g;
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
   108
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
   109
    if($rclone)
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
   110
    {
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
   111
       if (-d "$local_path/.hg")
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
   112
       {
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
   113
          # The repository already exists, so just do an update
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
   114
          print "Updating $local_path from $sf_repo at changeset $changeset\n";
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
   115
          system("hg", "pull", "-R", $local_path, $sf_repo);
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
   116
          system("hg","-R", $local_path,"update",$changeset);
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
   117
      }
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
   118
      else
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
   119
      {
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
   120
          # hg clone -U    http://«user»:«password»@developer.symbian.org/sfl/MCL/adaptation/stubs/",
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
   121
          print "Cloning $local_path from $sf_repo and update to changeset $changeset \n";
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
   122
          # need to update the working directory otherwise the parent of the tag change create a new head
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
   123
          system("hg", "clone", "--noupdate",$sf_repo, $local_path);
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
   124
          system("hg","-R", $local_path,"update",$changeset);
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
   125
      }
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
   126
    }
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
   127
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
   128
    if (-d "$local_path/.hg")
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
   129
    {
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
   130
      if($rincoming)
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
   131
      {
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
   132
          system("hg","-R", $local_path,"incoming",$sf_repo);
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
   133
      }
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
   134
      if($rstatus)
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
   135
      {
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
   136
          print "Identify $local_path ";
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
   137
          system("hg","-R", $local_path, "identify");
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
   138
          system("hg","-R", $local_path, "status");
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
   139
      }
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
   140
      if($rclean)
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
   141
      {
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
   142
        print "Clean $local_path ";
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
   143
        system("hg","-R", $local_path,"update","-C",$changeset);
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
   144
        my @added =`hg -R $local_path status`;
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
   145
        foreach my $addedfile (@added)
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
   146
        {
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
   147
          $addedfile =~ s/\?\s*/\.\/$local_path\//;
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
   148
          $addedfile =~ s!\/!\\!g;
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
   149
          print "del $addedfile\n";
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
   150
       #   system("del", $addedfile);
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
   151
          #unlink($addedfile);       
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
   152
        }
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
   153
      }
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
   154
    }
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
   155
    else
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
   156
    {
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
   157
        print "ERROR: No repository found at $local_path\n";
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
   158
    }
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
   159
}
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
   160
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
   161
sub Usage
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
   162
{
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
   163
  return <<"EOF";
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
   164
Usage: clone_BOM.pl -b <build info file> [-status] [-incoming] [-u <user name> -p <password>] [-verbose]
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
   165
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
   166
Description:
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
   167
	Clones repositories listed in the build BOM 
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
   168
	Optionally can display status of local repositories
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
   169
	and preview of incoming changes from Foundation repos
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
   170
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
   171
Arguments:
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
   172
    -h -> Output this usage message;
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
   173
    -b -> file containing the build info (xml BOM format)
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
   174
    -u -> User name (required if accessing the Foundation repositories)
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
   175
    -p -> Password (required if accessing the Foundation repositories)
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
   176
    -status -> Query hg identify and hg status for each local repo
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
   177
    -incoming -> Query any incoming changes from the Foundation host
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
   178
    -clean -> clean the local source tree (n.b. removes local files not committed to mercurial)
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
   179
    -noclone -> skip the clone repositories step
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
   180
    -verbose -> more debug statements (optional, default off)
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
   181
EOF
f57f08cb4e1d Add script to clone repositories and create workspace based on the BOM produced by the platform build
Andy Simpson<andrews@symbian.org>
parents:
diff changeset
   182
}