diff --git a/api/setup/setup.inc.php b/api/setup/setup.inc.php index 80bdaec128..3e18cfdd51 100644 --- a/api/setup/setup.inc.php +++ b/api/setup/setup.inc.php @@ -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'; diff --git a/api/src/Framework/Updates.php b/api/src/Framework/Updates.php index 68a9a57550..94b6bef301 100644 --- a/api/src/Framework/Updates.php +++ b/api/src/Framework/Updates.php @@ -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); diff --git a/api/templates/default/images/security-update.png b/api/templates/default/images/security-update.png new file mode 100644 index 0000000000..1a27f00cf0 Binary files /dev/null and b/api/templates/default/images/security-update.png differ diff --git a/api/templates/default/images/update.png b/api/templates/default/images/update.png new file mode 100644 index 0000000000..e290f917b0 Binary files /dev/null and b/api/templates/default/images/update.png differ diff --git a/doc/rpm-build/checkout-build-archives.php b/doc/rpm-build/checkout-build-archives.php index 50efbc5d92..d5899c091f 100755 --- a/doc/rpm-build/checkout-build-archives.php +++ b/doc/rpm-build/checkout-build-archives.php @@ -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 */ diff --git a/header.inc.php.template b/header.inc.php.template index 4e952ebb64..3ec4054b8c 100644 --- a/header.inc.php.template +++ b/header.inc.php.template @@ -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';