RPM PHP和PEAR包

时间:2010-08-30 19:55:24

标签: php pear rpm pyrus

我正在尝试使用一组pear包打包最新PHP(5.3.3)的自定义版本。不幸的是,这样做的选项似乎不起作用。我正在发布我认为它应该是的spec文件。给出的版本实际上并没有失败,但它将PEAR包安装在错误的位置。虽然它们应该放在/var/tmp/my_php-5.3.3-1-buildroot/usr/local/lib/php中,但它们最终会出现在/var/tmp/my_php-5.3.3-1-buildroot/var/中TMP / my_php-5.3.3-1-buildroot的在/ usr /本地/ LIB / PHP。

你还可以看到我必须破解pearcmd.php脚本的位置,因为它完全忽略了pear命令传递它的include_path设置(派生自PHP_PEAR_INSTALL_DIR环境变量)。这可能是完全错误的,但这是我能够实际安装任何东西的唯一方法。

我已尝试过此规范的许多其他变体,但它们似乎都以自己的方式“失败”。仅供参考,我也尝试使用Pyrus,但它有类似的问题(除了非PEAR2包的问题)。

%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" ]; then
  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

感谢您的帮助!

1 个答案:

答案 0 :(得分:0)

您的路径问题来自以%{PEAR_INSTALL}开头的行。您定义PHP_PEAR_INSTALL_DIR并添加包含-P的打包目录。结果是,pear会在$RPM_BUILD_ROOT/$PHP_PEAR_INSTALL_DIR中安装您的软件包,解释时为$RPM_BUILD_ROOT/$RPM_BUILD_ROOT/$PHP_PREFIX/lib/php

然后你有两个解决方案:

  • 从pear install
  • 中删除-P选项
  • $RPM_BUILD_ROOT
  • 的定义中删除PEAR_ROOT_INSTALL

对于你的sed行,我会看一下-i选项:

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