changes to build scripts to package Composer generated vendor directory instead depending on PEAR and post_install to install dependencies via PEAR

This commit is contained in:
Ralf Becker 2015-01-21 12:46:41 +00:00
parent 9bd80cdfc4
commit 376ba2d2c6
5 changed files with 39 additions and 174 deletions

View File

@ -38,8 +38,8 @@ RedirectMatch ^(/principals/users/.*)$ /egroupware/groupdav.php$1
php_value max_execution_time 90
php_admin_value mbstring.func_overload 0
php_value memory_limit 128M
php_value include_path .:/usr/share/pear
php_admin_value open_basedir /usr/share/egroupware:/var/lib/egroupware:/tmp:/usr/share/pear:/usr/bin/zip:/usr/share/jpgraph:/usr/bin/tnef:/usr/bin/aspell:/usr/share/fonts
php_value include_path .
php_admin_value open_basedir /usr/share/egroupware:/var/lib/egroupware:/tmp:/usr/bin
php_value upload_max_filesize 64M
php_admin_value upload_tmp_dir /tmp
php_value post_max_size 65M
@ -66,11 +66,3 @@ RedirectMatch ^(/principals/users/.*)$ /egroupware/groupdav.php$1
# RewriteCond %{HTTPS} !^on$
# RewriteRule .* https://%{HTTP_HOST}/%{REQUEST_URI} [L,R]
#</Directory>
<Directory /usr/share/egroupware/phpsysinfo/>
php_admin_value open_basedir /
</Directory>
<Directory /usr/share/egroupware/gallery/>
php_admin_value open_basedir /usr/share/egroupware:/var/lib/egroupware:/tmp:/usr/share/pear:/usr/bin:/bin
</Directory>

View File

@ -10,6 +10,7 @@ Package: egroupware-epl
Architecture: all
Depends:
egroupware-epl-core (= ${binary:Version}),
egroupware-epl-vendor (= ${binary:Version}),
egroupware-epl-jdots (= ${binary:Version}),
egroupware-epl-pixelegg (= ${binary:Version}),
egroupware-epl-stylite (= ${binary:Version}),
@ -53,8 +54,7 @@ Depends: apache2,
php5-sqlite,
php5-mysql | php5-pgsql | php5-odbc,
php5-json,
php5-gd, php-pear,
egroupware-epl-egw-pear,
php5-gd,
php5-mcrypt,
php5-xsl,
${misc:Depends}
@ -336,6 +336,17 @@ Description: web-based groupware suite - tracker application
This EGroupware application is a universal tracker for bugs, feature
requests, etc. with voting and bounties.
Package: egroupware-epl-vendor
Architecture: all
Depends: ${misc:Depends}
Description: web-based groupware suite - external dependencies
${commondesc}
.
With this package EGroupware no longer depends on PEAR.
Dependencies include:
- diverse Horde framework packages like Horde_Imap_Client
- some PEAR packages incl. PEAR itself
Package: egroupware-epl-wiki
Architecture: all
Depends: egroupware-epl-core (>= ${binary:Version}),

View File

@ -1,6 +1,6 @@
Format: 1.0
Source: egroupware-epl
Binary: egroupware-epl, egroupware-epl-core, egroupware-epl-bookmarks, egroupware-epl-calendar, egroupware-epl-developer-tools, egroupware-epl-emailadmin, egroupware-epl-esync, egroupware-epl-mail, egroupware-epl-filemanager, egroupware-epl-infolog, egroupware-epl-manual, egroupware-epl-news-admin, egroupware-epl-notifications, egroupware-epl-phpbrain, egroupware-epl-projectmanager, egroupware-epl-registration, egroupware-epl-resources, egroupware-epl-sambaadmin, egroupware-epl-sitemgr, egroupware-epl-timesheet, egroupware-epl-tracker, egroupware-epl-wiki, egroupware-epl-jdots, egroupware-epl-pixelegg
Binary: egroupware-epl, egroupware-epl-core, egroupware-epl-vendor, egroupware-epl-bookmarks, egroupware-epl-calendar, egroupware-epl-developer-tools, egroupware-epl-emailadmin, egroupware-epl-esync, egroupware-epl-mail, egroupware-epl-filemanager, egroupware-epl-infolog, egroupware-epl-manual, egroupware-epl-news-admin, egroupware-epl-notifications, egroupware-epl-phpbrain, egroupware-epl-projectmanager, egroupware-epl-registration, egroupware-epl-resources, egroupware-epl-sambaadmin, egroupware-epl-sitemgr, egroupware-epl-timesheet, egroupware-epl-tracker, egroupware-epl-wiki, egroupware-epl-jdots, egroupware-epl-pixelegg
Architecture: all
Version: 14.2.20141211-1
Maintainer: Ralf Becker <rb@stylite.de>

