Need Help With Spec File For Apache-2.4.7

Home » CentOS » Need Help With Spec File For Apache-2.4.7
CentOS 5 Comments

I am trying to build an RPM for Apache-2.4.7-1 on CentOS-6.5-i86_64. I am using mock.

The are three build dependencies that I am trying to resolve. One, mod_socache_dc / distcache, I have simply removed from the spec file. The other two are arp and apr-utils. Since httpd-2.4.7 needs arp >= 1.4 I got the two latter requirements from http://www.apache.org/dist/httpd/httpd-2.4.7-deps.tar.bz2 and extracted them into rpmbuild/SOURCES/httpd-2.4.7/srclib intending to use the
–with-included-arp configuration directive per rpmbuild/SOURCES/httpd-2.4.7/INSTALL.

I also revised the spec file to remove requirements for the removed dependencies.

#BuildRequires: apr-devel >= 1.4.0, apr-util-devel >= 1.4.0
# Replaced by –with-included-apr
. . .
#Requires: apr-devel, apr-util-devel
# Replaced by –with-included-apr

and this little ‘gotcha’

# forcibly prevent use of bundled apr, apr-util, pcre
# rm -rf srclib/{apr,apr-util,pcre}

removed this from %configure:

# –with-apr=%{_prefix} –with-apr-util=%{_prefix} \

and replaced it with this:

–with-included-apr \

and removed the reference to mod_socache_dc

#%files -n mod_socache_dc
#%defattr(-,root,root)
#%{_libdir}/httpd/modules/mod_socache_dc.so

However, the build dies saying that it cannot find arp/arp-utils:

configure: Configuring Apache Portable Runtime library… configure:
configure: error: Bundled APR requested but not found at ./srclib/. Download and unpack the corresponding apr and apr-util packages to ./srclib/. RPM build errors:
error: Bad exit status from /var/tmp/rpm-tmp.pXoIWK (%build)
Bad exit status from /var/tmp/rpm-tmp.pXoIWK (%build)
Child return code was: 1

Now, I added this in the Sources:

Source0: http://www.apache.org/dist/httpd/httpd-%{version}.tar.bz2
Source1: http://www.apache.org/dist/httpd/httpd-%{version}-deps.tar.bz2

And I have confirmed that the srclib directory contains the files for arp and arp-utils:

$ ll rpmbuild/SOURCES/httpd-2.4.7/srclib total 12
drwxr-xr-x. 27 byrnejb byrnejb 4096 Jan 3 14:11 apr drwxr-xr-x. 19 byrnejb byrnejb 4096 Nov 19 12:36 apr-util
-rw-r–r–. 1 byrnejb byrnejb 121 Feb 11 2005 Makefile.in

As this pretty much exhausts my small stock of knowledge respecting rpmbuild it is evident that I need some help with the spec file to get past this problem. The spec is provided below and I would be grateful if anyone could help me out with this. I am sure others would find the information useful as well.

Thanks.

<--- rpmbuild/SPECS/httpd.spec %define contentdir /var/www %define suexec_caller apache %define mmn 20120211 Summary: Apache HTTP Server Name: httpd Version: 2.4.7 Release: 1 URL: http://httpd.apache.org/ Vendor: Apache Software Foundation Source0: http://www.apache.org/dist/httpd/httpd-%{version}.tar.bz2 Source1: http://www.apache.org/dist/httpd/httpd-%{version}-deps.tar.bz2 License: Apache License, Version 2.0 Group: System Environment/Daemons BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root BuildRequires: autoconf, perl, pkgconfig, findutils BuildRequires: zlib-devel, libselinux-devel, libuuid-devel #BuildRequires: apr-devel >= 1.4.0, apr-util-devel >= 1.4.0
# using –with-included-apr instead BuildRequires: pcre-devel >= 5.0
Requires: initscripts >= 8.36, /etc/mime.types Obsoletes: httpd-suexec Requires(pre): /usr/sbin/useradd Requires(post): chkconfig Provides: webserver Provides: mod_dav = %{version}-%{release}, httpd-suexec = %{version}-%{release}
Provides: httpd-mmn = %{mmn}

%description Apache is a powerful, full-featured, efficient, and freely-available Web server. Apache is also the most popular Web server on the Internet.

%package devel Group: Development/Libraries Summary: Development tools for the Apache HTTP server. Obsoletes: secureweb-devel, apache-devel
#Requires: apr-devel, apr-util-devel # Replaced by –with-included-apr Requires: pkgconfig, libtool Requires: httpd = %{version}-%{release}

%description devel The httpd-devel package contains the APXS binary and other files that you need to build Dynamic Shared Objects (DSOs) for the Apache HTTP Server.

If you are installing the Apache HTTP server and you want to be able to compile or develop additional modules for Apache, you need to install this package.

%package manual Group: Documentation Summary: Documentation for the Apache HTTP server. Requires: httpd = :%{version}-%{release}
Obsoletes: secureweb-manual, apache-manual

