public function autoUpdate()
{
$debugArgs = ['supplier' => $this->supplier->getName(), 'name' => $this->name];
try {
/**
* @var UpdateInfo[]
*/
$updateInfoArray = $this->updateCheck($this->supplier->getName(), $this->name, $this->manifest['version']);
foreach ($updateInfoArray as $updateInfo) {
if (!$this->checkVersionSettings($updateInfo, $this->manifest['version'])) {
$this->log('Skipping Gadget update', LogLevel::INFO, ['info' => $updateInfo->getResponse(), 'new_version' => $updateInfo->getVersion(), 'current_version' => $this->manifest['version']]);
continue;
}
/**
* @var UpdateFile
*/
$updateFile = $this->downloadUpdateFile($updateInfo);
$this->log('Downloaded update file', LogLevel::DEBUG, $debugArgs);
if ($this->bypassSecurityAndJustInstall) {
$this->log('Gadget update verification bypassed', LogLevel::ALERT, $debugArgs);
$this->install($updateInfo, $updateFile);
return;
}
/**
* Don't proceed unless we've verified the signatures
*/
if ($this->verifyUpdateSignature($updateInfo, $updateFile)) {
if ($this->checkKeyggdrasil($updateInfo, $updateFile)) {
$this->install($updateInfo, $updateFile);
} else {
$this->log('Keyggdrasil check failed for this Gadget', LogLevel::ALERT, $debugArgs);
self::$continuumLogger->store(LogLevel::ALERT, 'Gadget update failed -- checksum not registered in Keyggdrasil', $this->getLogContext($updateInfo, $updateFile));
}
} else {
$this->log('Signature check failed for this Gadget', LogLevel::ALERT, $debugArgs);
self::$continuumLogger->store(LogLevel::ALERT, 'Gadget update failed -- invalid signature', $this->getLogContext($updateInfo, $updateFile));
}
}
} catch (NoAPIResponse $ex) {
// We should log this.
$this->log('Automatic update failure: NO API Response.', LogLevel::ERROR, \Airship\throwableToArray($ex));
self::$continuumLogger->store(LogLevel::ALERT, 'Gadget update failed -- no API Response', ['action' => 'UPDATE', 'name' => $this->name, 'supplier' => $this->supplier->getName(), 'type' => $this->type]);
}
}