--- a/tools/patcher/MozAUSLib.pm
+++ b/tools/patcher/MozAUSLib.pm
@@ -54,29 +54,31 @@ use MozBuild::Util qw(RunShellCommand Mk
require Exporter;
@ISA = qw(Exporter);
@EXPORT_OK = qw(CreatePartialMarFile CreatePartialMarPatchInfo
GetAUS2PlatformStrings GetBouncerPlatformStrings
ValidateToolsDirectory
EnsureDeliverablesDir
SubstitutePath
+ GetSnippetDirFromChannel
);
use strict;
##
## CONSTANTS
##
use vars qw($MAR_BIN $MBSDIFF_BIN $MAKE_BIN
$INCREMENTAL_UPDATE_BIN $UNWRAP_FULL_UPDATE_BIN
$TMPDIR_PREFIX
%BOUNCER_PLATFORMS %AUS2_PLATFORMS
- $DEFAULT_PARTIAL_MAR_OUTPUT_FILE);
+ $DEFAULT_PARTIAL_MAR_OUTPUT_FILE
+ $DEFAULT_SNIPPET_BASE_DIR $DEFAULT_SNIPPET_TEST_DIR);
$MAR_BIN = 'dist/host/bin/mar';
$MBSDIFF_BIN = 'dist/host/bin/mbsdiff';
$INCREMENTAL_UPDATE_BIN = 'tools/update-packaging/make_incremental_update.sh';
$UNWRAP_FULL_UPDATE_BIN = 'tools/update-packaging/unwrap_full_update.pl';
$MAKE_BIN = '/usr/bin/make';
@@ -90,16 +92,19 @@ use vars qw($MAR_BIN $MBSDIFF_BIN $MAKE_
%AUS2_PLATFORMS = ( 'macppc' => 'Darwin_ppc-gcc3',
'mac' => 'Darwin_Universal-gcc3',
'linux-i686' => 'Linux_x86-gcc3',
'win32' => 'WINNT_x86-msvc' );
$DEFAULT_PARTIAL_MAR_OUTPUT_FILE = 'partial.mar';
+$DEFAULT_SNIPPET_BASE_DIR = 'aus2';
+$DEFAULT_SNIPPET_TEST_DIR = $DEFAULT_SNIPPET_BASE_DIR . '.test';
+
sub EnsureDeliverablesDir
{
my %args = @_;
die "ASSERT: null config spec\n" if (not defined($args{'config'}));
my $configSpec = $args{'config'};
my $fullDeliverableDirPath = catfile($configSpec->GetDeliverableDir(),
@@ -312,9 +317,34 @@ sub SubstitutePath
$string =~ s/%locale%/$locale/g;
$string =~ s/%bouncer\-platform%/$bouncer_platform/g;
$string =~ s/%version%/$version/g;
$string =~ s/%app%/$app/g;
return $string;
}
+sub GetSnippetDirFromChannel {
+ my %args = @_;
+ die 'ASSERT: GetSnippetDirFromChannel(): null/invalid update config ' .
+ "object\n" if (!exists($args{'config'}) || ref($args{'config'}) ne 'HASH');
+ die "ASSERT: GetSnippetDirFromChannel(): null channel\n" if (
+ !exists($args{'channel'}));
+
+ my $channel = $args{'channel'};
+ my $currentUpdateConfig = $args{'config'};
+
+ die "ASSERT: GetSnippetDirFromChannel(): invalid update config object\n"
+ if (! exists($currentUpdateConfig->{'to'}) ||
+ !exists($currentUpdateConfig->{'from'}));
+
+ my $snippetDirTestKey = $channel . '-dir';
+
+ if (exists($currentUpdateConfig->{$snippetDirTestKey})) {
+ return $DEFAULT_SNIPPET_BASE_DIR . '.' .
+ $currentUpdateConfig->{$snippetDirTestKey};
+ } elsif ($channel =~ /test(-\w+)?$/) {
+ return $DEFAULT_SNIPPET_TEST_DIR;
+ } else {
+ return $DEFAULT_SNIPPET_BASE_DIR;
+ }
+}
1;
--- a/tools/patcher/patcher2.pl
+++ b/tools/patcher/patcher2.pl
@@ -46,51 +46,49 @@ use Getopt::Long;
use Data::Dumper;
use Cwd;
use English;
use IO::Handle;
use File::Path;
use File::Copy qw(move copy);
use File::Spec::Functions;
+use File::Basename;
use MozAUSConfig;
use MozAUSLib qw(CreatePartialMarFile
GetAUS2PlatformStrings
EnsureDeliverablesDir
- ValidateToolsDirectory SubstitutePath);
+ ValidateToolsDirectory SubstitutePath
+ GetSnippetDirFromChannel);
use MozBuild::Util qw(MkdirWithPath RunShellCommand DownloadFile HashFile);
$Data::Dumper::Indent = 1;
autoflush STDOUT 1;
autoflush STDERR 1;
##
## CONSTANTS
##
use vars qw($PID_FILE
$DEFAULT_HASH_TYPE
$DEFAULT_CVSROOT
$DEFAULT_SCHEMA_VERSION $CURRENT_SCHEMA_VERSION
- $SNIPPET_DIR $SNIPPET_TEST_DIR
$ST_SIZE );
$PID_FILE = 'patcher2.pid';
$DEFAULT_HASH_TYPE = 'SHA1';
$DEFAULT_CVSROOT = ':pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot';
$DEFAULT_SCHEMA_VERSION = 0;
$CURRENT_SCHEMA_VERSION = 1;
-$SNIPPET_DIR = 'aus2';
-$SNIPPET_TEST_DIR = $SNIPPET_DIR . '.test';
-
$ST_SIZE = 7;
sub main {
Startup();
my (%args, %move_args);
my $config = new MozAUSConfig();
@@ -673,17 +671,20 @@ sub CreateCompletePatchinfo {
path => $u_config->{$u}->{'license'},
locale => $l,
version => $to->{'appv'});
}
my $updateType = $config->GetCurrentUpdate()->{'updateType'};
for my $c (@channels) {
- my $aus_prefix = catfile($u, $SNIPPET_DIR,
+ my $snippetDir = GetSnippetDirFromChannel(
+ config => $config->GetCurrentUpdate(), channel => $c);
+
+ my $aus_prefix = catfile($u, $snippetDir,
$from_aus_app,
$from_aus_version,
$from_aus_platform,
$from_aus_buildid,
$l, $c);
my $complete_patch = $ul_config->{$l}->{'complete_patch'};
$complete_patch->{'info_path'} = catfile($aus_prefix,
@@ -739,18 +740,21 @@ sub CreateCompletePatchinfo {
my $testPatch = {};
foreach my $key (keys(%{$complete_patch})) {
$testPatch->{$key} = $complete_patch->{$key};
}
foreach my $testChan (split(/[\s,]+/,
$u_config->{$u}->{'testchannel'})) {
+ my $snippetDir = GetSnippetDirFromChannel(
+ config => $u_config->{$u}, channel => $testChan);
+
$testPatch->{'info_path'} = catfile($u,
- 'aus2.test', $from_aus_app,
+ $snippetDir, $from_aus_app,
$from_aus_version, $from_aus_platform,
$from_aus_buildid, $l, $testChan, 'complete.txt');
my $testUrlKey = $testChan . '-url';
if (exists($complete->{$testUrlKey})) {
$testPatch->{'url'} = SubstitutePath(
path => $complete->{$testUrlKey},
@@ -886,19 +890,19 @@ sub CreatePastReleasePatchinfo {
path => $config->GetCurrentUpdate()->{'license'},
locale => $locale,
version => $patchLocaleNode->{'appv'});
}
my $updateType = $config->GetCurrentUpdate()->{'updateType'};
foreach my $channel (@{$pastUpd->{'channels'}}) {
- my $ausDir = ($channel =~ /test(-\w+)?$/)
- ? $SNIPPET_TEST_DIR : $SNIPPET_DIR;
-
+ my $ausDir = GetSnippetDirFromChannel(config =>
+ $config->GetCurrentUpdate(), channel => $channel);
+
my $ausPrefix = catfile($prefixStr, $ausDir, $fromAusApp,
$fromAusVersion, $fromAusPlatform,
$fromAusBuildId, $locale,
$channel);
my $completePatch = {};
$completePatch ->{'info_path'} = catfile($ausPrefix,
'complete.txt');
@@ -1048,17 +1052,20 @@ sub CreatePartialPatchinfo {
path => $u_config->{$u}->{'license'},
locale => $l,
version => $to->{'appv'});
}
my $updateType = $u_config->{$u}->{'updateType'};
for my $c (@channels) {
- my $aus_prefix = catfile($u, $SNIPPET_DIR,
+ my $snippetDir = GetSnippetDirFromChannel(config =>
+ $u_config->{$u}, channel => $c);
+
+ my $aus_prefix = catfile($u, $snippetDir,
$from_aus_app,
$from_aus_version,
$from_aus_platform,
$from_aus_buildid,
$l,
$c);
my $partial_patch = $ul_config->{$l}->{'partial_patch'};
@@ -1113,18 +1120,21 @@ sub CreatePartialPatchinfo {
my $testPatch = {};
foreach my $key (keys(%{$partial_patch})) {
$testPatch->{$key} = $partial_patch->{$key};
}
foreach my $testChan (split(/[\s,]+/,
$u_config->{$u}->{'testchannel'})) {
+ my $snippetDir = GetSnippetDirFromChannel(config =>
+ $u_config->{$u}, channel => $testChan);
+
$testPatch->{'info_path'} = catfile($u,
- 'aus2.test', $from_aus_app,
+ $snippetDir, $from_aus_app,
$from_aus_version, $from_aus_platform,
$from_aus_buildid, $l, $testChan, 'partial.txt');
my $testChanKey = $testChan . '-url';
if (exists($partial->{$testChanKey})) {
$testPatch->{'url'} = SubstitutePath(
path => $partial->{$testChanKey},
@@ -1157,18 +1167,17 @@ sub CreatePartialPatchinfo {
sub write_patch_info {
my %args = @_;
my $patch = $args{'patch'};
my $schemaVersion = $args{'schemaVer'} || $DEFAULT_SCHEMA_VERSION;
my $info_path = $patch->{'info_path'};
- $info_path =~ m/^(.*)\/[^\/]*$/;
- my $info_path_parent = $1;
+ my $info_path_parent = dirname($patch->{'info_path'});
my $text;
if ($DEFAULT_SCHEMA_VERSION == $schemaVersion) {
$text = "$patch->{'type'}\n";
$text .= "$patch->{'url'}\n";
$text .= "$patch->{'hash_type'}\n";
$text .= "$patch->{'hash_value'}\n";