%description manual The httpd-manual package contains the complete manual and reference guide for the Apache HTTP server. The information can also be found at http://httpd.apache.org/docs/.

%package tools Group: System Environment/Daemons Summary: Tools for use with the Apache HTTP Server

%description tools The httpd-tools package contains tools which can be used with the Apache HTTP Server.

%package -n mod_authnz_ldap Group: System Environment/Daemons Summary: LDAP modules for the Apache HTTP server BuildRequires: openLDAP-devel Requires: httpd = %{version}-%{release}, httpd-mmn = %{mmn}

%description -n mod_authnz_ldap The mod_authnz_ldap module for the Apache HTTP server provides authentication and authorization against an LDAP server, while mod_ldap provides an LDAP cache.

%package -n mod_lua Group: System Environment/Daemons Summary: Lua language module for the Apache HTTP server BuildRequires: lua-devel Requires: httpd = %{version}-%{release}, httpd-mmn = %{mmn}

%description -n mod_lua The mod_lua module for the Apache HTTP server allows the server to be extended with scripts written in the Lua programming language.

%package -n mod_proxy_html Group: System Environment/Daemons Summary: Proxy HTML filter modules for the Apache HTTP server Epoch: 1
BuildRequires: libxml2-devel Requires: httpd = 0:%{version}-%{release}, httpd-mmn = %{mmn}

%description -n mod_proxy_html The mod_proxy_html module for the Apache HTTP server provides a filter to rewrite HTML links within web content when used within a reverse proxy environment. The mod_xml2enc module provides enhanced charset/internationalisation support for mod_proxy_html.

#%package -n mod_socache_dc
#Group: System Environment/Daemons
#Summary: Distcache shared object cache module for the Apache HTTP server
#BuildRequires: distcache-devel
#Requires: httpd = %{version}-%{release}, httpd-mmn = %{mmn}
#
#%description -n mod_socache_dc
#The mod_socache_dc module for the Apache HTTP server allows the shared
#object cache to use the distcache shared caching mechanism.

%package -n mod_ssl Group: System Environment/Daemons Summary: SSL/TLS module for the Apache HTTP server Epoch: 1
BuildRequires: openssl-devel Requires(post): openssl, /bin/cat Requires(pre): httpd Requires: httpd = 0:%{version}-%{release}, httpd-mmn = %{mmn}

%description -n mod_ssl The mod_ssl module provides strong cryptography for the Apache Web server via the Secure Sockets Layer (SSL) and Transport Layer Security (TLS) protocols.

%prep
%setup -q

