RPM PHP 和 PEAR 包
我正在尝试使用一组 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.txt
您还可以看到我必须在哪里破解 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 <[email protected]>
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
感谢您的帮助!
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 <[email protected]>
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
Thanks for any help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的路径问题来自于以
%{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_ROOT_INSTALL
的定义中删除$RPM_BUILD_ROOT
对于您的 sed 行,我会看一下
-i
选项:Your path problem comes from your lines starting with
%{PEAR_INSTALL}
. You definePHP_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 :
-P
option from pear install$RPM_BUILD_ROOT
from the definition ofPEAR_ROOT_INSTALL
For your sed lines, I would take a look at the
-i
option :