3 %bcond_without system_v8 # system v8
4 %bcond_with system_uv # system uv
5 %bcond_without shared # build libnode.so shared library
8 # - https://nodejs.org/en/download/releases/
10 # see "Modules" column in https://nodejs.org/en/download/releases/
11 %define node_module_version 11
12 Summary: Asynchronous JavaScript Engine
16 License: BSD and MIT and Apache v2.0 and GPL v3
17 Group: Development/Languages
18 Source0: https://nodejs.org/dist/v%{version}/node-v%{version}.tar.gz
19 # Source0-md5: 23822b192b74640551a20b680c150273
20 Patch1: %{name}-shared.patch
21 # force node to use /usr/lib/node as the systemwide module directory
22 Patch2: %{name}-libpath.patch
23 # use /usr/lib64/node as an arch-specific module dir when appropriate
24 Patch3: %{name}-lib64path.patch
25 Patch4: %{name}-use-system-certs.patch
27 # The invalid UTF8 fix has been reverted since this breaks v8 API, which cannot
28 # be done in a stable distribution release. This build of nodejs will behave as
29 # if NODE_INVALID_UTF8 was set. For more information on the implications, see:
30 # http://blog.nodejs.org/2014/06/16/openssl-and-breaking-utf-8-change/
31 Patch6: %{name}-revert-utf8-v8.patch
32 Patch7: %{name}-revert-utf8-node.patch
33 URL: https://nodejs.org/
34 BuildRequires: c-ares-devel
35 BuildRequires: gcc >= 5:4.0
36 BuildRequires: http-parser-devel >= 2.0
37 BuildRequires: libstdc++-devel
38 %{?with_system_uv:BuildRequires: libuv-devel >= 0.10}
39 BuildRequires: openssl-devel
40 BuildRequires: pkgconfig
41 BuildRequires: python >= 1:2.5.2
42 BuildRequires: python-jsmin
43 BuildRequires: rpm >= 4.4.9-56
44 BuildRequires: rpmbuild(macros) >= 1.219
45 BuildRequires: sed >= 4.0
46 %{?with_system_v8:BuildRequires: v8-devel >= 3.15.11.18-2}
47 BuildRequires: zlib-devel
48 Requires: ca-certificates
49 Provides: nodejs(engine) = %{version}
50 Provides: nodejs(module-version) = %{node_module_version}
52 ExclusiveArch: %{ix86} %{x8664} arm
53 BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
55 %define sover %(echo %{version} | cut -d. -f2)
56 # add macro, so adapter won't replace it back literal
57 %define doc_ver %{version}
60 Node.js is a platform built on Chrome's JavaScript runtime for easily
61 building fast, scalable network applications. Node.js uses an
62 event-driven, non-blocking I/O model that makes it lightweight and
63 efficient, perfect for data-intensive real-time applications that run
64 across distributed devices.
67 Summary: Development headers for nodejs
68 Group: Development/Libraries
69 Requires: %{name} = %{version}-%{release}
70 Requires: c-ares-devel
72 Requires: http-parser-devel
73 Requires: libstdc++-devel
74 %{?with_system_uv:Requires: libuv-devel}
75 Requires: openssl-devel
76 %{?with_system_v8:Requires: v8-devel}
80 Development headers for nodejs.
83 Summary: Evented I/O for V8 JavaScript - documentation
85 URL: https://nodejs.org/dist/v%{doc_ver}/docs/api
86 %if "%{_rpmversion}" >= "5"
91 Node.js is a server-side JavaScript environment that uses an
92 asynchronous event-driven model. Node's goal is to provide an easy way
93 to build scalable network programs.
95 This package contains the documentation for nodejs.
98 %setup -q -n node-v%{version}
99 %{?with_shared:%patch1 -p1}
100 %if %{_lib} == "lib64"
110 grep -r '#!.*env python' -l . | xargs %{__sed} -i -e '1 s,#!.*env python,#!%{__python},'
114 rm -r deps/http_parser
116 %{?with_system_uv:rm -r deps/uv}
117 %{?with_system_v8:rm -r deps/v8}
121 ver=$(awk '/#define NODE_MODULE_VERSION/{print $NF}' src/node.h)
122 if [ $ver != %{node_module_version} ]; then
123 echo "Set %%define node_module_version to $ver and re-run."
127 # CC used only to detect if CC is clang, not used for compiling
130 GYP_DEFINES="soname_version=%{sover}" \
132 %{?with_system_v8:--shared-v8} \
136 %{?with_system_uv:--shared-libuv} \
137 --shared-http-parser \
142 # add LFS defines from libuv (RHBZ#892601)
143 # CXXFLAGS must be exported, as it is needed for make, not gyp
144 CXXFLAGS="%{rpmcxxflags} -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -fPIC" \
145 LDFLAGS="%{rpmldflags}" \
146 %{__make} -C out V=1 BUILDTYPE=Release
149 rm -rf $RPM_BUILD_ROOT
150 %{__python} tools/install.py install "$RPM_BUILD_ROOT" "%{_lib}"
153 lib=$(basename $RPM_BUILD_ROOT%{_libdir}/libnode.so.*.*.*)
154 ln -s $lib $RPM_BUILD_ROOT%{_libdir}/libnode.so.10
155 ln -s $lib $RPM_BUILD_ROOT%{_libdir}/libnode.so
158 echo '.so man1/node.1' > $RPM_BUILD_ROOT%{_mandir}/man1/nodejs.1
160 install -d $RPM_BUILD_ROOT%{_includedir}/node
161 cp -p src/*.h $RPM_BUILD_ROOT%{_includedir}/node
163 # install for node-gyp
164 install -d $RPM_BUILD_ROOT%{_usrsrc}/%{name}
165 cp -p common.gypi $RPM_BUILD_ROOT%{_usrsrc}/%{name}
166 ln -s %{_includedir}/node $RPM_BUILD_ROOT%{_usrsrc}/%{name}/src
168 # for compat of fedora derivered scripts (shebangs)
169 ln -s node $RPM_BUILD_ROOT%{_bindir}/nodejs
171 # globally installed node modules (noarch)
172 install -d $RPM_BUILD_ROOT%{_prefix}/lib/node_modules
174 # default searchpaths
175 install -d $RPM_BUILD_ROOT{%{_libdir},%{_prefix}/lib}/node
178 install -d $RPM_BUILD_ROOT%{_pkgconfigdir}
179 cat <<'EOF' > $RPM_BUILD_ROOT%{_pkgconfigdir}/%{name}.pc
182 libdir=${prefix}/%{_lib}
183 includedir=${prefix}/include/node
186 Description: Evented I/O for V8 JavaScript.
188 Cflags: -I${includedir}
191 # install documentation
192 install -d $RPM_BUILD_ROOT%{_docdir}/%{name}-doc-%{version}
193 cp -a doc/api/* $RPM_BUILD_ROOT%{_docdir}/%{name}-doc-%{version}
194 rm $RPM_BUILD_ROOT%{_docdir}/%{name}-doc-%{version}/*.markdown
195 rm $RPM_BUILD_ROOT%{_docdir}/%{name}-doc-%{version}/*.json
198 rm -rf $RPM_BUILD_ROOT
201 %post -p /sbin/ldconfig
202 %postun -p /sbin/ldconfig
206 %defattr(644,root,root,755)
207 %doc README.md AUTHORS ChangeLog LICENSE
208 %attr(755,root,root) %{_bindir}/node
209 %attr(755,root,root) %{_bindir}/nodejs
211 %attr(755,root,root) %{_libdir}/libnode.so.*.*.*
212 %ghost %{_libdir}/libnode.so.10
214 %if "%{_lib}" != "lib"
217 %dir %{_prefix}/lib/node
218 %dir %{_prefix}/lib/node_modules
219 %{_mandir}/man1/node.1*
220 %{_mandir}/man1/nodejs.1
223 %defattr(644,root,root,755)
225 %{_libdir}/libnode.so
228 %{_pkgconfigdir}/nodejs.pc
232 %defattr(644,root,root,755)
233 %doc %{_docdir}/%{name}-doc-%{version}