开发者

RPM PHP and PEAR Packages

I'm trying to package a custom build of the latest PHP (5.3.3) with a set of pear packages. Unfortunately, the options given to do this don't seem to work. I'm posting the spec file as I see it should be. The version given doesn't actually fail, but it installs the PEAR packages in the wrong location. While they should go in /var/tmp/my_php-5.3.3-1-buildroot/usr/local/lib/php, but they end up in /var/tmp/my_php-5.3.3-1-buildroot/var/tmp/my_php-5.3.3-1-buildroot/usr/local/lib/php.

You can also see where I had to hack the pearcmd.php script because it was completely ignoring the include_path setting the pear command passed it (derived from the PHP_PEAR_INSTALL_DIR environment variable). This could be completely wrong, but it's the only way I could get it to actually install anything at all.

I have tried many other variations of this spec, but they all seem to "fail" in their own way. FYI, I've also tried using Pyrus, but it had similar issues (in addition to issues with non-PEAR2 packages).

%define PHP_PREFIX  /usr/local
%define CONF_PREFIX /home/config/php/conf
%define APXS_PATH   /usr/local/apache2/bin/apxs
%define ORCL_PATH   /usr/local/lib/oracle

%define PHP         %{PHP_PREFIX}/bin/php
%define PEAR        %{PHP_PREFIX}/bin/pear
%define PEAR_ROOT   %{PHP_PREFIX}/lib/php

%define PHP_INSTALL       $RPM_BUILD_ROOT%{PHP}
%define PEAR_INSTALL      $RPM_BUILD_ROOT%{PEAR}
%define PEAR_ROOT_INSTALL $RPM_BUILD_ROOT%{PEAR_ROOT}

%define PEARCMD %{PEAR_ROOT_INSTALL}/pearcmd.php
%define PECLCMD %{PEAR_ROOT_INSTALL}/peclcmd.php

%define _unpackaged_files_terminate_build 0

Summary: my_php package
Name: my_php
Version: 5.3.3
Release: 1
License: The PHP License, Version 3.01
Vendor: Me
Packager: Me <me@blah.com>
Group: Development/Languages
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot
Source0: php-%{version}.tar.bz2
Requires: my_httpd >= 2.2.0, oracle-instantclient >= 10.2.0.4
BuildRequires: my_httpd >= 2.2.0
Conflicts: php, php5

%description
PHP, My style

%prep
%setup -q -n php-%{version}

%build
LIB_DIR="lib"

if [ "%{_arch}" == "x86_64" ]; the开发者_运维百科n
  LIB_DIR="lib64"
fi

./configure \
  --prefix=%{PHP_PREFIX} \
  --with-libdir=${LIB_DIR} \
  --with-pear \
  --with-config-file-path=%{CONF_PREFIX} \
  --with-apxs2=%{APXS_PATH} \
  --with-oci8=instantclient,%{ORCL_PATH} \
  --with-mysql \
  --with-pgsql \
  --enable-sockets \
  --with-gd \
  --enable-gd-native-ttf \
  --with-freetype-dir \
  --with-curl \
  --with-bz2 \
  --with-zlib-dir \
  --enable-exif \
  --with-ldap \
  --with-gmp \
  --with-xsl

make clean
make -j

%install
rm -rf $RPM_BUILD_ROOT

# Don't try to change httpd.conf
sed -i.bak -e "s:&& \$(mkinstalldirs) '\$(INSTALL_ROOT)/.\+' \(&& %{APXS_PATH} .\+\)-S SYSCONFDIR='.\+' \(.\+\)-a \(.\+\):\1\2\3:" Makefile

# Install PHP to rpm staging area
make INSTALL_ROOT=$RPM_BUILD_ROOT install

# Modify *cmd.php to use correct include_path
sed -i.bak -e "s:'@'.'include_path'.'@':'%{PEAR_ROOT}':" %{PEARCMD}
sed -i.bak -e "s:'@'.'include_path'.'@':'%{PEAR_ROOT}':" %{PECLCMD}

# Install PEAR packages to rpm staging area
export PHP_PEAR_PHP_BIN="%{PHP_INSTALL}"
export PHP_PEAR_INSTALL_DIR="%{PEAR_ROOT_INSTALL}"

%{PEAR_INSTALL} install -P $RPM_BUILD_ROOT pear/MDB2-beta
%{PEAR_INSTALL} install -P $RPM_BUILD_ROOT pear/MDB2_Driver_oci8-beta
%{PEAR_INSTALL} install -P $RPM_BUILD_ROOT pear/MDB2_Driver_pgsql-beta
%{PEAR_INSTALL} install -P $RPM_BUILD_ROOT pear/MDB2_Driver_mysql-beta
%{PEAR_INSTALL} install -P $RPM_BUILD_ROOT pear/Mail
%{PEAR_INSTALL} install -P $RPM_BUILD_ROOT pear/Mail_Mime
%{PEAR_INSTALL} install -P $RPM_BUILD_ROOT pear/Spreadsheet_Excel_Writer-beta

# Revert *cmd.php
mv %{PEARCMD}.bak %{PEARCMD}
mv %{PECLCMD}.bak %{PECLCMD}

%files
%defattr(-,root,root)
/

%clean
rm -rf $RPM_BUILD_DIR/php-%{version} $RPM_BUILD_ROOT

Thanks for any help!


Your path problem comes from your lines starting with %{PEAR_INSTALL}. You define PHP_PEAR_INSTALL_DIR and add a packaging directory with -P. The result is that pear installs your packages in $RPM_BUILD_ROOT/$PHP_PEAR_INSTALL_DIR, which is $RPM_BUILD_ROOT/$RPM_BUILD_ROOT/$PHP_PREFIX/lib/php when interpreted.

You then have two solutions :

  • remove the -P option from pear install
  • remove $RPM_BUILD_ROOT from the definition of PEAR_ROOT_INSTALL

For your sed lines, I would take a look at the -i option :

       -i[SUFFIX], --in-place[=SUFFIX]
              edit files in place (makes backup if extension supplied)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