]> git.pld-linux.org Git - packages/nodejs.git/blob - nodejs.spec
export node module api version
[packages/nodejs.git] / nodejs.spec
1 #
2 # Conditional build:
3 %bcond_without  system_v8       # system v8
4 %bcond_without  system_uv       # system uv
5 %bcond_without  shared  # build libnode.so shared library
6
7 # NOTES:
8 # - https://nodejs.org/en/download/releases/
9
10 # see "Modules" column in https://nodejs.org/en/download/releases/
11 %define         node_module_version     11
12 Summary:        Asynchronous JavaScript Engine
13 Name:           nodejs
14 Version:        0.10.40
15 Release:        1
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:  f6ef20f327ecd6cb1586c41c7184290c
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
26 Patch5:         uv-fpic.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(module-version) = %{node_module_version}
50 Obsoletes:      nodejs-waf
51 ExclusiveArch:  %{ix86} %{x8664} arm
52 BuildRoot:      %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
53
54 %define         sover   %(echo %{version} | cut -d. -f2)
55
56 %description
57 Node.js is a platform built on Chrome's JavaScript runtime for easily
58 building fast, scalable network applications. Node.js uses an
59 event-driven, non-blocking I/O model that makes it lightweight and
60 efficient, perfect for data-intensive real-time applications that run
61 across distributed devices.
62
63 %package devel
64 Summary:        Development headers for nodejs
65 Group:          Development/Libraries
66 Requires:       %{name} = %{version}-%{release}
67 Requires:       c-ares-devel
68 Requires:       gcc
69 Requires:       http-parser-devel
70 Requires:       libstdc++-devel
71 %{?with_system_uv:Requires:     libuv-devel}
72 Requires:       openssl-devel
73 %{?with_system_v8:Requires:     v8-devel}
74 Requires:       zlib-devel
75
76 %description devel
77 Development headers for nodejs.
78
79 %package doc
80 Summary:        Evented I/O for V8 JavaScript - documentation
81 Group:          Documentation
82 %if "%{_rpmversion}" >= "5"
83 BuildArch:      noarch
84 %endif
85
86 %description doc
87 Node.js is a server-side JavaScript environment that uses an
88 asynchronous event-driven model. Node's goal is to provide an easy way
89 to build scalable network programs.
90
91 This package contains the documentation for nodejs.
92
93 %prep
94 %setup -q -n node-v%{version}
95 %{?with_shared:%patch1 -p1}
96 %if %{_lib} == "lib64"
97 %patch3 -p1
98 %else
99 %patch2 -p1
100 %endif
101 %patch4 -p1
102 %patch5 -p1
103 %patch6 -p1
104 %patch7 -p1
105
106 grep -r '#!.*env python' -l . | xargs %{__sed} -i -e '1 s,#!.*env python,#!%{__python},'
107
108 rm -r deps/npm
109 rm -r deps/cares
110 rm -r deps/http_parser
111 rm -r deps/openssl
112 %{?with_system_uv:rm -r deps/uv}
113 %{?with_system_v8:rm -r deps/v8}
114 rm -r deps/zlib
115
116 %build
117 ver=$(awk '/#define NODE_MODULE_VERSION/{print $NF}' src/node.h)
118 if [ $ver != %{node_module_version} ]; then
119         echo "Set %%define node_module_version to $ver and re-run."
120         exit 1
121 fi
122
123 # CC used only to detect if CC is clang, not used for compiling
124 CC="%{__cc}" \
125 CXX="%{__cxx}" \
126 GYP_DEFINES="soname_version=%{sover}" \
127 ./configure \
128         %{?with_system_v8:--shared-v8} \
129         --shared-zlib \
130         --shared-openssl \
131         --shared-cares \
132         %{?with_system_uv:--shared-libuv} \
133         --shared-http-parser \
134         --without-npm \
135         --without-dtrace \
136         --prefix=%{_prefix}
137
138 # add LFS defines from libuv (RHBZ#892601)
139 # CXXFLAGS must be exported, as it is needed for make, not gyp
140 CXXFLAGS="%{rpmcxxflags} -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -fPIC" \
141 LDFLAGS="%{rpmldflags}" \
142 %{__make} -C out V=1 BUILDTYPE=Release
143
144 %install
145 rm -rf $RPM_BUILD_ROOT
146 %{__python} tools/install.py install "$RPM_BUILD_ROOT" "%{_lib}"
147
148 %if %{with shared}
149 lib=$(basename $RPM_BUILD_ROOT%{_libdir}/libnode.so.*.*.*)
150 ln -s $lib $RPM_BUILD_ROOT%{_libdir}/libnode.so.10
151 ln -s $lib $RPM_BUILD_ROOT%{_libdir}/libnode.so
152 %endif
153
154 echo '.so man1/node.1' > $RPM_BUILD_ROOT%{_mandir}/man1/nodejs.1
155
156 install -d $RPM_BUILD_ROOT%{_includedir}/node
157 cp -p src/*.h $RPM_BUILD_ROOT%{_includedir}/node
158
159 # install for node-gyp
160 install -d $RPM_BUILD_ROOT%{_usrsrc}/%{name}
161 cp -p common.gypi $RPM_BUILD_ROOT%{_usrsrc}/%{name}
162 ln -s %{_includedir}/node $RPM_BUILD_ROOT%{_usrsrc}/%{name}/src
163
164 # for compat of fedora derivered scripts (shebangs)
165 ln -s node $RPM_BUILD_ROOT%{_bindir}/nodejs
166
167 # globally installed node modules (noarch)
168 install -d $RPM_BUILD_ROOT%{_prefix}/lib/node_modules
169
170 # default searchpaths
171 install -d $RPM_BUILD_ROOT{%{_libdir},%{_prefix}/lib}/node
172
173 # create pkgconfig
174 install -d $RPM_BUILD_ROOT%{_pkgconfigdir}
175 cat <<'EOF' > $RPM_BUILD_ROOT%{_pkgconfigdir}/%{name}.pc
176 version=%{version}
177 prefix=%{_prefix}
178 libdir=${prefix}/%{_lib}
179 includedir=${prefix}/include/node
180
181 Name: nodejs
182 Description: Evented I/O for V8 JavaScript.
183 Version: ${version}
184 Cflags: -I${includedir}
185 EOF
186
187 # install documentation
188 install -d $RPM_BUILD_ROOT%{_docdir}/%{name}-doc-%{version}
189 cp -a doc/api/* $RPM_BUILD_ROOT%{_docdir}/%{name}-doc-%{version}
190 rm $RPM_BUILD_ROOT%{_docdir}/%{name}-doc-%{version}/*.markdown
191 rm $RPM_BUILD_ROOT%{_docdir}/%{name}-doc-%{version}/*.json
192
193 %clean
194 rm -rf $RPM_BUILD_ROOT
195
196 %if %{with shared}
197 %post   -p /sbin/ldconfig
198 %postun -p /sbin/ldconfig
199 %endif
200
201 %files
202 %defattr(644,root,root,755)
203 %doc README.md AUTHORS ChangeLog LICENSE
204 %attr(755,root,root) %{_bindir}/node
205 %attr(755,root,root) %{_bindir}/nodejs
206 %if %{with shared}
207 %attr(755,root,root) %{_libdir}/libnode.so.*.*.*
208 %ghost %{_libdir}/libnode.so.10
209 %endif
210 %if "%{_lib}" != "lib"
211 %dir %{_libdir}/node
212 %endif
213 %dir %{_prefix}/lib/node
214 %dir %{_prefix}/lib/node_modules
215 %{_mandir}/man1/node.1*
216 %{_mandir}/man1/nodejs.1
217
218 %files devel
219 %defattr(644,root,root,755)
220 %if %{with shared}
221 %{_libdir}/libnode.so
222 %endif
223 %{_includedir}/node
224 %{_pkgconfigdir}/nodejs.pc
225 %{_usrsrc}/%{name}
226
227 %files doc
228 %defattr(644,root,root,755)
229 %doc %{_docdir}/%{name}-doc-%{version}
This page took 0.399248 seconds and 3 git commands to generate.