File nodejs.spec of Package nodejs

#
# spec file for package nodejs
#
# Copyright (c) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via http://bugs.opensuse.org/
#


Name:           nodejs
Version:        0.10.31
Release:        0
Summary:        Evented I/O for V8 JavaScript
License:        MIT
Group:          Development/Languages/Other
Url:            http://www.nodejs.org
Source:         http://nodejs.org/dist/v%{version}/node-v%{version}.tar.gz
Source1:        macros.nodejs
Patch0:         nodejs-lib64path.patch
Patch2:         nodejs-libpath.patch
Patch4:         node-gyp-addon-gypi.patch
Patch6:         nodejs-openssl-missing-api.patch
Patch7:         nodejs-add_missing_shebang_to_read-package-json.patch
BuildRequires:  curl
BuildRequires:  gcc-c++
BuildRequires:  procps
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
%if 0%{?suse_version}
BuildRequires:  libopenssl-devel
%else
BuildRequires:  openssl-devel
%endif
BuildRequires:  fdupes
BuildRequires:  pkg-config
BuildRequires:  python
BuildRequires:  zlib-devel
Provides:       npm = %{version}
Obsoletes:      npm < %{version}
#we need ABI virtual provides where SONAMEs aren't enough/not present so deps
#break when binary compatibility is broken
%global nodejs_abi 0.10
Provides:       nodejs(abi) = %{nodejs_abi}

#this corresponds to the "engine" requirement in package.json
Provides:       nodejs(engine) = %{version}

#building nodejs makes sense only on v8 archs
ExclusiveArch:  %{ix86} x86_64 %{arm}

%description
Provides an easy way to build scalable network programs
http://nodejs.org

%package devel
Summary:        Files needed for development of NodeJS platforms
Group:          Development/Languages/Other
Requires:       %{name} = %{version}
Requires:       gcc-c++
Requires:       python

%description devel
Provides an easy way to build scalable network programs
http://nodejs.org

%prep
%setup -q -n node-v%{version}
%if %{_lib} == "lib64"
%patch0 -p1
%else
%patch2 -p1
%endif
%patch4 -p1
%patch6
%patch7 -p1
# Make sure nothing gets included from bundled deps:
# We only delete the source and header files, because
# the remaining build scripts are still used.
###for dir in v8 openssl zlib; do
for dir in openssl zlib; do
  find deps/$dir -name *.[ch] -delete
done

# fix permissions of some files
find ./deps/npm/node_modules/request/ -type f -exec chmod 0644 {} \;

chmod -x deps/v8/include/v8-debug.h
chmod 0644 ./deps/npm/node_modules/uid-number/get-uid-gid.js
chmod 0644 ./deps/npm/node_modules/npmconf/node_modules/config-chain/index.js
chmod 0755 ./deps/npm/scripts/release.sh

# remove .orig file
find . -name "*.orig" -type f -delete -print

%build
# percent-configure pulls in something that confuses node's configure
# script, so we'll do it thus:
export CFLAGS="%{optflags}"
export CXXFLAGS="%{optflags}"
./configure \
    --prefix=%{_prefix} \
    --shared-openssl \
    --shared-zlib \
    --gdb

###    --shared-v8 \

make %{?_smp_mflags}

%install
%{?make_install} %{!?make_install:make install DESTDIR=$RPM_BUILD_ROOT}
# npm man page
cp -p deps/npm/man/man1/npm.1 %{buildroot}/%{_mandir}/man1
#install development headers
#FIXME: we probably don't really need *.h but node-gyp downloads the whole
#freaking source tree so I can't be sure ATM
mkdir -p %{buildroot}%{_includedir}/node
cp -p src/*.h %{buildroot}%{_includedir}/node
# Since we're using included V8, devel package would be incomplete without V8 headers
cp -pR deps/v8/include/*.h %{buildroot}%{_includedir}/node
cp -pR deps/uv/include/* %{buildroot}%{_includedir}/node

#node-gyp needs common.gypi too
mkdir -p %{buildroot}%{_datadir}/node
cp -p common.gypi %{buildroot}%{_datadir}/node

find '%{buildroot}%{_libdir}/' -type f -name .travis.yml -delete
find '%{buildroot}%{_libdir}/' -type f -name .npmignore -delete
find '%{buildroot}%{_libdir}/' -type f -name .gitmodules -delete
find '%{buildroot}%{_libdir}/' -type f -name Makefile -delete
find '%{buildroot}%{_libdir}/' -type f \( -name .jshintrc -o -name pylintrc \) -delete
find '%{buildroot}%{_libdir}/' -type f \( -name '*.cmd' -o -name '*.bat' \) -delete
find '%{buildroot}%{_libdir}/node_modules/' -type d -name tests | while read d; do rm -rf "$d"; done
find '%{buildroot}%{_libdir}/node_modules/' -type d -name tools | while read d; do rm -rf "$d"; done
find '%{buildroot}%{_libdir}/node_modules/' -type d \( -name example -o -name examples \) | while read d; do rm -rf "$d"; done
rm '%{buildroot}%{_libdir}/node_modules/npm/node_modules/node-gyp/gyp/gyp_dummy.c'
rm '%{buildroot}%{_libdir}/node_modules/npm/node_modules/request/node_modules/http-signature/.dir-locals.el'
rm -rf '%{buildroot}%{_libdir}/node_modules/npm/node_modules/request/node_modules/node-uuid/benchmark'
find '%{buildroot}%{_libdir}/node_modules/' -type f -name '*_test*' -delete

# Documentation
install -d %{buildroot}%{_docdir}/%{name}
cp -r doc/* %{buildroot}%{_docdir}/%{name}/
cp -r {AUTHORS,ChangeLog,CONTRIBUTING.md,LICENSE,README.md} %{buildroot}%{_docdir}/%{name}/

# RPM macros
install -d %{buildroot}%{_sysconfdir}/rpm
install -m 644 %{SOURCE1} %{buildroot}%{_sysconfdir}/rpm

# Own nodejs_modulesdir
%ifarch x86_64 ppc64
install -d %{buildroot}%{_prefix}/lib/node_modules
%endif

%fdupes %{buildroot}%{_libdir}/node_modules
%fdupes %{buildroot}%{_docdir}/%{name}

%files
%defattr(-, root, root)
%doc %{_docdir}/%{name}
%config %{_sysconfdir}/rpm/macros.nodejs
%{_bindir}/node
%{_bindir}/npm
%{_libdir}/node_modules
%ifarch x86_64 ppc64
%dir %{_prefix}/lib/node_modules
%endif
%{_mandir}/man1/*

%files devel
%defattr(-, root, root)
%{_includedir}/node
%{_datadir}/node

%changelog
openSUSE Build Service is sponsored by