From 145446532d329e2e06e284688587419a3f85ca74 Mon Sep 17 00:00:00 2001 From: "rhelmer%mozilla.com" Date: Thu, 1 Feb 2007 06:37:48 +0000 Subject: [PATCH] move to new RunShellCommand, split into substeps, various fixes and features. r= preed, b=368579 --- tools/release/Bootstrap/Step/Tag/Bump.pm | 167 +++++++++++++++++++ tools/release/Bootstrap/Step/Tag/Mozilla.pm | 62 +++++++ tools/release/Bootstrap/Step/Tag/Talkback.pm | 68 ++++++++ tools/release/Bootstrap/Step/Tag/l10n.pm | 94 +++++++++++ 4 files changed, 391 insertions(+) create mode 100644 tools/release/Bootstrap/Step/Tag/Bump.pm create mode 100644 tools/release/Bootstrap/Step/Tag/Mozilla.pm create mode 100644 tools/release/Bootstrap/Step/Tag/Talkback.pm create mode 100644 tools/release/Bootstrap/Step/Tag/l10n.pm diff --git a/tools/release/Bootstrap/Step/Tag/Bump.pm b/tools/release/Bootstrap/Step/Tag/Bump.pm new file mode 100644 index 000000000000..12fa0e78099d --- /dev/null +++ b/tools/release/Bootstrap/Step/Tag/Bump.pm @@ -0,0 +1,167 @@ +# +# Tag::Bump substep. Bumps version files for Mozilla appropriately. +# +package Bootstrap::Step::Tag::Bump; +use Bootstrap::Step; +use Bootstrap::Config; +use Bootstrap::Step::Tag; +use File::Copy qw(move); +use File::Spec::Functions; +use MozBuild::Util qw(MkdirWithPath); +@ISA = ("Bootstrap::Step::Tag"); + +my $config = new Bootstrap::Config; + +sub Execute { + my $this = shift; + + my $product = $config->Get('var' => 'product'); + my $productTag = $config->Get('var' => 'productTag'); + my $branchTag = $config->Get('var' => 'branchTag'); + my $pullDate = $config->Get('var' => 'pullDate'); + my $version = $config->Get('var' => 'version'); + my $appName = $config->Get('var' => 'appName'); + my $logDir = $config->Get('var' => 'logDir'); + my $mozillaCvsroot = $config->Get('var' => 'mozillaCvsroot'); + my $tagDir = $config->Get('var' => 'tagDir'); + + my $minibranchTag = $productTag.'_MINIBRANCH'; + my $releaseTag = $productTag.'_RELEASE'; + my $releaseTagDir = catfile($tagDir, $releaseTag); + my $cvsrootTagDir = catfile($releaseTagDir, 'cvsroot'); + + # pull version files + my $moduleVer = $appName . '/app/module.ver'; + my $versionTxt = $appName . '/config/version.txt'; + my @bumpFiles = ('client.mk', $moduleVer, $versionTxt); + + # Check out Mozilla from the branch you want to tag. + # TODO this should support running without branch tag or pull date. + $this->Shell( + 'cmd' => 'cvs', + 'cmdArgs' => ['-d', $mozillaCvsroot, + 'co', + '-r', $branchTag, + '-D', $pullDate, + catfile('mozilla', 'client.mk'), + catfile('mozilla', $moduleVer), + catfile('mozilla', $versionTxt), + ], + 'dir' => $cvsrootTagDir, + 'logFile' => catfile($logDir, 'tag-bump_checkout.log'), + ); + + # Create a minibranch for the pull scripts so we can change them without + # changing anything on the original branch. + $this->CvsTag( + 'tagName' => $minibranchTag, + 'branch' => '1', + 'files' => \@bumpFiles, + 'coDir' => catfile($cvsrootTagDir, 'mozilla'), + 'logFile' => catfile($logDir, 'tag-bump_cvsroot_tag-' . $minibranchTag . '.log'), + ); + + # Update to the minibranch you just created. + $this->Shell( + 'cmd' => 'cvs', + 'cmdArgs' => ['up', '-r', $minibranchTag, + @bumpFiles, + ], + 'dir' => catfile($cvsrootTagDir, 'mozilla'), + 'logFile' => catfile($logDir, 'tag-bump_update.log'), + ); + + # pull version files from the version bump minibranch + $this->Shell( + 'cmd' => 'cvs', + 'cmdArgs' => ['up', '-r', $minibranchTag, + @bumpFiles, + ], + 'dir' => catfile($cvsrootTagDir, 'mozilla'), + 'logFile' => catfile($logDir, 'tag-bump-pull_minibranch.log'), + ); + + ### Perform version bump + + my $parentDir = catfile($cvsrootTagDir, 'mozilla'); + foreach my $file (catfile($parentDir, $moduleVer), + catfile($parentDir, $versionTxt)) { + my $found = 0; + open(INFILE, "< $file") or die ("Could not open $file: $!"); + open(OUTFILE, "> $file.tmp") or die ("Could not open $file.tmp: $!"); + while() { + my $preVersion = $version . 'pre'; + if($_ =~ s/$preVersion/$version/) { + $found = 1; + } + + print OUTFILE $_; + } + close INFILE or die ("Could not close $file: $!"); + close OUTFILE or die ("Coule not close $file.tmp: $!"); + if (not $found) { + die("No " . $version . "pre in file $file: $!"); + } + + if (not move("$file.tmp", + "$file")) { + die "Cannot rename $clientMk.tmp to $clientMk: $!"; + } + } + + # Add the new product tag to the client.mk + my $clientMk = catfile($cvsrootTagDir, 'mozilla', 'client.mk'); + my $found = 0; + open(INFILE, "< $clientMk"); + open(OUTFILE, "> $clientMk.tmp"); + while() { + if ($_ =~ s/$branchTag/$releaseTag/g) { + $found = 1; + } + print OUTFILE $_; + } + close INFILE; + close OUTFILE; + + if (not $found) { + die("No $branchTag in file $clientMk : $!"); + } + + if (not move("$clientMk.tmp", + "$clientMk")) { + die "Cannot rename $clientMk.tmp to $clientMk: $!"; + } + + my $bumpCiMsg = 'version bump, remove pre tag for ' + . $product . ' ' . $version . ' release on ' + . $minibranchTag; + $this->Shell( + 'cmd' => 'cvs', + 'cmdArgs' => ['commit', '-m', $bumpCiMsg, + @bumpFiles, + ], + 'dir' => catfile($releaseTagDir, 'cvsroot', 'mozilla'), + 'logFile' => catfile($logDir, 'tag-bump_checkin.log'), + ); +} + +sub Verify { + my $this = shift; + my $logDir = $config->Get('var' => 'logDir'); + my $appName = $config->Get('var' => 'appName'); + + my $moduleVer = $appName . '/app/module.ver'; + my $versionTxt = $appName . '/config/version.txt'; + my @bumpFiles = ('client.mk', $moduleVer, $versionTxt); + + foreach my $file (@bumpFiles) { + foreach my $rule ('^Checking in ' . $file, '^done') { + $this->CheckLog( + 'log' => catfile($logDir, 'tag-bump_checkin.log'), + 'checkFor' => $rule, + ); + } + } +} + +1; diff --git a/tools/release/Bootstrap/Step/Tag/Mozilla.pm b/tools/release/Bootstrap/Step/Tag/Mozilla.pm new file mode 100644 index 000000000000..397b026c4cbc --- /dev/null +++ b/tools/release/Bootstrap/Step/Tag/Mozilla.pm @@ -0,0 +1,62 @@ +# +# Tag Mozilla substep. Applies appropriate tags to Mozilla source code. +# +package Bootstrap::Step::Tag::Mozilla; +use Bootstrap::Step; +use Bootstrap::Config; +use Bootstrap::Step::Tag; +use File::Copy qw(move); +use File::Spec::Functions; +use MozBuild::Util qw(MkdirWithPath); +@ISA = ("Bootstrap::Step::Tag"); + +my $config = new Bootstrap::Config; + +sub Execute { + my $this = shift; + my $product = $config->Get('var' => 'product'); + my $productTag = $config->Get('var' => 'productTag'); + my $branchTag = $config->Get('var' => 'branchTag'); + my $pullDate = $config->Get('var' => 'pullDate'); + my $rc = $config->Get('var' => 'rc'); + my $version = $config->Get('var' => 'version'); + my $appName = $config->Get('var' => 'appName'); + my $logDir = $config->Get('var' => 'logDir'); + my $mozillaCvsroot = $config->Get('var' => 'mozillaCvsroot'); + my $tagDir = $config->Get('var' => 'tagDir'); + + my $releaseTag = $productTag.'_RELEASE'; + my $rcTag = $productTag.'_RC'.$rc; + my $releaseTagDir = catfile($tagDir, $releaseTag); + my $cvsrootTagDir = catfile($releaseTagDir, 'cvsroot'); + + # Create the RELEASE and RC tags + foreach my $tag ($releaseTag, $rcTag) { + $this->CvsTag( + 'tagName' => $tag, + 'coDir' => catfile($cvsrootTagDir, 'mozilla'), + 'logFile' => catfile($logDir, + 'tag-mozilla_cvsroot_tag-' . $tag . '.log'), + ); + } +} + +sub Verify { + my $this = shift; + + my $productTag = $config->Get('var' => 'productTag'); + my $logDir = $config->Get('var' => 'logDir'); + my $rc = $config->Get('var' => 'rc'); + + my $releaseTag = $productTag.'_RELEASE'; + my $rcTag = $productTag.'_RC'.$rc; + + foreach my $tag ($releaseTag, $rcTag) { + $this->CheckLog( + 'log' => catfile($logDir, 'tag-mozilla_cvsroot_tag-' . $tag . '.log'), + 'checkFor' => '^T', + ); + } +} + +1; diff --git a/tools/release/Bootstrap/Step/Tag/Talkback.pm b/tools/release/Bootstrap/Step/Tag/Talkback.pm new file mode 100644 index 000000000000..eb1abb689c32 --- /dev/null +++ b/tools/release/Bootstrap/Step/Tag/Talkback.pm @@ -0,0 +1,68 @@ +# +# Tag step. Applies a CVS tag to the appropriate repositories. +# +package Bootstrap::Step::Tag::Talkback; +use Bootstrap::Step; +use Bootstrap::Config; +use Bootstrap::Step::Tag; +use File::Copy qw(move); +use File::Spec::Functions; +use MozBuild::Util qw(MkdirWithPath); +@ISA = ("Bootstrap::Step::Tag"); + +my $config = new Bootstrap::Config; + +sub Execute { + my $this = shift; + + my $product = $config->Get('var' => 'product'); + my $productTag = $config->Get('var' => 'productTag'); + my $branchTag = $config->Get('var' => 'branchTag'); + my $pullDate = $config->Get('var' => 'pullDate'); + my $logDir = $config->Get('var' => 'logDir'); + my $mofoCvsroot = $config->Get('var' => 'mofoCvsroot'); + my $tagDir = $config->Get('var' => 'tagDir'); + + my $releaseTag = $productTag.'_RELEASE'; + my $releaseTagDir = catfile($tagDir, $releaseTag); + + # Create the mofo tag directory. + my $mofoDir = catfile($releaseTagDir, 'mofo'); + if (not -d $mofoDir) { + MkdirWithPath('dir' => $mofoDir) + or die "Cannot mkdir $mofoDir: $!"; + } + + # Check out the talkback files from the branch you want to tag. + $this->Shell( + 'cmd' => 'cvs', + 'cmdArgs' => ['-d', $mofoCvsroot, 'co', '-r', $branchTag, '-D', + $pullDate, catfile('talkback', 'fullsoft')], + 'dir' => catfile($releaseTagDir, 'mofo'), + 'logFile' => catfile($logDir, 'tag-talkback_mofo-checkout.log'), + ); + + # Create the talkback RELEASE tag. + $this->CvsTag( + 'tagName' => $releaseTag, + 'coDir' => catfile($releaseTagDir, 'mofo', 'talkback', 'fullsoft'), + 'logFile' => catfile($logDir, + 'tag-talkback_mofo-tag-' . $releaseTag . '.log'), + ); +} + +sub Verify { + my $this = shift; + my $logDir = $config->Get('var' => 'logDir'); + my $productTag = $config->Get('var' => 'productTag'); + + my $releaseTag = $productTag.'_RELEASE'; + + $this->CheckLog( + 'log' => catfile($logDir, + 'tag-talkback_mofo-tag-' . $releaseTag . '.log'), + 'checkFor' => '^T', + ); +} + +1; diff --git a/tools/release/Bootstrap/Step/Tag/l10n.pm b/tools/release/Bootstrap/Step/Tag/l10n.pm new file mode 100644 index 000000000000..7b6eec09497d --- /dev/null +++ b/tools/release/Bootstrap/Step/Tag/l10n.pm @@ -0,0 +1,94 @@ +# +# Tag step. Applies a CVS tag to the appropriate repositories. +# +package Bootstrap::Step::Tag::l10n; +use Bootstrap::Step; +use Bootstrap::Config; +use Bootstrap::Step::Tag; +use File::Copy qw(move); +use File::Spec::Functions; +use MozBuild::Util qw(MkdirWithPath); +@ISA = ("Bootstrap::Step::Tag"); + +my $config = new Bootstrap::Config; + +sub Execute { + my $this = shift; + + my $product = $config->Get('var' => 'product'); + my $productTag = $config->Get('var' => 'productTag'); + my $branchTag = $config->Get('var' => 'branchTag'); + my $l10n_pullDate = $config->Get('var' => 'l10n_pullDate'); + my $rc = $config->Get('var' => 'rc'); + my $appName = $config->Get('var' => 'appName'); + my $logDir = $config->Get('var' => 'logDir'); + my $l10nCvsroot = $config->Get('var' => 'l10nCvsroot'); + my $tagDir = $config->Get('var' => 'tagDir'); + + my $releaseTag = $productTag.'_RELEASE'; + my $rcTag = $productTag.'_RC'.$rc; + my $releaseTagDir = catfile($tagDir, $releaseTag); + + # Create the l10n tag directory. + my $l10nDir = catfile($releaseTagDir, 'l10n'); + if (not -d $l10nDir) { + MkdirWithPath('dir' => $l10nDir) + or die "Cannot mkdir $l10nDir: $!"; + } + + # Grab list of shipped locales + my $shippedLocales = catfile($releaseTagDir, 'cvsroot', 'mozilla', + $appName, 'locales', 'shipped-locales'); + open (FILE, "< $shippedLocales") + or die "Cannot open file $shippedLocales: $!"; + my @locales = ; + close FILE or die "Cannot close file $shippedLocales: $!"; + + # Check out the l10n files from the branch you want to tag. + for my $locale (@locales) { + # only keep first column + $locale =~ s/(\s+).*//; + # remove line endings + $locale =~ s/(\n)//; + # skip en-US, this is the default locale + if ($locale eq 'en-US') { + next; + } + $this->Shell( + 'cmd' => 'cvs', + 'cmdArgs' => ['-d', $l10nCvsroot, 'co', '-r', $branchTag, '-D', + $l10n_pullDate, catfile('l10n', $locale)], + 'dir' => catfile($releaseTagDir, 'l10n'), + 'logFile' => catfile($logDir, 'tag-l10n_checkout.log'), + ); + } + + # Create the l10n RELEASE and RC tags. + foreach my $tag ($releaseTag, $rcTag) { + $this->CvsTag( + 'tagName' => $tag, + 'coDir' => catfile($releaseTagDir, 'l10n', 'l10n'), + 'logFile' => catfile($logDir, 'tag-l10n_tag_' . $tag. '.log'), + ); + } +} + +sub Verify { + my $this = shift; + + my $logDir = $config->Get('var' => 'logDir'); + my $productTag = $config->Get('var' => 'productTag'); + my $rc = $config->Get('var' => 'rc'); + + my $releaseTag = $productTag.'_RELEASE'; + my $rcTag = $productTag.'_RC'.$rc; + + foreach my $tag ($releaseTag, $rcTag) { + $this->CheckLog( + 'log' => catfile($logDir, 'tag-l10n_tag_' . $tag . '.log'), + 'checkFor' => '^T', + ); + } +} + +1;