From 6d6afaa39f5abd33f7931b94e0f1b16c9ec5ff75 Mon Sep 17 00:00:00 2001
From: Marcin Krol <hawk@tld-linux.org>
Date: Thu, 5 Feb 2015 07:16:53 +0000
Subject: [PATCH] - from PLD

---
 apr-disable-features.patch |  48 ++++++++++
 apr-libtool.patch          |  17 ++++
 apr-link.patch             |  20 ++++
 apr.spec                   | 189 +++++++++++++++++++++++++++++++++++++
 4 files changed, 274 insertions(+)
 create mode 100644 apr-disable-features.patch
 create mode 100644 apr-libtool.patch
 create mode 100644 apr-link.patch
 create mode 100644 apr.spec

diff --git a/apr-disable-features.patch b/apr-disable-features.patch
new file mode 100644
index 0000000..f2d3db7
--- /dev/null
+++ b/apr-disable-features.patch
@@ -0,0 +1,48 @@
+diff -urN apr-1.3.7.org/configure.in apr-1.3.7/configure.in
+--- apr-1.3.7.org/configure.in	2009-07-18 01:14:25.000000000 +0200
++++ apr-1.3.7/configure.in	2009-07-25 23:22:56.127016008 +0200
+@@ -787,7 +787,7 @@
+ 
+ int main()
+ {
+-    return epoll_create1(0) == -1;
++    return 1;
+ }], [apr_cv_epoll_create1=yes], [apr_cv_epoll_create1=no], [apr_cv_epoll_create1=no])])
+ 
+ if test "$apr_cv_epoll_create1" = "yes"; then
+@@ -801,7 +801,7 @@
+ 
+ int main()
+ {
+-    return dup3(STDOUT_FILENO, STDERR_FILENO, 0) == -1;
++    return 1;
+ }], [apr_cv_dup3=yes], [apr_cv_dup3=no], [apr_cv_dup3=no])])
+ 
+ if test "$apr_cv_dup3" = "yes"; then
+@@ -854,7 +854,7 @@
+             close(fd);
+             waitpid(pid, &status, 0);
+             unlink(A4_SOCK);
+-            return 0;
++            return 1;
+         }
+ 
+ cleanup_failure:
+@@ -878,7 +878,7 @@
+             ;
+ 
+         close(fd);
+-        return 0;
++        return 1;
+     }
+ }], [apr_cv_accept4=yes], [apr_cv_accept4=no], [apr_cv_accept4=no])])
+ 
+@@ -893,7 +893,7 @@
+ 
+ int main()
+ {
+-    return socket(AF_INET, SOCK_STREAM|SOCK_CLOEXEC, 0) == -1;
++    return 1;
+ }], [apr_cv_sock_cloexec=yes], [apr_cv_sock_cloexec=no], [apr_cv_sock_cloexec=no])])
+ 
+ if test "$apr_cv_sock_cloexec" = "yes"; then
diff --git a/apr-libtool.patch b/apr-libtool.patch
new file mode 100644
index 0000000..6618972
--- /dev/null
+++ b/apr-libtool.patch
@@ -0,0 +1,17 @@
+must give hint to libtool which tag to use, in case we use ccache and then
+libtool is unable to autodetect from $CC
+
+--- apr-1.5.0/configure.in.orig	2013-11-22 17:29:57.303051538 +0100
++++ apr-1.5.0/configure.in	2013-11-22 17:31:11.273048433 +0100
+@@ -280,9 +280,9 @@
+   [ use_libtool=$withval ], [ use_libtool="yes" ] )
+ 
+ if test "x$use_libtool" = "xyes"; then
+-      lt_compile='$(LIBTOOL) $(LTFLAGS) --mode=compile $(COMPILE) -o $@ -c $< && touch $@'
++      lt_compile='$(LIBTOOL) $(LTFLAGS) --mode=compile --tag=CC $(COMPILE) -o $@ -c $< && touch $@'
+       LT_VERSION="-version-info `$get_version libtool $version_hdr APR`"
+-      link="\$(LIBTOOL) \$(LTFLAGS) --mode=link \$(COMPILE) \$(LT_LDFLAGS) \$(LT_VERSION) \$(ALL_LDFLAGS) -o \$@"
++      link="\$(LIBTOOL) \$(LTFLAGS) --mode=link --tag=CC \$(COMPILE) \$(LT_LDFLAGS) \$(LT_VERSION) \$(ALL_LDFLAGS) -o \$@"
+       so_ext='lo'
+       lib_target='-rpath $(libdir) $(OBJECTS)'
+       export_lib_target='-rpath \$(libdir) \$(OBJECTS)'
diff --git a/apr-link.patch b/apr-link.patch
new file mode 100644
index 0000000..3db9baf
--- /dev/null
+++ b/apr-link.patch
@@ -0,0 +1,20 @@
+--- apr-1.3.0/configure.in.orig	2008-05-02 20:55:47.000000000 +0200
++++ apr-1.3.0/configure.in	2008-06-16 22:56:55.094888283 +0200
+@@ -600,7 +600,7 @@
+       AC_SEARCH_LIBS(gethostbyname, nsl)
+       AC_SEARCH_LIBS(gethostname, nsl)
+       AC_SEARCH_LIBS(socket, socket)
+-      AC_SEARCH_LIBS(crypt, crypt ufc)
++      dnl AC_SEARCH_LIBS(crypt, crypt ufc)
+       AC_CHECK_LIB(truerand, main)
+       AC_SEARCH_LIBS(modf, m)
+        ;;
+@@ -767,7 +767,7 @@
+ 
+ # The real-time POSIX extensions (e.g. shm_*, sem_*) may only
+ # be available if linking against librt.
+-AC_SEARCH_LIBS(shm_open, rt)
++dnl AC_SEARCH_LIBS(shm_open, rt)  -- not used by apr
+ 
+ case $host in
+  *-sysv*)
diff --git a/apr.spec b/apr.spec
new file mode 100644
index 0000000..33bf163
--- /dev/null
+++ b/apr.spec
@@ -0,0 +1,189 @@
+#
+# Conditional build:
+%bcond_with	tests	# perform make test
+#
+Summary:	Apache Portable Runtime
+Summary(pl.UTF-8):	Apache Portable Runtime - przenośna biblioteka uruchomieniowa
+Name:		apr
+Version:	1.5.1
+Release:	2
+Epoch:		1
+License:	Apache v2.0
+Group:		Libraries
+Source0:	http://www.apache.org/dist/apr/%{name}-%{version}.tar.bz2
+# Source0-md5:	5486180ec5a23efb5cae6d4292b300ab
+Patch0:		%{name}-link.patch
+Patch1:		%{name}-libtool.patch
+# disable some things that require recent kernel
+Patch2:		%{name}-disable-features.patch
+URL:		http://apr.apache.org/
+BuildRequires:	autoconf >= 2.59
+BuildRequires:	automake
+%if "%{pld_release}" != "ac"
+BuildRequires:	glibc-devel >= 6:2.9
+BuildRequires:	libtool >= 2:2.2
+%else
+BuildRequires:	libtool
+%endif
+BuildRequires:	libuuid-devel
+BuildRequires:	python
+BuildRequires:	rpm >= 4.4.9-56
+BuildRequires:	rpm-pythonprov
+BuildRequires:	sed >= 4.0
+%if "%{pld_release}" != "ac"
+BuildRequires:	uname(release) >= 2.6
+Requires:	uname(release) >= 2.6.28
+%endif
+# uuid.h misdetected from this one instead of libuuid-devel
+BuildConflicts:	ossp-uuid-devel < 1.6.2-6
+Conflicts:	kernel24
+Conflicts:	kernel24-smp
+BuildRoot:	%{tmpdir}/%{name}-%{version}-root-%(id -u -n)
+
+%define		_includedir	/usr/include/apr
+%define		_datadir	/usr/share/apr
+
+%description
+The mission of the Apache Portable Runtime (APR) project is to create
+and maintain software libraries that provide a predictable and
+consistent interface to underlying platform-specific implementations.
+The primary goal is to provide an API to which software developers may
+code and be assured of predictable if not identical behaviour
+regardless of the platform on which their software is built, relieving
+them of the need to code special-case conditions to work around or
+take advantage of platform-specific deficiencies or features.
+
+%description -l pl.UTF-8
+Celem projektu APR (Apache Portable Runtime) jest stworzenie i
+utrzymywanie bibliotek dostarczających przewidywalnego i spójnego
+interfejsu do leżących u podstaw implementacji zależnych od platformy.
+Głównym celem jest dostarczenie API, którego mogą używać programiści
+mając pewność, że zachowuje się w sposób przewidywalny, jeśli nie
+identyczny, niezależnie od platformy na jakiej oprogramowanie jest
+budowane oraz bez potrzeby kodowania specjalnych warunków do
+obchodzenia lub wykorzystywania specyficznych dla platform różnic lub
+możliwości.
+
+%package devel
+Summary:	Header files and development documentation for apr
+Summary(pl.UTF-8):	Pliki nagłówkowe i dokumentacja programisty do apr
+Group:		Development/Libraries
+Requires:	%{name} = %{epoch}:%{version}-%{release}
+Requires:	automake
+%if "%{pld_release}" != "ac"
+Requires:	libtool >= 2:2.2
+%else
+Requires:	libtool
+%endif
+Requires:	libuuid-devel
+Requires:	python-modules
+
+%description devel
+Header files and development documentation for apr.
+
+%description devel -l pl.UTF-8
+Pliki nagłówkowe i dokumentacja programisty do apr.
+
+%package static
+Summary:	Static apr library
+Summary(pl.UTF-8):	Statyczna biblioteka apr
+Group:		Development/Libraries
+Requires:	%{name}-devel = %{epoch}:%{version}-%{release}
+
+%description static
+Static apr library.
+
+%description static -l pl.UTF-8
+Statyczna biblioteka apr.
+
+%prep
+%setup -q
+%patch0 -p1
+%patch1 -p1
+%patch2 -p1
+
+cat >> config.layout <<'EOF'
+<Layout PLD>
+sbindir:	%{_sbindir}
+libexecdir:	%{_libdir}/apr
+installbuilddir: ${datadir}/build-${APR_MAJOR_VERSION}
+localstatedir:	/var/run
+runtimedir:	/var/run
+libsuffix:	-${APR_MAJOR_VERSION}
+</Layout>
+EOF
+
+%build
+install /usr/share/automake/config.* build
+%{__autoconf}
+
+%configure \
+	--enable-layout=PLD \
+%ifarch %{ix86} %{x8664}
+%ifnarch i386
+	--enable-nonportable-atomics \
+%endif
+%endif
+	--enable-threads \
+	--with-devrandom=/dev/urandom
+%{__make}
+
+%{?with_tests:%{__make} -j1 check}
+
+%install
+rm -rf $RPM_BUILD_ROOT
+
+%{__make} install \
+	DESTDIR=$RPM_BUILD_ROOT
+
+mv -f $RPM_BUILD_ROOT%{_datadir}/build-1 $RPM_BUILD_ROOT%{_datadir}/build
+install build/{*apr*.m4,*.awk,*.sh,gen-build.py} $RPM_BUILD_ROOT%{_datadir}/build
+ln -snf /usr/share/automake/config.{guess,sub} $RPM_BUILD_ROOT%{_datadir}/build
+if [ -f /usr/share/libtool/config/ltmain.sh ]; then
+	ln -snf /usr/share/libtool/config/ltmain.sh $RPM_BUILD_ROOT%{_datadir}/build
+else
+	ln -snf /usr/share/libtool/ltmain.sh $RPM_BUILD_ROOT%{_datadir}/build
+fi
+ln -snf /usr/bin/libtool $RPM_BUILD_ROOT%{_datadir}/build
+ln -sf build $RPM_BUILD_ROOT%{_datadir}/build-1
+
+sed -i -e 's@^\(APR_SOURCE_DIR=\).*@\1"%{_datadir}"@' \
+	$RPM_BUILD_ROOT%{_bindir}/apr-1-config
+sed -i -e 's@^\(apr_builddir\|apr_builders\)=.*@\1=%{_datadir}/build-1@' \
+	$RPM_BUILD_ROOT%{_datadir}/build/apr_rules.mk
+sed -i -e '1s@#!.*python@#!%{__python}@' $RPM_BUILD_ROOT%{_datadir}/build/gen-build.py
+
+%clean
+rm -rf $RPM_BUILD_ROOT
+
+%post	-p /sbin/ldconfig
+%postun	-p /sbin/ldconfig
+
+%files
+%defattr(644,root,root,755)
+%doc CHANGES docs/*.html
+%attr(755,root,root) %{_libdir}/libapr-1.so.*.*.*
+%attr(755,root,root) %ghost %{_libdir}/libapr-1.so.0
+
+%files devel
+%defattr(644,root,root,755)
+%attr(755,root,root) %{_bindir}/apr-1-config
+%attr(755,root,root) %{_libdir}/libapr-1.so
+%{_libdir}/libapr-1.la
+%{_libdir}/apr.exp
+%{_includedir}
+%dir %{_datadir}
+%dir %{_datadir}/build
+%{_datadir}/build/*.mk
+%{_datadir}/build/*.m4
+%{_datadir}/build/*.awk
+%attr(755,root,root) %{_datadir}/build/config.*
+%attr(755,root,root) %{_datadir}/build/*.sh
+%attr(755,root,root) %{_datadir}/build/libtool
+%attr(755,root,root) %{_datadir}/build/gen-build.py
+%{_datadir}/build-1
+%{_pkgconfigdir}/apr-1.pc
+
+%files static
+%defattr(644,root,root,755)
+%{_libdir}/libapr-1.a
-- 
2.49.0