bug 648087 - support channel changing

git-svn-id: svn://10.0.0.236/trunk@262239 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
robert%roberthelmer.com
2011-04-27 19:18:11 +00:00
parent 644f0dd595
commit 9c94dfa32c
5 changed files with 110 additions and 26 deletions

View File

@@ -31,6 +31,7 @@ class Verify(ColumnFixture):
"dist": "String",
"distVersion": "String",
"force": "String",
"newchannel": "String",
"licenseUrl": "String",
"lastURI": "String",
"newURI": "String",
@@ -57,6 +58,7 @@ class Verify(ColumnFixture):
self.dist = ""
self.distVersion = ""
self.force = ""
self.newchannel = ""
# For storign the last retrieved AUS XML and its URI.
self.lastURI = ""
@@ -86,7 +88,7 @@ class Verify(ColumnFixture):
def hasLicenseUrl(self):
return (self.licenseUrl in self.getXml())
# Check to see if the XML has a licenseURL.
# Check to see if the XML has force set.
def hasForce (self):
return ('force=1' in self.getXml())
@@ -156,6 +158,9 @@ class Verify(ColumnFixture):
if (self.force == 'true'):
url += '?force=1'
if (self.newchannel != "NULL"):
url += '?newchannel=' + self.newchannel
return url

View File

@@ -179,3 +179,9 @@
|build|channel|complete|partial|hasUpdate?|hasComplete?|hasPartial?|isValidXml?|
|1000000001|channel|complete001|partial001|true|true|false|true|
|1000000002|channel|complete002|partial002|true|true|true|true|
!1 Channel changing (newchannel)
2 newchannel with release works
|aus.Verify|${host}|3|${product}|${version}|${platform}|${locale}|${osVersion}|
|build|channel|complete|partial|newchannel|hasUpdate?|hasComplete?|hasPartial?|isValidXml?|
|1000000002|channel|complete002|partial002|channel|true|true|false|true|

View File

@@ -156,6 +156,16 @@ $productBranchVersions = array(
),
);
// Specify which release should be used for channel-changers wanting to go to
// release or beta channels.
$latestRelease = array(
'Firefox' => array(
'beta' => '5.0',
'release' => '5.0'
)
);
// Config for memcache.
define('MEMCACHE_NAMESPACE', 'aus'); // set memcache namespace. Keep this string as short and simple as possible.
define('MEMCACHE_EXPIRE', 1800); // how long items are stored in memcache

View File

