cross-plat-dev-utils/get_upstream.pl
changeset 2 39c28ec933dd
equal deleted inserted replaced
1:820b22e13ff1 2:39c28ec933dd
       
     1 #!/usr/bin/perl
       
     2 # Copyright (c) 2010 Symbian Foundation Ltd
       
     3 # This component and the accompanying materials are made available
       
     4 # under the terms of the License "Eclipse Public License v1.0"
       
     5 # which accompanies this distribution, and is available
       
     6 # at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 #
       
     8 # Initial Contributors:
       
     9 # Mike Kinghan, mikek@symbian.org for Symbian Foundation Ltd - initial contribution.
       
    10 
       
    11 # Script to clone the upstream package at the baseline revision.
       
    12 
       
    13 use strict;
       
    14 use Cwd;
       
    15 use get_baseline;
       
    16 use File::Spec;
       
    17 
       
    18 if (!@ARGV or @ARGV > 1 or grep(/$ARGV[0]/,("-h","--help"))) {
       
    19     print "This script clones or updates the upstream package at the baseline revision " .
       
    20 		"from http://developer.symbian.org/oss/MCL/sftools/dev/build\n";
       
    21     print "Valid arguments are -h, --help, or CLONEDIR, where CLONEDIR is the" .
       
    22 		" name of the existing directory into which the upstream package will " .
       
    23 		"be cloned if this does not seem to have been already done Otherwise " .
       
    24 		"CLONEDIR/build will be updated.\n";
       
    25 	exit 0;
       
    26 }         
       
    27 my $clonedir = $ARGV[0];
       
    28 unless ( -d "$clonedir") {
       
    29 	die "*** Error: directory \"$clonedir\" does not exist ***";
       
    30 }
       
    31 my $baseline_rev = get_baseline();
       
    32 print ">>> Baseline revision is $baseline_rev\n"; 
       
    33 my $cwd = cwd;
       
    34 my $cmd;
       
    35 chdir $clonedir or die $!;
       
    36 print ">>> Changed to dir \"$clonedir\"\n";
       
    37 my $hg_dir = File::Spec->catfile("build",".hg");
       
    38 if ( -d $hg_dir) {
       
    39 	print ">>> There seems to a repo of the build package in \"$clonedir\"\n";
       
    40 	print ">>> Will try to update it\n";
       
    41 	chdir "build" or die $!;
       
    42 	print ">>> Changed to dir \"build\"\n";
       
    43 	$cmd = "hg update -c -r $baseline_rev ";
       
    44 
       
    45 }
       
    46 else {
       
    47 	print ">>> There is no existing repo in \"$clonedir\"\n";
       
    48 	print ">>> Will clone fresh\n";
       
    49  	$cmd = "hg clone -r $baseline_rev " .
       
    50 	"http://developer.symbian.org/oss/MCL/sftools/dev/build";
       
    51 } 
       
    52 print ">>> Executing: $cmd\n";
       
    53 my $rc = system($cmd) >> 8;
       
    54 chdir $cwd or die $!;
       
    55 print ">>> Changed to dir \"$cwd\"\n";
       
    56 exit $rc;
       
    57