redis-libs.spec 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. ##
  2. ## redis-libs.spec -- OpenPKG RPM Package Specification
  3. ## Copyright (c) 2000-2020 OpenPKG Project <http://openpkg.org/>
  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. ##
  23. # package version
  24. %define V_hiredis_tgz 0.14.1
  25. %define V_hiredis_dir 0.14.1
  26. %define V_perl_redis 1.981
  27. %define V_perl_redis_hiredis 0.11.0
  28. %define V_predis 1.1.1
  29. %define V_phpredis 5.3.2
  30. %define V_rubyredis 4.2.2
  31. # package information
  32. Name: redis-libs
  33. Summary: Redis Client Libraries
  34. URL: http://redis.io/clients
  35. Vendor: Salvatore Sanfilippo et al.
  36. Packager: OpenPKG Project
  37. Distribution: OpenPKG Community
  38. Class: EVAL
  39. Group: Database
  40. License: Open Source
  41. Version: 0
  42. Release: 20201025
  43. # package options
  44. %option with_perl no
  45. %option with_php no
  46. %option with_ruby no
  47. # list of sources
  48. Source0: https://github.com/redis/hiredis/archive/v%{V_hiredis_tgz}.tar.gz
  49. Source1: http://www.cpan.org/authors/id/D/DA/DAMS/Redis-%{V_perl_redis}.tar.gz
  50. Source2: http://www.cpan.org/authors/id/N/NE/NEOPHENIX/Redis-hiredis-%{V_perl_redis_hiredis}.tar.gz
  51. Source3: http://github.com/nrk/predis/archive/v%{V_predis}.tar.gz
  52. Source4: https://github.com/phpredis/phpredis/archive/%{V_phpredis}.tar.gz
  53. Source5: https://rubygems.org/downloads/redis-%{V_rubyredis}.gem
  54. Patch0: redis-libs.patch
  55. # build information
  56. BuildPreReq: OpenPKG, openpkg >= 20160101, make
  57. PreReq: OpenPKG, openpkg >= 20160101
  58. %if "%{with_perl}" == "yes"
  59. BuildPreReq: perl, perl-openpkg
  60. PreReq: perl
  61. %endif
  62. %if "%{with_php}" == "yes"
  63. BuildPreReq: php, php::with_session = yes
  64. PreReq: php, php::with_session = yes
  65. %endif
  66. %if "%{with_ruby}" == "yes"
  67. BuildPreReq: ruby, ruby-gems
  68. PreReq: ruby, ruby-gems
  69. %endif
  70. %description
  71. This is a set of Redis client libraries for the programming
  72. languages C, Java, Scala, Perl and PHP.
  73. %track
  74. prog redis-libs:hiredis = {
  75. version = %{V_hiredis_tgz}
  76. url = https://github.com/redis/hiredis/releases
  77. regex = v(__VER__)\.tar\.gz
  78. }
  79. prog redis-libs:perl-redis = {
  80. version = %{V_perl_redis}
  81. url = http://www.cpan.org/authors/id/M/ME/MELO/
  82. regex = Redis-(__VER__)\.tar\.gz
  83. }
  84. prog redis-libs:perl-redis-hiredis = {
  85. version = %{V_perl_redis_hiredis}
  86. url = http://www.cpan.org/authors/id/N/NE/NEOPHENIX/
  87. regex = Redis-hiredis-(__VER__)\.tar\.gz
  88. }
  89. prog redis-libs:predis = {
  90. version = %{V_predis}
  91. url = http://github.com/nrk/predis/releases
  92. regex = v(__VER__)\.tar\.gz
  93. }
  94. prog redis-libs:phpredis = {
  95. version = %{V_phpredis}
  96. url = https://github.com/phpredis/phpredis/releases
  97. regex = (\d+\.\d+\.\d+)\.tar\.gz
  98. }
  99. prog redis-libs:rubyredis = {
  100. version = %{V_rubyredis}
  101. url = https://github.com/redis/redis-rb/releases
  102. regex = v(\d+\.\d+\.\d+)\.tar\.gz
  103. }
  104. %prep
  105. %setup -q -c
  106. %if "%{with_perl}" == "yes"
  107. %setup -q -T -D -a 1
  108. %setup -q -T -D -a 2
  109. %endif
  110. %if "%{with_php}" == "yes"
  111. %setup -q -T -D -a 3
  112. %setup -q -T -D -a 4
  113. %endif
  114. %patch -p0
  115. %build
  116. ( cd hiredis-%{V_hiredis_dir}
  117. %{l_make} %{l_mflags} \
  118. CC="%{l_cc} %{l_cflags -O}" DEBUG="" \
  119. libhiredis.a
  120. ) || exit $?
  121. %if "%{with_perl}" == "yes"
  122. ( cd Redis-%{V_perl_redis}
  123. %{l_prefix}/bin/perl-openpkg prepare
  124. %{l_prefix}/bin/perl-openpkg configure build
  125. ) || exit $?
  126. ( cd Redis-hiredis-%{V_perl_redis_hiredis}
  127. %{l_prefix}/bin/perl-openpkg prepare
  128. %{l_prefix}/bin/perl-openpkg configure build
  129. ) || exit $?
  130. %endif
  131. %if "%{with_php}" == "yes"
  132. ( cd phpredis-%{V_phpredis}
  133. %{l_prefix}/bin/phpize
  134. CC="%{l_cc}" \
  135. CFLAGS="%{l_cflags -O}" \
  136. CPPFLAGS="%{l_cppflags}" \
  137. LDFLAGS="%{l_ldflags}" \
  138. LIBS="-lssl -lcrypto" \
  139. GREP="grep" \
  140. ./configure \
  141. --prefix=%{l_prefix} \
  142. --with-php-config=%{l_prefix}/bin/php-config \
  143. --enable-shared \
  144. --disable-static
  145. %{l_make} %{l_mflags -O}
  146. ) || exit $?
  147. %endif
  148. %install
  149. %{l_shtool} mkdir -f -p -m 755 \
  150. $RPM_BUILD_ROOT%{l_prefix}/include/redis/adapters \
  151. $RPM_BUILD_ROOT%{l_prefix}/lib
  152. %{l_shtool} install -c -m 755 \
  153. hiredis-%{V_hiredis_dir}/libhiredis.a \
  154. $RPM_BUILD_ROOT%{l_prefix}/lib/
  155. %{l_shtool} install -c -m 644 \
  156. hiredis-%{V_hiredis_dir}/*.h \
  157. $RPM_BUILD_ROOT%{l_prefix}/include/redis/
  158. %{l_shtool} install -c -m 644 \
  159. hiredis-%{V_hiredis_dir}/adapters/*.h \
  160. $RPM_BUILD_ROOT%{l_prefix}/include/redis/adapters/
  161. %if "%{with_perl}" == "yes"
  162. %{l_prefix}/bin/perl-openpkg -d Redis-%{V_perl_redis} install
  163. %{l_prefix}/bin/perl-openpkg -d Redis-hiredis-%{V_perl_redis_hiredis} install
  164. %{l_prefix}/bin/perl-openpkg -F perl-openpkg-files fixate cleanup
  165. %else
  166. >perl-openpkg-files
  167. %endif
  168. %if "%{with_php}" == "yes"
  169. %{l_shtool} mkdir -f -p -m 755 \
  170. $RPM_BUILD_ROOT%{l_prefix}/lib/redis/Predis
  171. cp -r predis-%{V_predis}/src/* \
  172. $RPM_BUILD_ROOT%{l_prefix}/lib/redis/Predis/
  173. %{l_shtool} install -c -m 755 \
  174. phpredis-%{V_phpredis}/.libs/redis.so \
  175. $RPM_BUILD_ROOT%{l_prefix}/lib/redis/phpredis.so
  176. %endif
  177. %if "%{with_ruby}" == "yes"
  178. gem install --build-root $RPM_BUILD_ROOT %{SOURCE redis-%{V_rubyredis}.gem}
  179. %endif
  180. %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT %{l_files_std} `cat perl-openpkg-files`
  181. %files -f files
  182. %clean
  183. %post
  184. %if "%{with_php}" == "yes"
  185. if [ ".$1" = .1 ]; then
  186. # add hook to PHP configuration
  187. phpini="$RPM_INSTALL_PREFIX/etc/php/php.ini"
  188. if [ -f $phpini ]; then
  189. echo "extension = $RPM_INSTALL_PREFIX/lib/redis/phpredis.so" |\
  190. $RPM_INSTALL_PREFIX/lib/openpkg/rpmtool config \
  191. -a -i "$RPM_INSTALL_PREFIX:redis-libs" -p ";" $phpini
  192. fi
  193. # add hook to PHP-FPM configuration
  194. phpini="$RPM_INSTALL_PREFIX/etc/php-fpm/php-fpm.ini"
  195. if [ -f $phpini ]; then
  196. echo "extension = $RPM_INSTALL_PREFIX/lib/redis/phpredis.so" |\
  197. $RPM_INSTALL_PREFIX/lib/openpkg/rpmtool config \
  198. -a -i "$RPM_INSTALL_PREFIX:redis-libs" -p ";" $phpini
  199. fi
  200. # add hook to Apache/PHP configuration
  201. phpini="$RPM_INSTALL_PREFIX/etc/apache/apache-php.ini"
  202. if [ -f $phpini ]; then
  203. echo "extension = $RPM_INSTALL_PREFIX/lib/redis/phpredis.so" |\
  204. $RPM_INSTALL_PREFIX/lib/openpkg/rpmtool config \
  205. -a -i "$RPM_INSTALL_PREFIX:redis-libs" -p ";" $phpini
  206. fi
  207. fi
  208. %endif
  209. %postun
  210. %if "%{with_php}" == "yes"
  211. if [ ".$1" = .0 ]; then
  212. # remove hook from PHP configuration
  213. phpini="$RPM_INSTALL_PREFIX/etc/php/php.ini"
  214. if [ -f $phpini ]; then
  215. $RPM_INSTALL_PREFIX/lib/openpkg/rpmtool config \
  216. -r -i "$RPM_INSTALL_PREFIX:redis-libs" -p ";" $phpini
  217. fi
  218. # remove hook from PHP-FPM configuration
  219. phpini="$RPM_INSTALL_PREFIX/etc/php-fpm/php-fpm.ini"
  220. if [ -f $phpini ]; then
  221. $RPM_INSTALL_PREFIX/lib/openpkg/rpmtool config \
  222. -r -i "$RPM_INSTALL_PREFIX:redis-libs" -p ";" $phpini
  223. fi
  224. # remove hook from Apache/PHP configuration
  225. phpini="$RPM_INSTALL_PREFIX/etc/apache/apache-php.ini"
  226. if [ -f $phpini ]; then
  227. $RPM_INSTALL_PREFIX/lib/openpkg/rpmtool config \
  228. -r -i "$RPM_INSTALL_PREFIX:redis-libs" -p ";" $phpini
  229. fi
  230. fi
  231. %endif