I've started creating RPMs of software that I use, to allow me to be able to deploy it configured exactly how I want. However I can't figure out how to rename the package without also renaming the tarball that RPM builds it from.

For example I have the source of PHP5.6 in a tarball php-5.6.0RC3.tar.gz. During the RPM build process this gets extracted to the directory php-5.6.0RC3 and the build process cd's into that directory to make it.

I want to change the package name to phpcustom, and still have it built from php-5.6.0RC3.tar.gz. The extract process works, but then the build process tries to cd into the directory phpcustom-5.6.0RC3 which obviously doesn't exist, and so it breaks.

How do I tell the rpmbuild which directory the build should take place in?

I guess I could just move the php-5.6.0RC3 directory to be phpcustom-5.6.0RC3 ...but it seems a bit silly.

I've put my spec file below, just in case it is relevant.

%define        __spec_install_post %{nil}
%define          debug_package %{nil}
%define        __os_install_post %{_dbpath}/brp-compress

Summary: Custom built PHP with APCU
Name: php
#Name: phpcustom - this doesn't work
Provides: php
Conflicts: php
Version: 5.6.0RC3
Release: 1
License: None
Group: Development/Tools

Requires: bzip2, libcurl, libxml2

SOURCE0 : http://downloads.php.net/tyrael/php-5.6.0RC3.tar.gz
SOURCE1:        php.ini
SOURCE2:        php-cli.ini
SOURCE3:        apcu-4.0.6.tgz
URL: http://php.net/


%setup -q -n php-%{version}
%setup -T -D -a 3

mkdir -p  %{buildroot}
./configure  \
                --disable-cgi \
                --disable-debug \
                --disable-rpath \
                --disable-xmlreader \
                --disable-xmlwriter \
                --disable-xml \
                --enable-fpm \
                --enable-intl \
                --enable-json \
                --enable-mbregex \
                --enable-mbstring \
                --enable-pcntl \
                --enable-pdo \
                --enable-sockets \
                --enable-sysvsem \
                --enable-sysvshm \
                --enable-zip \
                --with-apcu \
                --with-bz2 \
                --with-config-file-path=/etc \
                --with-curl \
                --with-freetype-dir=/usr/lib \
                --with-gd \
                --with-jpeg-dir=/usr/lib \
                --with-mcrypt \
                --with-png-dir=/usr/lib \
                --with-pdo-mysql \
                --with-zlib \
                --with-mhash \
                --with-mysql \
                --with-mysqli=mysqlnd \
                --with-openssl \
                --with-pcre-regex \
                --without-pear \
                --without-zlib \
make -j4

rm -rf %{buildroot}
mkdir -p %{buildroot}%{_initrddir}
install -Dp -m0755 sapi/fpm/init.d.php-fpm.in %{buildroot}%{_initrddir}/php-fpm
%{__make} install INSTALL_ROOT="%{buildroot}"
cp %{SOURCE1} %{buildroot}/etc/php.ini
cp %{SOURCE2} %{buildroot}/etc/php-cli.ini

%/sbin/chkconfig --add php-fpm
%/sbin/chkconfig --level 2345 php-fpm on

 rm -rf %{buildroot}

if [ "$1" = 0 ] ; then
    /sbin/service php-fpm stop > /dev/null 2>&1
    /sbin/chkconfig --del php-fpm
exit 0

if [ "$1" -ge 1 ]; then
    /sbin/service php-fpm condrestart > /dev/null 2>&1
exit 0

%config(noreplace) %{_sysconfdir}/php.ini
%config(noreplace) %{_sysconfdir}/php-cli.ini

* Thu Apr 24 2009  Elia Pinto <devzero2000@rpm5.org> 1.0-1
- First Build


You can specify the unrolled directory with a -n parameter to %prep.

  • Ah, and that's also needed for merging other sources into the extracted directory, so "%setup -T -D -a 3 -n php-%{version}" – Danack Aug 13 '14 at 14:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.