# Safety check: prevent build if defined MMN does not equal upstream MMN. vmmn=`echo MODULE_MAGIC_NUMBER_MAJOR | cpp -include include/ap_mmn.h | sed -n ‘
/^2/p’`
if test “x${vmmn}” != “x%{mmn}”; then
: Error: Upstream MMN is now ${vmmn}, packaged MMN is %{mmn}.
: Update the mmn macro and rebuild.
exit 1
fi

%build
# forcibly prevent use of bundled apr, apr-util, pcre
# rm -rf srclib/{apr,apr-util,pcre}

# –with-apr=%{_prefix} –with-apr-util=%{_prefix} \

%configure \
–enable-layout=RPM \
–libdir=%{_libdir} \
–sysconfdir=%{_sysconfdir}/httpd/conf \
–includedir=%{_includedir}/httpd \
–libexecdir=%{_libdir}/httpd/modules \
–datadir=%{contentdir} \
–with-installbuilddir=%{_libdir}/httpd/build \
–enable-mpms-shared=all \
–with-included-apr \
–enable-suexec –with-suexec \
–with-suexec-caller=%{suexec_caller} \
–with-suexec-docroot=%{contentdir} \
–with-suexec-logfile=%{_localstatedir}/log/httpd/suexec.log \
–with-suexec-bin=%{_sbindir}/suexec \
–with-suexec-uidminP0 –with-suexec-gidmin0 \
–enable-pie \
–with-pcre \
–enable-mods-shared=all \
–enable-ssl –with-ssl –enable-socache-dc –enable-bucketeer \
–enable-case-filter –enable-case-filter-in \
–disable-imagemap

make %{?_smp_mflags}

%install rm -rf $RPM_BUILD_ROOT
make DESTDIR=$RPM_BUILD_ROOT install

# for holding mod_dav lock database mkdir -p $RPM_BUILD_ROOT%{_localstatedir}/lib/dav

# create a prototype session cache mkdir -p $RPM_BUILD_ROOT%{_localstatedir}/cache/mod_ssl touch $RPM_BUILD_ROOT%{_localstatedir}/cache/mod_ssl/scache.{dir,pag,sem}

# Make the MMN accessible to module packages echo %{mmn} > $RPM_BUILD_ROOT%{_includedir}/httpd/.mmn

# Set up /var directories mkdir -p $RPM_BUILD_ROOT%{_localstatedir}/log/httpd mkdir -p $RPM_BUILD_ROOT%{_localstatedir}/cache/httpd/cache-root

# symlinks for /etc/httpd ln -s ../..%{_localstatedir}/log/httpd $RPM_BUILD_ROOT/etc/httpd/logs ln -s ../..%{_localstatedir}/run $RPM_BUILD_ROOT/etc/httpd/run ln -s ../..%{_libdir}/httpd/modules $RPM_BUILD_ROOT/etc/httpd/modules mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/httpd/conf.d

# install SYSV init stuff mkdir -p $RPM_BUILD_ROOT/etc/rc.d/init.d install -m755 ./build/rpm/httpd.init \
$RPM_BUILD_ROOT/etc/rc.d/init.d/httpd install -m755 ./build/rpm/htcacheclean.init \
$RPM_BUILD_ROOT/etc/rc.d/init.d/htcacheclean

# install log rotation stuff mkdir -p $RPM_BUILD_ROOT/etc/logrotate.d install -m644 ./build/rpm/httpd.logrotate \
$RPM_BUILD_ROOT/etc/logrotate.d/httpd

# Remove unpackaged files rm -rf $RPM_BUILD_ROOT%{_libdir}/httpd/modules/*.exp \
$RPM_BUILD_ROOT%{contentdir}/cgi-bin/*

# Make suexec a+rw so it can be stripped. %%files lists real permissions chmod 755 $RPM_BUILD_ROOT%{_sbindir}/suexec

%pre
# Add the “apache” user
/usr/sbin/useradd -c “Apache” -u 48 \
-s /sbin/nologin -r -d %{contentdir} apache 2> /dev/null || :

%post
# Register the httpd service
/sbin/chkconfig –add httpd
/sbin/chkconfig –add htcacheclean

%preun if [ $1 = 0 ]; then
/sbin/service httpd stop > /dev/null 2>&1
/sbin/service htcacheclean stop > /dev/null 2>&1
/sbin/chkconfig –del httpd
/sbin/chkconfig –del htcacheclean fi

%post -n mod_ssl umask 077

if [ ! -f %{_sysconfdir}/httpd/conf/server.key ] ; then
%{_bindir}/openssl genrsa -rand
/proc/apm:/proc/cpuinfo:/proc/dma:/proc/filesystems:/proc/interrupts:/proc/ioports:/proc/pci:/proc/rtc:/proc/uptime
1024 > %{_sysconfdir}/httpd/conf/server.key 2> /dev/null fi

FQDN=`hostname`
if [ “x${FQDN}” = “x” ]; then
FQDN=localhost.localdomain fi

if [ ! -f %{_sysconfdir}/httpd/conf/server.crt ] ; then cat << EOF | %{_bindir}/openssl req -new -key %{_sysconfdir}/httpd/conf/server.key -x509 -days 365 -out %{_sysconfdir}/httpd/conf/server.crt 2>/dev/null

5 thoughts on - Need Help With Spec File For Apache-2.4.7

  • Thank you very much for that reference. This got me past that roadblock. I
    have resolved many other difficulties but I have run into another problem for which I am unable find any guidance. Now I am getting this error in the build:

    RPM build errors:
    File not found:
    /builddir/build/BUILDROOT/httpd-2.4.7-1.x86_64/usr/lib64/httpd/modules/mod_session_crypto.so Child return code was: 1
    EXCEPTION: Command failed. See logs for output.
    # [‘bash’, ‘–login’, ‘-c’, ‘rpmbuild -bb –target x86_64 –nodeps builddir/build/SPECS/httpd.spec’]

    I cannot find anything in the spec file that refers to this module by name other than the following:

    %{_libdir}/httpd/modules/mod_session_crypto.so

    Am I missing something obvious? Is there an undeclared dependency?

    Any assistance gratefully accepted.

  • I have gotten this to compile to completion but now I am getting an error that says:

    RPM build errors:
    error: Installed (but unpackaged) file(s) found:
    /usr/bin/apr-1-config
    /usr/bin/apu-1-config
    Installed (but unpackaged) file(s) found:
    /usr/bin/apr-1-config
    /usr/bin/apu-1-config Child return code was: 1

    However, if I add this to the %files directive:

    %files devel
    %defattr(-,root,root)
    . . .
    # Adds in apr libs
    %{_bindir}/apr-1-config
    %{_bindir}/apr-u-config

    The error becomes:

    error: File not found:
    /builddir/build/BUILDROOT/httpd-2.4.7-1.x86_64/usr/bin/apr-u-config RPM build errors:
    File not found:
    /builddir/build/BUILDROOT/httpd-2.4.7-1.x86_64/usr/bin/apr-u-config

    Where should the arp stuff go? Into its own package?

  • Ahhh. Thank you. I suppose that eventually I might have noticed. Sigh…

    Anyway, it is built and packaged now. Next I will see if it runs.

    Regards, and thanks.