node15.spec 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. ##
  2. ## node15.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_opkg 15.0.0
  25. %define V_dist 15.0.0
  26. # package information
  27. Name: node15
  28. Summary: Node JavaScript Run-Time (V15)
  29. URL: http://nodejs.org/
  30. Vendor: Node Foundation
  31. Packager: OpenPKG Project
  32. Distribution: OpenPKG Community
  33. Class: PLUS
  34. Group: Web
  35. License: MIT/BSD
  36. Version: %{V_opkg}
  37. Release: 20201021
  38. # package options
  39. %option with_icu yes
  40. %option with_node no
  41. # list of sources
  42. Source0: https://nodejs.org/download/release/v%{V_dist}/node-v%{V_dist}.tar.xz
  43. Source1: node.c
  44. Patch0: node15.patch
  45. # build information
  46. BuildPreReq: OpenPKG, openpkg >= 20160101, make, gcc, gcc::with_cxx = yes, python2, pkgconfig
  47. PreReq: OpenPKG, openpkg >= 20160101
  48. BuildPreReq: openssl11, libexecinfo, zlib, libuv, nghttp2
  49. PreReq: openssl11, libexecinfo, zlib, libuv, nghttp2
  50. %if "%{with_icu}" == "yes"
  51. BuildPreReq: icu
  52. PreReq: icu
  53. %endif
  54. %if "%{with_node}" == "yes"
  55. Provides: node = %{version}
  56. %endif
  57. %description
  58. Node.js (V15) provides an easy way to build scalable network
  59. servers in JavaScript. It is an event-driven I/O environment based
  60. on Google V8 JavaScript virtual machine version 8.4.371.19.
  61. %track
  62. prog node15 = {
  63. version = %{V_dist}
  64. url = https://nodejs.org/download/release/
  65. regex = v(15\.\d+\.\d+)/
  66. }
  67. %prep
  68. %setup -q -n node-v%{V_dist}
  69. %patch -p0
  70. %build
  71. # provide local tool wrapper scripts as we cannot
  72. # reliably pass the includes via configure variables
  73. cflags="-I`pwd`/deps/v8"
  74. cflags="$cflags -I`pwd`/deps/v8/include"
  75. cflags="$cflags -I`pwd`/deps/uv/include"
  76. cflags="$cflags -I`pwd`/deps/cares/include"
  77. %if "%{with_icu}" != "yes"
  78. cflags="$cflags -I`pwd`/deps/icu-small/source/common"
  79. %endif
  80. cflags="$cflags -I`pwd`/deps/llhttp/include"
  81. cflags="$cflags -I`pwd`/deps/http_parser"
  82. cflags="$cflags %{l_cppflags openssl11 .}"
  83. ldflags="%{l_ldflags openssl11 .}"
  84. mkdir tool
  85. for tool in gcc g++ c%{l_nil}c c++; do
  86. ( echo "#!/bin/sh"
  87. echo "exec %{l_prefix}/bin/$tool $cflags $ldflags \${1+\"\$@\"}"
  88. ) >tool/$tool
  89. chmod a+x tool/$tool
  90. done
  91. PATH="`pwd`/tool:$PATH"
  92. # configure program
  93. libs="-lexecinfo -lz"
  94. case "%{l_platform -t} " in
  95. *-linux* ) libs="$libs -ldl" ;;
  96. esac
  97. CC="gcc" \
  98. CXX="g++" \
  99. CFLAGS="%{l_cflags -O}" \
  100. CXXFLAGS="%{l_cxxflags -O} -Wno-deprecated-declarations" \
  101. CPPFLAGS="%{l_cppflags openssl11 .}" \
  102. LDFLAGS="%{l_ldflags openssl11 .}" \
  103. LIBS="$libs" \
  104. %{l_prefix}/bin/python2 ./configure \
  105. --prefix=%{l_prefix} \
  106. --shared-openssl \
  107. --shared-openssl-includes=%{l_prefix}/include/openssl11 \
  108. --shared-openssl-libpath=%{l_prefix}/lib/openssl11 \
  109. --shared-openssl-libname="ssl,crypto" \
  110. --shared-zlib \
  111. --shared-zlib-includes=%{l_prefix}/include \
  112. --shared-zlib-libpath=%{l_prefix}/lib \
  113. --shared-zlib-libname="z" \
  114. --shared-libuv \
  115. --shared-libuv-includes=%{l_prefix}/include \
  116. --shared-libuv-libpath=%{l_prefix}/lib \
  117. --shared-libuv-libname="uv" \
  118. --shared-nghttp2 \
  119. --shared-nghttp2-includes=%{l_prefix}/include \
  120. --shared-nghttp2-libpath=%{l_prefix}/lib \
  121. --shared-nghttp2-libname="nghttp2" \
  122. %if "%{with_icu}" == "yes"
  123. --with-intl=system-icu \
  124. %else
  125. --with-intl=small-icu \
  126. %endif
  127. --with-snapshot \
  128. --without-npm \
  129. --download=none
  130. # build program
  131. %{l_make} %{l_mflags -O}
  132. # build wrapper
  133. %{l_cc} %{l_cflags -O} %{l_cppflags} -DPREFIX="\"%{l_prefix}\"" %{l_ldflags} \
  134. -o node-wrapper %{SOURCE node.c}
  135. %install
  136. # install program
  137. ( PATH="`pwd`/tool:$PATH"
  138. %{l_make} %{l_mflags} install DESTDIR=$RPM_BUILD_ROOT
  139. ) || exit $?
  140. # install wrapper
  141. %{l_shtool} mkdir -f -p -m 755 \
  142. $RPM_BUILD_ROOT%{l_prefix}/libexec/node15
  143. mv $RPM_BUILD_ROOT%{l_prefix}/bin/node \
  144. $RPM_BUILD_ROOT%{l_prefix}/libexec/node15/node
  145. %{l_shtool} install -c -s -m 755 \
  146. node-wrapper $RPM_BUILD_ROOT%{l_prefix}/bin/node
  147. # post-installation strip-down
  148. strip $RPM_BUILD_ROOT%{l_prefix}/bin/* >/dev/null 2>&1 || true
  149. rm -rf $RPM_BUILD_ROOT%{l_prefix}/lib/dtrace
  150. rm -rf $RPM_BUILD_ROOT%{l_prefix}/share/systemtap
  151. rm -rf $RPM_BUILD_ROOT%{l_prefix}/share/doc
  152. %if "%{with_node}" == "yes"
  153. # create NPM package installation areas
  154. %{l_shtool} mkdir -f -p -m 755 \
  155. $RPM_BUILD_ROOT%{l_prefix}/lib/node/usr \
  156. $RPM_BUILD_ROOT%{l_prefix}/lib/node/pkg
  157. %endif
  158. # post-adjust installation
  159. mv $RPM_BUILD_ROOT%{l_prefix}/bin/node \
  160. $RPM_BUILD_ROOT%{l_prefix}/bin/node15
  161. mv $RPM_BUILD_ROOT%{l_prefix}/include/node \
  162. $RPM_BUILD_ROOT%{l_prefix}/include/node15
  163. mv $RPM_BUILD_ROOT%{l_prefix}/man/man1/node.1 \
  164. $RPM_BUILD_ROOT%{l_prefix}/man/man1/node15.1
  165. %if "%{with_node}" == "yes"
  166. # shim as Node
  167. ln -s node15 $RPM_BUILD_ROOT%{l_prefix}/bin/node
  168. ln -s node15 $RPM_BUILD_ROOT%{l_prefix}/include/node
  169. ln -s node15.1 $RPM_BUILD_ROOT%{l_prefix}/man/man1/node.1
  170. %endif
  171. # determine installation files
  172. %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT %{l_files_std}
  173. %files -f files
  174. %clean