View File

@ -43,14 +43,12 @@ Prefix: /usr/share
%define cron cron
%define apache_user wwwrun
%define apache_group www
%define pear_dir \\/usr\\/share\\/php5\\/PEAR:\\/etc\\/php5
%else
%define php php
%define httpdconfd /etc/httpd/conf.d
%define cron crontabs
%define apache_user apache
%define apache_group apache
%define pear_dir \\/usr\\/share\\/pear
%endif
%define install_log /root/%{name}-install.log
@ -82,7 +80,6 @@ Prefix: /usr/share
Distribution: %{distribution}
Source0: %{name}-%{version}.tar.gz
#Source1: %{name}-egw-pear-%{version}.tar.bz2
Source2: %{name}-stylite-%{version}.tar.bz2
#Source3: %{name}-pixelegg-%{version}.tar.bz2
Source4: %{name}-esyncpro-%{version}.tar.bz2
@ -127,6 +124,7 @@ Requires: %{name}-sambaadmin = %{version}
Requires: %{name}-sitemgr = %{version}
Requires: %{name}-timesheet = %{version}
Requires: %{name}-tracker = %{version}
Requires: %{name}-vendor = %{version}
Requires: %{name}-wiki = %{version}
Obsoletes: %{egw_packagename}
Obsoletes: %{egw_packagename}-core
@ -176,10 +174,6 @@ Obsoletes: %{name}-egw-pear
echo "Installing php -> php5 alternative"; \
/usr/sbin/update-alternatives --install /usr/bin/php php /usr/bin/php5 99; \
fi
if [ ! -f /usr/bin/pear -a -x /usr/bin/pear5 ]; then \
echo "Installing pear -> pear5 alternative"; \
/usr/sbin/update-alternatives --install /usr/bin/pear pear /usr/bin/pear5 99; \
fi
%endif
%if 0%{?rhel_version} || 0%{?fedora_version} || 0%{?centos_version}
chcon -R -u user_u -r object_r -t httpd_sys_content_t %{egwdatadir}
@ -211,7 +205,7 @@ Further contributed applications are available as separate packages.
Summary: The EGroupware core
Group: Web/Database
Requires: %{php} >= 5.3.2
Requires: %{php}-mbstring %{php}-gd %{php}-mcrypt %{php}-pear %{php}-posix %{extra_requires} %{cron} zip %{php}-json %{php}-xsl
Requires: %{php}-mbstring %{php}-gd %{php}-mcrypt %{php}-posix %{extra_requires} %{cron} zip %{php}-json %{php}-xsl
Provides: egw-core %{version}
Provides: egw-etemplate %{version}
Provides: egw-addressbook %{version}
@ -487,6 +481,18 @@ Obsoletes: %{egw_packagename}-wiki
%description wiki
This is the wiki app for EGroupware.
%package vendor
Version: %{version}
Summary: External EGroupware dependencies
Group: Web/Database
AutoReqProv: no
%description vendor
Dependencies have been installed using Composer.
With this package EGroupware no longer depends on PEAR.
Dependencies include:
- diverse Horde framework packages like Horde_Imap_Client
- some PEAR packages incl. PEAR itself
%package esyncpro
Version: %{version}
Summary: Stylite eSync Provisioning
@ -495,8 +501,8 @@ Group: Web/Database
AutoReqProv: no
Requires: egw-core >= %{version}, %{name}-esync >= %{version}
%description esyncpro
Stylite's eSync Provisioning app allows to edit and assign
policies to devices and keeps a central list of syncing devices.
Stylite's eSync Provisioning app allows to edit and assign
policies to devices and keeps a central list of syncing devices.
It also allows to remote wipe or view sync logs of all devices.
%post esyncpro
@ -524,7 +530,7 @@ echo "post_install: %{post_install}"
[ "%{buildroot}" != "/" ] && rm -rf %{buildroot}
mkdir -p $RPM_BUILD_ROOT%{egwdir}
mkdir -p $RPM_BUILD_ROOT%{httpdconfd}
sed 's/\/usr\/share\/pear/%{pear_dir}/' egroupware/doc/rpm-build/apache.conf > $RPM_BUILD_ROOT%{httpdconfd}/egroupware.conf
cp egroupware/doc/rpm-build/apache.conf > $RPM_BUILD_ROOT%{httpdconfd}/egroupware.conf
mkdir -p $RPM_BUILD_ROOT/etc/cron.d
sed 's/apache/%{apache_user}/' egroupware/doc/rpm-build/egroupware.cron > $RPM_BUILD_ROOT/etc/cron.d/egroupware
mkdir -p $RPM_BUILD_ROOT%{egwdatadir}/default/files
@ -547,6 +553,8 @@ ln -s ../../..%{egwdatadir}/header.inc.php
%defattr(-,root,root)
%dir %{egwdir}
%{egwdir}/about.php
%{egwdir}/composer.json
%{egwdir}/composer.lock
%{egwdir}/header.inc.php
%{egwdir}/header.inc.php.template
%{egwdir}/index.php
@ -684,6 +692,10 @@ ln -s ../../..%{egwdatadir}/header.inc.php
%defattr(-,root,root)
%{egwdir}/tracker
%files vendor
%defattr(-,root,root)
%{egwdir}/vendor
%files wiki
%defattr(-,root,root)
%{egwdir}/wiki

