]>
Commit | Line | Data |
---|---|---|
1 | # TODO | |
2 | # - unpackaged files | |
3 | # /usr/share/doc/node/gdbinit | |
4 | # /usr/share/systemtap/tapset/node.stp | |
5 | ||
6 | # Conditional build: | |
7 | %bcond_without system_uv # system uv | |
8 | %bcond_with shared # build libnode.so shared library | |
9 | ||
10 | # NOTES: | |
11 | # - https://nodejs.org/en/download/releases/ | |
12 | ||
13 | # NODE_MODULE_VERSION refers to the ABI (application binary interface) version | |
14 | # number of Node.js, used to determine which versions of Node.js compiled C++ | |
15 | # add-on binaries can be loaded in to without needing to be re-compiled. It | |
16 | # used to be stored as hex value in earlier versions, but is now represented as | |
17 | # an integer. | |
18 | %define node_module_version 48 | |
19 | Summary: Asynchronous JavaScript Engine | |
20 | Name: nodejs | |
21 | # 6.9 is LTS, Active LTS: 2018-04-18, EOL: 2019-04-18 | |
22 | # https://github.com/nodejs/LTS | |
23 | Version: 6.9.4 | |
24 | Release: 1 | |
25 | License: BSD and MIT and Apache v2.0 and GPL v3 | |
26 | Group: Development/Languages | |
27 | Source0: https://nodejs.org/dist/v%{version}/node-v%{version}.tar.gz | |
28 | # Source0-md5: 3795199b5950b25179248847b1a5fc86 | |
29 | Patch1: %{name}-shared.patch | |
30 | # force node to use /usr/lib/node as the systemwide module directory | |
31 | Patch2: %{name}-libpath.patch | |
32 | # use /usr/lib64/node as an arch-specific module dir when appropriate | |
33 | Patch3: %{name}-lib64path.patch | |
34 | Patch4: %{name}-use-system-certs.patch | |
35 | Patch5: uv-fpic.patch | |
36 | URL: https://nodejs.org/ | |
37 | BuildRequires: gcc >= 5:4.0 | |
38 | BuildRequires: http-parser-devel >= 2.7.0 | |
39 | BuildRequires: libstdc++-devel | |
40 | %{?with_system_uv:BuildRequires: libuv-devel >= 1.6.0} | |
41 | BuildRequires: openssl-devel >= 1.0.1 | |
42 | BuildRequires: pkgconfig | |
43 | BuildRequires: python >= 1:2.7 | |
44 | BuildRequires: python-jsmin | |
45 | BuildRequires: python-modules | |
46 | BuildRequires: rpm >= 4.4.9-56 | |
47 | BuildRequires: rpmbuild(macros) >= 1.219 | |
48 | BuildRequires: sed >= 4.0 | |
49 | BuildRequires: zlib-devel | |
50 | Requires: ca-certificates | |
51 | Provides: nodejs(engine) = %{version} | |
52 | Provides: nodejs(module-version) = %{node_module_version} | |
53 | Obsoletes: nodejs-waf | |
54 | ExclusiveArch: %{ix86} %{x8664} arm | |
55 | BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n) | |
56 | ||
57 | %define sover %(echo %{version} | cut -d. -f2) | |
58 | # add macro, so adapter won't replace it back literal | |
59 | %define doc_ver %{version} | |
60 | ||
61 | %description | |
62 | Node.js is a platform built on Chrome's JavaScript runtime for easily | |
63 | building fast, scalable network applications. Node.js uses an | |
64 | event-driven, non-blocking I/O model that makes it lightweight and | |
65 | efficient, perfect for data-intensive real-time applications that run | |
66 | across distributed devices. | |
67 | ||
68 | %package devel | |
69 | Summary: Development headers for nodejs | |
70 | Group: Development/Libraries | |
71 | Requires: %{name} = %{version}-%{release} | |
72 | Requires: gcc | |
73 | Requires: http-parser-devel >= 2.5.0 | |
74 | Requires: libstdc++-devel | |
75 | %{?with_system_uv:Requires: libuv-devel >= 1.6.0} | |
76 | Requires: openssl-devel | |
77 | Requires: zlib-devel | |
78 | ||
79 | %description devel | |
80 | Development headers for nodejs. | |
81 | ||
82 | %package doc | |
83 | Summary: Evented I/O for V8 JavaScript - documentation | |
84 | Group: Documentation | |
85 | URL: https://nodejs.org/dist/v%{doc_ver}/docs/api | |
86 | %if "%{_rpmversion}" >= "5" | |
87 | BuildArch: noarch | |
88 | %endif | |
89 | ||
90 | %description doc | |
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. | |
94 | ||
95 | This package contains the documentation for nodejs. | |
96 | ||
97 | %prep | |
98 | %setup -q -n node-v%{version} | |
99 | %{?with_shared:%patch1 -p1} | |
100 | #%patch1 -p1 | |
101 | %if %{_lib} == "lib64" | |
102 | %patch3 -p1 | |
103 | %else | |
104 | %patch2 -p1 | |
105 | %endif | |
106 | %patch4 -p1 | |
107 | rm src/node_root_certs.h | |
108 | #%{?with_system_uv:%patch5 -p1} | |
109 | ||
110 | grep -r '#!.*env python' -l . | xargs %{__sed} -i -e '1 s,#!.*env python,#!%{__python},' | |
111 | ||
112 | rm -r deps/npm | |
113 | rm -r deps/http_parser | |
114 | rm -r deps/openssl | |
115 | %{?with_system_uv:rm -r deps/uv} | |
116 | rm -r deps/zlib | |
117 | ||
118 | %build | |
119 | ver=$(awk '/#define NODE_MODULE_VERSION/{print $3}' src/node_version.h) | |
120 | test "$ver" = "%{node_module_version}" | |
121 | ||
122 | # CC used only to detect if CC is clang, not used for compiling | |
123 | CC="%{__cc}" \ | |
124 | CXX="%{__cxx}" \ | |
125 | GYP_DEFINES="soname_version=%{sover}" \ | |
126 | ./configure \ | |
127 | --shared-zlib \ | |
128 | --shared-openssl \ | |
129 | %{?0:--shared-cares} \ | |
130 | %{?with_system_uv:--shared-libuv} \ | |
131 | --shared-http-parser \ | |
132 | --without-npm \ | |
133 | --without-dtrace \ | |
134 | --prefix=%{_prefix} | |
135 | ||
136 | # add LFS defines from libuv (RHBZ#892601) | |
137 | # CXXFLAGS must be exported, as it is needed for make, not gyp | |
138 | CXXFLAGS="%{rpmcxxflags} -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -fPIC" \ | |
139 | LDFLAGS="%{rpmldflags}" \ | |
140 | %{__make} -C out V=1 BUILDTYPE=Release | |
141 | ||
142 | %install | |
143 | rm -rf $RPM_BUILD_ROOT | |
144 | %{__python} tools/install.py install "$RPM_BUILD_ROOT" "%{_prefix}" | |
145 | ||
146 | %if %{with shared} | |
147 | lib=$(basename $RPM_BUILD_ROOT%{_libdir}/libnode.so.*.*.*) | |
148 | ln -s $lib $RPM_BUILD_ROOT%{_libdir}/libnode.so.10 | |
149 | ln -s $lib $RPM_BUILD_ROOT%{_libdir}/libnode.so | |
150 | %endif | |
151 | ||
152 | echo '.so man1/node.1' > $RPM_BUILD_ROOT%{_mandir}/man1/nodejs.1 | |
153 | ||
154 | install -d $RPM_BUILD_ROOT%{_includedir}/node | |
155 | cp -p src/*.h $RPM_BUILD_ROOT%{_includedir}/node | |
156 | ||
157 | # install for node-gyp | |
158 | install -d $RPM_BUILD_ROOT%{_usrsrc}/%{name} | |
159 | cp -p common.gypi $RPM_BUILD_ROOT%{_usrsrc}/%{name} | |
160 | ln -s %{_includedir}/node $RPM_BUILD_ROOT%{_usrsrc}/%{name}/src | |
161 | ||
162 | # for compat of fedora derivered scripts (shebangs) | |
163 | ln -s node $RPM_BUILD_ROOT%{_bindir}/nodejs | |
164 | ||
165 | # globally installed node modules (noarch) | |
166 | install -d $RPM_BUILD_ROOT%{_prefix}/lib/node_modules | |
167 | ||
168 | # default searchpaths | |
169 | install -d $RPM_BUILD_ROOT{%{_libdir},%{_prefix}/lib}/node | |
170 | ||
171 | # create pkgconfig | |
172 | install -d $RPM_BUILD_ROOT%{_pkgconfigdir} | |
173 | cat <<'EOF' > $RPM_BUILD_ROOT%{_pkgconfigdir}/%{name}.pc | |
174 | version=%{version} | |
175 | prefix=%{_prefix} | |
176 | libdir=${prefix}/%{_lib} | |
177 | includedir=${prefix}/include/node | |
178 | ||
179 | Name: nodejs | |
180 | Description: Evented I/O for V8 JavaScript. | |
181 | Version: ${version} | |
182 | Cflags: -I${includedir} | |
183 | EOF | |
184 | ||
185 | # install documentation | |
186 | install -d $RPM_BUILD_ROOT%{_docdir}/%{name}-doc-%{version} | |
187 | cp -a doc/api/* $RPM_BUILD_ROOT%{_docdir}/%{name}-doc-%{version} | |
188 | rm $RPM_BUILD_ROOT%{_docdir}/%{name}-doc-%{version}/*.md | |
189 | rm $RPM_BUILD_ROOT%{_docdir}/%{name}-doc-%{version}/*.json | |
190 | ||
191 | %clean | |
192 | rm -rf $RPM_BUILD_ROOT | |
193 | ||
194 | %if %{with shared} | |
195 | %post -p /sbin/ldconfig | |
196 | %postun -p /sbin/ldconfig | |
197 | %endif | |
198 | ||
199 | %files | |
200 | %defattr(644,root,root,755) | |
201 | %doc README.md AUTHORS CHANGELOG.md ROADMAP.md LICENSE | |
202 | %attr(755,root,root) %{_bindir}/node | |
203 | %attr(755,root,root) %{_bindir}/nodejs | |
204 | %if %{with shared} | |
205 | %attr(755,root,root) %{_libdir}/libnode.so.*.*.* | |
206 | %ghost %{_libdir}/libnode.so.10 | |
207 | %endif | |
208 | %if "%{_lib}" != "lib" | |
209 | %dir %{_libdir}/node | |
210 | %endif | |
211 | %dir %{_prefix}/lib/node | |
212 | %dir %{_prefix}/lib/node_modules | |
213 | %{_mandir}/man1/node.1* | |
214 | %{_mandir}/man1/nodejs.1 | |
215 | ||
216 | %files devel | |
217 | %defattr(644,root,root,755) | |
218 | %if %{with shared} | |
219 | %{_libdir}/libnode.so | |
220 | %endif | |
221 | %{_includedir}/node | |
222 | %{_pkgconfigdir}/nodejs.pc | |
223 | %{_usrsrc}/%{name} | |
224 | ||
225 | %files doc | |
226 | %defattr(644,root,root,755) | |
227 | %doc %{_docdir}/%{name}-doc-%{version} |