Mon, 28 Jan 2013 17:37:18 +0100
Correct socket error reporting improvement with IPv6 portable code,
after helpful recommendation by Saúl Ibarra Corretgé on OSips devlist.
1 ##
2 ## memcached.spec -- OpenPKG RPM Package Specification
3 ## Copyright (c) 2000-2011 OpenPKG Foundation e.V. <http://openpkg.net/>
4 ##
5 ## Permission to use, copy, modify, and distribute this software for
6 ## any purpose with or without fee is hereby granted, provided that
7 ## the above copyright notice and this permission notice appear in all
8 ## copies.
9 ##
10 ## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
11 ## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
12 ## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
13 ## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
14 ## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
15 ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
16 ## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
17 ## USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
18 ## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
19 ## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
20 ## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
21 ## SUCH DAMAGE.
22 ##
24 # package versions
25 %define V_memcached 1.4.14
26 %define V_libmemcached 1.0.10
27 %define V_cache_memcached 1.28
29 # package information
30 Name: memcached
31 Summary: Memory Caching Daemon
32 URL: http://memcached.org/
33 Vendor: Brad Fitzpatrick
34 Packager: OpenPKG Foundation e.V.
35 Distribution: OpenPKG Community
36 Class: EVAL
37 Group: System
38 License: GPL
39 Version: %{V_memcached}
40 Release: 20120800
42 # list of sources
43 Source0: http://memcached.googlecode.com/files/memcached-%{V_memcached}.tar.gz
44 Source1: http://download.tangent.org/libmemcached-%{V_libmemcached}.tar.gz
45 Source2: http://www.cpan.org/authors/id/B/BR/BRADFITZ/Cache-Memcached-%{V_cache_memcached}.tar.gz
46 Source3: rc.memcached
47 Patch0: memcached.patch
49 # build information
50 BuildPreReq: OpenPKG, openpkg >= 20100101, gcc, make, perl, perl-openpkg
51 PreReq: OpenPKG, openpkg >= 20100101
52 BuildPreReq: libevent, sasl, libexecinfo
53 PreReq: libevent, sasl, libexecinfo
55 %description
56 Memcached is a high performance, distributed memory object caching
57 system, generic in nature, but intended for use in speeding up
58 dynamic web applications by alleviating database load. Additionally,
59 this package contains Perl and C client APIs to memcached.
61 %track
62 prog memcached:memcached = {
63 version = %{V_memcached}
64 url = http://code.google.com/p/memcached/downloads/list
65 regex = memcached-(\d+(\.\d+)+)\.tar\.gz
66 }
67 prog memcached:cache-memcached = {
68 version = %{V_cache_memcached}
69 url = http://www.cpan.org/authors/id/B/BR/BRADFITZ/
70 regex = Cache-Memcached-(__VER__)\.tar\.gz
71 }
72 prog memcached:libmemcached = {
73 version = %{V_libmemcached}
74 url = http://tangent.org/552/libmemcached.html
75 regex = libmemcached-(__VER__)\.tar\.gz
76 }
78 %prep
79 %setup -q -c
80 %setup -q -T -D -a 1
81 %setup -q -T -D -a 2
82 %patch -p0
83 %{l_shtool} subst \
84 -e 's/b = \(__sync_sub_and_fetch(\&a, 2);\)/return \1/' \
85 memcached-%{V_memcached}/configure
86 %{l_shtool} subst \
87 -e 's; *-Werror;;g' \
88 memcached-%{V_memcached}/configure
89 %{l_shtool} subst \
90 -e 's;\(libdir="\${libdir}\)/\${isainfo_k};\1;g' \
91 libmemcached-%{V_libmemcached}/configure
93 %build
94 # build daemon
95 ( cd memcached-%{V_memcached}
96 libs=""
97 case "%{l_platform -t}" in
98 *-linux* ) libs="$libs -lrt" ;;
99 *-sunos* ) libs="$libs -lsocket -lnsl" ;;
100 esac
101 CC="%{l_cc}" \
102 CFLAGS="%{l_cflags -O}" \
103 CPPFLAGS="%{l_cppflags}" \
104 LDFLAGS="%{l_ldflags}" \
105 LIBS="$libs" \
106 ./configure \
107 --prefix=%{l_prefix} \
108 --with-libevent=%{l_prefix} \
109 --enable-sasl \
110 --enable-sasl-pwdb
111 %{l_make} %{l_mflags -O}
112 ) || exit $?
114 # build C client API
115 ( cd libmemcached-%{V_libmemcached}
116 ( echo "ac_cv_func_malloc_0_nonnull=yes"
117 echo "ac_cv_func_realloc_0_nonnull=yes"
118 echo "ac_cv_env_CXXFLAGS_set=barf"
119 echo "ac_cv_env_CFLAGS_set=barf"
120 echo "ac_cv_header_priv_h=no"
121 echo "ac_cv_header_umem_h=no"
122 ) >config.cache
123 CC="%{l_cc}" \
124 CFLAGS="%{l_cflags -O}" \
125 CPPFLAGS="%{l_cppflags}" \
126 LDFLAGS="%{l_ldflags}" \
127 ./configure \
128 --cache-file=./config.cache \
129 --prefix=%{l_prefix} \
130 --mandir=%{l_prefix}/man \
131 --without-memcached \
132 --enable-libevent \
133 --with-libevent-prefix=%{l_prefix} \
134 --enable-sasl \
135 --with-libsasl2-prefix=%{l_prefix} \
136 --without-libinnodb-prefix \
137 --disable-shared
138 %{l_make} %{l_mflags -O}
139 ) || exit $?
141 # build Perl client API
142 %{l_prefix}/bin/perl-openpkg prepare
143 %{l_prefix}/bin/perl-openpkg -d Cache-Memcached-%{V_cache_memcached} configure build
145 %install
146 # install daemon
147 ( cd memcached-%{V_memcached}
148 %{l_shtool} mkdir -f -p -m 775 \
149 $RPM_BUILD_ROOT%{l_prefix}/bin \
150 $RPM_BUILD_ROOT%{l_prefix}/man/man1
151 %{l_shtool} install -c -s -m 775 \
152 memcached $RPM_BUILD_ROOT%{l_prefix}/bin/
153 %{l_shtool} install -c -m 644 \
154 doc/memcached.1 $RPM_BUILD_ROOT%{l_prefix}/man/man1/
155 ) || exit $?
157 # install C client API
158 ( cd libmemcached-%{V_libmemcached}
159 %{l_make} %{l_mflags} install DESTDIR="$RPM_BUILD_ROOT"
160 ) || exit $?
162 # correct header names and references
163 ( cd $RPM_BUILD_ROOT%{l_prefix}/include
164 mv libmemcachedutil-[0-9]* libmemcachedutil
165 mv libmemcachedprotocol-[0-9]* libmemcachedprotocol
166 rm -rf libhashkit && mv libhashkit-[0-9]* libhashkit
167 rm -rf libmemcached && mv libmemcached-[0-9]* libmemcached
168 find . -type f -print | xargs %{l_shtool} subst \
169 -e 's;\(#include <lib[^\-][^\-]*\)-[0-9\.][0-9\.]*;\1;g'
170 ) || exit $?
172 # install Perl client API
173 %{l_prefix}/bin/perl-openpkg -d Cache-Memcached-%{V_cache_memcached} install
174 %{l_prefix}/bin/perl-openpkg -F perl-openpkg-files fixate cleanup
176 # install daemon runcommand script
177 %{l_shtool} mkdir -f -p -m 755 \
178 $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d
179 %{l_shtool} install -c -m 755 %{l_value -s -a} \
180 %{SOURCE rc.memcached} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
182 # create directory hierarchy for daemon
183 %{l_shtool} mkdir -f -p -m 755 \
184 $RPM_BUILD_ROOT%{l_prefix}/var/memcached
186 # determine installation files
187 %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
188 %{l_files_std} `cat perl-openpkg-files` \
189 '%attr(-,%{l_nusr},%{l_ngrp}) %{l_prefix}/var/memcached'
191 %files -f files
193 %clean
195 %post
196 # after upgrade, restart service
197 [ $1 -eq 2 ] || exit 0
198 eval `%{l_rc} memcached status 2>/dev/null`
199 [ ".$memcached_active" = .yes ] && %{l_rc} memcached restart
200 exit 0
202 %preun
203 # before erase, stop service and remove log files
204 [ $1 -eq 0 ] || exit 0
205 %{l_rc} memcached stop 2>/dev/null
206 rm -f $RPM_INSTALL_PREFIX/var/memcached/* >/dev/null 2>&1 || true
207 exit 0