rpmbuild没有优化spec文件

%define _user wanson
%define _group ebsig
%define _prefix /usr/local/inonesoft/php7
Name: php
Version: 7.0.8
Release: 1%{?dist}
Summary: PHP is a server-side scripting language for creating dynamic Web pages
Group: Development/Languages
License: GPLv2
URL: http://www.php.net
Packager: cuibobo
Vendor: OneinStack
Source0: %{name}-%{version}.tar.gz
BuildRoot: %_topdir/BUILDROOT
Requires: libmcrypt-devel
Requires: mhash
Requires: mcrypt
Requires: libevent
Requires: pcre
Requires: pcre-devel
Requires: openssl
Requires: openssl-devel
Requires: freetype-devel
Requires: libpng-devel
Requires: libjpeg-turbo-devel
Requires: libcurl-devel
Requires: libxml2-devel

%description
PHP is a widely-used general-purpose scripting language that is especially suited for Web development and can be embedded into HTML.
%prep
%setup -q
%build
%configure --prefix=%{_prefix} --with-config-file-path=%{_prefix}/etc \
--with-fpm-user=%{_user} --with-fpm-group=%{_group} --enable-fpm \
--with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd \
--with-iconv-dir=/usr/local --with-freetype-dir=/usr --with-jpeg-dir=/usr --with-png-dir=/usr --with-libxml-dir=/usr \
--with-libxml-dir=/usr --enable-bcmath --enable-shmop --enable-embedded-mysqli --enable-maintainer-zts \
--enable-sysvsem --with-curl --enable-static --enable-mbstring \
--enable-mbstring --with-mcrypt --with-gd --with-zlib --enable-gd-native-ttf --with-openssl \
--with-mhash --enable-sockets --with-xmlrpc --enable-ftp \
--with-gettext --enable-zip --enable-soap

make
%install
rm -rf %{buildroot}
make INSTALL_ROOT=%{buildroot} install
rm -rf %{buildroot}/{.channels,.depdb,.depdblock,.filemap,.lock,.registry}
%{__install} -p -D -m 0755 sapi/fpm/init.d.php-fpm %{buildroot}/etc/init.d/php-fpm
%{__install} -p -D -m 0644 php.ini-production %{buildroot}/%{_prefix}/etc/php.ini
#rpm安装前执行的脚本
%pre
echo '/usr/local/lib' > /etc/ld.so.conf.d/local.conf
/sbin/ldconfig
if [ $1 == 1 -a -z "`grep ^%{_user} /etc/passwd`" ]; then # $1有3个值,代表动作,安装类型,处理类型
  groupadd %{_group} -g 1001 # 1:表示安装
  useradd -u 1001 -g 1001 -m %{_user} # 2:表示升级
fi # 0:表示卸载
#rpm安装后执行的脚本
%post
if [ $1 == 1 ];then
  [ -z "`grep ^'export PATH=' /etc/profile`" ] && echo "export PATH=%{_prefix}/bin:\$PATH" >> /etc/profile
  [ -n "`grep ^'export PATH=' /etc/profile`" -a -z "`grep '%{_prefix}' /etc/profile`" ] && sed -i "s@^export PATH=\(.*\)@export PATH=%{_prefix}/bin:\1@" /etc/profile
  cat > %{_prefix}/etc/php-fpm.conf < /dev/null 2>&1
  /sbin/chkconfig --del php-fpm
  if [ -e '/etc/profile.d/custom_profile_new.sh' ];then
    sed -i 's@%{_prefix}/bin:@@' /etc/profile.d/custom_profile_new.sh
  else
    sed -i 's@%{_prefix}/bin:@@' /etc/profile
  fi
fi
#%postun rpm卸载后执行的脚本
%clean
rm -rf %{buildroot}
%files
%defattr(-,root,root,-)
%{_prefix}
%attr(0755,root,root) /etc/init.d/php-fpm
%attr(0755,root,root) /etc/php-fpm.conf.default
%attr(0755,root,root) /etc/pear.conf
%attr(0755,root,root) /etc/php-fpm.d/www.conf.default

%changelog
* Tue Jun 27 2017 cuibobo 7.0.8-1
- Initial version

posted @ 2017-08-09 13:48  Mansoncui  阅读(253)  评论(0编辑  收藏  举报