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