maintain an maintenance_release version in api/setup/setup.inc.php, also move update-checker images to api

This commit is contained in:
Ralf Becker 2017-02-02 10:36:22 +01:00
parent e3bacb3565
commit be32282214
6 changed files with 47 additions and 14 deletions

View File

@ -14,6 +14,8 @@ $setup_info['api']['name'] = 'api';
$setup_info['api']['title'] = 'EGroupware API';
$setup_info['api']['version'] = '16.9.001';
$setup_info['api']['versions']['current_header'] = '1.29';
// maintenance release in sync with changelog in doc/rpm-build/debian.changes
$setup_info['api']['versions']['maintenance_release'] = '16.1.20170118';
$setup_info['api']['enable'] = 3;
$setup_info['api']['app_order'] = 1;
$setup_info['api']['license'] = 'GPL';

View File

@ -81,12 +81,12 @@ class Updates
{
return null;
}
return Html::a_href(Html::image('phpgwapi', 'security-update', lang('EGroupware security update %1 needs to be installed!', $versions['security'])),
return Html::a_href(Html::image('api', 'security-update', lang('EGroupware security update %1 needs to be installed!', $versions['security'])),
'http://www.egroupware.org/changelog', null, ' target="_blank"');
}
if ($GLOBALS['egw_info']['user']['apps']['admin'] && version_compare($api, $versions['current'], '<'))
{
return Html::a_href(Html::image('phpgwapi', 'update', lang('EGroupware maintenance update %1 available', $versions['current'])),
return Html::a_href(Html::image('api', 'update', lang('EGroupware maintenance update %1 available', $versions['current'])),
'http://www.egroupware.org/changelog', null, ' target="_blank"');
}
}
@ -121,7 +121,7 @@ class Updates
}
/**
* Get current API version from changelog or database, whichever is bigger
* Get current API version from api/setup/setup.inc.php "maintenance_release" or database, whichever is bigger
*
* @param string &$changelog on return path to changelog
* @return string
@ -130,16 +130,20 @@ class Updates
{
$changelog = EGW_SERVER_ROOT.'/doc/rpm-build/debian.changes';
return Cache::getTree(__CLASS__, 'api_version', function() use ($changelog)
return Cache::getTree(__CLASS__, 'api_version', function()
{
$version = preg_replace('/[^0-9.]/', '', $GLOBALS['egw_info']['server']['versions']['phpgwapi']);
// parse version from changelog
$matches = null;
if (($f = fopen($changelog, 'r')) && preg_match('/egroupware-epl \(([0-9.]+)/', fread($f, 80), $matches) &&
version_compare($version, $matches[1], '<'))
$version = preg_replace('/[^0-9.]/', '', $GLOBALS['egw_info']['server']['versions']['api']);
if (empty($GLOBALS['egw_info']['server']['versions']['maintenance_release']))
{
$version = $matches[1];
fclose($f);
$setup_info = null;
include (EGW_SERVER_ROOT.'/api/setup/setup.inc.php');
$GLOBALS['egw_info']['server']['versions'] += $setup_info['api']['versions'];
unset($setup_info);
}
if (version_compare($version, $GLOBALS['egw_info']['server']['versions']['maintenance_release'], '<'))
{
$version = $GLOBALS['egw_info']['server']['versions']['maintenance_release'];
}
return $version;
}, array(), 300);

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

View File

@ -595,13 +595,16 @@ function do_editchangelog()
throw new Exception("Changelog '$changelog' not found!");
}
file_put_contents($changelog, update_changelog(file_get_contents($changelog)));
update_api_setup($api_setup=$config['checkoutdir'].'/api/setup/setup.inc.php');
if (file_exists($config['checkoutdir'].'/.git'))
{
$cmd = $config['git']." commit -m 'Changelog for $config[version].$config[packaging]' ".$changelog;
$cmd = $config['git']." commit -m 'Changelog for $config[version].$config[packaging]' ".$changelog.' '.$api_setup;
}
else
{
$cmd = $svn." commit -m 'Changelog for $config[version].$config[packaging]' ".$changelog;
$cmd = $svn." commit -m 'Changelog for $config[version].$config[packaging]' ".$changelog.' '.$api_setup;
}
run_cmd($cmd);
@ -875,6 +878,30 @@ function update_changelog($content)
return $content;
}
/**
* Update content of api/setup/setup.inc.php file with new maintenance version
*
* @param string $path full path to "api/setup/setup.inc.php"
*/
function update_api_setup($path)
{
global $config;
if (!($content = file_get_contents($path)))
{
throw new Exception("Could not read file '$path' to update maintenance-version!");
}
$content = preg_replace('/'.preg_quote("\$setup_info['api']['versions']['maintenance_release']", '/').'[^;]+;',
"\$setup_info['api']['versions']['maintenance_release'] = '".$config['version'].'.'.$config['packaging']."';",
$content);
if (!file_put_contents($path, $content))
{
throw new Exception("Could not update file '$path' with maintenance-version!");
}
}
/**
* Sign sha1sum file
*/

View File

@ -52,8 +52,8 @@ $GLOBALS['egw_info']['server']['mcrypt_iv'] = '{MCRYPT_IV}';
$GLOBALS['egw_info']['flags']['page_start_time'] = microtime(true);
include(EGW_SERVER_ROOT.'/api/setup/setup.inc.php');
$GLOBALS['egw_info']['server']['versions'] = $setup_info['api']['versions'];
$GLOBALS['egw_info']['server']['versions']['phpgwapi'] = $GLOBALS['egw_info']['server']['versions']['api'] = $setup_info['api']['version'];
$GLOBALS['egw_info']['server']['versions']['current_header'] = $setup_info['api']['versions']['current_header'];
unset($setup_info);
$GLOBALS['egw_info']['server']['versions']['header'] = '1.29';