1

我正在尝试使用一组 pear 包打包最新 PHP (5.3.3) 的自定义版本。不幸的是,为此提供的选项似乎不起作用。我正在发布我认为应该的规范文件。给出的版本实际上并没有失败,但是它将 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/local/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

谢谢你的帮助!

4

1 回答 1

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

然后你有两个解决方案:

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

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

       -i[后缀], --in-place[=后缀]
              就地编辑文件(如果提供扩展名,则进行备份)
于 2010-11-23T07:59:58.113 回答