clone_packages/clone_all_packages.pl
changeset 325 28c70cc5e86f
parent 316 052986e0e361
equal deleted inserted replaced
324:c52fbeec9580 325:28c70cc5e86f
    57 -help          print this help information
    57 -help          print this help information
    58 -exec          execute command on each repository
    58 -exec          execute command on each repository
    59 -filter <RE>   only process repository paths matching regular expression <RE>
    59 -filter <RE>   only process repository paths matching regular expression <RE>
    60 -dummyrun      Dummy Run, don't execute any Mercurial commands.
    60 -dummyrun      Dummy Run, don't execute any Mercurial commands.
    61 -webhost       Web Mercurial host (defaults to developer.symbian.org)
    61 -webhost       Web Mercurial host (defaults to developer.symbian.org)
       
    62 -norev         Ignore any revision information in packagelist
    62 
    63 
    63 The -exec option processes the rest of the command line, treating it as
    64 The -exec option processes the rest of the command line, treating it as
    64 a command to apply to each repository in turn. Some keywords are expanded
    65 a command to apply to each repository in turn. Some keywords are expanded
    65 to repository-specific values, and "hg" is always expanded to "hg -R %REPO%"
    66 to repository-specific values, and "hg" is always expanded to "hg -R %REPO%"
    66 
    67 
    79   exit (1);  
    80   exit (1);  
    80   }
    81   }
    81 
    82 
    82 my @clone_options = (); # use ("--noupdate") to clone without extracting the source
    83 my @clone_options = (); # use ("--noupdate") to clone without extracting the source
    83 my @pull_options  = (); # use ("--rebase") to rebase your changes when pulling
    84 my @pull_options  = (); # use ("--rebase") to rebase your changes when pulling
    84 my $hostname = "developer-secure.symbian.org";
    85 my $hostname = "developer.symbian.org";
       
    86 my $pushhostname = "developer-secure.symbian.org";
       
    87 my $webhost_option = "";
    85 
    88 
    86 my $username = "";
    89 my $username = "";
    87 my $password = "";
    90 my $password = "";
    88 my $mirror = 0; # set to 1 if you want to mirror the repository structure
    91 my $mirror = 0; # set to 1 if you want to mirror the repository structure
    89 my $retries = 1;  # number of times to retry problem repos
    92 my $retries = 1;  # number of times to retry problem repos
    90 my $verbose = 0;  # turn on more tracing
    93 my $verbose = 0;  # turn on more tracing
    91 my $do_nothing = 0; # print the hg commands, don't actually do them
    94 my $do_nothing = 0; # print the hg commands, don't actually do them
    92 my $help = 0;
    95 my $help = 0;
    93 my $exec = 0;
    96 my $exec = 0;
    94 my $filter = "";
    97 my $filter = "";
       
    98 my $norev = 0; # ignore revision information in packagelist files
    95 my @packagelist_files = ();
    99 my @packagelist_files = ();
    96 
   100 
    97 # Analyse the rest of command-line parameters
   101 # Analyse the rest of command-line parameters
    98 if (!GetOptions(
   102 if (!GetOptions(
    99     "u|username=s" => \$username,
   103     "u|username=s" => \$username,
   105     "h|help" => \$help,
   109     "h|help" => \$help,
   106     "e|exec" => \$exec,
   110     "e|exec" => \$exec,
   107     "f|filter=s" => \$filter,
   111     "f|filter=s" => \$filter,
   108     "l|packagelist=s" => \@packagelist_files,
   112     "l|packagelist=s" => \@packagelist_files,
   109     "d|dummyrun" => \$do_nothing,
   113     "d|dummyrun" => \$do_nothing,
   110     "w|webhost=s" => \$hostname,
   114     "w|webhost=s" => \$webhost_option,
       
   115     "norev" => \$norev,
   111     ))
   116     ))
   112   {
   117   {
   113   Usage("Invalid argument");
   118   Usage("Invalid argument");
   114   }
   119   }
   115   
   120   
   116 Usage("Too many arguments") if (scalar @ARGV > 0 && !$exec);
   121 Usage("Too many arguments") if (scalar @ARGV > 0 && !$exec);
   117 Usage("Too few arguments for -exec") if (scalar @ARGV == 0 && $exec);
   122 Usage("Too few arguments for -exec") if (scalar @ARGV == 0 && $exec);
   118 Usage("") if ($help);
   123 Usage("") if ($help);
   119 
   124 
       
   125 if ($webhost_option)
       
   126 	{
       
   127 	$hostname = $webhost_option;
       
   128 	$pushhostname = $webhost_option;
       
   129 	}
       
   130 
   120 # Important: This script uses http access to the repositories, so
   131 # Important: This script uses http access to the repositories, so
   121 # the username and password will be stored as cleartext in the
   132 # the username and password will be stored as cleartext in the
   122 # .hg/hgrc file in each repository.
   133 # .hg/hgrc file in each repository.
   123 
   134 
   124 my $needs_id = 1; # assumed necessary for clone/pull
   135 my $needs_id = 1; # assumed necessary for clone/pull
   148   {
   159   {
   149   print "Password: ";
   160   print "Password: ";
   150   $password = <STDIN>;
   161   $password = <STDIN>;
   151   chomp $password;
   162   chomp $password;
   152   }
   163   }
   153 
       
   154 my %export_control_special_case = (
       
   155   "oss/MCL/sf/os/security" => 1,
       
   156   "oss/FCL/sf/os/security" => 1,
       
   157   );
       
   158 
   164 
   159 sub do_system(@)
   165 sub do_system(@)
   160   {
   166   {
   161   my (@cmd) = @_;
   167   my (@cmd) = @_;
   162   
   168   
   197       }
   203       }
   198     }
   204     }
   199   
   205   
   200   $path .= "/$destdir";   # this is where the repository will go
   206   $path .= "/$destdir";   # this is where the repository will go
   201 
   207 
   202   my $repo_url = "https://$username:$password\@$hostname/$package/";
   208   my $repo_push_url = "https://$username:$password\@$pushhostname/$package/";
   203   my $repo_push_url =$repo_url;
   209   my $repo_url = $repo_push_url;
   204   if ($license ne "sfl" && !$export_control_special_case{$package})
   210   if ($license ne "sfl")
   205     {
   211     {
   206     # user registration is not required for reading public package repositories
   212     # user registration is not required for reading public package repositories
   207     $repo_url = "http://$hostname/$package/";
   213     $repo_url = "http://$hostname/$package/";
   208     }
   214     }
   209   
   215   
   210   my @rev_options = ();
   216   my @rev_options = ();
   211   my $revision = $revisions{$package};
   217   my $revision = $revisions{$package};
   212   if (defined($revision))
   218   if (defined($revision) && $norev == 0)
   213     {
   219     {
   214     @rev_options = ("--rev", $revision);
   220     @rev_options = ("--rev", $revision);
   215     }
   221     }
   216   else
   222   else
   217     {
   223     {
   312       }
   318       }
   313  
   319  
   314  		# sources.csv format
   320  		# sources.csv format
   315  		# http://developer.symbian.org/oss/FCL/sf/app/browserui/,/sf/app/browserui,tag,tip_bulk,layers.sysdef.xml
   321  		# http://developer.symbian.org/oss/FCL/sf/app/browserui/,/sf/app/browserui,tag,tip_bulk,layers.sysdef.xml
   316  		# http://developer.symbian.org/oss/FCL/sf/app/browserui/,/sf/app/browserui,changeset,e086c7f635d5,layers.sysdef.xml
   322  		# http://developer.symbian.org/oss/FCL/sf/app/browserui/,/sf/app/browserui,changeset,e086c7f635d5,layers.sysdef.xml
   317 		if ($line =~ /^(http[^,]+),(\S+),\S+,(\S+),\S*$/)
   323 		if ($line =~ /^(http[^,]+),([^,]+),[^,]+,([^,]+),.*$/)
   318 			{
   324 			{
   319 			$line = $1;
   325 			$line = $1;
   320 			$revision = $3;
   326 			$revision = $3;
   321 			}
   327 			}
   322 
   328