rpmbuild php,rpmbuild打包php

安装php依赖库

mkdir -pv ~/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}

php有一个依赖库,在yum源于epel源中都没有需要自己打包libiconv

编写libiconv spec文件

%define __os_install_post %{nil}

%define debug_package %{nil}

Name: libiconv

Version: 1.15

Release: 1%{?dist}

Summary: liconv

Group: liconv

License: GPL

URL: http://www.test.net

Packager: test

Vendor: test

Source0: libiconv-1.15.tar.gz

BuildRoot: %{_tmppath}/%{name}-%{version}-buildroot

%description

iconv

%prep

%setup -q

%build

./configure --prefix=/usr/share/libiconv-1.15 \

make

%install

make install DESTDIR=%{buildroot}

%files

%defattr(-,root,root,-)

%attr(0655,root,root) /usr/share/libiconv-1.15/*

%attr(0755,root,root) /usr/share/libiconv-1.15/bin/*

%clean

rm -rf $RPM_BUILD_DIR/%{name}-%{version}

%post

ln -sv /usr/share/libiconv-1.15/ /usr/share/libiconv

%changelog

* Sun Aug 24 2018 LC 1.15-1

- package libiconv-1.15

编写php spec文件

Name: php

Version: 7.1.17

Release: 1%{?dist}

Summary: php

Group: php

License: GPL

URL: http://php.org

Packager: php

Vendor: php

Source0: php-7.1.17.tar.bz2

Source1: php.ini

BuildRoot: %{_tmppath}/%{name}-%{version}-buildroot

Requires: libiconv,zlib-devel,libxml2-devel,libjpeg-devel,libjpeg-turbo-devel,freetype-devel,libpng-devel,gd-devel,curl-devel,libxslt-devel,bzip2-devel,gmp-devel,readline-devel,mcrypt,mhash,libmcrypt-devel

%description

php

%prep

id nginx || useradd nginx -s /sbin/nologin -M

%setup -q

%build

./configure \

--prefix=/usr/share/php-7.1.17 \

--with-config-file-path=/etc/php/ \

--exec-prefix=/usr \

--bindir=/usr/bin \

--sbindir=/usr/sbin \

--mandir=/usr/share/man \

--sysconfdir=/etc/php/ \

--with-mysqli=mysqlnd \

--with-iconv-dir=/usr/share/libiconv \

--with-jpeg-dir \

--with-png-dir \

--with-zlib-dir \

--with-libxml-dir \

--enable-xml \

--disable-rpath \

--enable-safe-mode \

--enable-bcmath \

--enable-shmop \

--enable-sysvsem \

--enable-inline-optimization \

--with-curl \

--enable-mbregex \

--enable-fpm \

--enable-mbstring \

--with-mcrypt \

--with-gd \

--enable-gd-native-ttf \

--with-openssl \

--with-mhash \

--enable-pcntl \

--enable-sockets \

--with-xmlrpc \

--enable-zip \

--enable-soap \

--enable-short-tags \

--enable-zend-multibyte \

--enable-static \

--with-xsl \

--with-fpm-user=nginx \

--with-fpm-group=nginx

make -j 4

%install

rm -rf %{buildroot}

make INSTALL_ROOT=%{buildroot} install

%{__install} -p -D %{SOURCE1} %{buildroot}/etc/php/php.ini

%files

%defattr(-,root,root,-)

/usr/share/php-7.1.17/*

%attr(0744,root,root) /usr/bin/*

%attr(0744,root,root) /usr/sbin/*

/usr/share/man/*

/etc/php/*

%pre

id nginx || useradd nginx -s /sbin/nologin -M

%post

cp /etc/php/php-fpm.conf.default /etc/php/php-fpm.conf

cp /etc/php/php-fpm.d/www.conf.default /etc/php/php-fpm.d/www.conf

%postun

userdel nginx

%changelog

* Sun Aug 10 2018 lc lc

- package php-7.1.71

构建PHP RPM包遇到的问题

RPM build errors:

bogus date in %changelog: Sun Aug 10 2018 lc zhoushilong

Explicit %attr() mode not applicaple to symlink: /root/rpmbuild/BUILDROOT/php-7.1.17-1.el7.centos.x86_64/usr/bin/phar

Installed (but unpackaged) file(s) found:

/.channels/.alias/pear.txt

/.channels/.alias/pecl.txt

/.channels/.alias/phpdocs.txt

/.channels/__uri.reg

/.channels/doc.php.net.reg

/.channels/pear.php.net.reg

/.channels/pecl.php.net.reg

/.depdb

/.depdblock

/.filemap

/.lock

解决方法如下:

方法1

生成的rpm包里有前面在%files里添加的这个文件,如下:

/usr/local/php/.channels

方法二,下面是直接删除的解决办法,实践OK(视具体情况是删除还是添加选一个即可):

rm -rf %{buildroot}/{.channels,.depdb,.depdblock,.filemap,.lock}

方法三,/usr/lib/rpm/macros修改宏

# 构建根目录中的未打包文件是否应终止构建?

%_unpackaged_files_terminate_build 1 # 把1改为0只警告

%__check_files %{_rpmconfigdir}/check-files %{buildroot} # 这一行,把这一行注释掉,然后重新编译

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值