@@ -65,6 +65,9 @@ class Patch extends AUS_Object {
// Array the defines which channels are flagged as 'nightly' channels.
var $nightlyChannels;
// Array that defines which releases are considered the latest, for channel-changing purposes.
var $latestRelease;
// Valid patch flag.
var $isPatch;
@@ -81,13 +84,18 @@ class Patch extends AUS_Object {
var $hasUpdateInfo;
var $hasDetailsUrl;
// Is this a channel-changing request?
var $isChangingChannel;
/**
* Constructor.
*/
function Patch($productBranchVersions=array(),$nightlyChannels,$type='complete') {
function Patch($productBranchVersions=array(),$nightlyChannels,$type='complete',$latestRelease=null) {
$this->setProductBranchVersions($productBranchVersions);
$this->setNightlyChannels($nightlyChannels);
$this->setVar('latestRelease',$latestRelease);
$this->setVar('isPatch',false);
$this->setVar('isChangingChannel',false);
$this->setVar('patchType',$type);
$this->setVar('updateType','minor');
$this->setVar('hasUpdateInfo',false);
@@ -257,18 +265,35 @@ class Patch extends AUS_Object {
// Determine the branch of the client's version.
$branchVersion = $this->getBranch($product,$version,$channel);
// Otherwise, if it is a complete patch and a nightly channel, force the complete update to take the user to the latest build.
if ($this->isComplete() && $this->isNightlyChannel($channel)) {
if ($this->isComplete()) {
// If it is a complete patch and a nightly channel, force the complete update to take the user to the latest build.
if ($this->isNightlyChannel($channel) || $this->isChangingChannel()) {
$buildSource = 3;
if ($this->isNightlyChannel($channel)) {
$buildSource = 2;
} else {
if (isset($this->latestRelease[$product][$channel])) {
$branchVersion = $this->latestRelease[$product][$channel];
if (!$branchVersion) {
return false;
}
}
}
// Get the latest build that has an update for this branch.
$latestCompleteBuild = $this->getLatestCompleteBuild($product,$branchVersion,$platform,$locale);
// If we have the latest complete build, the path is valid, the file exists, and the filesize is greater than zero, we have a valid complete patch.
if ($latestCompleteBuild && $this->setPath($product,$platform,$locale,$branchVersion,$latestCompleteBuild,2,$channel) && file_exists($this->path) && filesize($this->path) > 0) {
$this->setSnippet($this->path);
return $this->isNewerBuild($build);
// Get the latest build that has an update for this branch.
$latestCompleteBuild = $this->getLatestCompleteBuild($product,$branchVersion,$platform,$locale,$buildSource,$channel);
// If we have the latest complete build, the path is valid, the file exists, and the filesize is greater than zero, we have a valid complete patch.
if ($latestCompleteBuild && $this->setPath($product,$platform,$locale,$branchVersion,$latestCompleteBuild,$buildSource,$channel) && file_exists($this->path) && filesize($this->path) > 0) {
$this->setSnippet($this->path);
if ($this->isChangingChannel()) {
return true;
} elseif ($this->isNightlyChannel($channel)) {
return $this->isNewerBuild($build);
}
}
}
}
}
// Otherwise, check for the partial snippet info. If an update exists, pass it along.
if ($this->isPartial() && $this->isNightlyChannel($channel) && $this->setPath($product,$platform,$locale,$branchVersion,$build,2,$channel) && file_exists($this->path) && filesize($this->path) > 0) {
@@ -325,6 +350,25 @@ class Patch extends AUS_Object {
return in_array($channel,$this->nightlyChannels);
}
/**
* Set whether this is a channel-changing request.
*
* @param boolean $option
* @return boolean
*/
function setChangingChannel($option) {
return $this->setVar('isChangingChannel', $option, true);
}
/**
* Determine whether or not this is a channel-changing request.
*
* @return boolean
*/
function isChangingChannel() {
return $this->isChangingChannel;
}
/**
* Determine whether or not the incoming version matches a (wildcard) version pattern
*
@@ -448,10 +492,10 @@ class Patch extends AUS_Object {
* @param string $platform
* @param return string|false false if there is no matching build
*/
function getLatestCompleteBuild($product,$branchVersion,$platform,$locale) {
function getLatestCompleteBuild($product,$branchVersion,$platform,$locale,$buildSource,$channel) {
$files = array();
$dir = SOURCE_DIR.'/2/'.$product.'/'.$branchVersion.'/'.$platform;
$dir = SOURCE_DIR.'/'.$buildSource.'/'.$product.'/'.$branchVersion.'/'.$platform;
// Find the build ids for the given product/branchVersion/platform. The last complete update
// is normally found in the second-to-last build directory.
@@ -472,7 +516,10 @@ class Patch extends AUS_Object {
// Return the directory with the non-empty complete.txt, which is the latest available build
foreach ($files as $buildID) {
if (!empty($buildID) && is_numeric($buildID)) {
$testPath = $dir.'/'.$buildID.'/'.$locale.'/complete.txt';
$testPath = $dir.'/'.$buildID.'/'.$locale.'/'.$channel.'/complete.txt';
if ($this->isNightlyChannel($channel)) {
$testPath = $dir.'/'.$buildID.'/'.$locale.'/complete.txt';
}
if (file_exists($testPath) && filesize($testPath) > 0) {
return $buildID;
}
@@ -481,7 +528,7 @@ class Patch extends AUS_Object {
}
// By default we return false, meaning that there is no latest complete update.
// Doing so means no updates for the nightly channel.
// Doing so means no updates for this channel.
return false;
}

View File

@@ -72,6 +72,11 @@ $rawPath = substr(urldecode($_SERVER['QUERY_STRING']),5,255);
// Munge he resulting string and store it in $path.
$path = explode('/',$rawPath);
// Check to see if the user is requesting channel changing.
if ( !(empty($_GET['newchannel']))) {
$newchannel = $_GET['newchannel'];
}
// Determine incoming request and clean inputs.
$clean = Array();
$clean['updateVersion'] = isset($path[0]) ? intval($path[0]) : null;
@@ -84,6 +89,7 @@ $clean['channel'] = isset($path[6]) ? trim($path[6]) : null;
$clean['platformVersion'] = isset($path[7]) ? trim($path[7]) : null;
$clean['dist'] = isset($path[8]) ? trim($path[8]) : null;
$clean['distVersion'] = isset($path[9]) ? trim($path[9]) : null;
$clean['newchannel'] = isset($newchannel) ? trim($newchannel) : null;
// Check to see if we have a beta on PPC, and if so don't update since beta 4
// doesn't work on PPC. See bug 588412.
@@ -192,10 +198,16 @@ if ($_cached_xml) {
$update = new Update();
// Instantiate our complete patch.
$completePatch = new Patch($productBranchVersions,$nightlyChannels,'complete');
$completePatch = new Patch($productBranchVersions,$nightlyChannels,'complete',$latestRelease);
$channel = $clean['channel'];
if (isset($clean['newchannel'])) {
$completePatch->setChangingChannel(true);
$channel = $clean['newchannel'];
}
// If our complete patch exists and is valid, set the patch line.
if ($completePatch->findPatch($clean['product'],$clean['platform'],$clean['locale'],$clean['version'],$clean['build'],$clean['channel']) && $completePatch->isPatch()) {
if ($completePatch->findPatch($clean['product'],$clean['platform'],$clean['locale'],$clean['version'],$clean['build'],$channel) && $completePatch->isPatch()) {
// Set our patchLine.
$xml->setPatchLine($completePatch);
@@ -223,16 +235,20 @@ if ($_cached_xml) {
}
}
// Instantiate our partial patch.
$partialPatch = new Patch($productBranchVersions,$nightlyChannels,'partial');
// if we are channel-switching, do not check for partial updates.
if (!isset($clean['newchannel'])) {
// If our partial patch exists and is valid, set the patch line.
if ($partialPatch->findPatch($clean['product'],$clean['platform'],$clean['locale'],$clean['version'],$clean['build'],$clean['channel'])
&& $partialPatch->isPatch()
&& $partialPatch->isOneStepFromLatest($completePatch->build)) {
$xml->setPatchLine($partialPatch);
}
// Instantiate our partial patch.
$partialPatch = new Patch($productBranchVersions,$nightlyChannels,'partial');
// If our partial patch exists and is valid, set the patch line.
if ($partialPatch->findPatch($clean['product'],$clean['platform'],$clean['locale'],$clean['version'],$clean['build'],$clean['channel'])
&& $partialPatch->isPatch()
&& $partialPatch->isOneStepFromLatest($completePatch->build)) {
$xml->setPatchLine($partialPatch);
}
}
// If we have valid patchLine(s), set up our output.
if ($xml->hasPatchLine() && $completePatch->isSupported($completePatch->updateType, $clean['product'], $clean['version'], $clean['platformVersion'], $unsupportedPlatforms)) {
$xml->startUpdate($update);