View File

@ -16,7 +16,6 @@ if (php_sapi_name() !== 'cli') // security precaution: forbit calling post_insta
$verbose = false;
$config = array(
'php' => '/usr/bin/php',
'pear' => '/usr/bin/pear',
'source_dir' => '/usr/share/egroupware',
'data_dir' => '/var/lib/egroupware',
'header' => '$data_dir/header.inc.php', // symlinked to source_dir by rpm
@ -102,7 +101,6 @@ function set_distro_defaults($distro=null)
case 'suse':
// openSUSE 12.1+ no longer uses php5
if (file_exists('/usr/bin/php5')) $config['php'] = '/usr/bin/php5';
if (file_exists('/usr/bin/pear5')) $config['pear'] = '/usr/bin/pear5';
$config['start_db'] = '/sbin/service mysql';
$config['autostart_db'] = '/sbin/chkconfig --level 345 mysql on';
$config['start_webserver'] = '/sbin/service apache2';
@ -261,9 +259,6 @@ foreach(array('php','source_dir','data_dir','setup-cli') as $name)
// fix important php.ini and conf.d/*.ini settings
check_fix_php_apc_ini();
// install/upgrade required pear packages
check_install_pear_packages();
$setup_cli = $config['php'].' -d memory_limit=256M '.$config['setup-cli'];
if (!file_exists($config['header']) || filesize($config['header']) < 200) // default header redirecting to setup is 147 bytes
@ -578,151 +573,6 @@ function usage($error=null)
exit(0);
}
/**
* Get installed pear packages, optional from a certain channel
*
* @global type $config
* @param string $channel=''
* @return null|array with package => version
*/
function pear_list($channel='')
{
global $config;
$out = $ret = null;
exec($config['pear'].' list'.($channel?' -c '.$channel:''),$out,$ret);
if ($channel && $ret == 1)
{
return null;
}
if ($ret)
{
echo "Error running pear command ($config[pear])!\n";
exit(95);
}
$packages_installed = array();
foreach($out as $line)
{
$matches = null;
if (preg_match('/^([a-z0-9_]+)\s+([0-9.]+[a-z0-9]*)\s+([a-z]+)/i',$line,$matches))
{
$packages_installed[($channel?$channel.'/':'').$matches[1]] = $matches[2];
}
}
return $packages_installed;
}
/**
* Check if required PEAR packges are installed and install them if not, update pear packages with to low version
*/
function check_install_pear_packages()
{
global $config;
$packages_installed = pear_list();
// some setup files use autoloader
define('EGW_SERVER_ROOT', dirname(dirname(__DIR__)));
define('EGW_INCLUDE_ROOT', EGW_SERVER_ROOT);
define('EGW_API_INC', EGW_SERVER_ROOT.'/phpgwapi/inc');
include_once(EGW_API_INC.'/common_functions.inc.php');
// read required packages from apps
$packages = array('PEAR' => true); // pear must be the first, to run it's update first!
$channels = array();
$setup_info = array();
foreach(scandir($config['source_dir']) as $app)
{
if (is_dir($dir=$config['source_dir'].'/'.$app) && file_exists($file=$dir.'/setup/setup.inc.php')) include $file;
}
foreach($setup_info as $app => $data)
{
if (isset($data['check_install']))
{
foreach($data['check_install'] as $package => $args)
{
if ($args['func'] == 'pear_check')
{
if (!$package) $package = 'PEAR';
// if package is prefixed with a channel, list or discover it first
if (strpos($package, '/'))
{
list($channel) = explode('/', $package);
if (!in_array($channel, $channels))
{
if (($channel_packages = pear_list($channel)))
{
$packages_installed += $channel_packages;
}
else
{
$discover_cmd = $config['pear'].' channel-discover '.$channel;
echo "$discover_cmd\n"; system($discover_cmd);
}
$channels[] = $channel;
}
}
// only overwrite lower version or no version
if (!isset($packages[$package]) || $packages[$package] === true || isset($args['version']) && version_compare($args['version'],$packages[$package],'>'))
{
$packages[$package] = isset($args['version']) ? $args['version'] : true;
}
}
}
}
}
//echo 'Installed: '; print_r($packages_installed);
//echo 'Required: '; print_r($packages);
$to_install = array_diff(array_keys($packages),array_keys($packages_installed));
$need_upgrade = array();
foreach($packages as $package => $version)
{
if ($version !== true && $version !== '999.egw-pear' && isset($packages_installed[$package]) &&
version_compare($version, $packages_installed[$package], '>'))
{
$need_upgrade[] = $package;
}
}
//echo 'Need upgrade: '; print_r($need_upgrade);
//echo 'To install: '; print_r($to_install);
if (($to_install || $need_upgrade))
{
if (getmyuid())
{
echo "You need to run as user root to be able to install/upgrade required PEAR packages!\n";
}
else
{
echo "Install/upgrade required PEAR packages:\n";
// need to run upgrades first, they might be required for install!
if ($need_upgrade)
{
if (in_array('PEAR',$need_upgrade)) // updating pear itself can be very tricky, this is what's needed for stock RHEL pear
{
$cmd = $config['pear'].' channel-update pear.php.net';
echo "$cmd\n"; system($cmd);
$cmd = $config['pear'].' upgrade --force Console_Getopt Archive_Tar';
echo "$cmd\n"; system($cmd);
}
$cmd = $config['pear'].' upgrade '.implode(' ',$need_upgrade);
echo "$cmd\n"; system($cmd);
}
if ($to_install)
{
// package install can fail if a required package of one to install is of an older version
// unfortunately there is no option to automatic update the required packages automatic
// as a quick fix for that situation, we always run "pear upgrade-all" first
$cmd = $config['pear'].' upgrade-all';
echo "$cmd\n"; system($cmd);
$cmd = $config['pear'].' install '.implode(' ', $to_install);
echo "$cmd\n"; system($cmd);
}
}
}
}
function lang() {} // required to be able to include */setup/setup.inc.php files
/**
* fix egw_cache perms evtl. created by root, stoping webserver from accessing it
*/