bug 462143: factor Bootstrap's HgClone/HgPush into Step.pm. r=nrthomas, patch=me

git-svn-id: svn://10.0.0.236/trunk@255002 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
bhearsum%mozilla.com 2008-11-12 14:15:56 +00:00
parent 9f0560d845
commit 3111902dca
12 changed files with 125 additions and 14 deletions

View File

@ -7,10 +7,12 @@ package Bootstrap::Step;
use IO::Handle;
use File::Spec::Functions;
use POSIX qw(strftime);
use File::Basename;
use File::Path;
use File::Temp qw(tempfile);
use Bootstrap::Config;
use Bootstrap::Util qw(CvsCatfile);
use Bootstrap::Util qw(CvsCatfile GetPushRepo);
use MozBuild::Util qw(RunShellCommand Email);
use base 'Exporter';
@ -282,6 +284,67 @@ sub CvsCo {
$this->Shell(%cvsCoArgs);
}
sub HgClone {
my $this = shift;
my %args = @_;
# Required arguments
die "ASSERT: Bootstrap::Step::HgClone(): null repo" if
(!exists($args{'repo'}));
my $repo = $args{'repo'};
die "ASSERT: Bootstrap::Step::HgClone(): null workDir" if
(!exists($args{'workDir'}));
my $workDir = $args{'workDir'};
my $repoDir = catfile($workDir, basename($repo));
if (-e $repoDir) {
$this->Log(msg => $repoDir . ' exists, removing it.');
rmtree($repoDir);
}
$this->Shell(
cmd => 'hg',
cmdArgs => ['clone', $repo],
dir => $workDir
);
}
sub HgPush {
my $this = shift;
my %args = @_;
my $config = new Bootstrap::Config();
# Required arguments
die "ASSERT: Bootstrap::Step::HgPush(): null repo" if
(!exists($args{'repo'}));
my $repo = $args{'repo'};
die "ASSERT: Bootstrap::Step::HgPush(): null dir" if
(!exists($args{'workDir'}));
my $workDir = $args{'workDir'};
# Required config file variables
die "ASSERT: Bootstrap::Step::HgPush(): null hgSshKey" if
(! $config->Exists(sysvar => 'hgSshKey'));
my $hgSshKey = $config->Get(sysvar => 'hgSshKey');
die "ASSERT: Bootstrap::Step::HgPush(): null hgUsername" if
(! $config->Exists(var => 'hgUsername'));
my $hgUsername = $config->Get(var => 'hgUsername');
my $pushRepo = GetPushRepo(repo => $repo);
my @cmdArgs = ['push', '-e',
'ssh -l ' . $hgUsername . ' -i "' . $hgSshKey . '"',
$repo];
$this->Shell(
cmd => 'hg',
cmdArgs => @cmdArgs,
dir => $workDir
);
}
sub CreateCandidatesDir() {
my $this = shift;

View File

@ -66,10 +66,9 @@ sub Execute {
# bug 456400 moved the BumpPatcherConfig logic to an external script to
# more easily support both CVS and Mercurial based releases
$this->Shell(
cmd => 'hg',
cmdArgs => ['clone', $hgToolsRepo],
dir => catfile($versionedConfigBumpDir)
$this->HgClone(
repo => $hgToolsRepo,
workDir => catfile($versionedConfigBumpDir)
);
$this->CvsCo(
cvsroot => $mozillaCvsroot,

View File

@ -81,10 +81,9 @@ sub Execute {
# bug 449208 moved this logic to an external script to more easily
# support both CVS and Mercurial based releases
$this->Shell(
cmd => 'hg',
cmdArgs => ['clone', $hgToolsRepo],
dir => catfile($buildTagDir)
$this->HgClone(
repo => $hgToolsRepo,
workDir => catfile($buildTagDir)
);
$this->Shell(
cmd => 'perl',

View File

@ -10,6 +10,7 @@ use MozBuild::Util qw(RunShellCommand);
use base qw(Exporter);
our @EXPORT_OK = qw(CvsCatfile CvsTag
GetPushRepo
GetDiffFileList
GetFtpNightlyDir
LoadLocaleManifest
@ -245,6 +246,23 @@ sub CvsTag {
return RunShellCommand(%cvsTagArgs);
}
sub GetPushRepo {
my %args = @_;
my ($repo, $pushRepo);
# Required arguments
die "ASSERT: Bootstrap::Util::GetPushRepo(): null repo" if
(!exists($args{'repo'}));
$pushRepo = $repo = $args{'repo'};
$pushRepo =~ s/^https?/ssh/;
if ($pushRepo !~ m/^ssh/) {
die "ASSERT: Bootstrap::Util::GetPushRepo(): could not generate " .
"push repo for: $repo";
}
return $pushRepo;
}
sub GetDiffFileList {
my %args = @_;

View File

@ -81,3 +81,7 @@ symbolServerKey = /home/cltbld/.ssh/ffxbld_dsa
useTarGz = 1
useBetaChannel = 1
hgToolsRepo = https://hg.mozilla.org/build/tools
hgUsername = ffxbld
win32_hgSshKey = /c/Documents and Settings/cltbld/.ssh/ffxbld_dsa
linux_hgSshKey = /home/cltbld/.ssh/ffxbld_dsa
macosx_hgSshKey = /Users/cltbld/.ssh/ffxbld_dsa

View File

@ -80,4 +80,8 @@ symbolServerPath = /data/symbols
symbolServerKey = /home/cltbld/.ssh/id_rsa
useTarGz = 1
useBetaChannel = 1
hgToolsRepo = https://hg.mozilla.org/build/tools
hgToolsRepo = https://hg.mozilla.org/users/stage-ffxbld/tools
hgUsername = stage-ffxbld
win32_hgSshKey = /c/Documents and Settings/cltbld/.ssh/ffxbld_dsa
linux_hgSshKey = /home/cltbld/.ssh/ffxbld_dsa
macosx_hgSshKey = /Users/cltbld/.ssh/ffxbld_dsa

View File

@ -85,3 +85,7 @@ useTalkback = 0
useCvsCompression = 1
useBetaChannel = 1
hgToolsRepo = https://hg.mozilla.org/build/tools
hgUsername = ffxbld
win32_hgSshKey = /c/Documents and Settings/cltbld/.ssh/ffxbld_dsa
linux_hgSshKey = /home/cltbld/.ssh/ffxbld_dsa
macosx_hgSshKey = /Users/cltbld/.ssh/ffxbld_dsa

View File

@ -84,4 +84,8 @@ sshServer = fx-linux-1.9-slave1.build.mozilla.org
useTalkback = 0
useCvsCompression = 1
useBetaChannel = 0
hgToolsRepo = https://hg.mozilla.org/build/tools
hgToolsRepo = https://hg.mozilla.org/users/stage-ffxbld/tools
hgUsername = stage-ffxbld
win32_hgSshKey = /c/Documents and Settings/cltbld/.ssh/ffxbld_dsa
linux_hgSshKey = /home/cltbld/.ssh/ffxbld_dsa
macosx_hgSshKey = /Users/cltbld/.ssh/ffxbld_dsa

View File

@ -74,3 +74,7 @@ symbolServerKey = /home/cltbld/.ssh/tbirdbld_dsa
useTarGz = 1
useBetaChannel = 1
hgToolsRepo = https://hg.mozilla.org/build/tools
hgUsername = ffxbld
win32_hgSshKey = /c/Documents and Settings/cltbld/.ssh/ffxbld_dsa
linux_hgSshKey = /home/cltbld/.ssh/ffxbld_dsa
macosx_hgSshKey = /Users/cltbld/.ssh/ffxbld_dsa

View File

@ -80,4 +80,8 @@ symbolServerPath = /data/symbols
symbolServerKey = /home/cltbld/.ssh/id_rsa
useTarGz = 1
useBetaChannel = 1
hgToolsRepo = https://hg.mozilla.org/build/tools
hgToolsRepo = https://hg.mozilla.org/users/stage-ffxbld/tools
hgUsername = stage-ffxbld
win32_hgSshKey = /c/Documents and Settings/cltbld/.ssh/ffxbld_dsa
linux_hgSshKey = /home/cltbld/.ssh/ffxbld_dsa
macosx_hgSshKey = /Users/cltbld/.ssh/ffxbld_dsa

View File

@ -84,4 +84,8 @@ sshServer = stage-old.mozilla.org
useTalkback = 0
useCvsCompression = 1
useBetaChannel = 0
hgToolsRepo = https://hg.mozilla.org/build/tools
hgToolsRepo = hg.mozilla.org/build/tools
hgUsername = ffxbld
win32_hgSshKey = /c/Documents and Settings/cltbld/.ssh/ffxbld_dsa
linux_hgSshKey = /home/cltbld/.ssh/ffxbld_dsa
macosx_hgSshKey = /Users/cltbld/.ssh/ffxbld_dsa

View File

@ -82,4 +82,8 @@ sshServer = fx-linux-1.9-slave1.build.mozilla.org
useTalkback = 0
useCvsCompression = 1
useBetaChannel = 0
hgToolsRepo = https://hg.mozilla.org/build/tools
hgToolsRepo = hg.mozilla.org/users/stage-ffxbld/tools
hgUsername = stage-ffxbld
win32_hgSshKey = /c/Documents and Settings/cltbld/.ssh/ffxbld_dsa
linux_hgSshKey = /home/cltbld/.ssh/ffxbld_dsa
macosx_hgSshKey = /Users/cltbld/.ssh/ffxbld_dsa